diff --git a/trunk/src/com/jpexs/decompiler/flash/Main.java b/trunk/src/com/jpexs/decompiler/flash/Main.java index 6b2000b51..ee3336927 100644 --- a/trunk/src/com/jpexs/decompiler/flash/Main.java +++ b/trunk/src/com/jpexs/decompiler/flash/Main.java @@ -17,7 +17,6 @@ package com.jpexs.decompiler.flash; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.gui.AboutDialog; import com.jpexs.decompiler.flash.gui.LoadingDialog; import com.jpexs.decompiler.flash.gui.MainFrame; @@ -25,7 +24,6 @@ import com.jpexs.decompiler.flash.gui.ModeFrame; import com.jpexs.decompiler.flash.gui.View; import com.jpexs.decompiler.flash.gui.player.FlashPlayerPanel; import com.jpexs.decompiler.flash.gui.proxy.ProxyFrame; -import com.jpexs.decompiler.flash.helpers.Highlighting; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; diff --git a/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java b/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java index a94a06213..3be40f376 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java @@ -529,13 +529,13 @@ public class SWFInputStream extends InputStream { stack.pop(); getConstantPool(localData, stack, output, code, condition ? (code.adr2pos(((ActionIf) ins).getAddress() + ((ActionIf) ins).getBytes(code.version).length + ((ActionIf) ins).offset)) : ip + 1, ip, constantPools, visited); } else { - if(ins instanceof ActionIf){ + if (ins instanceof ActionIf) { stack.pop(); } visited.add(ip); List branches = ins.getBranches(code); for (int b : branches) { - Stack brStack=(Stack)stack.clone(); + Stack brStack = (Stack) stack.clone(); if (b >= 0) { getConstantPool(localData, brStack, output, code, b, ip, constantPools, visited); } else { @@ -619,7 +619,7 @@ public class SWFInputStream extends InputStream { //Action.setConstantPool(ret, cpool); try { - s = Highlighting.stripHilights(Action.actionsToString(ret, null, version,false)); + s = Highlighting.stripHilights(Action.actionsToString(ret, null, version, false)); ret = ASMParser.parse(false, new ByteArrayInputStream(s.getBytes()), SWF.DEFAULT_VERSION); } catch (ParseException ex) { Logger.getLogger(SWFInputStream.class.getName()).log(Level.SEVERE, "parsing error", ex); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java b/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java index 31f6022aa..d4940f78c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java @@ -73,7 +73,7 @@ public class ABC { public int removeTraps() { int rem = 0; for (MethodBody body : bodies) { - rem += body.removeTraps(constants); + rem += body.removeTraps(constants, this); } return rem; } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java index 94ffe26ed..9cfc2ff00 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java @@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.ABCInputStream; import com.jpexs.decompiler.flash.abc.CopyOutputStream; import com.jpexs.decompiler.flash.abc.avm2.graph.AVM2Graph; +import com.jpexs.decompiler.flash.abc.avm2.graph.AVM2GraphSource; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; @@ -49,6 +50,8 @@ 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.GraphSourceItem; +import com.jpexs.decompiler.flash.graph.GraphSourceItemPos; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.flash.helpers.Highlighting; @@ -125,11 +128,11 @@ public class AVM2Code implements Serializable { new CoerceSIns(), new InstructionDefinition(0x88, "coerce_u", new int[]{}), //stack:-1+1 new InstructionDefinition(0x9a, "concat", new int[]{}) { - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; //? - } -}, + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; //? + } + }, new ConstructIns(), new ConstructPropIns(), new ConstructSuperIns(), @@ -141,11 +144,11 @@ public class AVM2Code implements Serializable { new ConvertSIns(), new InstructionDefinition(0x79, "convert_m", new int[]{}), //-1 +1 new InstructionDefinition(0x7a, "convert_m_p", new int[]{AVM2Code.OPT_U30 /*param (?)*/}) { - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } -}, + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, new DebugIns(), new DebugFileIns(), new DebugLineIns(), @@ -725,9 +728,9 @@ public class AVM2Code implements Serializable { int largeLimit = 20000; boolean markOffsets = code.size() <= largeLimit; for (AVM2Instruction ins : code) { - if(hex){ + if (hex) { ret.append(""); - ret.append(Helper.bytesToHexString(ins.getBytes())); + ret.append(Helper.bytesToHexString(ins.getBytes())); ret.append("\n"); } if (ins.labelname != null) { @@ -1671,163 +1674,184 @@ public class AVM2Code implements Serializable { code.add(pos, instruction); } - public int removeTraps(ConstantPool constants, MethodBody body) { + public int removeTraps(ConstantPool constants, MethodBody body, ABC abc) { removeDeadCode(constants, body); - boolean isSecure = true; - try { - if (code.size() > 4) { - AVM2Instruction first = code.get(0); - AVM2Instruction second = code.get(1); - boolean firstValue = false; - boolean secondValue = false; - if (first.definition instanceof PushFalseIns) { - firstValue = false; - } else if (first.definition instanceof PushTrueIns) { - firstValue = true; - } else { - isSecure = false; - } - if (isSecure) { - if (second.definition instanceof PushFalseIns) { - secondValue = false; - } else if (second.definition instanceof PushTrueIns) { - secondValue = true; - } else { - isSecure = false; - } - if (isSecure) { - int pos = 2; - AVM2Instruction third = code.get(pos); - if (third.definition instanceof SwapIns) { - pos++; - boolean dup = firstValue; - firstValue = secondValue; - secondValue = dup; - third.ignored = true; - } - while (third.definition instanceof JumpIns) { - pos = adr2pos(pos2adr(pos) + third.getBytes().length + third.operands[0]); - third = code.get(pos); - } - AVM2Instruction firstSet = code.get(pos); - while (firstSet.definition instanceof JumpIns) { - pos = adr2pos(pos2adr(pos) + firstSet.getBytes().length + firstSet.operands[0]); - firstSet = code.get(pos); - } - pos++; - AVM2Instruction secondSet = code.get(pos); - while (secondSet.definition instanceof JumpIns) { - pos = adr2pos(pos2adr(pos) + secondSet.getBytes().length + secondSet.operands[0]); - secondSet = code.get(pos); - } - int trueIndex = -1; - int falseIndex = -1; - if (firstSet.definition instanceof SetLocalTypeIns) { - if (secondValue == true) { - trueIndex = ((SetLocalTypeIns) firstSet.definition).getRegisterId(firstSet); - } - if (secondValue == false) { - falseIndex = ((SetLocalTypeIns) firstSet.definition).getRegisterId(firstSet); - } - } else { - isSecure = false; - } - if (isSecure) { - if (secondSet.definition instanceof SetLocalTypeIns) { - if (firstValue == true) { - trueIndex = ((SetLocalTypeIns) secondSet.definition).getRegisterId(secondSet); - } - if (firstValue == false) { - falseIndex = ((SetLocalTypeIns) secondSet.definition).getRegisterId(secondSet); - } - secondSet.ignored = true; - firstSet.ignored = true; - first.ignored = true; - second.ignored = true; - boolean found; - do { - found = false; - for (int ip = 0; ip < code.size(); ip++) { - if (code.get(ip).ignored) { - continue; - } - if (code.get(ip).definition instanceof GetLocalTypeIns) { - int regIndex = ((GetLocalTypeIns) code.get(ip).definition).getRegisterId(code.get(ip)); - if ((regIndex == trueIndex) || (regIndex == falseIndex)) { - found = true; - Stack myStack = new Stack(); - do { - AVM2Instruction ins = code.get(ip); - /*if (ins.ignored) { - ip++; - continue; - } else*/ if (ins.definition instanceof GetLocalTypeIns) { - regIndex = ((GetLocalTypeIns) ins.definition).getRegisterId(ins); - if (regIndex == trueIndex) { - myStack.push(true); - } - if (regIndex == falseIndex) { - myStack.push(false); - } - ip++; - ins.ignored = true; - } else if (ins.definition instanceof DupIns) { - Boolean b = myStack.pop(); - myStack.push(b); - myStack.push(b); - ins.ignored = true; - ip++; - } else if (ins.definition instanceof PopIns) { - myStack.pop(); - ins.ignored = true; - ip++; - } else if (ins.definition instanceof IfTrueIns) { - boolean val = myStack.pop(); - if (val) { - code.get(ip).definition = new JumpIns(); - ip = adr2pos(pos2adr(ip + 1) + code.get(ip).operands[0]); - } else { - code.get(ip).ignored = true; - ip++; - } - } else if (ins.definition instanceof IfFalseIns) { - boolean val = myStack.pop(); - if (!val) { - code.get(ip).definition = new JumpIns(); - ip = adr2pos(pos2adr(ip + 1) + code.get(ip).operands[0]); - } else { - code.get(ip).ignored = true; - ip++; - } - } else if (ins.definition instanceof JumpIns) { - ip = adr2pos(pos2adr(ip + 1) + code.get(ip).operands[0]); - } else { - ip++; - } + /* boolean isSecure = true; + try { + if (code.size() > 4) { + AVM2Instruction first = code.get(0); + AVM2Instruction second = code.get(1); + boolean firstValue = false; + boolean secondValue = false; + if (first.definition instanceof PushFalseIns) { + firstValue = false; + } else if (first.definition instanceof PushTrueIns) { + firstValue = true; + } else { + isSecure = false; + } + if (isSecure) { + if (second.definition instanceof PushFalseIns) { + secondValue = false; + } else if (second.definition instanceof PushTrueIns) { + secondValue = true; + } else { + isSecure = false; + } + if (isSecure) { + int pos = 2; + AVM2Instruction third = code.get(pos); + if (third.definition instanceof SwapIns) { + pos++; + boolean dup = firstValue; + firstValue = secondValue; + secondValue = dup; + third.ignored = true; + } + while (third.definition instanceof JumpIns) { + pos = adr2pos(pos2adr(pos) + third.getBytes().length + third.operands[0]); + third = code.get(pos); + } + AVM2Instruction firstSet = code.get(pos); + while (firstSet.definition instanceof JumpIns) { + pos = adr2pos(pos2adr(pos) + firstSet.getBytes().length + firstSet.operands[0]); + firstSet = code.get(pos); + } + pos++; + AVM2Instruction secondSet = code.get(pos); + while (secondSet.definition instanceof JumpIns) { + pos = adr2pos(pos2adr(pos) + secondSet.getBytes().length + secondSet.operands[0]); + secondSet = code.get(pos); + } + int trueIndex = -1; + int falseIndex = -1; + if (firstSet.definition instanceof SetLocalTypeIns) { + if (secondValue == true) { + trueIndex = ((SetLocalTypeIns) firstSet.definition).getRegisterId(firstSet); + } + if (secondValue == false) { + falseIndex = ((SetLocalTypeIns) firstSet.definition).getRegisterId(firstSet); + } + } else { + isSecure = false; + } + if (isSecure) { + if (secondSet.definition instanceof SetLocalTypeIns) { + if (firstValue == true) { + trueIndex = ((SetLocalTypeIns) secondSet.definition).getRegisterId(secondSet); + } + if (firstValue == false) { + falseIndex = ((SetLocalTypeIns) secondSet.definition).getRegisterId(secondSet); + } + secondSet.ignored = true; + firstSet.ignored = true; + first.ignored = true; + second.ignored = true; + boolean found; + do { + found = false; + for (int ip = 0; ip < code.size(); ip++) { + if (code.get(ip).ignored) { + continue; + } + if (code.get(ip).definition instanceof GetLocalTypeIns) { + int regIndex = ((GetLocalTypeIns) code.get(ip).definition).getRegisterId(code.get(ip)); + if ((regIndex == trueIndex) || (regIndex == falseIndex)) { + found = true; + Stack myStack = new Stack(); + do { + AVM2Instruction ins = code.get(ip); + if (ins.definition instanceof GetLocalTypeIns) { + regIndex = ((GetLocalTypeIns) ins.definition).getRegisterId(ins); + if (regIndex == trueIndex) { + myStack.push(true); + } + if (regIndex == falseIndex) { + myStack.push(false); + } + ip++; + ins.ignored = true; + } else if (ins.definition instanceof DupIns) { + Boolean b = myStack.pop(); + myStack.push(b); + myStack.push(b); + ins.ignored = true; + ip++; + } else if (ins.definition instanceof PopIns) { + myStack.pop(); + ins.ignored = true; + ip++; + } else if (ins.definition instanceof IfTrueIns) { + boolean val = myStack.pop(); + if (val) { + code.get(ip).definition = new JumpIns(); + ip = adr2pos(pos2adr(ip + 1) + code.get(ip).operands[0]); + } else { + code.get(ip).ignored = true; + ip++; + } + } else if (ins.definition instanceof IfFalseIns) { + boolean val = myStack.pop(); + if (!val) { + code.get(ip).definition = new JumpIns(); + ip = adr2pos(pos2adr(ip + 1) + code.get(ip).operands[0]); + } else { + code.get(ip).ignored = true; + ip++; + } + } else if (ins.definition instanceof JumpIns) { + ip = adr2pos(pos2adr(ip + 1) + code.get(ip).operands[0]); + } else { + ip++; + } - } while (myStack.size() > 0); + } while (myStack.size() > 0 && ip < code.size()); - break; - } + break; + } - } - } - } while (found); - removeIgnored(constants, body); - removeDeadCode(constants, body); - } else { - //isSecure = false; - } - } + } + } + } while (found); + removeIgnored(constants, body); + removeDeadCode(constants, body); + } else { + //isSecure = false; + } + } - } - } - } - } catch (ConvertException cex) { - } - int ret = isSecure ? 1 : 0; - ret += visitCodeTrap(body, new int[code.size()]); + } + } + } + } catch (ConvertException cex) { + } + int ret = isSecure ? 1 : 0; + ret += visitCodeTrap(body, new int[code.size()]);*/ + + //definition.translate((Boolean) localData.get(0), (Integer) localData.get(1), + //(HashMap) localData.get(2), stack, + //(Stack) localData.get(3), (ConstantPool) localData.get(4), this, + //(MethodInfo[]) localData.get(5), output, + //(MethodBody) localData.get(6), (ABC) localData.get(7), + //(HashMap) localData.get(8), (List) localData.get(8)); + + List localData = new ArrayList(); + localData.add((Boolean) false); //isStatic + localData.add((Integer) 0); //classIndex + localData.add(new HashMap()); + localData.add(new Stack()); + localData.add(abc.constants); + localData.add(abc.method_info); + localData.add(body); + localData.add(abc); + localData.add(new HashMap()); //localRegNames + localData.add(new ArrayList()); //fullyQualifiedNames + localData.add(new ArrayList()); + localData.add(new ArrayList()); + localData.add(new ArrayList()); + int ret = 0; + ret += removeTraps(localData, new AVM2GraphSource(this, false, 0, new HashMap(), new Stack(), abc, body, new HashMap(), new ArrayList()), 0); removeIgnored(constants, body); removeDeadCode(constants, body); @@ -2257,7 +2281,7 @@ public class AVM2Code implements Serializable { invalidateCache(); try { List outputMap = new ArrayList(); - String src = Highlighting.stripHilights(toASMSource(constants, body, outputMap,false)); + String src = Highlighting.stripHilights(toASMSource(constants, body, outputMap, false)); AVM2Code acode = ASM3Parser.parse(new ByteArrayInputStream(src.getBytes()), constants, null, body); for (int i = 0; i < acode.code.size(); i++) { @@ -2297,7 +2321,7 @@ public class AVM2Code implements Serializable { public void removeIgnored(ConstantPool constants, MethodBody body) { try { List outputMap = new ArrayList(); - String src = toASMSource(constants, body, outputMap,false); + String src = toASMSource(constants, body, outputMap, false); AVM2Code acode = ASM3Parser.parse(new ByteArrayInputStream(src.getBytes()), constants, body); for (int i = 0; i < acode.code.size(); i++) { if (outputMap.size() > i) { @@ -2367,4 +2391,78 @@ public class AVM2Code implements Serializable { return null; } } + + private static int removeTraps(List localData, Stack stack, List output, AVM2GraphSource code, int ip, int lastIp, List visited) { + boolean debugMode = false; + int ret = 0; + while ((ip > -1) && ip < code.size()) { + if (visited.contains(ip)) { + break; + } + visited.add(ip); + lastIp = ip; + GraphSourceItem ins = code.get(ip); + if (debugMode) { + System.out.println("Visit " + ip + ": " + ins + " stack:" + Highlighting.stripHilights(stack.toString())); + } + if ((ins instanceof AVM2Instruction) && (((AVM2Instruction) ins).definition instanceof NewFunctionIns)) { + stack.push(new BooleanTreeItem(null, true)); + } else { + ins.translate(localData, stack, output); + } + if (ins.isExit()) { + break; + } + + if (ins.isBranch() || ins.isJump()) { + List branches = ins.getBranches(code); + if (ins.isBranch() && !stack.isEmpty() && (stack.peek().isCompileTime())) { + boolean condition = stack.peek().toBoolean(); + if (debugMode) { + if (condition) { + System.out.println("JUMP"); + } else { + System.out.println("SKIP"); + } + } + if (condition) { + ((AVM2Instruction) ins).definition = new JumpIns(); + } else { + ins.setIgnored(true); + } + GraphTargetItem tar = stack.pop(); + for (GraphSourceItemPos pos : tar.getNeededSources()) { + pos.item.setIgnored(true); + } + + ret += removeTraps(localData, stack, output, code, condition ? branches.get(0) : branches.get(1), ip, visited); + } else { + if (ins.isBranch()) { + stack.pop(); + } + + for (int b : branches) { + Stack brStack = (Stack) stack.clone(); + if (b >= 0) { + ret += removeTraps(localData, brStack, output, code, b, ip, visited); + } else { + if (debugMode) { + System.out.println("Negative branch:" + b); + } + } + } + } + break; + } + ip++; + }; + if (ip < 0) { + System.out.println("Visited Negative: " + ip); + } + return ret; + } + + public static int removeTraps(List localData, AVM2GraphSource code, int addr) { + return removeTraps(localData, new Stack(), new ArrayList(), code, code.adr2pos(addr), 0, new ArrayList()); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java index 472cd97d0..d7463499a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java @@ -224,6 +224,7 @@ public class AVM2Instruction implements Serializable, GraphSourceItem { return " ;" + comment; } + @Override public boolean isIgnored() { return ignored; } @@ -243,7 +244,7 @@ public class AVM2Instruction implements Serializable, GraphSourceItem { @Override public void translate(List localData, Stack stack, List output) { - definition.translate((Boolean) localData.get(0), (Integer) localData.get(1), (HashMap) localData.get(2), stack, (Stack) localData.get(3), (ConstantPool) localData.get(4), this, (MethodInfo[]) localData.get(5), output, (MethodBody) localData.get(6), (ABC) localData.get(7), (HashMap) localData.get(8), (List) localData.get(8)); + definition.translate((Boolean) localData.get(0), (Integer) localData.get(1), (HashMap) localData.get(2), stack, (Stack) localData.get(3), (ConstantPool) localData.get(4), this, (MethodInfo[]) localData.get(5), output, (MethodBody) localData.get(6), (ABC) localData.get(7), (HashMap) localData.get(8), (List) localData.get(9)); } @Override @@ -288,4 +289,9 @@ public class AVM2Instruction implements Serializable, GraphSourceItem { public boolean ignoredLoops() { return false; } + + @Override + public void setIgnored(boolean ignored) { + this.ignored = ignored; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/ASM3Parser.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/ASM3Parser.java index c2b27e1dd..17eac25f1 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/ASM3Parser.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/ASM3Parser.java @@ -138,8 +138,8 @@ public class ASM3Parser { } ABCException ex = new ABCException(); - ex.name_index = checkMultinameIndex(constants,(int) (long) (Long) exName.value,lexer.yyline()); - ex.type_index = checkMultinameIndex(constants,(int) (long) (Long) exType.value,lexer.yyline()); + ex.name_index = checkMultinameIndex(constants, (int) (long) (Long) exName.value, lexer.yyline()); + ex.type_index = checkMultinameIndex(constants, (int) (long) (Long) exType.value, lexer.yyline()); exceptions.add(ex); exceptionIndices.add((int) (long) (Long) exIndex.value); continue; @@ -155,7 +155,7 @@ public class ASM3Parser { switch (def.operands[i]) { case AVM2Code.DAT_MULTINAME_INDEX: if (parsedOperand.type == ParsedSymbol.TYPE_MULTINAME) { - operandsList.add(checkMultinameIndex(constants,(int) (long) (Long) parsedOperand.value,lexer.yyline())); + operandsList.add(checkMultinameIndex(constants, (int) (long) (Long) parsedOperand.value, lexer.yyline())); } else { throw new ParseException("Multiname expected", lexer.yyline()); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/BooleanTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/BooleanTreeItem.java index 36611d2d1..b8a84e239 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/BooleanTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/BooleanTreeItem.java @@ -44,4 +44,19 @@ public class BooleanTreeItem extends TreeItem { public boolean isTrue() { return value == true; } + + @Override + public boolean toBoolean() { + return value; + } + + @Override + public double toNumber() { + return value ? 1 : 0; + } + + @Override + public boolean isCompileTime() { + return true; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/FloatValueTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/FloatValueTreeItem.java index 0b94786d7..f58ff0ded 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/FloatValueTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/FloatValueTreeItem.java @@ -34,4 +34,14 @@ public class FloatValueTreeItem extends NumberValueTreeItem { public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { return hilight("" + value); } + + @Override + public double toNumber() { + return value; + } + + @Override + public boolean isCompileTime() { + return true; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/IntegerValueTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/IntegerValueTreeItem.java index cfdfde3d7..512228250 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/IntegerValueTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/IntegerValueTreeItem.java @@ -34,4 +34,14 @@ public class IntegerValueTreeItem extends NumberValueTreeItem { public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { return hilight("" + value); } + + @Override + public double toNumber() { + return value; + } + + @Override + public boolean isCompileTime() { + return true; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/LocalRegTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/LocalRegTreeItem.java index 1bd7387d1..4dfbcaae1 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/LocalRegTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/LocalRegTreeItem.java @@ -50,4 +50,19 @@ public class LocalRegTreeItem extends TreeItem { public GraphTargetItem getThroughRegister() { return computedValue.getThroughRegister(); } + + @Override + public double toNumber() { + return computedValue.toNumber(); + } + + @Override + public boolean toBoolean() { + return computedValue.toBoolean(); + } + + @Override + public boolean isCompileTime() { + return computedValue.isCompileTime(); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NullTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NullTreeItem.java index de0fa313b..ff9a5a9b3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NullTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NullTreeItem.java @@ -31,4 +31,19 @@ public class NullTreeItem extends TreeItem { public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { return hilight("null"); } + + @Override + public boolean isCompileTime() { + return true; + } + + @Override + public double toNumber() { + return 0; + } + + @Override + public boolean toBoolean() { + return false; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/AddTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/AddTreeItem.java index 07e8e8f22..06616e403 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/AddTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/AddTreeItem.java @@ -16,32 +16,36 @@ */ package com.jpexs.decompiler.flash.abc.avm2.treemodel.operations; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.graph.BinaryOpItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; -import java.util.HashMap; import java.util.List; -public class AddTreeItem extends BinaryOpTreeItem { +public class AddTreeItem extends BinaryOpItem { public AddTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { super(instruction, PRECEDENCE_ADDITIVE, leftSide, rightSide, "+"); } @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + public String toString(List localData) { if (rightSide.precedence >= precedence) { String ret = ""; if (leftSide.precedence > precedence) { - ret += "(" + leftSide.toString(constants, localRegNames, fullyQualifiedNames) + ")"; + ret += "(" + leftSide.toString(localData) + ")"; } else { - ret += leftSide.toString(constants, localRegNames, fullyQualifiedNames); + ret += leftSide.toString(localData); } ret += hilight(operator); - ret += "(" + rightSide.toString(constants, localRegNames, fullyQualifiedNames) + ")"; + ret += "(" + rightSide.toString(localData) + ")"; return ret; } else { - return super.toString(constants, localRegNames, fullyQualifiedNames); + return super.toString(localData); } } + + @Override + public double toNumber() { + return leftSide.toNumber() + rightSide.toNumber(); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/AndTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/AndTreeItem.java index 67c8f4e6c..19b06e04f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/AndTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/AndTreeItem.java @@ -17,10 +17,11 @@ package com.jpexs.decompiler.flash.abc.avm2.treemodel.operations; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.graph.BinaryOpItem; import com.jpexs.decompiler.flash.graph.GraphPart; import com.jpexs.decompiler.flash.graph.GraphTargetItem; -public class AndTreeItem extends BinaryOpTreeItem { +public class AndTreeItem extends BinaryOpItem { public GraphPart firstPart; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/AsTypeTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/AsTypeTreeItem.java index 07c764285..99cefa9a5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/AsTypeTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/AsTypeTreeItem.java @@ -17,9 +17,10 @@ package com.jpexs.decompiler.flash.abc.avm2.treemodel.operations; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.graph.BinaryOpItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; -public class AsTypeTreeItem extends BinaryOpTreeItem { +public class AsTypeTreeItem extends BinaryOpItem { public AsTypeTreeItem(AVM2Instruction instruction, GraphTargetItem value, GraphTargetItem type) { super(instruction, PRECEDENCE_RELATIONAL, value, type, " as "); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/BinaryOpTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/BinaryOpTreeItem.java deleted file mode 100644 index eb2408931..000000000 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/BinaryOpTreeItem.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2010-2013 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.treemodel.operations; - -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.TreeItem; -import com.jpexs.decompiler.flash.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; - -public abstract class BinaryOpTreeItem extends TreeItem { - - public GraphTargetItem leftSide; - public GraphTargetItem rightSide; - protected String operator = ""; - - public BinaryOpTreeItem(AVM2Instruction instruction, int precedence, GraphTargetItem leftSide, GraphTargetItem rightSide, String operator) { - super(instruction, precedence); - this.leftSide = leftSide; - this.rightSide = rightSide; - this.operator = operator; - } - - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - String ret = ""; - if (leftSide.precedence > precedence) { - ret += "(" + leftSide.toString(constants, localRegNames, fullyQualifiedNames) + ")"; - } else { - ret += leftSide.toString(constants, localRegNames, fullyQualifiedNames); - } - ret += hilight(operator); - if (rightSide.precedence > precedence) { - ret += "(" + rightSide.toString(constants, localRegNames, fullyQualifiedNames) + ")"; - } else { - ret += rightSide.toString(constants, localRegNames, fullyQualifiedNames); - } - return ret; - } -} diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/BitAndTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/BitAndTreeItem.java index 1581721d2..873367267 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/BitAndTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/BitAndTreeItem.java @@ -17,11 +17,17 @@ package com.jpexs.decompiler.flash.abc.avm2.treemodel.operations; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.graph.BinaryOpItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; -public class BitAndTreeItem extends BinaryOpTreeItem { +public class BitAndTreeItem extends BinaryOpItem { public BitAndTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { super(instruction, PRECEDENCE_BITWISEAND, leftSide, rightSide, "&"); } + + @Override + public double toNumber() { + return ((int) leftSide.toNumber()) & ((int) rightSide.toNumber()); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/BitNotTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/BitNotTreeItem.java index 4b12b4471..f8d3d9dd3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/BitNotTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/BitNotTreeItem.java @@ -16,12 +16,18 @@ */ package com.jpexs.decompiler.flash.abc.avm2.treemodel.operations; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.graph.GraphSourceItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import com.jpexs.decompiler.flash.graph.UnaryOpItem; -public class BitNotTreeItem extends UnaryOpTreeItem { +public class BitNotTreeItem extends UnaryOpItem { - public BitNotTreeItem(AVM2Instruction instruction, GraphTargetItem value) { + public BitNotTreeItem(GraphSourceItem instruction, GraphTargetItem value) { super(instruction, PRECEDENCE_UNARY, value, "~"); } + + @Override + public double toNumber() { + return ~((int) value.toNumber()); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/BitOrTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/BitOrTreeItem.java index bf57f4a95..fd008c117 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/BitOrTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/BitOrTreeItem.java @@ -17,11 +17,17 @@ package com.jpexs.decompiler.flash.abc.avm2.treemodel.operations; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.graph.BinaryOpItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; -public class BitOrTreeItem extends BinaryOpTreeItem { +public class BitOrTreeItem extends BinaryOpItem { public BitOrTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { super(instruction, PRECEDENCE_BITWISEOR, leftSide, rightSide, "|"); } + + @Override + public double toNumber() { + return ((int) leftSide.toNumber()) | ((int) rightSide.toNumber()); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/BitXorTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/BitXorTreeItem.java index 4f4609c98..74a41c2cb 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/BitXorTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/BitXorTreeItem.java @@ -17,11 +17,17 @@ package com.jpexs.decompiler.flash.abc.avm2.treemodel.operations; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.graph.BinaryOpItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; -public class BitXorTreeItem extends BinaryOpTreeItem { +public class BitXorTreeItem extends BinaryOpItem { public BitXorTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { super(instruction, PRECEDENCE_BITWISEXOR, leftSide, rightSide, "^"); } + + @Override + public double toNumber() { + return ((int) leftSide.toNumber()) ^ ((int) rightSide.toNumber()); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/DivideTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/DivideTreeItem.java index 17f4ff367..7488ebb68 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/DivideTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/DivideTreeItem.java @@ -17,11 +17,17 @@ package com.jpexs.decompiler.flash.abc.avm2.treemodel.operations; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.graph.BinaryOpItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; -public class DivideTreeItem extends BinaryOpTreeItem { +public class DivideTreeItem extends BinaryOpItem { public DivideTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { super(instruction, PRECEDENCE_MULTIPLICATIVE, leftSide, rightSide, "/"); } + + @Override + public double toNumber() { + return leftSide.toNumber() / rightSide.toNumber(); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/EqTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/EqTreeItem.java index 6a8b4a394..a9be9e1c8 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/EqTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/EqTreeItem.java @@ -16,18 +16,24 @@ */ package com.jpexs.decompiler.flash.abc.avm2.treemodel.operations; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.graph.BinaryOpItem; +import com.jpexs.decompiler.flash.graph.GraphSourceItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import com.jpexs.decompiler.flash.graph.LogicalOpItem; -public class EqTreeItem extends BinaryOpTreeItem implements LogicalOpItem { +public class EqTreeItem extends BinaryOpItem implements LogicalOpItem { - public EqTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { + public EqTreeItem(GraphSourceItem instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { super(instruction, PRECEDENCE_EQUALITY, leftSide, rightSide, "=="); } + @Override + public boolean toBoolean() { + return (leftSide.toBoolean() == rightSide.toBoolean()) && (leftSide.toNumber() == rightSide.toNumber()); + } + @Override public GraphTargetItem invert() { - return new NeqTreeItem(instruction, leftSide, rightSide); + return new NeqTreeItem(src, leftSide, rightSide); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/GeTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/GeTreeItem.java index c6f95a2b4..8ff8960ea 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/GeTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/GeTreeItem.java @@ -16,18 +16,24 @@ */ package com.jpexs.decompiler.flash.abc.avm2.treemodel.operations; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.graph.BinaryOpItem; +import com.jpexs.decompiler.flash.graph.GraphSourceItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import com.jpexs.decompiler.flash.graph.LogicalOpItem; -public class GeTreeItem extends BinaryOpTreeItem implements LogicalOpItem { +public class GeTreeItem extends BinaryOpItem implements LogicalOpItem { - public GeTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { + public GeTreeItem(GraphSourceItem instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { super(instruction, PRECEDENCE_RELATIONAL, leftSide, rightSide, ">="); } @Override public GraphTargetItem invert() { - return new LtTreeItem(instruction, leftSide, rightSide); + return new LtTreeItem(src, leftSide, rightSide); + } + + @Override + public boolean toBoolean() { + return leftSide.toNumber() >= rightSide.toNumber(); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/GtTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/GtTreeItem.java index d5bb298d5..30d2d4daa 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/GtTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/GtTreeItem.java @@ -16,18 +16,24 @@ */ package com.jpexs.decompiler.flash.abc.avm2.treemodel.operations; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.graph.BinaryOpItem; +import com.jpexs.decompiler.flash.graph.GraphSourceItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import com.jpexs.decompiler.flash.graph.LogicalOpItem; -public class GtTreeItem extends BinaryOpTreeItem implements LogicalOpItem { +public class GtTreeItem extends BinaryOpItem implements LogicalOpItem { - public GtTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { + public GtTreeItem(GraphSourceItem instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { super(instruction, PRECEDENCE_RELATIONAL, leftSide, rightSide, ">"); } @Override public GraphTargetItem invert() { - return new LeTreeItem(instruction, leftSide, rightSide); + return new LeTreeItem(src, leftSide, rightSide); + } + + @Override + public boolean toBoolean() { + return leftSide.toNumber() > rightSide.toNumber(); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/InTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/InTreeItem.java index f40f1ddd2..de3ddc120 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/InTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/InTreeItem.java @@ -17,9 +17,10 @@ package com.jpexs.decompiler.flash.abc.avm2.treemodel.operations; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.graph.BinaryOpItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; -public class InTreeItem extends BinaryOpTreeItem { +public class InTreeItem extends BinaryOpItem { public InTreeItem(AVM2Instruction instruction, GraphTargetItem name, GraphTargetItem object) { super(instruction, PRECEDENCE_RELATIONAL, name, object, " in "); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/InstanceOfTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/InstanceOfTreeItem.java index 99a634ee7..899d10062 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/InstanceOfTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/InstanceOfTreeItem.java @@ -17,9 +17,10 @@ package com.jpexs.decompiler.flash.abc.avm2.treemodel.operations; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.graph.BinaryOpItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; -public class InstanceOfTreeItem extends BinaryOpTreeItem { +public class InstanceOfTreeItem extends BinaryOpItem { public InstanceOfTreeItem(AVM2Instruction instruction, GraphTargetItem value, GraphTargetItem type) { super(instruction, PRECEDENCE_RELATIONAL, value, type, " instanceof "); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/IsTypeTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/IsTypeTreeItem.java index 799949be5..4c8d03c88 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/IsTypeTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/IsTypeTreeItem.java @@ -17,9 +17,10 @@ package com.jpexs.decompiler.flash.abc.avm2.treemodel.operations; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.graph.BinaryOpItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; -public class IsTypeTreeItem extends BinaryOpTreeItem { +public class IsTypeTreeItem extends BinaryOpItem { public IsTypeTreeItem(AVM2Instruction instruction, GraphTargetItem value, GraphTargetItem type) { super(instruction, PRECEDENCE_RELATIONAL, value, type, " is "); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/LShiftTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/LShiftTreeItem.java index 32738cd4a..73a979bdf 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/LShiftTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/LShiftTreeItem.java @@ -17,11 +17,17 @@ package com.jpexs.decompiler.flash.abc.avm2.treemodel.operations; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.graph.BinaryOpItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; -public class LShiftTreeItem extends BinaryOpTreeItem { +public class LShiftTreeItem extends BinaryOpItem { public LShiftTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { super(instruction, PRECEDENCE_BITWISESHIFT, leftSide, rightSide, "<<"); } + + @Override + public double toNumber() { + return ((int) leftSide.toNumber()) << ((int) rightSide.toNumber()); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/LeTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/LeTreeItem.java index 85da0b269..6b8677bcb 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/LeTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/LeTreeItem.java @@ -16,18 +16,24 @@ */ package com.jpexs.decompiler.flash.abc.avm2.treemodel.operations; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.graph.BinaryOpItem; +import com.jpexs.decompiler.flash.graph.GraphSourceItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import com.jpexs.decompiler.flash.graph.LogicalOpItem; -public class LeTreeItem extends BinaryOpTreeItem implements LogicalOpItem { +public class LeTreeItem extends BinaryOpItem implements LogicalOpItem { - public LeTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { + public LeTreeItem(GraphSourceItem instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { super(instruction, PRECEDENCE_RELATIONAL, leftSide, rightSide, "<="); } @Override public GraphTargetItem invert() { - return new GtTreeItem(instruction, leftSide, rightSide); + return new GtTreeItem(src, leftSide, rightSide); + } + + @Override + public boolean toBoolean() { + return leftSide.toNumber() <= rightSide.toNumber(); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/LtTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/LtTreeItem.java index 873c1f693..8ad8820aa 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/LtTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/LtTreeItem.java @@ -16,18 +16,24 @@ */ package com.jpexs.decompiler.flash.abc.avm2.treemodel.operations; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.graph.BinaryOpItem; +import com.jpexs.decompiler.flash.graph.GraphSourceItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import com.jpexs.decompiler.flash.graph.LogicalOpItem; -public class LtTreeItem extends BinaryOpTreeItem implements LogicalOpItem { +public class LtTreeItem extends BinaryOpItem implements LogicalOpItem { - public LtTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { + public LtTreeItem(GraphSourceItem instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { super(instruction, PRECEDENCE_RELATIONAL, leftSide, rightSide, "<"); } @Override public GraphTargetItem invert() { - return new GeTreeItem(instruction, leftSide, rightSide); + return new GeTreeItem(src, leftSide, rightSide); + } + + @Override + public boolean toBoolean() { + return leftSide.toNumber() < rightSide.toNumber(); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/ModuloTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/ModuloTreeItem.java index 561087b4c..7fab90745 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/ModuloTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/ModuloTreeItem.java @@ -17,11 +17,17 @@ package com.jpexs.decompiler.flash.abc.avm2.treemodel.operations; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.graph.BinaryOpItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; -public class ModuloTreeItem extends BinaryOpTreeItem { +public class ModuloTreeItem extends BinaryOpItem { public ModuloTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { super(instruction, PRECEDENCE_MULTIPLICATIVE, leftSide, rightSide, "%"); } + + @Override + public double toNumber() { + return ((int) leftSide.toNumber()) % ((int) rightSide.toNumber()); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/MultiplyTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/MultiplyTreeItem.java index 24fd6f879..a1ac661ae 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/MultiplyTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/MultiplyTreeItem.java @@ -17,11 +17,17 @@ package com.jpexs.decompiler.flash.abc.avm2.treemodel.operations; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.graph.BinaryOpItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; -public class MultiplyTreeItem extends BinaryOpTreeItem { +public class MultiplyTreeItem extends BinaryOpItem { public MultiplyTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { super(instruction, PRECEDENCE_MULTIPLICATIVE, leftSide, rightSide, "*"); } + + @Override + public double toNumber() { + return leftSide.toNumber() * rightSide.toNumber(); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/NegTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/NegTreeItem.java index 952a41f94..6ee1751cc 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/NegTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/NegTreeItem.java @@ -18,10 +18,16 @@ package com.jpexs.decompiler.flash.abc.avm2.treemodel.operations; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import com.jpexs.decompiler.flash.graph.UnaryOpItem; -public class NegTreeItem extends UnaryOpTreeItem { +public class NegTreeItem extends UnaryOpItem { public NegTreeItem(AVM2Instruction instruction, GraphTargetItem value) { super(instruction, PRECEDENCE_UNARY, value, "-"); } + + @Override + public double toNumber() { + return -value.toNumber(); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/NeqTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/NeqTreeItem.java index 9a3d22a35..6f6303bb0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/NeqTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/NeqTreeItem.java @@ -16,18 +16,24 @@ */ package com.jpexs.decompiler.flash.abc.avm2.treemodel.operations; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.graph.BinaryOpItem; +import com.jpexs.decompiler.flash.graph.GraphSourceItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import com.jpexs.decompiler.flash.graph.LogicalOpItem; -public class NeqTreeItem extends BinaryOpTreeItem implements LogicalOpItem { +public class NeqTreeItem extends BinaryOpItem implements LogicalOpItem { - public NeqTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { + public NeqTreeItem(GraphSourceItem instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { super(instruction, PRECEDENCE_EQUALITY, leftSide, rightSide, "!="); } + @Override + public boolean toBoolean() { + return (leftSide.toNumber() != rightSide.toNumber()) || (leftSide.toBoolean() != rightSide.toBoolean()); + } + @Override public GraphTargetItem invert() { - return new EqTreeItem(instruction, leftSide, rightSide); + return new EqTreeItem(src, leftSide, rightSide); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/OrTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/OrTreeItem.java index 3a3b5ec60..b5b44c503 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/OrTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/OrTreeItem.java @@ -17,14 +17,20 @@ package com.jpexs.decompiler.flash.abc.avm2.treemodel.operations; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.graph.BinaryOpItem; import com.jpexs.decompiler.flash.graph.GraphPart; import com.jpexs.decompiler.flash.graph.GraphTargetItem; -public class OrTreeItem extends BinaryOpTreeItem { +public class OrTreeItem extends BinaryOpItem { public GraphPart firstPart; public OrTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { super(instruction, PRECEDENCE_LOGICALOR, leftSide, rightSide, "||"); } + + @Override + public boolean toBoolean() { + return leftSide.toBoolean() || rightSide.toBoolean(); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/PreDecrementTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/PreDecrementTreeItem.java index ab03932c3..5e1e0cdfa 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/PreDecrementTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/PreDecrementTreeItem.java @@ -19,8 +19,9 @@ package com.jpexs.decompiler.flash.abc.avm2.treemodel.operations; 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.GraphTargetItem; +import com.jpexs.decompiler.flash.graph.UnaryOpItem; -public class PreDecrementTreeItem extends UnaryOpTreeItem implements AssignmentTreeItem { +public class PreDecrementTreeItem extends UnaryOpItem implements AssignmentTreeItem { public PreDecrementTreeItem(AVM2Instruction instruction, GraphTargetItem object) { super(instruction, PRECEDENCE_UNARY, object, "--"); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/PreIncrementTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/PreIncrementTreeItem.java index 2c42de3a8..e67350d6d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/PreIncrementTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/PreIncrementTreeItem.java @@ -18,8 +18,9 @@ package com.jpexs.decompiler.flash.abc.avm2.treemodel.operations; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import com.jpexs.decompiler.flash.graph.UnaryOpItem; -public class PreIncrementTreeItem extends UnaryOpTreeItem { +public class PreIncrementTreeItem extends UnaryOpItem { public PreIncrementTreeItem(AVM2Instruction instruction, GraphTargetItem object) { super(instruction, PRECEDENCE_UNARY, object, "++"); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/RShiftTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/RShiftTreeItem.java index 968fea3f9..c6086e856 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/RShiftTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/RShiftTreeItem.java @@ -17,11 +17,17 @@ package com.jpexs.decompiler.flash.abc.avm2.treemodel.operations; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.graph.BinaryOpItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; -public class RShiftTreeItem extends BinaryOpTreeItem { +public class RShiftTreeItem extends BinaryOpItem { public RShiftTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { super(instruction, PRECEDENCE_BITWISESHIFT, leftSide, rightSide, ">>"); } + + @Override + public double toNumber() { + return ((int) leftSide.toNumber()) >> ((int) rightSide.toNumber()); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/StrictEqTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/StrictEqTreeItem.java index 5f159678f..5845b5c8d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/StrictEqTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/StrictEqTreeItem.java @@ -16,18 +16,24 @@ */ package com.jpexs.decompiler.flash.abc.avm2.treemodel.operations; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.graph.BinaryOpItem; +import com.jpexs.decompiler.flash.graph.GraphSourceItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import com.jpexs.decompiler.flash.graph.LogicalOpItem; -public class StrictEqTreeItem extends BinaryOpTreeItem implements LogicalOpItem { +public class StrictEqTreeItem extends BinaryOpItem implements LogicalOpItem { - public StrictEqTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { + public StrictEqTreeItem(GraphSourceItem instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { super(instruction, PRECEDENCE_EQUALITY, leftSide, rightSide, "==="); } + @Override + public boolean toBoolean() { + return (leftSide.toBoolean() == rightSide.toBoolean()) && (leftSide.toNumber() == rightSide.toNumber()); + } + @Override public GraphTargetItem invert() { - return new StrictNeqTreeItem(instruction, leftSide, rightSide); + return new StrictNeqTreeItem(src, leftSide, rightSide); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/StrictNeqTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/StrictNeqTreeItem.java index 4910384cd..e46921df1 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/StrictNeqTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/StrictNeqTreeItem.java @@ -16,18 +16,24 @@ */ package com.jpexs.decompiler.flash.abc.avm2.treemodel.operations; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.graph.BinaryOpItem; +import com.jpexs.decompiler.flash.graph.GraphSourceItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import com.jpexs.decompiler.flash.graph.LogicalOpItem; -public class StrictNeqTreeItem extends BinaryOpTreeItem implements LogicalOpItem { +public class StrictNeqTreeItem extends BinaryOpItem implements LogicalOpItem { - public StrictNeqTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { + public StrictNeqTreeItem(GraphSourceItem instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { super(instruction, PRECEDENCE_EQUALITY, leftSide, rightSide, "!=="); } @Override public GraphTargetItem invert() { - return new StrictEqTreeItem(instruction, leftSide, rightSide); + return new StrictEqTreeItem(src, leftSide, rightSide); + } + + @Override + public boolean toBoolean() { + return (leftSide.toBoolean() != rightSide.toBoolean()) && (leftSide.toNumber() != rightSide.toNumber()); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/SubtractTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/SubtractTreeItem.java index 89885c939..82b387216 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/SubtractTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/SubtractTreeItem.java @@ -17,11 +17,17 @@ package com.jpexs.decompiler.flash.abc.avm2.treemodel.operations; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.graph.BinaryOpItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; -public class SubtractTreeItem extends BinaryOpTreeItem { +public class SubtractTreeItem extends BinaryOpItem { public SubtractTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { super(instruction, PRECEDENCE_ADDITIVE, leftSide, rightSide, "-"); } + + @Override + public double toNumber() { + return leftSide.toNumber() - rightSide.toNumber(); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/TypeOfTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/TypeOfTreeItem.java index 2eb09f628..fa62db03f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/TypeOfTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/TypeOfTreeItem.java @@ -18,8 +18,9 @@ package com.jpexs.decompiler.flash.abc.avm2.treemodel.operations; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.graph.GraphTargetItem; +import com.jpexs.decompiler.flash.graph.UnaryOpItem; -public class TypeOfTreeItem extends UnaryOpTreeItem { +public class TypeOfTreeItem extends UnaryOpItem { public TypeOfTreeItem(AVM2Instruction instruction, GraphTargetItem value) { super(instruction, PRECEDENCE_UNARY, value, "typeof "); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/URShiftTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/URShiftTreeItem.java index 8cf7f4083..7135da6f9 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/URShiftTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/URShiftTreeItem.java @@ -17,11 +17,17 @@ package com.jpexs.decompiler.flash.abc.avm2.treemodel.operations; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.graph.BinaryOpItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; -public class URShiftTreeItem extends BinaryOpTreeItem { +public class URShiftTreeItem extends BinaryOpItem { public URShiftTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { super(instruction, PRECEDENCE_BITWISESHIFT, leftSide, rightSide, ">>>"); } + + @Override + public double toNumber() { + return ((int) leftSide.toNumber()) >>> ((int) rightSide.toNumber()); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/UnaryOpTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/UnaryOpTreeItem.java deleted file mode 100644 index 34079e1a1..000000000 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/UnaryOpTreeItem.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2010-2013 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.treemodel.operations; - -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.TreeItem; -import com.jpexs.decompiler.flash.graph.GraphTargetItem; -import com.jpexs.decompiler.flash.helpers.Helper; -import java.util.HashMap; -import java.util.List; - -public abstract class UnaryOpTreeItem extends TreeItem { - - public GraphTargetItem value; - public String operator; - - public UnaryOpTreeItem(AVM2Instruction instruction, int precedence, GraphTargetItem value, String operator) { - super(instruction, precedence); - this.value = value; - this.operator = operator; - } - - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - String s = value.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)); - if (value.precedence > precedence) { - s = "(" + s + ")"; - } - return hilight(operator) + s; - } -} diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/ASMSourceEditorPane.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/ASMSourceEditorPane.java index 3c7a6d3cd..7a6e34191 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/ASMSourceEditorPane.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/ASMSourceEditorPane.java @@ -44,33 +44,31 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi private DecompiledEditorPane decompiledEditor; private boolean ignoreCarret = false; private String name; - private String textWithHex=""; - private String textNoHex=""; - private boolean hex=false; + private String textWithHex = ""; + private String textNoHex = ""; + private boolean hex = false; public boolean isHex() { return hex; } - public void switchHex(){ + public void switchHex() { setHex(!hex); } - + public void setHex(boolean hex) { - if(this.hex==hex){ + if (this.hex == hex) { return; } this.hex = hex; - long oldOffset=getSelectedOffset(); - if(hex){ + long oldOffset = getSelectedOffset(); + if (hex) { setText(textWithHex); - }else{ + } else { setText(textNoHex); } hilighOffset(oldOffset); } - - public void setIgnoreCarret(boolean ignoreCarret) { this.ignoreCarret = ignoreCarret; @@ -105,10 +103,10 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi this.bodyIndex = bodyIndex; this.abc = abc; this.name = name; - String textWithHexTags=abc.bodies[bodyIndex].code.toASMSource(abc.constants, abc.bodies[bodyIndex],true); - textWithHex=Helper.hexToComments(textWithHexTags); - textNoHex=Helper.stripComments(textWithHexTags); - setText(hex?textWithHex:textNoHex); + String textWithHexTags = abc.bodies[bodyIndex].code.toASMSource(abc.constants, abc.bodies[bodyIndex], true); + textWithHex = Helper.hexToComments(textWithHexTags); + textNoHex = Helper.stripComments(textWithHexTags); + setText(hex ? textWithHex : textNoHex); } public void graph() { @@ -143,7 +141,7 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi disassembledHilights = Highlighting.getInstrHighlights(t); t = Highlighting.stripHilights(t); super.setText(t); - } + } public void selectInstruction(int pos) { String text = getText(); @@ -200,8 +198,7 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi requestFocus(); } - - public long getSelectedOffset(){ + public long getSelectedOffset() { int pos = getCaretPosition(); Highlighting lastH = new Highlighting(0, 0, 0); for (Highlighting h : disassembledHilights) { @@ -212,8 +209,7 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi } return lastH.offset; } - - + @Override public void caretUpdate(CaretEvent e) { if (isEditable()) { @@ -223,7 +219,7 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi return; } getCaret().setVisible(true); - + decompiledEditor.hilightOffset(getSelectedOffset()); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/MethodCodePanel.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/MethodCodePanel.java index 08a6459e0..08efbcf6c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/MethodCodePanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/MethodCodePanel.java @@ -21,7 +21,6 @@ import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; import com.jpexs.decompiler.flash.gui.View; import java.awt.BorderLayout; -import java.awt.FlowLayout; import java.awt.Font; import java.awt.Insets; import java.awt.event.ActionEvent; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java index 2b71c329e..b37317db2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java @@ -69,8 +69,8 @@ public class MethodBody implements Cloneable, Serializable { code.restoreControlFlow(constants, this); } - public int removeTraps(ConstantPool constants) { - return code.removeTraps(constants, this); + public int removeTraps(ConstantPool constants, ABC abc) { + return code.removeTraps(constants, this, abc); } public HashMap getLocalRegNames(ABC abc) { @@ -115,7 +115,7 @@ public class MethodBody implements Cloneable, Serializable { MethodBody b = (MethodBody) Helper.deepCopy(this); deobfuscated = b.code; deobfuscated.markMappedOffsets(); - deobfuscated.removeTraps(constants, b); + deobfuscated.removeTraps(constants, b, abc); //deobfuscated.restoreControlFlow(constants, b); try { s += deobfuscated.toSource(path, isStatic, classIndex, abc, constants, method_info, b, hilight, getLocalRegNames(abc), scopeStack, isStaticInitializer, fullyQualifiedNames, initTraits); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java index d712d49fc..e3159f23f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java @@ -189,10 +189,11 @@ public class TraitClass extends Trait { } } - private void parseImportsUsagesFromMethodInfo(List abcTags, ABC abc, int method_index, List imports, List uses, String ignorePackage, List fullyQualifiedNames) { + private void parseImportsUsagesFromMethodInfo(List abcTags, ABC abc, int method_index, List imports, List uses, String ignorePackage, List fullyQualifiedNames, List visitedMethods) { if (method_index > abc.method_info.length) { return; } + visitedMethods.add(method_index); if (abc.method_info[method_index].ret_type != 0) { parseImportsUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[abc.method_info[method_index].ret_type], ignorePackage, fullyQualifiedNames); } @@ -209,7 +210,11 @@ public class TraitClass extends Trait { } for (AVM2Instruction ins : body.code.code) { if (ins.definition instanceof NewFunctionIns) { - parseImportsUsagesFromMethodInfo(abcTags, abc, ins.operands[0], imports, uses, ignorePackage, fullyQualifiedNames); + if (ins.operands[0] != method_index) { + if (!visitedMethods.contains(ins.operands[0])) { + parseImportsUsagesFromMethodInfo(abcTags, abc, ins.operands[0], imports, uses, ignorePackage, fullyQualifiedNames, visitedMethods); + } + } } if ((ins.definition instanceof FindPropertyStrictIns) || (ins.definition instanceof FindPropertyIns) @@ -244,7 +249,7 @@ public class TraitClass extends Trait { TraitMethodGetterSetter tm = (TraitMethodGetterSetter) t; parseImportsUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[tm.name_index], ignorePackage, fullyQualifiedNames); if (tm.method_info != 0) { - parseImportsUsagesFromMethodInfo(abcTags, abc, tm.method_info, imports, uses, ignorePackage, fullyQualifiedNames); + parseImportsUsagesFromMethodInfo(abcTags, abc, tm.method_info, imports, uses, ignorePackage, fullyQualifiedNames, new ArrayList()); } } parseImportsUsagesFromMultiname(abcTags, abc, imports, uses, t.getName(abc), ignorePackage, fullyQualifiedNames); @@ -274,14 +279,14 @@ public class TraitClass extends Trait { parseImportsUsagesFromTraits(abcTags, abc, abc.class_info[class_info].static_traits, imports, uses, packageName, fullyQualifiedNames); //static initializer - parseImportsUsagesFromMethodInfo(abcTags, abc, abc.class_info[class_info].cinit_index, imports, uses, packageName, fullyQualifiedNames); + parseImportsUsagesFromMethodInfo(abcTags, abc, abc.class_info[class_info].cinit_index, imports, uses, packageName, fullyQualifiedNames, new ArrayList()); //instance parseImportsUsagesFromTraits(abcTags, abc, abc.instance_info[class_info].instance_traits, imports, uses, packageName, fullyQualifiedNames); //instance initializer - parseImportsUsagesFromMethodInfo(abcTags, abc, abc.instance_info[class_info].iinit_index, imports, uses, packageName, fullyQualifiedNames); + parseImportsUsagesFromMethodInfo(abcTags, abc, abc.instance_info[class_info].iinit_index, imports, uses, packageName, fullyQualifiedNames, new ArrayList()); return imports; } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/Action.java b/trunk/src/com/jpexs/decompiler/flash/action/Action.java index dcd91c1b9..da8a7ab9b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/Action.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/Action.java @@ -340,7 +340,7 @@ public class Action implements GraphSourceItem { * @return ASM source as String */ public static String actionsToString(List list, List importantOffsets, int version, boolean hex) { - return actionsToString(list, importantOffsets, new ArrayList(), version,hex); + return actionsToString(list, importantOffsets, new ArrayList(), version, hex); } /** @@ -363,8 +363,8 @@ public class Action implements GraphSourceItem { offset = 0; for (Action a : list) { - if(hex){ - ret+=""+Helper.bytesToHexString((a instanceof ActionContainer)?((ActionContainer)a).getHeaderBytes():a.getBytes(version))+"\r\n"; + if (hex) { + ret += "" + Helper.bytesToHexString((a instanceof ActionContainer) ? ((ActionContainer) a).getHeaderBytes() : a.getBytes(version)) + "\r\n"; } offset = a.getAddress(); if (importantOffsets.contains(offset)) { @@ -378,10 +378,10 @@ public class Action implements GraphSourceItem { } } else { if (a.beforeInsert != null) { - ret += a.beforeInsert.getASMSource(importantOffsets, constantPool, version,hex) + "\r\n"; + ret += a.beforeInsert.getASMSource(importantOffsets, constantPool, version, hex) + "\r\n"; } //if (!(a instanceof ActionNop)) { - ret += Highlighting.hilighOffset("", offset) + a.getASMSource(importantOffsets, constantPool, version,hex) + (a.ignored ? "; ignored" : "") + "\r\n"; + ret += Highlighting.hilighOffset("", offset) + a.getASMSource(importantOffsets, constantPool, version, hex) + (a.ignored ? "; ignored" : "") + "\r\n"; //} } offset += a.getBytes(version).length; @@ -540,6 +540,16 @@ public class Action implements GraphSourceItem { return new ArrayList(); } + @Override + public boolean isIgnored() { + return ignored; + } + + @Override + public void setIgnored(boolean ignored) { + this.ignored = ignored; + } + private static class Loop { public long loopContinue; @@ -1001,7 +1011,7 @@ public class Action implements GraphSourceItem { List ret = actions; String s = null; try { - s = Highlighting.stripHilights(Action.actionsToString(ret, null, version,false)); + s = Highlighting.stripHilights(Action.actionsToString(ret, null, version, false)); ret = ASMParser.parse(true, new ByteArrayInputStream(s.getBytes()), SWF.DEFAULT_VERSION); } catch (Exception ex) { Logger.getLogger(SWFInputStream.class.getName()).log(Level.SEVERE, "parsing error", ex); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/gui/ActionPanel.java b/trunk/src/com/jpexs/decompiler/flash/action/gui/ActionPanel.java index c1337edc2..8e6fca179 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/gui/ActionPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/gui/ActionPanel.java @@ -72,7 +72,7 @@ public class ActionPanel extends JPanel implements ActionListener { private String srcWithHex; private String srcNoHex; - public void setText(String text){ + public void setText(String text) { int pos = editor.getCaretPosition(); Highlighting lastH = new Highlighting(0, 0, 0); for (Highlighting h : disassembledHilights) { @@ -81,7 +81,7 @@ public class ActionPanel extends JPanel implements ActionListener { } lastH = h; } - long offset=lastH.offset; + long offset = lastH.offset; disassembledHilights = Highlighting.getInstrHighlights(text); editor.setText(Highlighting.stripHilights(text)); for (Highlighting h : disassembledHilights) { @@ -90,9 +90,9 @@ public class ActionPanel extends JPanel implements ActionListener { break; } } - + } - + public void setHex(boolean hex) { setText(hex ? srcWithHex : srcNoHex); } @@ -138,7 +138,7 @@ public class ActionPanel extends JPanel implements ActionListener { decompiledEditor.setEditable(false); - JButton graphButton = new JButton(View.getIcon("graph16")); + JButton graphButton = new JButton(View.getIcon("graph16")); graphButton.setActionCommand("GRAPH"); graphButton.addActionListener(this); graphButton.setToolTipText("View Graph"); @@ -154,18 +154,18 @@ public class ActionPanel extends JPanel implements ActionListener { topButtonsPan.setLayout(new BoxLayout(topButtonsPan, BoxLayout.X_AXIS)); topButtonsPan.add(graphButton); topButtonsPan.add(hexButton); - JPanel panCode=new JPanel(new BorderLayout()); + JPanel panCode = new JPanel(new BorderLayout()); panCode.add(new JScrollPane(editor), BorderLayout.CENTER); panCode.add(topButtonsPan, BorderLayout.NORTH); - + JPanel panB = new JPanel(); panB.setLayout(new BorderLayout()); asmLabel.setHorizontalAlignment(SwingConstants.CENTER); asmLabel.setBorder(new BevelBorder(BevelBorder.RAISED)); panB.add(asmLabel, BorderLayout.NORTH); - panB.add(panCode,BorderLayout.CENTER); - - + panB.add(panCode, BorderLayout.CENTER); + + JPanel buttonsPan = new JPanel(); buttonsPan.setLayout(new FlowLayout()); @@ -176,7 +176,7 @@ public class ActionPanel extends JPanel implements ActionListener { //buttonsPan.add(saveHexButton); //buttonsPan.add(loadHexButton); panB.add(buttonsPan, BorderLayout.SOUTH); - + saveHexButton.addActionListener(this); saveHexButton.setActionCommand("SAVEHEXACTION"); @@ -289,7 +289,7 @@ public class ActionPanel extends JPanel implements ActionListener { cancelButton.setVisible(true); editor.getCaret().setVisible(true); } else { - setText(hexButton.isSelected()?srcWithHex:srcNoHex); + setText(hexButton.isSelected() ? srcWithHex : srcNoHex); editor.setEditable(false); saveButton.setVisible(false); editButton.setVisible(true); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/special/ActionContainer.java b/trunk/src/com/jpexs/decompiler/flash/action/special/ActionContainer.java index 4a1d664c8..10ec9bf77 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/special/ActionContainer.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/special/ActionContainer.java @@ -5,5 +5,6 @@ package com.jpexs.decompiler.flash.action.special; * @author JPEXS */ public interface ActionContainer { + public byte[] getHeaderBytes(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionWith.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionWith.java index 70571d960..72dd78257 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionWith.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionWith.java @@ -29,7 +29,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.List; -public class ActionWith extends Action implements ActionContainer{ +public class ActionWith extends Action implements ActionContainer { public List actions; public int size; @@ -69,7 +69,7 @@ public class ActionWith extends Action implements ActionContainer{ } return baos2.toByteArray(); } - + @Override public byte[] getBytes(int version) { ByteArrayOutputStream baos2 = new ByteArrayOutputStream(); @@ -88,7 +88,7 @@ public class ActionWith extends Action implements ActionContainer{ @Override public String getASMSource(List knownAddreses, List constantPool, int version, boolean hex) { - return "With {\r\n" + Action.actionsToString(actions, knownAddreses, constantPool, version,hex) + "}"; + return "With {\r\n" + Action.actionsToString(actions, knownAddreses, constantPool, version, hex) + "}"; } @Override @@ -100,6 +100,4 @@ public class ActionWith extends Action implements ActionContainer{ public List getAllIfsOrJumps() { return Action.getActionsAllIfsOrJumps(actions); } - - } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionTry.java b/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionTry.java index 9380549de..24d95ea18 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionTry.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionTry.java @@ -166,7 +166,7 @@ public class ActionTry extends Action { public String getASMSource(List knownAddreses, List constantPool, int version, boolean hex) { String ret = ""; ret += "Try {"; - ret += Action.actionsToString(tryBody, knownAddreses, constantPool, version,hex); + ret += Action.actionsToString(tryBody, knownAddreses, constantPool, version, hex); ret += "}"; if (catchBlockFlag) { ret += "\r\nCatch "; @@ -176,12 +176,12 @@ public class ActionTry extends Action { ret += "\"" + Helper.escapeString(catchName) + "\""; } ret += " {\r\n"; - ret += Action.actionsToString(catchBody, knownAddreses, constantPool, version,hex); + ret += Action.actionsToString(catchBody, knownAddreses, constantPool, version, hex); ret += "}"; } if (finallyBlockFlag) { ret += "\r\nFinally {\r\n"; - ret += Action.actionsToString(finallyBody, knownAddreses, constantPool, version,hex); + ret += Action.actionsToString(finallyBody, knownAddreses, constantPool, version, hex); ret += "}"; } return ret; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/DefineLocalTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/DefineLocalTreeItem.java index 467b3eb54..45facefce 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/DefineLocalTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/DefineLocalTreeItem.java @@ -20,7 +20,7 @@ import com.jpexs.decompiler.flash.graph.GraphSourceItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import java.util.List; -public class DefineLocalTreeItem extends TreeItem implements SetTypeTreeItem{ +public class DefineLocalTreeItem extends TreeItem implements SetTypeTreeItem { public GraphTargetItem name; public GraphTargetItem value; @@ -46,7 +46,7 @@ public class DefineLocalTreeItem extends TreeItem implements SetTypeTreeItem{ ret.addAll(name.getNeededSources()); return ret; } - + @Override public GraphTargetItem getObject() { return new DefineLocalTreeItem(src, name, null); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/clauses/ForInTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/clauses/ForInTreeItem.java index c99061795..c8395e31e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/clauses/ForInTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/clauses/ForInTreeItem.java @@ -51,7 +51,7 @@ public class ForInTreeItem extends LoopTreeItem implements Block { public String toString(ConstantPool constants) { String ret = ""; ret += "loop" + loop.id + ":\r\n"; - ret += hilight("for(") + ((variableName instanceof DirectValueTreeItem)&&(((DirectValueTreeItem)variableName).value instanceof RegisterNumber)?"var ":"")+stripQuotes(variableName) + " in " + enumVariable.toString(constants) + ")\r\n{\r\n"; + ret += hilight("for(") + ((variableName instanceof DirectValueTreeItem) && (((DirectValueTreeItem) variableName).value instanceof RegisterNumber) ? "var " : "") + stripQuotes(variableName) + " in " + enumVariable.toString(constants) + ")\r\n{\r\n"; for (GraphTargetItem ti : commands) { ret += ti.toStringSemicoloned(constants) + "\r\n"; } diff --git a/trunk/src/com/jpexs/decompiler/flash/graph/GraphSourceItem.java b/trunk/src/com/jpexs/decompiler/flash/graph/GraphSourceItem.java index e6ace7ab8..16788ce9e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/graph/GraphSourceItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/graph/GraphSourceItem.java @@ -22,4 +22,8 @@ public interface GraphSourceItem { public boolean ignoredLoops(); public List getBranches(GraphSource code); + + public boolean isIgnored(); + + public void setIgnored(boolean ignored); } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java index b0f07e376..94914033c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java @@ -1263,7 +1263,7 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi } else { int bi = abcPanel.detailPanel.methodTraitPanel.methodCodePanel.getBodyIndex(); if (bi != -1) { - cnt += abcPanel.abc.bodies[bi].removeTraps(abcPanel.abc.constants); + cnt += abcPanel.abc.bodies[bi].removeTraps(abcPanel.abc.constants, abcPanel.abc); } abcPanel.detailPanel.methodTraitPanel.methodCodePanel.setBodyIndex(bi, abcPanel.abc); } @@ -1319,6 +1319,7 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi Main.stopWork(); JOptionPane.showMessageDialog(null, "Identifiers renamed: " + cnt); abcPanel.reload(); + doFilter(); return true; } }.execute(); @@ -1354,9 +1355,9 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi if (deobfuscationDialog.codeProcessingLevel.getValue() == DeobfuscationDialog.LEVEL_REMOVE_DEAD_CODE) { abcPanel.abc.bodies[bi].removeDeadCode(abcPanel.abc.constants); } else if (deobfuscationDialog.codeProcessingLevel.getValue() == DeobfuscationDialog.LEVEL_REMOVE_TRAPS) { - abcPanel.abc.bodies[bi].removeTraps(abcPanel.abc.constants); + abcPanel.abc.bodies[bi].removeTraps(abcPanel.abc.constants, abcPanel.abc); } else if (deobfuscationDialog.codeProcessingLevel.getValue() == DeobfuscationDialog.LEVEL_RESTORE_CONTROL_FLOW) { - abcPanel.abc.bodies[bi].removeTraps(abcPanel.abc.constants); + abcPanel.abc.bodies[bi].removeTraps(abcPanel.abc.constants, abcPanel.abc); abcPanel.abc.bodies[bi].restoreControlFlow(abcPanel.abc.constants); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/TagNode.java b/trunk/src/com/jpexs/decompiler/flash/gui/TagNode.java index d18b5d5e8..ecd47fadb 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/TagNode.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/TagNode.java @@ -262,7 +262,7 @@ public class TagNode { } String ret; if (isPcode) { - ret = Highlighting.stripHilights(((ASMSource) node.tag).getASMSource(SWF.DEFAULT_VERSION,false)); + ret = Highlighting.stripHilights(((ASMSource) node.tag).getASMSource(SWF.DEFAULT_VERSION, false)); } else { List as = ((ASMSource) node.tag).getActions(SWF.DEFAULT_VERSION); Action.setActionsAddresses(as, 0, SWF.DEFAULT_VERSION); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java index 840b9e29a..9f23f38cd 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java @@ -38,8 +38,8 @@ public class FlashPlayerPanel extends Panel { IntByReference ibr = new IntByReference(); Kernel32.INSTANCE.WriteFile(pipe, new byte[]{2}, 1, ibr, null); Kernel32.INSTANCE.WriteFile(pipe, new byte[]{ - (byte) (getWidth() / 256), (byte) (getWidth() % 256), - (byte) (getHeight() / 256), (byte) (getHeight() % 256),}, 4, ibr, null); + (byte) (getWidth() / 256), (byte) (getWidth() % 256), + (byte) (getHeight() / 256), (byte) (getHeight() % 256),}, 4, ibr, null); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/player/jna/platform/win32/SHELLEXECUTEINFO.java b/trunk/src/com/jpexs/decompiler/flash/gui/player/jna/platform/win32/SHELLEXECUTEINFO.java index 6d6b066e6..164514a74 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/player/jna/platform/win32/SHELLEXECUTEINFO.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/player/jna/platform/win32/SHELLEXECUTEINFO.java @@ -31,6 +31,6 @@ public class SHELLEXECUTEINFO extends Structure { @Override protected List getFieldOrder() { return Arrays.asList(new String[]{"cbSize", "fMask", "hwnd", "lpVerb", "lpFile", "lpParameters", "lpDirectory", "nShow", "hInstApp", "lpIDList", - "lpClass", "hKeyClass", "dwHotKey", "hMonitor", "hProcess"}); + "lpClass", "hKeyClass", "dwHotKey", "hMonitor", "hProcess"}); } } \ No newline at end of file diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/player/jna/platform/win32/WinDef.java b/trunk/src/com/jpexs/decompiler/flash/gui/player/jna/platform/win32/WinDef.java index 8e541ea8e..3c7328e49 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/player/jna/platform/win32/WinDef.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/player/jna/platform/win32/WinDef.java @@ -610,7 +610,7 @@ public interface WinDef extends StdCallLibrary { */ protected List getFieldOrder() { return Arrays.asList(new String[]{"left", "top", "right", - "bottom"}); + "bottom"}); } /** diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/player/jna/platform/win32/WinUser.java b/trunk/src/com/jpexs/decompiler/flash/gui/player/jna/platform/win32/WinUser.java index a01b79a8a..de471c541 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/player/jna/platform/win32/WinUser.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/player/jna/platform/win32/WinUser.java @@ -89,8 +89,8 @@ public interface WinUser extends StdCallLibrary, WinDef { protected List getFieldOrder() { return Arrays.asList(new String[]{"cbSize", "flags", - "hwndActive", "hwndFocus", "hwndCapture", "hwndMenuOwner", - "hwndMoveSize", "hwndCaret", "rcCaret"}); + "hwndActive", "hwndFocus", "hwndCapture", "hwndMenuOwner", + "hwndMoveSize", "hwndCaret", "rcCaret"}); } } @@ -109,9 +109,9 @@ public interface WinUser extends StdCallLibrary, WinDef { protected List getFieldOrder() { return Arrays.asList(new String[]{"cbSize", "rcWindow", - "rcClient", "dwStyle", "dwExStyle", "dwWindowStatus", - "cxWindowBorders", "cyWindowBorders", "atomWindowType", - "wCreatorVersion"}); + "rcClient", "dwStyle", "dwExStyle", "dwWindowStatus", + "cxWindowBorders", "cyWindowBorders", "atomWindowType", + "wCreatorVersion"}); } } int GWL_EXSTYLE = -20; @@ -168,7 +168,7 @@ public interface WinUser extends StdCallLibrary, WinDef { protected List getFieldOrder() { return Arrays.asList(new String[]{"hWnd", "message", "wParam", - "lParam", "time", "pt"}); + "lParam", "time", "pt"}); } } @@ -182,7 +182,7 @@ public interface WinUser extends StdCallLibrary, WinDef { protected List getFieldOrder() { return Arrays.asList(new String[]{"cbSize", "hWnd", "dwFlags", - "uCount", "dwTimeout"}); + "uCount", "dwTimeout"}); } } @@ -232,7 +232,7 @@ public interface WinUser extends StdCallLibrary, WinDef { protected List getFieldOrder() { return Arrays.asList(new String[]{"BlendOp", "BlendFlags", - "SourceConstantAlpha", "AlphaFormat"}); + "SourceConstantAlpha", "AlphaFormat"}); } } int VK_SHIFT = 16; @@ -332,7 +332,7 @@ public interface WinUser extends StdCallLibrary, WinDef { protected List getFieldOrder() { return Arrays.asList(new String[]{"vkCode", "scanCode", "flags", - "time", "dwExtraInfo"}); + "time", "dwExtraInfo"}); } } int SM_CXSCREEN = 0; @@ -690,7 +690,7 @@ public interface WinUser extends StdCallLibrary, WinDef { protected List getFieldOrder() { return Arrays.asList(new String[]{"wVk", "wScan", "dwFlags", - "time", "dwExtraInfo"}); + "time", "dwExtraInfo"}); } } @@ -726,7 +726,7 @@ public interface WinUser extends StdCallLibrary, WinDef { protected List getFieldOrder() { return Arrays.asList(new String[]{"dx", "dy", "mouseData", - "dwFlags", "time", "dwExtraInfo"}); + "dwFlags", "time", "dwExtraInfo"}); } } @@ -834,9 +834,9 @@ public interface WinUser extends StdCallLibrary, WinDef { @Override protected List getFieldOrder() { return Arrays.asList(new String[]{"cbSize", "style", - "lpfnWndProc", "cbClsExtra", "cbWndExtra", "hInstance", - "hIcon", "hCursor", "hbrBackground", "lpszMenuName", - "lpszClassName", "hIconSm"}); + "lpfnWndProc", "cbClsExtra", "cbWndExtra", "hInstance", + "hIcon", "hCursor", "hbrBackground", "lpszMenuName", + "lpszClassName", "hIconSm"}); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/helpers/Helper.java b/trunk/src/com/jpexs/decompiler/flash/helpers/Helper.java index e45998185..c5ea0cbbd 100644 --- a/trunk/src/com/jpexs/decompiler/flash/helpers/Helper.java +++ b/trunk/src/com/jpexs/decompiler/flash/helpers/Helper.java @@ -185,9 +185,10 @@ public class Helper { return ret; } - public static String bytesToHexString(byte bytes[]){ - return bytesToHexString(bytes,0); + public static String bytesToHexString(byte bytes[]) { + return bytesToHexString(bytes, 0); } + public static String bytesToHexString(byte bytes[], int start) { StringBuilder sb = new StringBuilder(); if (start < bytes.length) { @@ -323,12 +324,12 @@ public class Helper { } catch (Exception ex) { } } - - public static String stripComments(String str){ + + public static String stripComments(String str) { return str.replaceAll("[^\r\n]*\r?\n", ""); } - - public static String hexToComments(String str){ + + public static String hexToComments(String str) { return str.replaceAll("([^\r\n]*)(\r?\n)", "; $1$2"); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java index eda2d369a..ad1ffeb05 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java @@ -115,8 +115,8 @@ public class DefineButtonTag extends CharacterTag implements ASMSource, BoundedT * @param version SWF version * @return ASM source */ - public String getASMSource(int version,boolean hex) { - return Action.actionsToString(getActions(version), null, version,hex); + public String getASMSource(int version, boolean hex) { + return Action.actionsToString(getActions(version), null, version, hex); } /** diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DoActionTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DoActionTag.java index 01dbe88c2..ec0bdef50 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DoActionTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DoActionTag.java @@ -71,8 +71,8 @@ public class DoActionTag extends Tag implements ASMSource { * @return ASM source */ @Override - public String getASMSource(int version,boolean hex) { - return Action.actionsToString(getActions(version), null, version,hex); + public String getASMSource(int version, boolean hex) { + return Action.actionsToString(getActions(version), null, version, hex); } /** diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java index 01c84b27d..4a7fcd816 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java @@ -93,8 +93,8 @@ public class DoInitActionTag extends CharacterTag implements ASMSource { * @return ASM source */ @Override - public String getASMSource(int version,boolean hex) { - return Action.actionsToString(getActions(version), null, version,hex); + public String getASMSource(int version, boolean hex) { + return Action.actionsToString(getActions(version), null, version, hex); } @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/base/ASMSource.java b/trunk/src/com/jpexs/decompiler/flash/tags/base/ASMSource.java index 9d0d58014..7899d6e03 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/base/ASMSource.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/base/ASMSource.java @@ -33,7 +33,7 @@ public interface ASMSource { * @param hex Add hexadecimal? * @return ASM source */ - public String getASMSource(int version,boolean hex); + public String getASMSource(int version, boolean hex); /** * Whether or not this object contains ASM source diff --git a/trunk/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java b/trunk/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java index e66063816..f37a8f149 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java @@ -111,8 +111,8 @@ public class BUTTONCONDACTION implements ASMSource { * @param version SWF version * @return ASM source */ - public String getASMSource(int version,boolean hex) { - return Action.actionsToString(getActions(version), null, version,hex); + public String getASMSource(int version, boolean hex) { + return Action.actionsToString(getActions(version), null, version, hex); } /** diff --git a/trunk/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java b/trunk/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java index a7d07ea3f..d51ade343 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java @@ -78,8 +78,8 @@ public class CLIPACTIONRECORD implements ASMSource { * @param version SWF version * @return ASM source */ - public String getASMSource(int version,boolean hex) { - return Action.actionsToString(getActions(version), null, version,hex); + public String getASMSource(int version, boolean hex) { + return Action.actionsToString(getActions(version), null, version, hex); } /**