mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 12:21:04 +00:00
Fixed while and/or loops
This commit is contained in:
@@ -50,6 +50,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.Trait;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
|
||||
import com.jpexs.decompiler.flash.graph.Graph;
|
||||
import com.jpexs.decompiler.flash.graph.GraphPart;
|
||||
import com.jpexs.decompiler.flash.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.flash.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.flash.graph.GraphTargetItem;
|
||||
@@ -1032,7 +1033,7 @@ public class AVM2Code implements Serializable {
|
||||
return pos2adr(fixIPAfterDebugLine(adr2pos(addr)));
|
||||
}
|
||||
|
||||
public ConvertOutput toSourceOutput(boolean processJumps, boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap<Integer, GraphTargetItem> localRegs, Stack<GraphTargetItem> stack, Stack<GraphTargetItem> scopeStack, ABC abc, ConstantPool constants, MethodInfo method_info[], MethodBody body, int start, int end, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, boolean visited[]) throws ConvertException {
|
||||
public ConvertOutput toSourceOutput(GraphPart part, boolean processJumps, boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap<Integer, GraphTargetItem> localRegs, Stack<GraphTargetItem> stack, Stack<GraphTargetItem> scopeStack, ABC abc, ConstantPool constants, MethodInfo method_info[], MethodBody body, int start, int end, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, boolean visited[]) throws ConvertException {
|
||||
boolean debugMode = DEBUG_MODE;
|
||||
if (debugMode) {
|
||||
System.out.println("OPEN SubSource:" + start + "-" + end + " " + code.get(start).toString() + " to " + code.get(end).toString());
|
||||
@@ -1064,101 +1065,6 @@ public class AVM2Code implements Serializable {
|
||||
int ipfix = fixIPAfterDebugLine(ip);
|
||||
int addrfix = pos2adr(ipfix);
|
||||
int maxend = -1;
|
||||
if (processTry) {
|
||||
List<ABCException> catchedExceptions = new ArrayList<ABCException>();
|
||||
for (int e = 0; e < body.exceptions.length; e++) {
|
||||
if (addrfix == fixAddrAfterDebugLine(body.exceptions[e].start)) {
|
||||
if (!body.exceptions[e].isFinally()) {
|
||||
if ((fixAddrAfterDebugLine(body.exceptions[e].end) > maxend) && (!parsedExceptions.contains(body.exceptions[e]))) {
|
||||
catchedExceptions.clear();
|
||||
maxend = fixAddrAfterDebugLine(body.exceptions[e].end);
|
||||
catchedExceptions.add(body.exceptions[e]);
|
||||
} else if (fixAddrAfterDebugLine(body.exceptions[e].end) == maxend) {
|
||||
catchedExceptions.add(body.exceptions[e]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (catchedExceptions.size() > 0) {
|
||||
ip = ipfix;
|
||||
addr = addrfix;
|
||||
parsedExceptions.addAll(catchedExceptions);
|
||||
int endpos = adr2pos(fixAddrAfterDebugLine(catchedExceptions.get(0).end));
|
||||
|
||||
|
||||
List<List<GraphTargetItem>> catchedCommands = new ArrayList<List<GraphTargetItem>>();
|
||||
if (code.get(endpos).definition instanceof JumpIns) {
|
||||
int afterCatchAddr = pos2adr(endpos + 1) + code.get(endpos).operands[0];
|
||||
int afterCatchPos = adr2pos(afterCatchAddr);
|
||||
Collections.sort(catchedExceptions, new Comparator<ABCException>() {
|
||||
@Override
|
||||
public int compare(ABCException o1, ABCException o2) {
|
||||
try {
|
||||
return fixAddrAfterDebugLine(o1.target) - fixAddrAfterDebugLine(o2.target);
|
||||
} catch (ConvertException ex) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
List<GraphTargetItem> finallyCommands = new ArrayList<GraphTargetItem>();
|
||||
int returnPos = afterCatchPos;
|
||||
for (int e = 0; e < body.exceptions.length; e++) {
|
||||
if (body.exceptions[e].isFinally()) {
|
||||
if (addr == fixAddrAfterDebugLine(body.exceptions[e].start)) {
|
||||
if (afterCatchPos + 1 == adr2pos(fixAddrAfterDebugLine(body.exceptions[e].end))) {
|
||||
AVM2Instruction jmpIns = code.get(adr2pos(fixAddrAfterDebugLine(body.exceptions[e].end)));
|
||||
if (jmpIns.definition instanceof JumpIns) {
|
||||
int finStart = adr2pos(fixAddrAfterDebugLine(body.exceptions[e].end) + jmpIns.getBytes().length + jmpIns.operands[0]);
|
||||
finallyJumps.add(finStart);
|
||||
if (unknownJumps.contains(finStart)) {
|
||||
unknownJumps.remove((Integer) finStart);
|
||||
}
|
||||
for (int f = finStart; f <= end; f++) {
|
||||
if (code.get(f).definition instanceof LookupSwitchIns) {
|
||||
AVM2Instruction swins = code.get(f);
|
||||
if (swins.operands.length >= 3) {
|
||||
if (swins.operands[0] == swins.getBytes().length) {
|
||||
if (adr2pos(pos2adr(f) + swins.operands[2]) < finStart) {
|
||||
finallyCommands = toSourceOutput(processJumps, isStatic, scriptIndex, classIndex, localRegs, stack, scopeStack, abc, constants, method_info, body, finStart, f - 1, localRegNames, fullyQualifiedNames, visited).output;
|
||||
returnPos = f + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int e = 0; e < catchedExceptions.size(); e++) {
|
||||
int eendpos;
|
||||
if (e < catchedExceptions.size() - 1) {
|
||||
eendpos = adr2pos(fixAddrAfterDebugLine(catchedExceptions.get(e + 1).target)) - 2;
|
||||
} else {
|
||||
eendpos = afterCatchPos - 1;
|
||||
}
|
||||
Stack<GraphTargetItem> substack = new Stack<GraphTargetItem>();
|
||||
substack.add(new ExceptionTreeItem(catchedExceptions.get(e)));
|
||||
catchedCommands.add(toSourceOutput(processJumps, isStatic, scriptIndex, classIndex, localRegs, substack, new Stack<GraphTargetItem>(), abc, constants, method_info, body, adr2pos(fixAddrAfterDebugLine(catchedExceptions.get(e).target)), eendpos, localRegNames, fullyQualifiedNames, visited).output);
|
||||
}
|
||||
|
||||
List<GraphTargetItem> tryCommands = toSourceOutput(processJumps, isStatic, scriptIndex, classIndex, localRegs, stack, scopeStack, abc, constants, method_info, body, ip, endpos - 1, localRegNames, fullyQualifiedNames, visited).output;
|
||||
|
||||
|
||||
output.add(new TryTreeItem(tryCommands, catchedExceptions, catchedCommands, finallyCommands));
|
||||
ip = returnPos;
|
||||
addr = pos2adr(ip);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (ip > end) {
|
||||
break;
|
||||
@@ -1277,8 +1183,10 @@ public class AVM2Code implements Serializable {
|
||||
if (((GetLocalTypeIns) code.get(t).definition).getRegisterId(code.get(t)) == reg) {
|
||||
if (code.get(t + 1).definition instanceof KillIns) {
|
||||
if (code.get(t + 1).operands[0] == reg) {
|
||||
ConvertOutput assignment = toSourceOutput(processJumps, isStatic, scriptIndex, classIndex, localRegs, stack, scopeStack, abc, constants, method_info, body, ip + 2, t - 1, localRegNames, fullyQualifiedNames, visited);
|
||||
stack.push(assignment.output.remove(assignment.output.size() - 1));
|
||||
ConvertOutput assignment = toSourceOutput(part, processJumps, isStatic, scriptIndex, classIndex, localRegs, stack, scopeStack, abc, constants, method_info, body, ip + 2, t - 1, localRegNames, fullyQualifiedNames, visited);
|
||||
GraphTargetItem tar = assignment.output.remove(assignment.output.size() - 1);
|
||||
tar.firstPart = part;
|
||||
stack.push(tar);
|
||||
ip = t + 2;
|
||||
continue iploop;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConvertOutput;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.graph.GraphPart;
|
||||
import com.jpexs.decompiler.flash.graph.GraphSource;
|
||||
import com.jpexs.decompiler.flash.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.flash.graph.GraphTargetItem;
|
||||
@@ -62,9 +63,9 @@ public class AVM2GraphSource extends GraphSource {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> translatePart(List localData, Stack<GraphTargetItem> stack, int start, int end) {
|
||||
public List<GraphTargetItem> translatePart(GraphPart part, List localData, Stack<GraphTargetItem> stack, int start, int end) {
|
||||
List<GraphTargetItem> ret = new ArrayList<GraphTargetItem>();
|
||||
ConvertOutput co = code.toSourceOutput(false, isStatic, scriptIndex, classIndex, localRegs, stack, (Stack<GraphTargetItem>) localData.get(AVM2Graph.DATA_SCOPESTACK), abc, abc.constants, abc.method_info, body, start, end, localRegNames, fullyQualifiedNames, new boolean[size()]);
|
||||
ConvertOutput co = code.toSourceOutput(part, false, isStatic, scriptIndex, classIndex, localRegs, stack, (Stack<GraphTargetItem>) localData.get(AVM2Graph.DATA_SCOPESTACK), abc, abc.constants, abc.method_info, body, start, end, localRegNames, fullyQualifiedNames, new boolean[size()]);
|
||||
ret.addAll(co.output);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.List;
|
||||
|
||||
public class CoerceTreeItem extends TreeItem {
|
||||
|
||||
public GraphTargetItem value;
|
||||
//public GraphTargetItem value;
|
||||
public String type;
|
||||
|
||||
public CoerceTreeItem(AVM2Instruction instruction, GraphTargetItem value, String type) {
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.List;
|
||||
|
||||
public class ConvertTreeItem extends TreeItem {
|
||||
|
||||
public GraphTargetItem value;
|
||||
//public GraphTargetItem value;
|
||||
public String type;
|
||||
|
||||
public ConvertTreeItem(AVM2Instruction instruction, GraphTargetItem value, String type) {
|
||||
|
||||
@@ -27,7 +27,7 @@ public class InitPropertyTreeItem extends TreeItem implements SetTypeTreeItem, A
|
||||
|
||||
public GraphTargetItem object;
|
||||
public FullMultinameTreeItem propertyName;
|
||||
public GraphTargetItem value;
|
||||
//public GraphTargetItem value;
|
||||
|
||||
public InitPropertyTreeItem(AVM2Instruction instruction, GraphTargetItem object, FullMultinameTreeItem propertyName, GraphTargetItem value) {
|
||||
super(instruction, PRECEDENCE_ASSIGMENT);
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.List;
|
||||
public class NameValuePair extends TreeItem {
|
||||
|
||||
public GraphTargetItem name;
|
||||
public GraphTargetItem value;
|
||||
//public GraphTargetItem value;
|
||||
|
||||
public NameValuePair(GraphTargetItem name, GraphTargetItem value) {
|
||||
super(name.src, NOPRECEDENCE);
|
||||
|
||||
@@ -25,8 +25,7 @@ import java.util.List;
|
||||
|
||||
public class ReturnValueTreeItem extends TreeItem implements ExitItem {
|
||||
|
||||
public GraphTargetItem value;
|
||||
|
||||
//public GraphTargetItem value;
|
||||
public ReturnValueTreeItem(AVM2Instruction instruction, GraphTargetItem value) {
|
||||
super(instruction, NOPRECEDENCE);
|
||||
this.value = value;
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.treemodel;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.graph.GraphPart;
|
||||
import com.jpexs.decompiler.flash.graph.GraphTargetItem;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -25,7 +26,12 @@ import java.util.List;
|
||||
public class SetGlobalSlotTreeItem extends TreeItem {
|
||||
|
||||
public int slotId;
|
||||
public GraphTargetItem value;
|
||||
//public GraphTargetItem value;
|
||||
|
||||
@Override
|
||||
public GraphPart getFirstPart() {
|
||||
return value.getFirstPart();
|
||||
}
|
||||
|
||||
public SetGlobalSlotTreeItem(AVM2Instruction instruction, int slotId, GraphTargetItem value) {
|
||||
super(instruction, PRECEDENCE_ASSIGMENT);
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.util.List;
|
||||
public class SetLocalTreeItem extends TreeItem implements SetTypeTreeItem, AssignmentTreeItem {
|
||||
|
||||
public int regIndex;
|
||||
public GraphTargetItem value;
|
||||
//public GraphTargetItem value;
|
||||
|
||||
public SetLocalTreeItem(AVM2Instruction instruction, int regIndex, GraphTargetItem value) {
|
||||
super(instruction, PRECEDENCE_ASSIGMENT);
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.abc.avm2.treemodel;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.treemodel.clauses.AssignmentTreeItem;
|
||||
import com.jpexs.decompiler.flash.graph.GraphPart;
|
||||
import com.jpexs.decompiler.flash.graph.GraphTargetItem;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -29,6 +30,11 @@ public class SetPropertyTreeItem extends TreeItem implements SetTypeTreeItem, As
|
||||
public FullMultinameTreeItem propertyName;
|
||||
public GraphTargetItem value;
|
||||
|
||||
@Override
|
||||
public GraphPart getFirstPart() {
|
||||
return value.getFirstPart();
|
||||
}
|
||||
|
||||
public SetPropertyTreeItem(AVM2Instruction instruction, GraphTargetItem object, FullMultinameTreeItem propertyName, GraphTargetItem value) {
|
||||
super(instruction, PRECEDENCE_ASSIGMENT);
|
||||
this.object = object;
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.treemodel.clauses.AssignmentTreeItem;
|
||||
import com.jpexs.decompiler.flash.abc.types.Multiname;
|
||||
import com.jpexs.decompiler.flash.graph.GraphPart;
|
||||
import com.jpexs.decompiler.flash.graph.GraphTargetItem;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -27,7 +28,7 @@ import java.util.List;
|
||||
public class SetSlotTreeItem extends TreeItem implements SetTypeTreeItem, AssignmentTreeItem {
|
||||
|
||||
public Multiname slotName;
|
||||
public GraphTargetItem value;
|
||||
//public GraphTargetItem value;
|
||||
public GraphTargetItem scope;
|
||||
|
||||
public SetSlotTreeItem(AVM2Instruction instruction, GraphTargetItem scope, Multiname slotName, GraphTargetItem value) {
|
||||
@@ -37,6 +38,11 @@ public class SetSlotTreeItem extends TreeItem implements SetTypeTreeItem, Assign
|
||||
this.scope = scope;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphPart getFirstPart() {
|
||||
return value.getFirstPart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.treemodel;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.graph.GraphPart;
|
||||
import com.jpexs.decompiler.flash.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.flash.helpers.Highlighting;
|
||||
import java.util.HashMap;
|
||||
@@ -25,10 +26,15 @@ import java.util.List;
|
||||
|
||||
public class SetSuperTreeItem extends TreeItem {
|
||||
|
||||
public GraphTargetItem value;
|
||||
//public GraphTargetItem value;
|
||||
public GraphTargetItem object;
|
||||
public FullMultinameTreeItem propertyName;
|
||||
|
||||
@Override
|
||||
public GraphPart getFirstPart() {
|
||||
return value.getFirstPart();
|
||||
}
|
||||
|
||||
public SetSuperTreeItem(AVM2Instruction instruction, GraphTargetItem value, GraphTargetItem object, FullMultinameTreeItem propertyName) {
|
||||
super(instruction, PRECEDENCE_ASSIGMENT);
|
||||
this.value = value;
|
||||
|
||||
@@ -24,8 +24,7 @@ import java.util.List;
|
||||
|
||||
public class ThrowTreeItem extends TreeItem {
|
||||
|
||||
public GraphTargetItem value;
|
||||
|
||||
//public GraphTargetItem value;
|
||||
public ThrowTreeItem(AVM2Instruction instruction, GraphTargetItem value) {
|
||||
super(instruction, NOPRECEDENCE);
|
||||
this.value = value;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.jpexs.decompiler.flash.action;
|
||||
|
||||
import com.jpexs.decompiler.flash.graph.GraphPart;
|
||||
import com.jpexs.decompiler.flash.graph.GraphSource;
|
||||
import com.jpexs.decompiler.flash.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.flash.graph.GraphTargetItem;
|
||||
@@ -55,7 +56,7 @@ public class ActionGraphSource extends GraphSource {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphTargetItem> translatePart(List localData, Stack<GraphTargetItem> stack, int start, int end) {
|
||||
public List<GraphTargetItem> translatePart(GraphPart part, List localData, Stack<GraphTargetItem> stack, int start, int end) {
|
||||
return (Action.actionsPartToTree(registerNames, variables, functions, stack, actions, start, end, version));
|
||||
}
|
||||
private List<Long> posCache = null;
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.List;
|
||||
public class DefineLocalTreeItem extends TreeItem implements SetTypeTreeItem {
|
||||
|
||||
public GraphTargetItem name;
|
||||
public GraphTargetItem value;
|
||||
//public GraphTargetItem value;
|
||||
private int tempRegister = -1;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.List;
|
||||
|
||||
public class MBStringExtractTreeItem extends TreeItem {
|
||||
|
||||
public GraphTargetItem value;
|
||||
//public GraphTargetItem value;
|
||||
public GraphTargetItem index;
|
||||
public GraphTargetItem count;
|
||||
|
||||
|
||||
@@ -22,8 +22,7 @@ import java.util.List;
|
||||
|
||||
public class MBStringLengthTreeItem extends TreeItem {
|
||||
|
||||
public GraphTargetItem value;
|
||||
|
||||
//public GraphTargetItem value;
|
||||
public MBStringLengthTreeItem(GraphSourceItem instruction, GraphTargetItem value) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.value = value;
|
||||
|
||||
@@ -23,8 +23,7 @@ import java.util.List;
|
||||
|
||||
public class ReturnTreeItem extends TreeItem implements ExitItem {
|
||||
|
||||
public GraphTargetItem value;
|
||||
|
||||
//public GraphTargetItem value;
|
||||
public ReturnTreeItem(GraphSourceItem instruction, GraphTargetItem value) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.value = value;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.action.treemodel;
|
||||
|
||||
import com.jpexs.decompiler.flash.graph.GraphPart;
|
||||
import com.jpexs.decompiler.flash.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.flash.graph.GraphTargetItem;
|
||||
import static com.jpexs.decompiler.flash.graph.GraphTargetItem.PRECEDENCE_ASSIGMENT;
|
||||
@@ -25,9 +26,14 @@ public class SetMemberTreeItem extends TreeItem implements SetTypeTreeItem {
|
||||
|
||||
public GraphTargetItem object;
|
||||
public GraphTargetItem objectName;
|
||||
public GraphTargetItem value;
|
||||
//public GraphTargetItem value;
|
||||
private int tempRegister = -1;
|
||||
|
||||
@Override
|
||||
public GraphPart getFirstPart() {
|
||||
return value.getFirstPart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(GraphTargetItem value) {
|
||||
this.value = value;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.action.treemodel;
|
||||
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.graph.GraphPart;
|
||||
import com.jpexs.decompiler.flash.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.flash.graph.GraphTargetItem;
|
||||
import static com.jpexs.decompiler.flash.graph.GraphTargetItem.PRECEDENCE_ASSIGMENT;
|
||||
@@ -26,7 +27,12 @@ public class SetPropertyTreeItem extends TreeItem implements SetTypeTreeItem {
|
||||
|
||||
public GraphTargetItem target;
|
||||
public int propertyIndex;
|
||||
public GraphTargetItem value;
|
||||
//public GraphTargetItem value;
|
||||
|
||||
@Override
|
||||
public GraphPart getFirstPart() {
|
||||
return value.getFirstPart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(GraphTargetItem value) {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.action.treemodel;
|
||||
|
||||
import com.jpexs.decompiler.flash.graph.GraphPart;
|
||||
import com.jpexs.decompiler.flash.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.flash.graph.GraphTargetItem;
|
||||
import static com.jpexs.decompiler.flash.graph.GraphTargetItem.PRECEDENCE_ASSIGMENT;
|
||||
@@ -24,9 +25,14 @@ import java.util.List;
|
||||
public class SetVariableTreeItem extends TreeItem implements SetTypeTreeItem {
|
||||
|
||||
public GraphTargetItem name;
|
||||
public GraphTargetItem value;
|
||||
//public GraphTargetItem value;
|
||||
private int tempRegister = -1;
|
||||
|
||||
@Override
|
||||
public GraphPart getFirstPart() {
|
||||
return value.getFirstPart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(GraphTargetItem value) {
|
||||
this.value = value;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.action.treemodel;
|
||||
|
||||
import com.jpexs.decompiler.flash.action.swf4.RegisterNumber;
|
||||
import com.jpexs.decompiler.flash.graph.GraphPart;
|
||||
import com.jpexs.decompiler.flash.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.flash.graph.GraphTargetItem;
|
||||
import java.util.List;
|
||||
@@ -24,9 +25,14 @@ import java.util.List;
|
||||
public class StoreRegisterTreeItem extends TreeItem implements SetTypeTreeItem {
|
||||
|
||||
public RegisterNumber register;
|
||||
public GraphTargetItem value;
|
||||
//public GraphTargetItem value;
|
||||
public boolean define = false;
|
||||
|
||||
@Override
|
||||
public GraphPart getFirstPart() {
|
||||
return value.getFirstPart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(GraphTargetItem value) {
|
||||
this.value = value;
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.List;
|
||||
|
||||
public class StringExtractTreeItem extends TreeItem {
|
||||
|
||||
public GraphTargetItem value;
|
||||
//public GraphTargetItem value;
|
||||
public GraphTargetItem index;
|
||||
public GraphTargetItem count;
|
||||
|
||||
|
||||
+1
-2
@@ -23,8 +23,7 @@ import com.jpexs.decompiler.flash.graph.GraphTargetItem;
|
||||
|
||||
public class StringLengthTreeItem extends TreeItem {
|
||||
|
||||
public GraphTargetItem value;
|
||||
|
||||
//public GraphTargetItem value;
|
||||
public StringLengthTreeItem(GraphSourceItem instruction, GraphTargetItem value) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.value = value;
|
||||
|
||||
@@ -20,18 +20,6 @@ import java.util.List;
|
||||
|
||||
public class AndItem extends BinaryOpItem {
|
||||
|
||||
public GraphPart firstPart;
|
||||
|
||||
public GraphPart getFirstPart() {
|
||||
if (leftSide instanceof AndItem) {
|
||||
return ((AndItem) leftSide).getFirstPart();
|
||||
}
|
||||
if (leftSide instanceof OrItem) {
|
||||
return ((OrItem) leftSide).getFirstPart();
|
||||
}
|
||||
return firstPart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItemPos> getNeededSources() {
|
||||
List<GraphSourceItemPos> ret = super.getNeededSources();
|
||||
|
||||
@@ -24,6 +24,15 @@ public abstract class BinaryOpItem extends GraphTargetItem {
|
||||
public GraphTargetItem rightSide;
|
||||
protected String operator = "";
|
||||
|
||||
@Override
|
||||
public GraphPart getFirstPart() {
|
||||
GraphPart fp = leftSide.getFirstPart();
|
||||
if (fp == null) {
|
||||
return super.getFirstPart();
|
||||
}
|
||||
return fp;
|
||||
}
|
||||
|
||||
public BinaryOpItem(GraphSourceItem instruction, int precedence, GraphTargetItem leftSide, GraphTargetItem rightSide, String operator) {
|
||||
super(instruction, precedence);
|
||||
this.leftSide = leftSide;
|
||||
|
||||
@@ -463,7 +463,7 @@ public class Graph {
|
||||
}
|
||||
end = p.end;
|
||||
int start = p.start;
|
||||
ret.addAll(code.translatePart(localData, stack, start, end));
|
||||
ret.addAll(code.translatePart(part, localData, stack, start, end));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -536,7 +536,7 @@ public class Graph {
|
||||
}*/
|
||||
|
||||
try {
|
||||
output.addAll(code.translatePart(localData, stack, start, end));
|
||||
output.addAll(code.translatePart(p, localData, stack, start, end));
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(Graph.class.getName()).log(Level.SEVERE, "error during printgraph", ex);
|
||||
return ret;
|
||||
@@ -824,11 +824,9 @@ public class Graph {
|
||||
ret.addAll(output);
|
||||
}
|
||||
if (loop) {
|
||||
if (expr instanceof AndItem) {
|
||||
currentLoop.loopContinue = ((AndItem) expr).getFirstPart();
|
||||
}
|
||||
if (expr instanceof OrItem) {
|
||||
currentLoop.loopContinue = ((OrItem) expr).getFirstPart();
|
||||
GraphPart f = expr.getFirstPart();
|
||||
if (f != null) {
|
||||
currentLoop.loopContinue = f;
|
||||
}
|
||||
}
|
||||
GraphPart loopBodyStart = null;
|
||||
|
||||
@@ -18,7 +18,7 @@ public abstract class GraphSource {
|
||||
|
||||
public abstract boolean isEmpty();
|
||||
|
||||
public abstract List<GraphTargetItem> translatePart(List localData, Stack<GraphTargetItem> stack, int start, int end);
|
||||
public abstract List<GraphTargetItem> translatePart(GraphPart part, List localData, Stack<GraphTargetItem> stack, int start, int end);
|
||||
|
||||
private void visitCode(int ip, int lastIp, HashMap<Integer, List<Integer>> refs, int endIp) {
|
||||
boolean debugMode = false;
|
||||
|
||||
@@ -31,6 +31,19 @@ public abstract class GraphTargetItem {
|
||||
public int pos = 0;
|
||||
public int precedence;
|
||||
public List<GraphSourceItemPos> moreSrc = new ArrayList<GraphSourceItemPos>();
|
||||
public GraphPart firstPart;
|
||||
public GraphTargetItem value;
|
||||
|
||||
public GraphPart getFirstPart() {
|
||||
if (value == null) {
|
||||
return firstPart;
|
||||
}
|
||||
GraphPart ret = value.getFirstPart();
|
||||
if (ret == null) {
|
||||
return firstPart;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public GraphTargetItem(GraphSourceItem src, int precedence) {
|
||||
this.src = src;
|
||||
|
||||
@@ -20,18 +20,6 @@ import java.util.List;
|
||||
|
||||
public class OrItem extends BinaryOpItem {
|
||||
|
||||
public GraphPart firstPart;
|
||||
|
||||
public GraphPart getFirstPart() {
|
||||
if (leftSide instanceof AndItem) {
|
||||
return ((AndItem) leftSide).getFirstPart();
|
||||
}
|
||||
if (leftSide instanceof OrItem) {
|
||||
return ((OrItem) leftSide).getFirstPart();
|
||||
}
|
||||
return firstPart;
|
||||
}
|
||||
|
||||
public OrItem(GraphSourceItem src, GraphTargetItem leftSide, GraphTargetItem rightSide) {
|
||||
super(src, PRECEDENCE_LOGICALOR, leftSide, rightSide, "||");
|
||||
this.leftSide = leftSide;
|
||||
|
||||
Reference in New Issue
Block a user