diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java index 8c7cdf158..8547bfb93 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java @@ -27,6 +27,7 @@ import com.jpexs.decompiler.flash.abc.avm2.deobfuscation.AVM2DeobfuscatorSimple; 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.AVM2Instructions; import com.jpexs.decompiler.flash.abc.avm2.instructions.DeobfuscatePopIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; @@ -790,7 +791,7 @@ public class AVM2Code implements Cloneable { List switchAddresses = new ArrayList<>(); int availableBytes = ais.available(); for (int i = 0; i < availableBytes; i++) { - codeMap.put((long) i, new AVM2Instruction(i, new NopIns(), null)); + codeMap.put((long) i, new AVM2Instruction(i, AVM2Instructions.Nop, null)); } long startPos = ais.getPosition(); @@ -833,7 +834,7 @@ public class AVM2Code implements Cloneable { int instructionCode = ais.read("instructionCode"); InstructionDefinition instr = instructionSet[instructionCode]; - if (instr instanceof LookupSwitchIns) { + if (instructionCode == AVM2Instructions.LookupSwitch) { if (!isSwitch) { switchAddresses.add(startOffset); continue loopaddr; @@ -1268,10 +1269,10 @@ public class AVM2Code implements Cloneable { if (fixBranch > -1) { if (ins.definition instanceof IfTypeIns) { for (int i = 0; i < -ins.definition.getStackDelta(ins, null/*IfTypeIns do not require ABCs*/); i++) { - writer.appendNoHilight(new DeobfuscatePopIns().instructionName).newLine(); + writer.appendNoHilight(DeobfuscatePopIns.NAME).newLine(); } if (fixBranch == 0) { // jump - writer.appendNoHilight(new JumpIns().instructionName + " ofs" + Helper.formatAddress(ofs + ins.getBytesLength() + ins.operands[0])); + writer.appendNoHilight(JumpIns.NAME + " ofs" + Helper.formatAddress(ofs + ins.getBytesLength() + ins.operands[0])); } else { // nojump, ignore } @@ -1301,16 +1302,24 @@ public class AVM2Code implements Cloneable { private List posCache; + private Map posCacheReverse; + private void buildCache() { - posCache = new ArrayList<>(); + List posCache = new ArrayList<>(code.size() + 1); + Map posCacheReverse = new HashMap<>(code.size() + 1); long a = 0; - for (int i = 0; i < code.size(); i++) { + int i = 0; + for (; i < code.size(); i++) { AVM2Instruction ins = code.get(i); posCache.add(ins.offset); + posCacheReverse.put(ins.offset, i); a = ins.offset + ins.getBytesLength(); } posCache.add(a); + posCacheReverse.put(a, i); + this.posCache = posCache; + this.posCacheReverse = posCacheReverse; cacheActual = true; } @@ -1322,8 +1331,8 @@ public class AVM2Code implements Cloneable { if (!cacheActual) { buildCache(); } - int ret = posCache.indexOf(address); - if (ret == -1) { + Integer ret = posCacheReverse.get(address); + if (ret == null) { if (nearest) { for (long a : posCache) { if (a > address) { @@ -2023,8 +2032,8 @@ public class AVM2Code implements Cloneable { boolean someIgnored = false; for (Long insAddr : insAddrToRemove) { - int pos = posCache.indexOf(insAddr); - if (pos > -1) { + Integer pos = posCacheReverse.get(insAddr); + if (pos != null) { code.get(pos).ignored = true; someIgnored = true; } @@ -2322,7 +2331,8 @@ public class AVM2Code implements Cloneable { handleRegister(stats, ((GetLocalTypeIns) ins.definition).getRegisterId(ins)); } else { for (int i = 0; i < ins.definition.operands.length; i++) { - if (ins.definition.operands[i] == DAT_REGISTER_INDEX) { + int op = ins.definition.operands[i]; + if (op == DAT_REGISTER_INDEX/* || op == DAT_LOCAL_REG_INDEX ???*/) { handleRegister(stats, ins.operands[i]); } } @@ -2559,7 +2569,7 @@ public class AVM2Code implements Cloneable { prev.ignored = true; prev2.ignored = true; if (prev.operands[0] == prev2.operands[0]) { - ins.definition = new JumpIns(); + ins.definition = AVM2Code.instructionSet[AVM2Instructions.Jump]; visited[ip]--; } else { ins.ignored = true; @@ -2572,7 +2582,7 @@ public class AVM2Code implements Cloneable { prev.ignored = true; prev2.ignored = true; if (prev.operands[0] != prev2.operands[0]) { - ins.definition = new JumpIns(); + ins.definition = AVM2Code.instructionSet[AVM2Instructions.Jump]; visited[ip]--; } else { ins.ignored = true; @@ -2586,7 +2596,7 @@ public class AVM2Code implements Cloneable { if ((prev != null) && ins.definition instanceof IfTrueIns) { if (prev.definition instanceof PushTrueIns) { prev.ignored = true; - ins.definition = new JumpIns(); + ins.definition = AVM2Code.instructionSet[AVM2Instructions.Jump]; visited[ip]--; ret++; continue; @@ -2601,7 +2611,7 @@ public class AVM2Code implements Cloneable { if ((prev != null) && ins.definition instanceof IfFalseIns) { if (prev.definition instanceof PushFalseIns) { prev.ignored = true; - ins.definition = new JumpIns(); + ins.definition = AVM2Code.instructionSet[AVM2Instructions.Jump]; visited[ip]--; ret++; continue; @@ -2869,11 +2879,11 @@ public class AVM2Code implements Cloneable { if (ins2.isExit()) { code.set(i, new AVM2Instruction(ofs, ins2.definition, ins2.operands)); AVM2Instruction nopIns; - nopIns = new AVM2Instruction(ofs + 1, new NopIns(), null); + nopIns = new AVM2Instruction(ofs + 1, AVM2Instructions.Nop, null); code.add(i + 1, nopIns); - nopIns = new AVM2Instruction(ofs + 2, new NopIns(), null); + nopIns = new AVM2Instruction(ofs + 2, AVM2Instructions.Nop, null); code.add(i + 2, nopIns); - nopIns = new AVM2Instruction(ofs + 3, new NopIns(), null); + nopIns = new AVM2Instruction(ofs + 3, AVM2Instructions.Nop, null); code.add(i + 3, nopIns); i += 3; csize = code.size(); @@ -3206,7 +3216,7 @@ public class AVM2Code implements Cloneable { if (secondPass) { if (condition && (dec.jumpUsed) && (!dec.skipUsed)) { ins.setFixBranch(0); - //((AVM2Instruction) ins).definition = new JumpIns(); + //ins.definition = AVM2Code.instructionSet[AVM2Instructions.Jump]; } if ((!condition) && (!dec.jumpUsed) && (dec.skipUsed)) { ins.setFixBranch(1); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/deobfuscation/AVM2DeobfuscatorRegisters.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/deobfuscation/AVM2DeobfuscatorRegisters.java index decac097a..ea41b1f28 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/deobfuscation/AVM2DeobfuscatorRegisters.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/deobfuscation/AVM2DeobfuscatorRegisters.java @@ -67,16 +67,38 @@ public class AVM2DeobfuscatorRegisters extends AVM2DeobfuscatorSimple { } + private Set getRegisters(AVM2Code code) { + Set regs = new HashSet<>(); + for (AVM2Instruction ins : code.code) { + InstructionDefinition def = ins.definition; + if (def instanceof SetLocalTypeIns) { + int regId = ((SetLocalTypeIns) def).getRegisterId(ins); + regs.add(regId); + } else if (def instanceof GetLocalTypeIns) { + int regId = ((GetLocalTypeIns) def).getRegisterId(ins); + regs.add(regId); + } else { + for (int p = 0; p < ins.definition.operands.length; p++) { + int op = ins.definition.operands[p]; + if (op == AVM2Code.DAT_REGISTER_INDEX || op == AVM2Code.DAT_LOCAL_REG_INDEX) { + int regId = ins.operands[p]; + regs.add(regId); + } + } + } + } + + return regs; + } + @Override - public void deobfuscate(String path, int classIndex, boolean isStatic, int scriptIndex, ABC abc, AVM2ConstantPool cpool, Trait trait, MethodInfo minfo, MethodBody abody) throws InterruptedException { + public void deobfuscate(String path, int classIndex, boolean isStatic, int scriptIndex, ABC abc, AVM2ConstantPool cpool, Trait trait, MethodInfo minfo, MethodBody body) throws InterruptedException { //System.err.println("regdeo:" + path); - removeUnreachableInstructions(abody.getCode(), cpool, trait, minfo, abody); + MethodBody originalBody = body; + removeUnreachableInstructions(body.getCode(), cpool, trait, minfo, body); Set ignoredRegs = new HashSet<>(); - MethodBody body = abody.clone(); - Reference assignment = new Reference<>(null); - ignoredRegs.clear(); int localReservedCount = body.getLocalReservedCount(); for (int i = 0; i < localReservedCount; i++) { ignoredRegs.add(i); @@ -86,22 +108,27 @@ public class AVM2DeobfuscatorRegisters extends AVM2DeobfuscatorSimple { List listedRegs = new ArrayList<>(); List listedLastBodies = new ArrayList<>(); Set ignoredRegGets = new HashSet<>(); + Reference assignmentRef = new Reference<>(null); while (setReg > -1) { + if (Thread.currentThread().isInterrupted()) { + throw new InterruptedException(); + } + MethodBody bodybefore = body; body = bodybefore.clone(); - setReg = getFirstRegisterSetter(assignment, classIndex, isStatic, scriptIndex, abc, cpool, trait, minfo, body, ignoredRegs, ignoredRegGets); - //System.err.println("setreg " + setReg + " ass:" + assignment.getVal()); + setReg = getFirstRegisterSetter(assignmentRef, classIndex, isStatic, scriptIndex, abc, body, ignoredRegs, ignoredRegGets); + //System.err.println("setreg " + setReg + " ass:" + assignment); if (setReg < 0) { break; } - //if there is second assignment + // if there is second assignment if (listedRegs.contains(setReg)) { //System.err.println("second assignment of loc" + setReg + ", ignoring"); int lindex = listedRegs.indexOf(setReg); - body = listedLastBodies.get(lindex); //switch to body before - ignoredRegs.add(setReg); //this is not obfuscated + body = listedLastBodies.get(lindex); // switch to body before + ignoredRegs.add(setReg); // this is not obfuscated for (int i = listedRegs.size() - 1; i >= lindex; i--) { int r = listedRegs.get(i); listedRegs.remove(i); @@ -111,11 +138,13 @@ public class AVM2DeobfuscatorRegisters extends AVM2DeobfuscatorSimple { continue; } - if ((assignment.getVal().definition instanceof SetLocalTypeIns) || (assignment.getVal().definition instanceof GetLocalTypeIns /*First usage -> value undefined*/)) { - super.removeObfuscationIfs(classIndex, isStatic, scriptIndex, abc, cpool, trait, minfo, body, Arrays.asList(assignment.getVal())); + AVM2Instruction assignment = assignmentRef.getVal(); + InstructionDefinition def = assignment.definition; + if ((def instanceof SetLocalTypeIns) || (def instanceof GetLocalTypeIns /*First usage -> value undefined*/)) { + super.removeObfuscationIfs(classIndex, isStatic, scriptIndex, abc, cpool, trait, minfo, body, Arrays.asList(assignment)); } - if (assignment.getVal().definition instanceof GetLocalTypeIns) { + if (def instanceof GetLocalTypeIns) { ignoredRegGets.add(setReg); } @@ -123,9 +152,9 @@ public class AVM2DeobfuscatorRegisters extends AVM2DeobfuscatorSimple { listedLastBodies.add(bodybefore); } - abody.exceptions = body.exceptions; - abody.setCode(body.getCode()); - removeUnreachableInstructions(abody.getCode(), cpool, trait, minfo, abody); + originalBody.exceptions = body.exceptions; + originalBody.setCode(body.getCode()); + removeUnreachableInstructions(body.getCode(), cpool, trait, minfo, body); //System.err.println("/deo"); } @@ -142,7 +171,7 @@ public class AVM2DeobfuscatorRegisters extends AVM2DeobfuscatorSimple { SetLocalTypeIns slt = (SetLocalTypeIns) ins.definition; int regId = slt.getRegisterId(ins); if (singleRegisters.containsKey(regId)) { - code.replaceInstruction(i, new AVM2Instruction(ins.offset, new DeobfuscatePopIns(), null), body); + code.replaceInstruction(i, new AVM2Instruction(ins.offset, DeobfuscatePopIns.getInstance(), null), body); } } @@ -156,22 +185,21 @@ public class AVM2DeobfuscatorRegisters extends AVM2DeobfuscatorSimple { } } - private int getFirstRegisterSetter(Reference assignment, int classIndex, boolean isStatic, int scriptIndex, ABC abc, AVM2ConstantPool cpool, Trait trait, MethodInfo minfo, MethodBody body, Set ignoredRegisters, Set ignoredGets) throws InterruptedException { + private int getFirstRegisterSetter(Reference assignment, int classIndex, boolean isStatic, int scriptIndex, ABC abc, MethodBody body, Set ignoredRegisters, Set ignoredGets) throws InterruptedException { AVM2Code code = body.getCode(); if (code.code.isEmpty()) { return -1; } - ExecutionResult res = new ExecutionResult(); - return visitCode(assignment, new HashSet<>(), new TranslateStack("deo"), classIndex, isStatic, body, scriptIndex, abc, code, 0, code.code.size() - 1, res, ignoredRegisters, ignoredGets); + return visitCode(assignment, new HashSet<>(), new TranslateStack("deo"), classIndex, isStatic, body, scriptIndex, abc, code, 0, code.code.size() - 1, ignoredRegisters, ignoredGets); } - private int visitCode(Reference assignment, Set visited, TranslateStack stack, int classIndex, boolean isStatic, MethodBody body, int scriptIndex, ABC abc, AVM2Code code, int idx, int endIdx, ExecutionResult result, Set ignored, Set ignoredGets) throws InterruptedException { + private int visitCode(Reference assignment, Set visited, TranslateStack stack, int classIndex, boolean isStatic, MethodBody body, int scriptIndex, ABC abc, AVM2Code code, int idx, int endIdx, Set ignored, Set ignoredGets) throws InterruptedException { List output = new ArrayList<>(); AVM2LocalData localData = newLocalData(scriptIndex, abc, abc.constants, body, isStatic, classIndex); initLocalRegs(localData, body.getLocalReservedCount(), body.max_regs); - localData.localRegs.put(0, new NullAVM2Item(null));//this + localData.localRegs.put(0, new NullAVM2Item(null)); // this List toVisit = new ArrayList<>(); toVisit.add(idx); @@ -179,6 +207,10 @@ public class AVM2DeobfuscatorRegisters extends AVM2DeobfuscatorSimple { toVisitStacks.add(stack); outer: while (!toVisit.isEmpty()) { + if (Thread.currentThread().isInterrupted()) { + throw new InterruptedException(); + } + idx = toVisit.remove(0); stack = toVisitStacks.remove(0); @@ -219,7 +251,7 @@ public class AVM2DeobfuscatorRegisters extends AVM2DeobfuscatorSimple { } else { for (int p = 0; p < ins.definition.operands.length; p++) { int op = ins.definition.operands[p]; - if (op == AVM2Code.DAT_REGISTER_INDEX) { + if (op == AVM2Code.DAT_REGISTER_INDEX/* || op == AVM2Code.DAT_LOCAL_REG_INDEX ???*/) { int regId = ins.operands[p]; if (!ignored.contains(regId)) { assignment.setVal(ins); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/deobfuscation/AVM2DeobfuscatorSimple.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/deobfuscation/AVM2DeobfuscatorSimple.java index 98ad011cd..8481d5180 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/deobfuscation/AVM2DeobfuscatorSimple.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/deobfuscation/AVM2DeobfuscatorSimple.java @@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.FixItemCounterTranslateStack; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.abc.avm2.instructions.DeobfuscatePopIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; @@ -109,30 +110,30 @@ public class AVM2DeobfuscatorSimple implements SWFDecompilerListener { if (ovalue instanceof Long) { long value = (Long) ovalue; if (value >= -128 && value <= 127) { - return new AVM2Instruction(0, new PushByteIns(), new int[]{(int) (long) value}); + return new AVM2Instruction(0, AVM2Instructions.PushByte, new int[]{(int) (long) value}); } else if (value >= -32768 && value <= 32767) { - return new AVM2Instruction(0, new PushShortIns(), new int[]{((int) (long) value) & 0xffff}); + return new AVM2Instruction(0, AVM2Instructions.PushShort, new int[]{((int) (long) value) & 0xffff}); } else { - return new AVM2Instruction(0, new PushIntIns(), new int[]{cpool.getIntId(value, true)}); + return new AVM2Instruction(0, AVM2Instructions.PushInt, new int[]{cpool.getIntId(value, true)}); } } if (ovalue instanceof Double) { - return new AVM2Instruction(0, new PushDoubleIns(), new int[]{cpool.getDoubleId((Double) ovalue, true)}); + return new AVM2Instruction(0, AVM2Instructions.PushDouble, new int[]{cpool.getDoubleId((Double) ovalue, true)}); } if (ovalue instanceof String) { - return new AVM2Instruction(0, new PushStringIns(), new int[]{cpool.getStringId((String) ovalue, true)}); + return new AVM2Instruction(0, AVM2Instructions.PushString, new int[]{cpool.getStringId((String) ovalue, true)}); } if (ovalue instanceof Boolean) { if ((Boolean) ovalue) { - return new AVM2Instruction(0, new PushTrueIns(), null); + return new AVM2Instruction(0, AVM2Instructions.PushTrue, null); } - return new AVM2Instruction(0, new PushFalseIns(), null); + return new AVM2Instruction(0, AVM2Instructions.PushFalse, null); } if (ovalue instanceof Null) { - return new AVM2Instruction(0, new PushNullIns(), null); + return new AVM2Instruction(0, AVM2Instructions.PushNull, null); } if (ovalue instanceof Undefined) { - return new AVM2Instruction(0, new PushUndefinedIns(), null); + return new AVM2Instruction(0, AVM2Instructions.PushUndefined, null); } return null; } @@ -191,8 +192,7 @@ public class AVM2DeobfuscatorSimple implements SWFDecompilerListener { localData.localRegs.clear(); initLocalRegs(localData, localReservedCount, body.max_regs); - ExecutionResult result = new ExecutionResult(); - executeInstructions(staticRegs, body, abc, code, localData, i, code.code.size() - 1, result, inlineIns); + executeInstructions(staticRegs, body, abc, code, localData, i, code.code.size() - 1, null, inlineIns); } return false; @@ -202,12 +202,16 @@ public class AVM2DeobfuscatorSimple implements SWFDecompilerListener { code.removeDeadCode(body); } - protected boolean removeZeroJumps(AVM2Code code, MethodBody body) { + protected boolean removeZeroJumps(AVM2Code code, MethodBody body) throws InterruptedException { boolean result = false; for (int i = 0; i < code.code.size(); i++) { AVM2Instruction ins = code.code.get(i); if (ins.definition instanceof JumpIns) { if (ins.operands[0] == 0) { + if (Thread.currentThread().isInterrupted()) { + throw new InterruptedException(); + } + code.removeInstruction(i, body); i--; result = true; @@ -284,7 +288,7 @@ public class AVM2DeobfuscatorSimple implements SWFDecompilerListener { if (def instanceof SetLocalTypeIns) { int regId = ((SetLocalTypeIns) def).getRegisterId(ins); staticRegs.put(regId, localData.localRegs.get(regId).getNotCoerced()); - code.replaceInstruction(idx, new AVM2Instruction(0, new DeobfuscatePopIns(), null), body); + code.replaceInstruction(idx, new AVM2Instruction(0, DeobfuscatePopIns.getInstance(), null), body); } } if (def instanceof GetLocalTypeIns) { @@ -308,6 +312,7 @@ public class AVM2DeobfuscatorSimple implements SWFDecompilerListener { } boolean ok = false; + // todo: honfika: order by statistics if (def instanceof PushByteIns || def instanceof PushShortIns || def instanceof PushIntIns @@ -390,22 +395,22 @@ public class AVM2DeobfuscatorSimple implements SWFDecompilerListener { if (EcmaScript.toBoolean(res)) { //System.err.println("replacing " + ins + " on " + idx + " with jump"); - AVM2Instruction jumpIns = new AVM2Instruction(0, new JumpIns(), new int[]{0}); + AVM2Instruction jumpIns = new AVM2Instruction(0, AVM2Instructions.Jump, new int[]{0}); //jumpIns.operands[0] = ins.operands[0] /*- ins.getBytes().length*/ + jumpIns.getBytes().length; code.replaceInstruction(idx, jumpIns, body); jumpIns.operands[0] = (int) (tarIns.offset - jumpIns.offset - jumpIns.getBytesLength()); for (int s = 0; s < stackCount; s++) { - code.insertInstruction(idx, new AVM2Instruction(ins.offset, new DeobfuscatePopIns(), null), true, body); + code.insertInstruction(idx, new AVM2Instruction(ins.offset, DeobfuscatePopIns.getInstance(), null), true, body); } idx = code.adr2pos(jumpIns.offset + jumpIns.getBytesLength() + jumpIns.operands[0]); } else { //System.err.println("replacing " + ins + " on " + idx + " with pop"); - code.replaceInstruction(idx, new AVM2Instruction(ins.offset, new DeobfuscatePopIns(), null), body); + code.replaceInstruction(idx, new AVM2Instruction(ins.offset, DeobfuscatePopIns.getInstance(), null), body); for (int s = 1 /*first is replaced*/; s < stackCount; s++) { - code.insertInstruction(idx, new AVM2Instruction(ins.offset, new DeobfuscatePopIns(), null), true, body); + code.insertInstruction(idx, new AVM2Instruction(ins.offset, DeobfuscatePopIns.getInstance(), null), true, body); } - //ins.definition = new DeobfuscatePopIns(); + //ins.definition = DeobfuscatePopIns.getInstance(); idx++; } ifed = true; @@ -416,12 +421,13 @@ public class AVM2DeobfuscatorSimple implements SWFDecompilerListener { instructionsProcessed++; - if (stack.allItemsFixed()) { + if (result != null && stack.allItemsFixed()) { result.idx = idx == code.code.size() ? idx - 1 : idx; result.instructionsProcessed = instructionsProcessed; result.stack.clear(); result.stack.addAll(stack); } + if (ifed) { break; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java index e10e132eb..f3a8e641a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java @@ -66,6 +66,10 @@ public class AVM2Instruction implements Cloneable, GraphSourceItem { this.line = line; } + public AVM2Instruction(long offset, int insructionCode, int[] operands) { + this(offset, AVM2Code.instructionSet[insructionCode], operands); + } + public AVM2Instruction(long offset, InstructionDefinition definition, int[] operands) { this.definition = definition; this.operands = operands != null && operands.length > 0 ? operands : null; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instructions.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instructions.java new file mode 100644 index 000000000..38e630f38 --- /dev/null +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instructions.java @@ -0,0 +1,438 @@ +/* + * Copyright (C) 2010-2015 JPEXS, All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions; + +/** + * + * @author JPEXS + */ +public class AVM2Instructions { + + public static final int Bkpt = 0x01; + + public static final int Nop = 0x02; + + public static final int Throw = 0x03; + + public static final int GetSuper = 0x04; + + public static final int SetSuper = 0x05; + + public static final int DXNS = 0x06; + + public static final int DXNSLate = 0x07; + + public static final int Kill = 0x08; + + public static final int Label = 0x09; + + public static final int Lf32x4 = 0x0A; + + public static final int Sf32x4 = 0x0B; + + public static final int IfNLt = 0x0C; + + public static final int IfNLe = 0x0D; + + public static final int IfNGt = 0x0E; + + public static final int IfNGe = 0x0F; + + public static final int Jump = 0x10; + + public static final int IfTrue = 0x11; + + public static final int IfFalse = 0x12; + + public static final int IfEq = 0x13; + + public static final int IfNe = 0x14; + + public static final int IfLt = 0x15; + + public static final int IfLe = 0x16; + + public static final int IfGt = 0x17; + + public static final int IfGe = 0x18; + + public static final int IfStrictEq = 0x19; + + public static final int IfStrictNe = 0x1A; + + public static final int LookupSwitch = 0x1B; + + public static final int PushWith = 0x1C; + + public static final int PopScope = 0x1D; + + public static final int NextName = 0x1E; + + public static final int HasNext = 0x1F; + + public static final int PushNull = 0x20; + + public static final int PushUndefined = 0x21; + + public static final int PushConstant = 0x22; + + public static final int NextValue = 0x23; + + public static final int PushByte = 0x24; + + public static final int PushShort = 0x25; + + public static final int PushTrue = 0x26; + + public static final int PushFalse = 0x27; + + public static final int PushNan = 0x28; + + public static final int Pop = 0x29; + + public static final int Dup = 0x2A; + + public static final int Swap = 0x2B; + + public static final int PushString = 0x2C; + + public static final int PushInt = 0x2D; + + public static final int PushUInt = 0x2E; + + public static final int PushDouble = 0x2F; + + public static final int PushScope = 0x30; + + public static final int PushNamespace = 0x31; + + public static final int HasNext2 = 0x32; + + public static final int PushDecimal = 0x33; + + public static final int PushDNan = 0x34; + + public static final int Li8 = 0x35; + + public static final int Li16 = 0x36; + + public static final int Li32 = 0x37; + + public static final int Lf32 = 0x38; + + public static final int Lf64 = 0x39; + + public static final int Si8 = 0x3A; + + public static final int Si16 = 0x3B; + + public static final int Si32 = 0x3C; + + public static final int Sf32 = 0x3D; + + public static final int Sf64 = 0x3E; + + public static final int NewFunction = 0x40; + + public static final int Call = 0x41; + + public static final int Construct = 0x42; + + public static final int CallMethod = 0x43; + + public static final int CallStatic = 0x44; + + public static final int CallSuper = 0x45; + + public static final int CallProperty = 0x46; + + public static final int ReturnVoid = 0x47; + + public static final int ReturnValue = 0x48; + + public static final int ConstructSuper = 0x49; + + public static final int ConstructProp = 0x4A; + + public static final int CallSuperId = 0x4B; + + public static final int CallPropLex = 0x4C; + + public static final int CallInterface = 0x4D; + + public static final int CallSuperVoid = 0x4E; + + public static final int CallPropVoid = 0x4F; + + public static final int Sxi1 = 0x50; + + public static final int Sxi8 = 0x51; + + public static final int Sxi16 = 0x52; + + public static final int ApplyType = 0x53; + + public static final int PushFloat4 = 0x54; + + public static final int NewObject = 0x55; + + public static final int NewArray = 0x56; + + public static final int NewActivation = 0x57; + + public static final int NewClass = 0x58; + + public static final int GetDescendants = 0x59; + + public static final int NewCatch = 0x5A; + + public static final int DelDescendants = 0x5B; + + public static final int FindPropGlobal = 0x5C; + + public static final int FindPropertyStrict = 0x5D; + + public static final int FindProperty = 0x5E; + + public static final int FindDef = 0x5F; + + public static final int GetLex = 0x60; + + public static final int SetProperty = 0x61; + + public static final int GetLocal = 0x62; + + public static final int SetLocal = 0x63; + + public static final int GetGlobalScope = 0x64; + + public static final int GetScopeObject = 0x65; + + public static final int GetProperty = 0x66; + + public static final int GetOuterScope = 0x67; + + public static final int InitProperty = 0x68; + + public static final int SetPropertyLate = 0x69; + + public static final int DeleteProperty = 0x6A; + + public static final int DeletePropertyLate = 0x6B; + + public static final int GetSlot = 0x6C; + + public static final int SetSlot = 0x6D; + + public static final int GetGlobalSlot = 0x6E; + + public static final int SetGlobalSlot = 0x6F; + + public static final int ConvertS = 0x70; + + public static final int EscXElem = 0x71; + + public static final int EscXAttr = 0x72; + + public static final int ConvertI = 0x73; + + public static final int ConvertU = 0x74; + + public static final int ConvertD = 0x75; + + public static final int ConvertB = 0x76; + + public static final int ConvertO = 0x77; + + public static final int CheckFilter = 0x78; + + public static final int ConvertM = 0x79; + + public static final int ConvertMP = 0x7A; + + public static final int ConvertF4 = 0x7B; + + public static final int Coerce = 0x80; + + public static final int CoerceB = 0x81; + + public static final int CoerceA = 0x82; + + public static final int CoerceI = 0x83; + + public static final int CoerceD = 0x84; + + public static final int CoerceS = 0x85; + + public static final int AsType = 0x86; + + public static final int AsTypeLate = 0x87; + + public static final int CoerceU = 0x88; + + public static final int CoerceO = 0x89; + + public static final int NegateP = 0x8F; + + public static final int Negate = 0x90; + + public static final int Increment = 0x91; + + public static final int IncLocal = 0x92; + + public static final int Decrement = 0x93; + + public static final int DecLocal = 0x94; + + public static final int TypeOf = 0x95; + + public static final int Not = 0x96; + + public static final int BitNot = 0x97; + + public static final int Concat = 0x9A; + + public static final int AddD = 0x9B; + + public static final int IncrementP = 0x9C; + + public static final int IncLocalP = 0x9D; + + public static final int DecrementP = 0x9E; + + public static final int DecLocalP = 0x9F; + + public static final int Add = 0xA0; + + public static final int Subtract = 0xA1; + + public static final int Multiply = 0xA2; + + public static final int Divide = 0xA3; + + public static final int Modulo = 0xA4; + + public static final int LShift = 0xA5; + + public static final int RShift = 0xA6; + + public static final int URShift = 0xA7; + + public static final int BitAnd = 0xA8; + + public static final int BitOr = 0xA9; + + public static final int BitXor = 0xAA; + + public static final int Equals = 0xAB; + + public static final int StrictEquals = 0xAC; + + public static final int LessThan = 0xAD; + + public static final int LessEquals = 0xAE; + + public static final int GreaterThan = 0xAF; + + public static final int GreaterEquals = 0xB0; + + public static final int InstanceOf = 0xB1; + + public static final int IsType = 0xB2; + + public static final int IsTypeLate = 0xB3; + + public static final int In = 0xB4; + + public static final int AddP = 0xB5; + + public static final int SubtractP = 0xB6; + + public static final int MultiplyP = 0xB7; + + public static final int DivideP = 0xB8; + + public static final int ModuloP = 0xB9; + + public static final int IncrementI = 0xC0; + + public static final int DecrementI = 0xC1; + + public static final int IncLocalI = 0xC2; + + public static final int DecLocalI = 0xC3; + + public static final int NegateI = 0xC4; + + public static final int AddI = 0xC5; + + public static final int SubtractI = 0xC6; + + public static final int MultiplyI = 0xC7; + + public static final int GetLocal0 = 0xD0; + + public static final int GetLocal1 = 0xD1; + + public static final int GetLocal2 = 0xD2; + + public static final int GetLocal3 = 0xD3; + + public static final int SetLocal0 = 0xD4; + + public static final int SetLocal1 = 0xD5; + + public static final int SetLocal2 = 0xD6; + + public static final int SetLocal3 = 0xD7; + + public static final int Invalid = 0xED; + + public static final int AbsJump = 0xEE; + + public static final int Debug = 0xEF; + + public static final int DebugLine = 0xF0; + + public static final int DebugFile = 0xF1; + + public static final int BkptLine = 0xF2; + + public static final int Timestamp = 0xF3; + + public static final int VerifyPass = 0xF5; + + public static final int Alloc = 0xF6; + + public static final int Mark = 0xF7; + + public static final int Wb = 0xF8; + + public static final int Prologue = 0xF9; + + public static final int SendEnter = 0xFA; + + public static final int DoubleToAtom = 0xFB; + + public static final int Sweep = 0xFC; + + public static final int CodeGenOp = 0xFD; + + public static final int VerifyOp = 0xFE; + + public static final int Decode = 0xFF; +} diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/DeobfuscatePopIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/DeobfuscatePopIns.java index 1b602f092..1c721c9db 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/DeobfuscatePopIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/DeobfuscatePopIns.java @@ -29,8 +29,16 @@ import java.util.List; */ public class DeobfuscatePopIns extends PopIns { - public DeobfuscatePopIns() { - instructionName = "ffdec_deobfuscatepop"; + public static final String NAME = "ffdec_deobfuscatepop"; + + private static final DeobfuscatePopIns instance = new DeobfuscatePopIns(); + + public static final DeobfuscatePopIns getInstance() { + return instance; + } + + private DeobfuscatePopIns() { + instructionName = NAME; } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/InstructionDefinition.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/InstructionDefinition.java index 0dd942366..6bbd614c9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/InstructionDefinition.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/InstructionDefinition.java @@ -42,7 +42,7 @@ import java.util.List; import java.util.Set; import java.util.Stack; -public class InstructionDefinition implements Serializable { +public abstract class InstructionDefinition implements Serializable { public static final long serialVersionUID = 1L; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIIns.java index 2e6dd1e80..c7e39fa03 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIIns.java @@ -42,4 +42,9 @@ public class AddIIns extends AddIns { public int getStackPopCount(AVM2Instruction ins, ABC abc) { return 2; } + + @Override + public int getStackPushCount(AVM2Instruction ins, ABC abc) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/JumpIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/JumpIns.java index af9f6d16d..28997ded6 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/JumpIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/JumpIns.java @@ -28,8 +28,10 @@ import java.util.List; public class JumpIns extends InstructionDefinition implements IfTypeIns { + public static final String NAME = "jump"; + public JumpIns() { - super(0x10, "jump", new int[]{AVM2Code.DAT_OFFSET}, false); + super(0x10, NAME, new int[]{AVM2Code.DAT_OFFSET}, false); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/AVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/AVM2Item.java index 47ddf1194..4ee87bbb6 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/AVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/AVM2Item.java @@ -18,9 +18,10 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.IdentifiersDeobfuscation; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PopIns; import com.jpexs.decompiler.flash.abc.avm2.parser.script.AVM2SourceGenerator; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; @@ -130,11 +131,12 @@ public abstract class AVM2Item extends GraphTargetItem { return toSource(localData, generator); } List ret = toSource(localData, generator); - ret.add(new AVM2Instruction(0, new PopIns(), null)); + ret.add(new AVM2Instruction(0, AVM2Instructions.Pop, null)); return ret; } - public static AVM2Instruction ins(InstructionDefinition def, Integer... operands) { + public static AVM2Instruction ins(int instructionCode, Integer... operands) { + InstructionDefinition def = AVM2Code.instructionSet[instructionCode]; List ops = new ArrayList<>(); for (Integer o : operands) { if (o != null) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/AlchemyLoadAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/AlchemyLoadAVM2Item.java index d9acc90a8..b2ba617ca 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/AlchemyLoadAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/AlchemyLoadAVM2Item.java @@ -17,12 +17,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy.Lf32Ins; -import com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy.Lf64Ins; -import com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy.Li16Ins; -import com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy.Li32Ins; -import com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy.Li8Ins; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.DottedChain; @@ -62,25 +57,25 @@ public class AlchemyLoadAVM2Item extends AVM2Item { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { String ts = "" + type + size; - InstructionDefinition def = null; + int code = 0; switch (ts) { case "i8": - def = new Li8Ins(); + code = AVM2Instructions.Li8; break; case "i16": - def = new Li16Ins(); + code = AVM2Instructions.Li16; break; case "i32": - def = new Li32Ins(); + code = AVM2Instructions.Li32; break; case "f": - def = new Lf32Ins(); + code = AVM2Instructions.Lf32; break; case "f32": - def = new Lf64Ins(); + code = AVM2Instructions.Lf64; break; } - return toSourceMerge(localData, generator, ofs, ins(def)); + return toSourceMerge(localData, generator, ofs, ins(code)); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/AlchemySignExtendAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/AlchemySignExtendAVM2Item.java index ea770a025..c0fd834df 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/AlchemySignExtendAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/AlchemySignExtendAVM2Item.java @@ -17,10 +17,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy.Sxi16Ins; -import com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy.Sxi1Ins; -import com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy.Sxi8Ins; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.DottedChain; @@ -63,18 +60,18 @@ public class AlchemySignExtendAVM2Item extends AVM2Item { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { - InstructionDefinition def = null; + int code = 0; switch (size) { case 1: - def = new Sxi1Ins(); + code = AVM2Instructions.Sxi1; break; case 8: - def = new Sxi8Ins(); + code = AVM2Instructions.Sxi8; break; case 16: - def = new Sxi16Ins(); + code = AVM2Instructions.Sxi16; break; } - return toSourceMerge(localData, generator, value, ins(def)); + return toSourceMerge(localData, generator, value, ins(code)); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/AlchemyStoreAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/AlchemyStoreAVM2Item.java index ee89de09a..9abe8f8be 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/AlchemyStoreAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/AlchemyStoreAVM2Item.java @@ -17,12 +17,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy.Sf32Ins; -import com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy.Sf64Ins; -import com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy.Si16Ins; -import com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy.Si32Ins; -import com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy.Si8Ins; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.GraphSourceItem; @@ -73,24 +68,24 @@ public class AlchemyStoreAVM2Item extends AVM2Item { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { String ts = "" + type + size; - InstructionDefinition def = null; + int code = 0; switch (ts) { case "i8": - def = new Si8Ins(); + code = AVM2Instructions.Si8; break; case "i16": - def = new Si16Ins(); + code = AVM2Instructions.Si16; break; case "i32": - def = new Si32Ins(); + code = AVM2Instructions.Si32; break; case "f32": - def = new Sf32Ins(); + code = AVM2Instructions.Sf32; break; case "f64": - def = new Sf64Ins(); + code = AVM2Instructions.Sf64; break; } - return toSourceMerge(localData, generator, ofs, ins(def)); + return toSourceMerge(localData, generator, ofs, ins(code)); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ApplyTypeAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ApplyTypeAVM2Item.java index 1ce999c26..7fa3d8dea 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ApplyTypeAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ApplyTypeAVM2Item.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.types.ApplyTypeIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.GraphSourceItem; @@ -74,15 +74,15 @@ public class ApplyTypeAVM2Item extends AVM2Item { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { - //int qname = AVM2SourceGenerator.resolveType(localData,object,((AVM2SourceGenerator)generator).abc,((AVM2SourceGenerator)generator).allABCs); + //int qname = AVM2SourceGenerator.resolveType(localData, object, ((AVM2SourceGenerator)generator).abc, ((AVM2SourceGenerator)generator).allABCs); List nparams = new ArrayList<>(); for (GraphTargetItem i : params) { - nparams.addAll(i.toSource(localData, generator));//ins(new GetLexIns(),AVM2SourceGenerator.resolveType(localData,i,((AVM2SourceGenerator)generator).abc,((AVM2SourceGenerator)generator).allABCs))); + nparams.addAll(i.toSource(localData, generator));//ins(AVM2Instructions.GetLex, AVM2SourceGenerator.resolveType(localData, i, ((AVM2SourceGenerator)generator).abc,((AVM2SourceGenerator)generator).allABCs))); } return toSourceMerge(localData, generator, object, nparams, - ins(new ApplyTypeIns(), params.size()) + ins(AVM2Instructions.ApplyType, params.size()) ); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/BooleanAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/BooleanAVM2Item.java index d187d7340..88671ef4a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/BooleanAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/BooleanAVM2Item.java @@ -1,24 +1,24 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library 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 * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushFalseIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushTrueIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.GraphSourceItem; @@ -56,7 +56,7 @@ public class BooleanAVM2Item extends AVM2Item { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { return toSourceMerge(localData, generator, - new AVM2Instruction(0, value ? new PushTrueIns() : new PushFalseIns(), null) + new AVM2Instruction(0, value ? AVM2Instructions.PushTrue : AVM2Instructions.PushFalse, null) ); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/CallPropertyAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/CallPropertyAVM2Item.java index 421271e0a..278bfb0ae 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/CallPropertyAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/CallPropertyAVM2Item.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.executing.CallPropertyIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.abc.avm2.parser.script.AVM2SourceGenerator; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; @@ -64,7 +64,7 @@ public class CallPropertyAVM2Item extends AVM2Item { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { return toSourceMerge(localData, generator, receiver, arguments, - new AVM2Instruction(0, new CallPropertyIns(), new int[]{((AVM2SourceGenerator) generator).propertyName(propertyName), arguments.size()}) + new AVM2Instruction(0, AVM2Instructions.CallProperty, new int[]{((AVM2SourceGenerator) generator).propertyName(propertyName), arguments.size()}) ); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/CoerceAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/CoerceAVM2Item.java index 3ce33aadc..fcae92833 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/CoerceAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/CoerceAVM2Item.java @@ -18,13 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceAIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceSIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.types.ConvertBIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.types.ConvertDIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.types.ConvertIIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.types.ConvertUIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.abc.avm2.parser.script.AVM2SourceGenerator; import com.jpexs.decompiler.flash.ecma.Null; import com.jpexs.decompiler.flash.ecma.Undefined; @@ -112,26 +106,26 @@ public class CoerceAVM2Item extends AVM2Item { AVM2Instruction ins; switch (typeObj.toString()) { case "*": - ins = new AVM2Instruction(0, new CoerceAIns(), null); + ins = new AVM2Instruction(0, AVM2Instructions.CoerceA, null); break; case "String": - ins = new AVM2Instruction(0, new CoerceSIns(), null); + ins = new AVM2Instruction(0, AVM2Instructions.CoerceS, null); break; case "Boolean": - ins = new AVM2Instruction(0, new ConvertBIns(), null); + ins = new AVM2Instruction(0, AVM2Instructions.ConvertB, null); break; case "int": - ins = new AVM2Instruction(0, new ConvertIIns(), null); + ins = new AVM2Instruction(0, AVM2Instructions.ConvertI, null); break; case "uint": - ins = new AVM2Instruction(0, new ConvertUIns(), null); + ins = new AVM2Instruction(0, AVM2Instructions.ConvertU, null); break; case "Number": - ins = new AVM2Instruction(0, new ConvertDIns(), null); + ins = new AVM2Instruction(0, AVM2Instructions.ConvertD, null); break; default: int type_index = AVM2SourceGenerator.resolveType(localData, typeObj, ((AVM2SourceGenerator) generator).abc, (((AVM2SourceGenerator) generator).allABCs)); - ins = new AVM2Instruction(0, new CoerceIns(), new int[]{type_index}); + ins = new AVM2Instruction(0, AVM2Instructions.Coerce, new int[]{type_index}); break; } return toSourceMerge(localData, generator, value, ins); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ConstructSuperAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ConstructSuperAVM2Item.java index 28c63efde..7f54143a4 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ConstructSuperAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ConstructSuperAVM2Item.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.ConstructSuperIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.GraphSourceItem; @@ -70,7 +70,7 @@ public class ConstructSuperAVM2Item extends AVM2Item { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { return toSourceMerge(localData, generator, object, args, - new AVM2Instruction(0, new ConstructSuperIns(), new int[]{args.size()}) + new AVM2Instruction(0, AVM2Instructions.ConstructSuper, new int[]{args.size()}) ); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/DefaultXMLNamespace.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/DefaultXMLNamespace.java index 955755ac1..49f797e65 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/DefaultXMLNamespace.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/DefaultXMLNamespace.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.xml.DXNSLateIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.GraphSourceItem; @@ -59,6 +59,6 @@ public class DefaultXMLNamespace extends AVM2Item { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { - return toSourceMerge(localData, generator, ns, ins(new DXNSLateIns())); + return toSourceMerge(localData, generator, ns, ins(AVM2Instructions.DXNSLate)); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/EscapeXAttrAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/EscapeXAttrAVM2Item.java index 0652c7679..e99bf9475 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/EscapeXAttrAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/EscapeXAttrAVM2Item.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.xml.EscXAttrIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.GraphSourceItem; @@ -57,6 +57,6 @@ public class EscapeXAttrAVM2Item extends AVM2Item { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { - return toSourceMerge(localData, generator, value, ins(new EscXAttrIns())); + return toSourceMerge(localData, generator, value, ins(AVM2Instructions.EscXAttr)); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/EscapeXElemAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/EscapeXElemAVM2Item.java index 932298837..afde2d67f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/EscapeXElemAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/EscapeXElemAVM2Item.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.xml.EscXElemIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.GraphSourceItem; @@ -57,6 +57,6 @@ public class EscapeXElemAVM2Item extends AVM2Item { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { - return toSourceMerge(localData, generator, value, ins(new EscXElemIns())); + return toSourceMerge(localData, generator, value, ins(AVM2Instructions.EscXElem)); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/FloatValueAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/FloatValueAVM2Item.java index 55b09abcf..705b6843c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/FloatValueAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/FloatValueAVM2Item.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushDoubleIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.abc.avm2.parser.script.AVM2SourceGenerator; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; @@ -57,7 +57,7 @@ public class FloatValueAVM2Item extends NumberValueAVM2Item { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { return toSourceMerge(localData, generator, - new AVM2Instruction(0, new PushDoubleIns(), new int[]{((AVM2SourceGenerator) generator).abc.constants.getDoubleId(value, true)}) + new AVM2Instruction(0, AVM2Instructions.PushDouble, new int[]{((AVM2SourceGenerator) generator).abc.constants.getDoubleId(value, true)}) ); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetPropertyAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetPropertyAVM2Item.java index bd782394a..442baa689 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetPropertyAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetPropertyAVM2Item.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetPropertyIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.abc.avm2.parser.script.AVM2SourceGenerator; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; @@ -49,7 +49,7 @@ public class GetPropertyAVM2Item extends AVM2Item { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { return toSourceMerge(localData, generator, object, - new AVM2Instruction(0, new GetPropertyIns(), new int[]{((AVM2SourceGenerator) generator).propertyName(propertyName)}) + new AVM2Instruction(0, AVM2Instructions.GetProperty, new int[]{((AVM2SourceGenerator) generator).propertyName(propertyName)}) ); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/InAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/InAVM2Item.java index 425f08140..2b76da4e9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/InAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/InAVM2Item.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.InIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.GraphSourceItem; @@ -59,6 +59,6 @@ public class InAVM2Item extends AVM2Item { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { - return toSourceMerge(localData, generator, object, collection, ins(new InIns())); + return toSourceMerge(localData, generator, object, collection, ins(AVM2Instructions.In)); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/InitVectorAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/InitVectorAVM2Item.java index 335bd63e7..309a102ff 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/InitVectorAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/InitVectorAVM2Item.java @@ -19,12 +19,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.ConstructIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.FindPropertyStrictIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetPropertyIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.SetPropertyIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.DupIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.types.ApplyTypeIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.abc.avm2.parser.script.AVM2SourceGenerator; import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.flash.abc.types.Namespace; @@ -117,19 +112,19 @@ public class InitVectorAVM2Item extends AVM2Item { public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { AVM2SourceGenerator g = (AVM2SourceGenerator) generator; List ret = toSourceMerge(localData, generator, - ins(new FindPropertyStrictIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.MULTINAME, g.abc.constants.getStringId("Vector", true), 0, g.abc.constants.getNamespaceSetId(new NamespaceSet(new int[]{g.abc.constants.getNamespaceId(new Namespace(Namespace.KIND_PACKAGE, g.abc.constants.getStringId("__AS3__.vec", true)), 0, true)}), true), 0, new ArrayList<>()), true)), - ins(new GetPropertyIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.MULTINAME, g.abc.constants.getStringId("Vector", true), 0, allNsSet(g.abc), 0, new ArrayList<>()), true)), + ins(AVM2Instructions.FindPropertyStrict, g.abc.constants.getMultinameId(new Multiname(Multiname.MULTINAME, g.abc.constants.getStringId("Vector", true), 0, g.abc.constants.getNamespaceSetId(new NamespaceSet(new int[]{g.abc.constants.getNamespaceId(new Namespace(Namespace.KIND_PACKAGE, g.abc.constants.getStringId("__AS3__.vec", true)), 0, true)}), true), 0, new ArrayList<>()), true)), + ins(AVM2Instructions.GetProperty, g.abc.constants.getMultinameId(new Multiname(Multiname.MULTINAME, g.abc.constants.getStringId("Vector", true), 0, allNsSet(g.abc), 0, new ArrayList<>()), true)), subtype, - ins(new ApplyTypeIns(), 1), + ins(AVM2Instructions.ApplyType, 1), new IntegerValueAVM2Item(null, (long) arguments.size()), - ins(new ConstructIns(), 1) + ins(AVM2Instructions.Construct, 1) ); for (int i = 0; i < arguments.size(); i++) { ret.addAll(toSourceMerge(localData, generator, - ins(new DupIns()), + ins(AVM2Instructions.Dup), new IntegerValueAVM2Item(null, (long) i), arguments.get(i), - ins(new SetPropertyIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.MULTINAMEL, 0, 0, g.abc.constants.getNamespaceSetId(new NamespaceSet(new int[]{g.abc.constants.getNamespaceId(new Namespace(Namespace.KIND_PACKAGE, g.abc.constants.getStringId("", true)), 0, true)}), true), precedence, openedNamespaces), true)) + ins(AVM2Instructions.SetProperty, g.abc.constants.getMultinameId(new Multiname(Multiname.MULTINAMEL, 0, 0, g.abc.constants.getNamespaceSetId(new NamespaceSet(new int[]{g.abc.constants.getNamespaceId(new Namespace(Namespace.KIND_PACKAGE, g.abc.constants.getStringId("", true)), 0, true)}), true), precedence, openedNamespaces), true)) )); } return ret; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/IntegerValueAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/IntegerValueAVM2Item.java index b1201dab2..fbf7c8d71 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/IntegerValueAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/IntegerValueAVM2Item.java @@ -18,9 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushByteIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushIntIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushShortIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.abc.avm2.parser.script.AVM2SourceGenerator; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; @@ -132,11 +130,11 @@ public class IntegerValueAVM2Item extends NumberValueAVM2Item implements Integer public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { AVM2Instruction ins = null; if (value >= -128 && value <= 127) { - ins = new AVM2Instruction(0, new PushByteIns(), new int[]{(int) (long) value}); + ins = new AVM2Instruction(0, AVM2Instructions.PushByte, new int[]{(int) (long) value}); } else if (value >= -32768 && value <= 32767) { - ins = new AVM2Instruction(0, new PushShortIns(), new int[]{((int) (long) value) & 0xffff}); + ins = new AVM2Instruction(0, AVM2Instructions.PushShort, new int[]{((int) (long) value) & 0xffff}); } else { - ins = new AVM2Instruction(0, new PushIntIns(), new int[]{((AVM2SourceGenerator) generator).abc.constants.getIntId(value, true)}); + ins = new AVM2Instruction(0, AVM2Instructions.PushInt, new int[]{((AVM2SourceGenerator) generator).abc.constants.getIntId(value, true)}); } return toSourceMerge(localData, generator, ins); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/LocalRegAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/LocalRegAVM2Item.java index 40322a77a..faaa142ba 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/LocalRegAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/LocalRegAVM2Item.java @@ -18,11 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.GetLocal0Ins; -import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.GetLocal1Ins; -import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.GetLocal2Ins; -import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.GetLocal3Ins; -import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.GetLocalIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.abc.avm2.model.clauses.FilterAVM2Item; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; @@ -94,19 +90,19 @@ public class LocalRegAVM2Item extends AVM2Item { AVM2Instruction ins; switch (regIndex) { case 0: - ins = new AVM2Instruction(0, new GetLocal0Ins(), null); + ins = new AVM2Instruction(0, AVM2Instructions.GetLocal0, null); break; case 1: - ins = new AVM2Instruction(0, new GetLocal1Ins(), null); + ins = new AVM2Instruction(0, AVM2Instructions.GetLocal1, null); break; case 2: - ins = new AVM2Instruction(0, new GetLocal2Ins(), null); + ins = new AVM2Instruction(0, AVM2Instructions.GetLocal2, null); break; case 3: - ins = new AVM2Instruction(0, new GetLocal3Ins(), null); + ins = new AVM2Instruction(0, AVM2Instructions.GetLocal3, null); break; default: - ins = new AVM2Instruction(0, new GetLocalIns(), new int[]{regIndex}); + ins = new AVM2Instruction(0, AVM2Instructions.GetLocal, new int[]{regIndex}); break; } return toSourceMerge(localData, generator, ins); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NanAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NanAVM2Item.java index 7ea68e9fd..3db653df5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NanAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NanAVM2Item.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushNanIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.DottedChain; @@ -43,7 +43,7 @@ public class NanAVM2Item extends AVM2Item { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { return toSourceMerge(localData, generator, - new AVM2Instruction(0, new PushNanIns(), null) + new AVM2Instruction(0, AVM2Instructions.PushNan, null) ); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NewArrayAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NewArrayAVM2Item.java index 541b8192e..c0a6b48fd 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NewArrayAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NewArrayAVM2Item.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.NewArrayIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.GraphSourceItem; @@ -62,7 +62,7 @@ public class NewArrayAVM2Item extends AVM2Item { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { return toSourceMerge(localData, generator, values, - new AVM2Instruction(0, new NewArrayIns(), new int[]{values.size()}) + new AVM2Instruction(0, AVM2Instructions.NewArray, new int[]{values.size()}) ); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NewObjectAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NewObjectAVM2Item.java index 5be4b4f32..e46512926 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NewObjectAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NewObjectAVM2Item.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.NewObjectIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.DottedChain; @@ -80,7 +80,7 @@ public class NewObjectAVM2Item extends AVM2Item { args.add(p.value); } return toSourceMerge(localData, generator, args, - new AVM2Instruction(0, new NewObjectIns(), new int[]{pairs.size()}) + new AVM2Instruction(0, AVM2Instructions.NewObject, new int[]{pairs.size()}) ); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NullAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NullAVM2Item.java index 637d7fdcb..df2c1be06 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NullAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NullAVM2Item.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushNullIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.ecma.Null; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; @@ -55,7 +55,7 @@ public class NullAVM2Item extends AVM2Item { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { return toSourceMerge(localData, generator, - new AVM2Instruction(0, new PushNullIns(), null) + new AVM2Instruction(0, AVM2Instructions.PushNull, null) ); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetLocalAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetLocalAVM2Item.java index c36dd682e..5cfa3bc0e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetLocalAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetLocalAVM2Item.java @@ -18,12 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.SetLocal0Ins; -import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.SetLocal1Ins; -import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.SetLocal2Ins; -import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.SetLocal3Ins; -import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.SetLocalIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.DupIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.abc.avm2.model.clauses.AssignmentAVM2Item; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; @@ -72,23 +67,23 @@ public class SetLocalAVM2Item extends AVM2Item implements SetTypeAVM2Item, Assig AVM2Instruction ins; switch (regIndex) { case 0: - ins = new AVM2Instruction(0, new SetLocal0Ins(), null); + ins = new AVM2Instruction(0, AVM2Instructions.SetLocal0, null); break; case 1: - ins = new AVM2Instruction(0, new SetLocal1Ins(), null); + ins = new AVM2Instruction(0, AVM2Instructions.SetLocal1, null); break; case 2: - ins = new AVM2Instruction(0, new SetLocal2Ins(), null); + ins = new AVM2Instruction(0, AVM2Instructions.SetLocal2, null); break; case 3: - ins = new AVM2Instruction(0, new SetLocal3Ins(), null); + ins = new AVM2Instruction(0, AVM2Instructions.SetLocal3, null); break; default: - ins = new AVM2Instruction(0, new SetLocalIns(), new int[]{regIndex}); + ins = new AVM2Instruction(0, AVM2Instructions.SetLocal, new int[]{regIndex}); break; } return toSourceMerge(localData, generator, value, - new AVM2Instruction(0, new DupIns(), null), ins); + new AVM2Instruction(0, AVM2Instructions.Dup, null), ins); } @Override @@ -96,19 +91,19 @@ public class SetLocalAVM2Item extends AVM2Item implements SetTypeAVM2Item, Assig AVM2Instruction ins; switch (regIndex) { case 0: - ins = new AVM2Instruction(0, new SetLocal0Ins(), null); + ins = new AVM2Instruction(0, AVM2Instructions.SetLocal0, null); break; case 1: - ins = new AVM2Instruction(0, new SetLocal1Ins(), null); + ins = new AVM2Instruction(0, AVM2Instructions.SetLocal1, null); break; case 2: - ins = new AVM2Instruction(0, new SetLocal2Ins(), null); + ins = new AVM2Instruction(0, AVM2Instructions.SetLocal2, null); break; case 3: - ins = new AVM2Instruction(0, new SetLocal3Ins(), null); + ins = new AVM2Instruction(0, AVM2Instructions.SetLocal3, null); break; default: - ins = new AVM2Instruction(0, new SetLocalIns(), new int[]{regIndex}); + ins = new AVM2Instruction(0, AVM2Instructions.SetLocal, new int[]{regIndex}); break; } return toSourceMerge(localData, generator, value, ins); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetPropertyAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetPropertyAVM2Item.java index ec7233a73..1caca13b9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetPropertyAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetPropertyAVM2Item.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.SetPropertyIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.abc.avm2.model.clauses.AssignmentAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.parser.script.AVM2SourceGenerator; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; @@ -76,7 +76,7 @@ public class SetPropertyAVM2Item extends AVM2Item implements SetTypeAVM2Item, As @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { return toSourceMerge(localData, generator, object, value, - new AVM2Instruction(0, new SetPropertyIns(), new int[]{((AVM2SourceGenerator) generator).propertyName(propertyName)}) + new AVM2Instruction(0, AVM2Instructions.SetProperty, new int[]{((AVM2SourceGenerator) generator).propertyName(propertyName)}) ); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/StringAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/StringAVM2Item.java index 2f14ce4c0..5adc103c2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/StringAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/StringAVM2Item.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushStringIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.abc.avm2.parser.script.AVM2SourceGenerator; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; @@ -59,7 +59,7 @@ public class StringAVM2Item extends AVM2Item implements SimpleValue { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { return toSourceMerge(localData, generator, - new AVM2Instruction(0, new PushStringIns(), new int[]{((AVM2SourceGenerator) generator).str(value)}) + new AVM2Instruction(0, AVM2Instructions.PushString, new int[]{((AVM2SourceGenerator) generator).str(value)}) ); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ThisAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ThisAVM2Item.java index 07562c810..a93ce2dd8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ThisAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ThisAVM2Item.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.GetLocal0Ins; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; @@ -51,7 +51,7 @@ public class ThisAVM2Item extends AVM2Item { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { - return toSourceMerge(localData, generator, new AVM2Instruction(0, new GetLocal0Ins(), null) + return toSourceMerge(localData, generator, new AVM2Instruction(0, AVM2Instructions.GetLocal0, null) ); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/UndefinedAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/UndefinedAVM2Item.java index c488463ef..9c7e01331 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/UndefinedAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/UndefinedAVM2Item.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushUndefinedIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.ecma.Undefined; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; @@ -65,7 +65,7 @@ public class UndefinedAVM2Item extends AVM2Item { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { return toSourceMerge(localData, generator, - new AVM2Instruction(0, new PushUndefinedIns(), null) + new AVM2Instruction(0, AVM2Instructions.PushUndefined, null) ); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/AddAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/AddAVM2Item.java index 20555563e..d04d023c9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/AddAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/AddAVM2Item.java @@ -18,8 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.AddIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.IncrementIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.flash.ecma.EcmaType; @@ -77,12 +76,12 @@ public class AddAVM2Item extends BinaryOpItem { IntegerValueAVM2Item iv = (IntegerValueAVM2Item) rightSide; if (iv.value == 1) { return toSourceMerge(localData, generator, leftSide, - new AVM2Instruction(0, new IncrementIns(), null) + new AVM2Instruction(0, AVM2Instructions.Increment, null) ); } } return toSourceMerge(localData, generator, leftSide, rightSide, - new AVM2Instruction(0, new AddIns(), null) + new AVM2Instruction(0, AVM2Instructions.Add, null) ); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/AsTypeAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/AsTypeAVM2Item.java index 92004efd3..e9920034b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/AsTypeAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/AsTypeAVM2Item.java @@ -1,23 +1,24 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library 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 * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.types.AsTypeLateIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -34,7 +35,7 @@ public class AsTypeAVM2Item extends BinaryOpItem { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { return toSourceMerge(localData, generator, leftSide, rightSide, - new AVM2Instruction(0, new AsTypeLateIns(), null) + new AVM2Instruction(0, AVM2Instructions.AsTypeLate, null) ); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitAndAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitAndAVM2Item.java index 5c75dfda3..987124682 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitAndAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitAndAVM2Item.java @@ -1,23 +1,24 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library 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 * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise.BitAndIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.GraphSourceItem; @@ -41,7 +42,7 @@ public class BitAndAVM2Item extends BinaryOpItem { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { return toSourceMerge(localData, generator, leftSide, rightSide, - new AVM2Instruction(0, new BitAndIns(), null) + new AVM2Instruction(0, AVM2Instructions.BitAnd, null) ); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitNotAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitNotAVM2Item.java index 72ddcb498..9c4bd920a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitNotAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitNotAVM2Item.java @@ -1,23 +1,24 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library 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 * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise.BitNotIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.GraphSourceItem; @@ -41,7 +42,7 @@ public class BitNotAVM2Item extends UnaryOpItem { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { return toSourceMerge(localData, generator, value, - new AVM2Instruction(0, new BitNotIns(), null) + new AVM2Instruction(0, AVM2Instructions.BitNot, null) ); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitOrAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitOrAVM2Item.java index cf86eca82..b8632f9ff 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitOrAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitOrAVM2Item.java @@ -1,23 +1,24 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library 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 * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise.BitOrIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.GraphSourceItem; @@ -41,7 +42,7 @@ public class BitOrAVM2Item extends BinaryOpItem { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { return toSourceMerge(localData, generator, leftSide, rightSide, - new AVM2Instruction(0, new BitOrIns(), null) + new AVM2Instruction(0, AVM2Instructions.BitOr, null) ); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitXorAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitXorAVM2Item.java index acd224d0a..96ee3b91a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitXorAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitXorAVM2Item.java @@ -1,23 +1,24 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library 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 * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise.BitXorIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.GraphSourceItem; @@ -41,7 +42,7 @@ public class BitXorAVM2Item extends BinaryOpItem { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { return toSourceMerge(localData, generator, leftSide, rightSide, - new AVM2Instruction(0, new BitXorIns(), null) + new AVM2Instruction(0, AVM2Instructions.BitXor, null) ); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/DeletePropertyAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/DeletePropertyAVM2Item.java index fc2a76564..611848928 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/DeletePropertyAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/DeletePropertyAVM2Item.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.DeletePropertyIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item; import com.jpexs.decompiler.flash.abc.avm2.parser.script.IndexAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.parser.script.NamespacedAVM2Item; @@ -71,7 +71,7 @@ public class DeletePropertyAVM2Item extends AVM2Item { if (p instanceof PropertyAVM2Item) { PropertyAVM2Item prop = (PropertyAVM2Item) p; return toSourceMerge(localData, generator, prop.resolveObject(localData, generator), - ins(new DeletePropertyIns(), prop.resolveProperty(localData)) + ins(AVM2Instructions.DeleteProperty, prop.resolveProperty(localData)) ); } if (p instanceof IndexAVM2Item) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/DivideAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/DivideAVM2Item.java index 7e634f029..b0c4b74c0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/DivideAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/DivideAVM2Item.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.DivideIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; @@ -70,7 +70,7 @@ public class DivideAVM2Item extends BinaryOpItem { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { return toSourceMerge(localData, generator, leftSide, rightSide, - new AVM2Instruction(0, new DivideIns(), null) + new AVM2Instruction(0, AVM2Instructions.Divide, null) ); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/EqAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/EqAVM2Item.java index 99a31e159..557d315be 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/EqAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/EqAVM2Item.java @@ -18,10 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.instructions.comparison.EqualsIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfEqIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfNeIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.DottedChain; @@ -41,13 +38,13 @@ public class EqAVM2Item extends BinaryOpItem implements LogicalOpItem, IfConditi } @Override - public InstructionDefinition getIfDefinition() { - return new IfEqIns(); + public int getIfDefinition() { + return AVM2Instructions.IfEq; } @Override - public InstructionDefinition getIfNotDefinition() { - return new IfNeIns(); + public int getIfNotDefinition() { + return AVM2Instructions.IfNe; } @Override @@ -63,7 +60,7 @@ public class EqAVM2Item extends BinaryOpItem implements LogicalOpItem, IfConditi @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { return toSourceMerge(localData, generator, leftSide, rightSide, - new AVM2Instruction(0, new EqualsIns(), null) + new AVM2Instruction(0, AVM2Instructions.Equals, null) ); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/GeAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/GeAVM2Item.java index 73f353ace..609e89661 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/GeAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/GeAVM2Item.java @@ -18,10 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.instructions.comparison.GreaterEqualsIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfGeIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfNGeIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.DottedChain; @@ -40,13 +37,13 @@ public class GeAVM2Item extends BinaryOpItem implements LogicalOpItem, IfConditi } @Override - public InstructionDefinition getIfDefinition() { - return new IfGeIns(); + public int getIfDefinition() { + return AVM2Instructions.IfGe; } @Override - public InstructionDefinition getIfNotDefinition() { - return new IfNGeIns(); + public int getIfNotDefinition() { + return AVM2Instructions.IfNGe; } @Override @@ -69,7 +66,7 @@ public class GeAVM2Item extends BinaryOpItem implements LogicalOpItem, IfConditi @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { return toSourceMerge(localData, generator, leftSide, rightSide, - new AVM2Instruction(0, new GreaterEqualsIns(), null) + new AVM2Instruction(0, AVM2Instructions.GreaterEquals, null) ); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/GtAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/GtAVM2Item.java index f2d51939e..75d805478 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/GtAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/GtAVM2Item.java @@ -18,10 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.instructions.comparison.GreaterThanIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfGtIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfNGtIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.DottedChain; @@ -40,13 +37,13 @@ public class GtAVM2Item extends BinaryOpItem implements LogicalOpItem, IfConditi } @Override - public InstructionDefinition getIfDefinition() { - return new IfGtIns(); + public int getIfDefinition() { + return AVM2Instructions.IfGt; } @Override - public InstructionDefinition getIfNotDefinition() { - return new IfNGtIns(); + public int getIfNotDefinition() { + return AVM2Instructions.IfNGt; } @Override @@ -62,7 +59,7 @@ public class GtAVM2Item extends BinaryOpItem implements LogicalOpItem, IfConditi @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { return toSourceMerge(localData, generator, leftSide, rightSide, - new AVM2Instruction(0, new GreaterThanIns(), null) + new AVM2Instruction(0, AVM2Instructions.GreaterThan, null) ); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/IfCondition.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/IfCondition.java index 97c87ac9b..12013a3a0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/IfCondition.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/IfCondition.java @@ -1,21 +1,21 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library 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 * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.graph.model.BinaryOp; /** @@ -24,7 +24,7 @@ import com.jpexs.decompiler.graph.model.BinaryOp; */ public interface IfCondition extends BinaryOp { - public InstructionDefinition getIfDefinition(); + public int getIfDefinition(); - public InstructionDefinition getIfNotDefinition(); + public int getIfNotDefinition(); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/InAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/InAVM2Item.java index 1e901e867..2f7f17d3c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/InAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/InAVM2Item.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.InIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphSourceItem; @@ -37,7 +37,7 @@ public class InAVM2Item extends BinaryOpItem { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { return toSourceMerge(localData, generator, leftSide, rightSide, - new AVM2Instruction(0, new InIns(), null) + new AVM2Instruction(0, AVM2Instructions.In, null) ); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/InstanceOfAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/InstanceOfAVM2Item.java index a98653559..dc26f0dbb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/InstanceOfAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/InstanceOfAVM2Item.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.types.InstanceOfIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphSourceItem; @@ -37,7 +37,7 @@ public class InstanceOfAVM2Item extends BinaryOpItem { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { return toSourceMerge(localData, generator, leftSide, rightSide, - new AVM2Instruction(0, new InstanceOfIns(), null) + new AVM2Instruction(0, AVM2Instructions.InstanceOf, null) ); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/IsTypeAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/IsTypeAVM2Item.java index 4034f4311..a77b0a20a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/IsTypeAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/IsTypeAVM2Item.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.types.IsTypeLateIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphSourceItem; @@ -37,7 +37,7 @@ public class IsTypeAVM2Item extends BinaryOpItem { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { return toSourceMerge(localData, generator, leftSide, rightSide, - new AVM2Instruction(0, new IsTypeLateIns(), null) + new AVM2Instruction(0, AVM2Instructions.IsTypeLate, null) ); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/LShiftAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/LShiftAVM2Item.java index bb8981c96..6d026df91 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/LShiftAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/LShiftAVM2Item.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise.LShiftIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.GraphSourceItem; @@ -42,7 +42,7 @@ public class LShiftAVM2Item extends BinaryOpItem { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { return toSourceMerge(localData, generator, leftSide, rightSide, - new AVM2Instruction(0, new LShiftIns(), null) + new AVM2Instruction(0, AVM2Instructions.LShift, null) ); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/LeAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/LeAVM2Item.java index ae2062b04..edc949e31 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/LeAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/LeAVM2Item.java @@ -18,10 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.instructions.comparison.LessEqualsIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfLeIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfNLeIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.DottedChain; @@ -40,13 +37,13 @@ public class LeAVM2Item extends BinaryOpItem implements LogicalOpItem, IfConditi } @Override - public InstructionDefinition getIfDefinition() { - return new IfLeIns(); + public int getIfDefinition() { + return AVM2Instructions.IfLe; } @Override - public InstructionDefinition getIfNotDefinition() { - return new IfNLeIns(); + public int getIfNotDefinition() { + return AVM2Instructions.IfNLe; } @Override @@ -69,7 +66,7 @@ public class LeAVM2Item extends BinaryOpItem implements LogicalOpItem, IfConditi @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { return toSourceMerge(localData, generator, leftSide, rightSide, - new AVM2Instruction(0, new LessEqualsIns(), null) + new AVM2Instruction(0, AVM2Instructions.LessEquals, null) ); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/LtAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/LtAVM2Item.java index 4b0d55c83..678b86322 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/LtAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/LtAVM2Item.java @@ -18,10 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.instructions.comparison.LessThanIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfLtIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfNLtIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.DottedChain; @@ -40,13 +37,13 @@ public class LtAVM2Item extends BinaryOpItem implements LogicalOpItem, IfConditi } @Override - public InstructionDefinition getIfDefinition() { - return new IfLtIns(); + public int getIfDefinition() { + return AVM2Instructions.IfLt; } @Override - public InstructionDefinition getIfNotDefinition() { - return new IfNLtIns(); + public int getIfNotDefinition() { + return AVM2Instructions.IfNLt; } @Override @@ -62,7 +59,7 @@ public class LtAVM2Item extends BinaryOpItem implements LogicalOpItem, IfConditi @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { return toSourceMerge(localData, generator, leftSide, rightSide, - new AVM2Instruction(0, new LessThanIns(), null) + new AVM2Instruction(0, AVM2Instructions.LessThan, null) ); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/ModuloAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/ModuloAVM2Item.java index 9204cdbb5..91477dcef 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/ModuloAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/ModuloAVM2Item.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.ModuloIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; @@ -70,7 +70,7 @@ public class ModuloAVM2Item extends BinaryOpItem { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { return toSourceMerge(localData, generator, leftSide, rightSide, - new AVM2Instruction(0, new ModuloIns(), null) + new AVM2Instruction(0, AVM2Instructions.Modulo, null) ); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/MultiplyAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/MultiplyAVM2Item.java index eabdb8ed2..ad3f95104 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/MultiplyAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/MultiplyAVM2Item.java @@ -1,23 +1,24 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library 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 * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.MultiplyIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; @@ -65,7 +66,7 @@ public class MultiplyAVM2Item extends BinaryOpItem { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { return toSourceMerge(localData, generator, leftSide, rightSide, - new AVM2Instruction(0, new MultiplyIns(), null) + new AVM2Instruction(0, AVM2Instructions.Multiply, null) ); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/NegAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/NegAVM2Item.java index 1d61a3e42..aba09fb56 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/NegAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/NegAVM2Item.java @@ -1,23 +1,24 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library 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 * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.NegateIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.GraphSourceItem; @@ -41,7 +42,7 @@ public class NegAVM2Item extends UnaryOpItem { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { return toSourceMerge(localData, generator, value, - new AVM2Instruction(0, new NegateIns(), null) + new AVM2Instruction(0, AVM2Instructions.Negate, null) ); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/NeqAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/NeqAVM2Item.java index 518020d09..45c4ca5ee 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/NeqAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/NeqAVM2Item.java @@ -18,11 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.NotIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.comparison.EqualsIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfEqIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfNeIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.DottedChain; @@ -41,13 +37,13 @@ public class NeqAVM2Item extends BinaryOpItem implements LogicalOpItem, IfCondit } @Override - public InstructionDefinition getIfDefinition() { - return new IfNeIns(); + public int getIfDefinition() { + return AVM2Instructions.IfNe; } @Override - public InstructionDefinition getIfNotDefinition() { - return new IfEqIns(); + public int getIfNotDefinition() { + return AVM2Instructions.IfEq; } @Override @@ -63,8 +59,8 @@ public class NeqAVM2Item extends BinaryOpItem implements LogicalOpItem, IfCondit @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { return toSourceMerge(localData, generator, leftSide, rightSide, - new AVM2Instruction(0, new EqualsIns(), null), - new AVM2Instruction(0, new NotIns(), null) + new AVM2Instruction(0, AVM2Instructions.Equals, null), + new AVM2Instruction(0, AVM2Instructions.Not, null) ); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/RShiftAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/RShiftAVM2Item.java index a242ae444..88f7681a9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/RShiftAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/RShiftAVM2Item.java @@ -1,23 +1,24 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library 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 * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise.RShiftIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.GraphSourceItem; @@ -41,7 +42,7 @@ public class RShiftAVM2Item extends BinaryOpItem { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { return toSourceMerge(localData, generator, leftSide, rightSide, - new AVM2Instruction(0, new RShiftIns(), null) + new AVM2Instruction(0, AVM2Instructions.RShift, null) ); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/StrictEqAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/StrictEqAVM2Item.java index 315489125..5881126bf 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/StrictEqAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/StrictEqAVM2Item.java @@ -18,10 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.instructions.comparison.StrictEqualsIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfStrictEqIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfStrictNeIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.DottedChain; @@ -41,13 +38,13 @@ public class StrictEqAVM2Item extends BinaryOpItem implements LogicalOpItem, IfC } @Override - public InstructionDefinition getIfDefinition() { - return new IfStrictEqIns(); + public int getIfDefinition() { + return AVM2Instructions.IfStrictEq; } @Override - public InstructionDefinition getIfNotDefinition() { - return new IfStrictNeIns(); + public int getIfNotDefinition() { + return AVM2Instructions.IfStrictNe; } @Override @@ -66,7 +63,7 @@ public class StrictEqAVM2Item extends BinaryOpItem implements LogicalOpItem, IfC @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { return toSourceMerge(localData, generator, leftSide, rightSide, - new AVM2Instruction(0, new StrictEqualsIns(), null) + new AVM2Instruction(0, AVM2Instructions.StrictEquals, null) ); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/StrictNeqAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/StrictNeqAVM2Item.java index 80bf7e953..3a9b94692 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/StrictNeqAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/StrictNeqAVM2Item.java @@ -18,11 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.NotIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.comparison.StrictEqualsIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfStrictEqIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfStrictNeIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.DottedChain; @@ -41,13 +37,13 @@ public class StrictNeqAVM2Item extends BinaryOpItem implements LogicalOpItem, If } @Override - public InstructionDefinition getIfDefinition() { - return new IfStrictNeIns(); + public int getIfDefinition() { + return AVM2Instructions.IfStrictNe; } @Override - public InstructionDefinition getIfNotDefinition() { - return new IfStrictEqIns(); + public int getIfNotDefinition() { + return AVM2Instructions.IfStrictEq; } @Override @@ -66,8 +62,8 @@ public class StrictNeqAVM2Item extends BinaryOpItem implements LogicalOpItem, If @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { return toSourceMerge(localData, generator, leftSide, rightSide, - new AVM2Instruction(0, new StrictEqualsIns(), null), - new AVM2Instruction(0, new NotIns(), null) + new AVM2Instruction(0, AVM2Instructions.StrictEquals, null), + new AVM2Instruction(0, AVM2Instructions.Not, null) ); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/SubtractAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/SubtractAVM2Item.java index 315446d25..1e3bf974f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/SubtractAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/SubtractAVM2Item.java @@ -1,24 +1,24 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library 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 * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.DecrementIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.SubtractIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; @@ -70,12 +70,12 @@ public class SubtractAVM2Item extends BinaryOpItem { IntegerValueAVM2Item iv = (IntegerValueAVM2Item) rightSide; if (iv.value == 1) { return toSourceMerge(localData, generator, leftSide, - new AVM2Instruction(0, new DecrementIns(), null) + new AVM2Instruction(0, AVM2Instructions.Decrement, null) ); } } return toSourceMerge(localData, generator, leftSide, rightSide, - new AVM2Instruction(0, new SubtractIns(), null) + new AVM2Instruction(0, AVM2Instructions.Subtract, null) ); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/TypeOfAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/TypeOfAVM2Item.java index fdb8135d6..59f20d865 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/TypeOfAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/TypeOfAVM2Item.java @@ -1,23 +1,24 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library 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 * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.types.TypeOfIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.flash.ecma.EcmaType; import com.jpexs.decompiler.graph.CompilationException; @@ -70,7 +71,7 @@ public class TypeOfAVM2Item extends UnaryOpItem { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { return toSourceMerge(localData, generator, value, - new AVM2Instruction(0, new TypeOfIns(), null) + new AVM2Instruction(0, AVM2Instructions.TypeOf, null) ); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/URShiftAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/URShiftAVM2Item.java index 1418d29fd..8aca7ff80 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/URShiftAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/URShiftAVM2Item.java @@ -1,23 +1,24 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library 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 * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise.URShiftIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.GraphSourceItem; @@ -41,7 +42,7 @@ public class URShiftAVM2Item extends BinaryOpItem { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { return toSourceMerge(localData, generator, leftSide, rightSide, - new AVM2Instruction(0, new URShiftIns(), null) + new AVM2Instruction(0, AVM2Instructions.URShift, null) ); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/pcode/ASM3Parser.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/pcode/ASM3Parser.java index 169a26f4b..d1be8a242 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/pcode/ASM3Parser.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/pcode/ASM3Parser.java @@ -910,7 +910,7 @@ public class ASM3Parser { } } if (symb.value.toString().toLowerCase().equals("ffdec_deobfuscatepop")) { - lastIns = new AVM2Instruction(offset, new DeobfuscatePopIns(), null); + lastIns = new AVM2Instruction(offset, DeobfuscatePopIns.getInstance(), null); code.code.add(lastIns); offset += lastIns.getBytesLength(); insFound = true; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java index 208b2cae6..3814ad1c7 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java @@ -21,54 +21,12 @@ import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.NotIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.ConstructIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.ConstructSuperIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.NewActivationIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.NewCatchIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.NewClassIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.NewFunctionIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.NewObjectIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfFalseIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfStrictNeIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfTrueIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.JumpIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.LookupSwitchIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.GetLocal0Ins; -import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.KillIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.FindPropertyIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.FindPropertyStrictIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetDescendantsIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetGlobalScopeIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetLexIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetScopeObjectIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetSlotIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.HasNext2Ins; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.InitPropertyIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.LabelIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.NextNameIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.NextValueIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ReturnValueIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ReturnVoidIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.SetPropertyIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.SetSlotIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ThrowIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.DupIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PopIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PopScopeIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushByteIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushFalseIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushNullIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushScopeIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushStringIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushTrueIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushUndefinedIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushWithIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.SwapIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceAIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.types.ConvertBIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.xml.CheckFilterIns; import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.ApplyTypeAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.BooleanAVM2Item; @@ -164,18 +122,22 @@ public class AVM2SourceGenerator implements SourceGenerator { public static final int MARK_E_FINALLYPART = 3; + private AVM2Instruction ins(int instructionCode, int... operands) { + return new AVM2Instruction(0, instructionCode, operands); + } + private AVM2Instruction ins(InstructionDefinition def, int... operands) { return new AVM2Instruction(0, def, operands); } @Override public List generate(SourceGeneratorLocalData localData, FalseItem item) throws CompilationException { - return GraphTargetItem.toSourceMerge(localData, this, ins(new PushFalseIns())); + return GraphTargetItem.toSourceMerge(localData, this, ins(AVM2Instructions.PushFalse)); } @Override public List generate(SourceGeneratorLocalData localData, TrueItem item) throws CompilationException { - return GraphTargetItem.toSourceMerge(localData, this, ins(new PushTrueIns())); + return GraphTargetItem.toSourceMerge(localData, this, ins(AVM2Instructions.PushTrue)); } public List generate(SourceGeneratorLocalData localData, GetDescendantsAVM2Item item) throws CompilationException { @@ -187,7 +149,7 @@ public class AVM2SourceGenerator implements SourceGenerator { return GraphTargetItem.toSourceMerge(localData, this, item.object, - ins(new GetDescendantsIns(), abc.constants.getMultinameId(new Multiname(Multiname.MULTINAME, abc.constants.getStringId(item.nameStr, true), 0, nsset, 0, new ArrayList<>()), true)) + ins(AVM2Instructions.GetDescendants, abc.constants.getMultinameId(new Multiname(Multiname.MULTINAME, abc.constants.getStringId(item.nameStr, true), 0, nsset, 0, new ArrayList<>()), true)) ); } @@ -196,13 +158,13 @@ public class AVM2SourceGenerator implements SourceGenerator { List ret = new ArrayList<>(); ret.addAll(generateToActionList(localData, item.leftSide)); if (!("" + item.leftSide.returnType()).equals("Boolean")) { - ret.add(ins(new ConvertBIns())); + ret.add(ins(AVM2Instructions.ConvertB)); } - ret.add(ins(new DupIns())); + ret.add(ins(AVM2Instructions.Dup)); List andExpr = generateToActionList(localData, item.rightSide); - andExpr.add(0, ins(new PopIns())); + andExpr.add(0, ins(AVM2Instructions.Pop)); int andExprLen = insToBytes(andExpr).length; - ret.add(ins(new IfFalseIns(), andExprLen)); + ret.add(ins(AVM2Instructions.IfFalse, andExprLen)); ret.addAll(andExpr); return ret; @@ -228,13 +190,13 @@ public class AVM2SourceGenerator implements SourceGenerator { List ret = new ArrayList<>(); ret.addAll(generateToActionList(localData, item.leftSide)); if (!("" + item.leftSide.returnType()).equals("Boolean")) { - ret.add(ins(new ConvertBIns())); + ret.add(ins(AVM2Instructions.ConvertB)); } - ret.add(ins(new DupIns())); + ret.add(ins(AVM2Instructions.Dup)); List orExpr = generateToActionList(localData, item.rightSide); - orExpr.add(0, ins(new PopIns())); + orExpr.add(0, ins(AVM2Instructions.Pop)); int orExprLen = insToBytes(orExpr).length; - ret.add(ins(new IfTrueIns(), orExprLen)); + ret.add(ins(AVM2Instructions.IfTrue, orExprLen)); ret.addAll(orExpr); return ret; } @@ -261,7 +223,7 @@ public class AVM2SourceGenerator implements SourceGenerator { IfCondition ic = (IfCondition) t; return GraphTargetItem.toSourceMerge(localData, this, ic.getLeftSide(), ic.getRightSide(), ins(ic.getIfDefinition(), offset)); } - return GraphTargetItem.toSourceMerge(localData, this, t, ins(new IfTrueIns(), offset)); + return GraphTargetItem.toSourceMerge(localData, this, t, ins(AVM2Instructions.IfTrue, offset)); } private List notCondition(SourceGeneratorLocalData localData, GraphTargetItem t, int offset) throws CompilationException { @@ -269,7 +231,7 @@ public class AVM2SourceGenerator implements SourceGenerator { IfCondition ic = (IfCondition) t; return GraphTargetItem.toSourceMerge(localData, this, ic.getLeftSide(), ic.getRightSide(), ins(ic.getIfNotDefinition(), offset)); } - return GraphTargetItem.toSourceMerge(localData, this, t, ins(new IfFalseIns(), offset)); + return GraphTargetItem.toSourceMerge(localData, this, t, ins(AVM2Instructions.IfFalse, offset)); } private List generateIf(SourceGeneratorLocalData localData, GraphTargetItem expression, List onTrueCmds, List onFalseCmds, boolean ternar) throws CompilationException { @@ -295,7 +257,7 @@ public class AVM2SourceGenerator implements SourceGenerator { if (!((!nonempty(onTrue).isEmpty()) && ((onTrue.get(onTrue.size() - 1).definition instanceof ContinueJumpIns) || ((onTrue.get(onTrue.size() - 1).definition instanceof BreakJumpIns))))) { - ajmp = ins(new JumpIns(), 0); + ajmp = ins(AVM2Instructions.Jump, 0); onTrue.add(ajmp); } } @@ -324,28 +286,28 @@ public class AVM2SourceGenerator implements SourceGenerator { final Reference xmlListReg = new Reference<>(0); List xmlListSetTemp = AssignableAVM2Item.setTemp(localData, this, xmlListReg); ret.addAll(GraphTargetItem.toSourceMerge(localData, this, - ins(new PushByteIns(), 0), + ins(AVM2Instructions.PushByte, 0), AssignableAVM2Item.setTemp(localData, this, counterReg), item.object, - ins(new CheckFilterIns()), + ins(AVM2Instructions.CheckFilter), NameAVM2Item.generateCoerce(localData, this, TypeItem.UNBOUNDED), AssignableAVM2Item.setTemp(localData, this, collectionReg), - ins(new GetLexIns(), abc.constants.getMultinameId(new Multiname(Multiname.QNAME, abc.constants.getStringId("XMLList", true), abc.constants.getNamespaceId(new Namespace(Namespace.KIND_PACKAGE, abc.constants.getStringId("", true)), 0, true), 0, 0, new ArrayList<>()), true)), - ins(new PushStringIns(), abc.constants.getStringId("", true)), - ins(new ConstructIns(), 1), + ins(AVM2Instructions.GetLex, abc.constants.getMultinameId(new Multiname(Multiname.QNAME, abc.constants.getStringId("XMLList", true), abc.constants.getNamespaceId(new Namespace(Namespace.KIND_PACKAGE, abc.constants.getStringId("", true)), 0, true), 0, 0, new ArrayList<>()), true)), + ins(AVM2Instructions.PushString, abc.constants.getStringId("", true)), + ins(AVM2Instructions.Construct, 1), xmlListSetTemp )); final Reference tempVal1 = new Reference<>(0); final Reference tempVal2 = new Reference<>(0); List forBody = toInsList(GraphTargetItem.toSourceMerge(localData, this, - ins(new LabelIns()), + ins(AVM2Instructions.Label), AssignableAVM2Item.getTemp(localData, this, collectionReg), AssignableAVM2Item.getTemp(localData, this, counterReg), - ins(new NextValueIns()), + ins(AVM2Instructions.NextValue), AssignableAVM2Item.dupSetTemp(localData, this, tempVal1), AssignableAVM2Item.dupSetTemp(localData, this, tempVal2), - ins(new PushWithIns()) + ins(AVM2Instructions.PushWith) )); localData.scopeStack.add(new LocalRegAVM2Item(null, tempVal2.getVal(), null)); forBody.addAll(toInsList(item.value.toSource(localData, this))); @@ -357,20 +319,20 @@ public class AVM2SourceGenerator implements SourceGenerator { for (int i = 0; i < item.openedNamespaces.size(); i++) { nss[i] = item.openedNamespaces.get(i); } - trueBody.add(ins(new SetPropertyIns(), abc.constants.getMultinameId(new Multiname(Multiname.MULTINAMEL, 0, 0, abc.constants.getNamespaceSetId(new NamespaceSet(nss), true), 0, new ArrayList<>()), true))); - forBody.add(ins(new IfFalseIns(), insToBytes(trueBody).length)); + trueBody.add(ins(AVM2Instructions.SetProperty, abc.constants.getMultinameId(new Multiname(Multiname.MULTINAMEL, 0, 0, abc.constants.getNamespaceSetId(new NamespaceSet(nss), true), 0, new ArrayList<>()), true))); + forBody.add(ins(AVM2Instructions.IfFalse, insToBytes(trueBody).length)); forBody.addAll(trueBody); - forBody.add(ins(new PopScopeIns())); + forBody.add(ins(AVM2Instructions.PopScope)); localData.scopeStack.remove(localData.scopeStack.size() - 1); forBody.addAll(toInsList(AssignableAVM2Item.killTemp(localData, this, Arrays.asList(tempVal2, tempVal1)))); int forBodyLen = insToBytes(forBody).length; - AVM2Instruction forwardJump = ins(new JumpIns(), forBodyLen); + AVM2Instruction forwardJump = ins(AVM2Instructions.Jump, forBodyLen); ret.add(forwardJump); List expr = new ArrayList<>(); - expr.add(ins(new HasNext2Ins(), collectionReg.getVal(), counterReg.getVal())); - AVM2Instruction backIf = ins(new IfTrueIns(), 0); + expr.add(ins(AVM2Instructions.HasNext2, collectionReg.getVal(), counterReg.getVal())); + AVM2Instruction backIf = ins(AVM2Instructions.IfTrue, 0); expr.add(backIf); int exprLen = insToBytes(expr).length; @@ -402,12 +364,12 @@ public class AVM2SourceGenerator implements SourceGenerator { if (ins.definition instanceof ContinueJumpIns) { if (continueOffset != Integer.MAX_VALUE) { ins.operands[0] = (-pos + continueOffset); - code.get(a).definition = new JumpIns(); + ins.definition = AVM2Code.instructionSet[AVM2Instructions.Jump]; } } if (ins.definition instanceof BreakJumpIns) { ins.operands[0] = (-pos + breakOffset); - code.get(a).definition = new JumpIns(); + ins.definition = AVM2Code.instructionSet[AVM2Instructions.Jump]; } } } @@ -439,9 +401,9 @@ public class AVM2SourceGenerator implements SourceGenerator { whileExpr.addAll(generateToInsList(localData, ex)); } List whileBody = generateToInsList(localData, item.commands); - AVM2Instruction forwardJump = ins(new JumpIns(), 0); + AVM2Instruction forwardJump = ins(AVM2Instructions.Jump, 0); ret.add(forwardJump); - whileBody.add(0, ins(new LabelIns())); + whileBody.add(0, ins(AVM2Instructions.Label)); ret.addAll(whileBody); int whileBodyLen = insToBytes(whileBody).length; forwardJump.operands[0] = whileBodyLen; @@ -471,7 +433,7 @@ public class AVM2SourceGenerator implements SourceGenerator { } ret.addAll(GraphTargetItem.toSourceMerge(localData, this, - ins(new PushByteIns(), 0), + ins(AVM2Instructions.PushByte, 0), AssignableAVM2Item.setTemp(localData, this, counterReg), collection, NameAVM2Item.generateCoerce(localData, this, TypeItem.UNBOUNDED), @@ -500,26 +462,26 @@ public class AVM2SourceGenerator implements SourceGenerator { return toSourceMerge(localData, generator, AssignableAVM2Item.getTemp(localData, generator, collectionReg), AssignableAVM2Item.getTemp(localData, generator, counterReg), - ins(each ? new NextValueIns() : new NextNameIns()) + ins(each ? AVM2Instructions.NextValue : AVM2Instructions.NextName) ); } }; assignable.setAssignedValue(assigned); List forBody = toInsList(GraphTargetItem.toSourceMerge(localData, this, - ins(new LabelIns()), + ins(AVM2Instructions.Label), assignable.toSourceIgnoreReturnValue(localData, this) )); forBody.addAll(generateToInsList(localData, commands)); int forBodyLen = insToBytes(forBody).length; - AVM2Instruction forwardJump = ins(new JumpIns(), forBodyLen); + AVM2Instruction forwardJump = ins(AVM2Instructions.Jump, forBodyLen); ret.add(forwardJump); List expr = new ArrayList<>(); - expr.add(ins(new HasNext2Ins(), collectionReg.getVal(), counterReg.getVal())); - AVM2Instruction backIf = ins(new IfTrueIns(), 0); + expr.add(ins(AVM2Instructions.HasNext2, collectionReg.getVal(), counterReg.getVal())); + AVM2Instruction backIf = ins(AVM2Instructions.IfTrue, 0); expr.add(backIf); int exprLen = insToBytes(expr).length; @@ -550,10 +512,10 @@ public class AVM2SourceGenerator implements SourceGenerator { } List dowhileBody = generateToInsList(localData, item.commands); List labelBody = new ArrayList<>(); - labelBody.add(ins(new LabelIns())); + labelBody.add(ins(AVM2Instructions.Label)); int labelBodyLen = insToBytes(labelBody).length; - AVM2Instruction forwardJump = ins(new JumpIns(), labelBodyLen); + AVM2Instruction forwardJump = ins(AVM2Instructions.Jump, labelBodyLen); ret.add(forwardJump); ret.addAll(labelBody); ret.addAll(dowhileBody); @@ -573,9 +535,9 @@ public class AVM2SourceGenerator implements SourceGenerator { Reference tempReg = new Reference<>(0); ret.addAll(AssignableAVM2Item.dupSetTemp(localData, this, tempReg)); localData.scopeStack.add(new WithObjectAVM2Item(null, new LocalRegAVM2Item(null, tempReg.getVal(), null))); - ret.add(ins(new PushWithIns())); + ret.add(ins(AVM2Instructions.PushWith)); ret.addAll(generate(localData, item.items)); - ret.add(ins(new PopScopeIns())); + ret.add(ins(AVM2Instructions.PopScope)); ret.addAll(AssignableAVM2Item.killTemp(localData, this, Arrays.asList(tempReg))); localData.scopeStack.remove(localData.scopeStack.size() - 1); return ret; @@ -607,9 +569,9 @@ public class AVM2SourceGenerator implements SourceGenerator { ret.addAll(generateToInsList(localData, item.firstCommands)); - AVM2Instruction forwardJump = ins(new JumpIns(), 0); + AVM2Instruction forwardJump = ins(AVM2Instructions.Jump, 0); ret.add(forwardJump); - forBody.add(0, ins(new LabelIns())); + forBody.add(0, ins(AVM2Instructions.Label)); ret.addAll(forBody); ret.addAll(forFinalCommands); int forBodyLen = insToBytes(forBody).length; @@ -634,17 +596,17 @@ public class AVM2SourceGenerator implements SourceGenerator { public List generate(SourceGeneratorLocalData localData, SwitchItem item) throws CompilationException { List ret = new ArrayList<>(); Reference switchedReg = new Reference<>(0); - AVM2Instruction forwardJump = ins(new JumpIns(), 0); + AVM2Instruction forwardJump = ins(AVM2Instructions.Jump, 0); ret.add(forwardJump); List cases = new ArrayList<>(); cases.addAll(toInsList(new IntegerValueAVM2Item(null, (long) item.caseValues.size()).toSource(localData, this))); int cLen = insToBytes(cases).length; List caseLast = new ArrayList<>(); - caseLast.add(0, ins(new JumpIns(), cLen)); + caseLast.add(0, ins(AVM2Instructions.Jump, cLen)); caseLast.addAll(0, toInsList(new IntegerValueAVM2Item(null, (long) item.caseValues.size()).toSource(localData, this))); int cLastLen = insToBytes(caseLast).length; - caseLast.add(0, ins(new JumpIns(), cLastLen)); + caseLast.add(0, ins(AVM2Instructions.Jump, cLastLen)); cases.addAll(0, caseLast); List preCases = new ArrayList<>(); @@ -654,29 +616,29 @@ public class AVM2SourceGenerator implements SourceGenerator { for (int i = item.caseValues.size() - 1; i >= 0; i--) { List sub = new ArrayList<>(); sub.addAll(toInsList(new IntegerValueAVM2Item(null, (long) i).toSource(localData, this))); - sub.add(ins(new JumpIns(), insToBytes(cases).length)); + sub.add(ins(AVM2Instructions.Jump, insToBytes(cases).length)); int subLen = insToBytes(sub).length; cases.addAll(0, sub); - cases.add(0, ins(new IfStrictNeIns(), subLen)); + cases.add(0, ins(AVM2Instructions.IfStrictNe, subLen)); cases.addAll(0, toInsList(AssignableAVM2Item.getTemp(localData, this, switchedReg))); cases.addAll(0, toInsList(item.caseValues.get(i).toSource(localData, this))); } cases.addAll(0, preCases); - AVM2Instruction lookupOp = new AVM2Instruction(0, new LookupSwitchIns(), new int[item.caseValues.size() + 1 + 1 + 1]); + AVM2Instruction lookupOp = new AVM2Instruction(0, AVM2Instructions.LookupSwitch, new int[item.caseValues.size() + 1 + 1 + 1]); cases.addAll(toInsList(AssignableAVM2Item.killTemp(localData, this, Arrays.asList(switchedReg)))); List bodies = new ArrayList<>(); List bodiesOffsets = new ArrayList<>(); int defOffset; int casesLen = insToBytes(cases).length; bodies.addAll(generateToInsList(localData, item.defaultCommands)); - bodies.add(0, ins(new LabelIns())); + bodies.add(0, ins(AVM2Instructions.Label)); bodies.add(ins(new BreakJumpIns(item.loop.id), 0)); //There could be two breaks when default clause ends with break, but official compiler does this too, so who cares... defOffset = -(insToBytes(bodies).length + casesLen); for (int i = item.caseCommands.size() - 1; i >= 0; i--) { bodies.addAll(0, generateToInsList(localData, item.caseCommands.get(i))); - bodies.add(0, ins(new LabelIns())); + bodies.add(0, ins(AVM2Instructions.Label)); bodiesOffsets.add(0, -(insToBytes(bodies).length + casesLen)); } lookupOp.operands[0] = defOffset; @@ -702,14 +664,14 @@ public class AVM2SourceGenerator implements SourceGenerator { }*/ List ret = new ArrayList<>(); ret.addAll(item.getOriginal().toSource(localData, this)); - ret.add(ins(new NotIns())); + ret.add(ins(AVM2Instructions.Not)); return ret; } @Override public List generate(SourceGeneratorLocalData localData, DuplicateItem item) { List ret = new ArrayList<>(); - ret.add(ins(new DupIns())); + ret.add(ins(AVM2Instructions.Dup)); return ret; } @@ -725,18 +687,18 @@ public class AVM2SourceGenerator implements SourceGenerator { List ret = new ArrayList<>(); int scope = 0; if (!item.functionName.isEmpty()) { - ret.add(ins(new NewObjectIns(), 0)); - ret.add(ins(new PushWithIns())); + ret.add(ins(AVM2Instructions.NewObject, 0)); + ret.add(ins(AVM2Instructions.PushWith)); scope = localData.scopeStack.size(); localData.scopeStack.add(new PropertyAVM2Item(null, item.functionName, abc, allABCs, new ArrayList<>(), localData.callStack)); } - ret.add(ins(new NewFunctionIns(), method(true, false, localData.callStack, localData.pkg, item.needsActivation, item.subvariables, 0 /*Set later*/, item.hasRest, item.line, localData.currentClass, null, false, localData, item.paramTypes, item.paramNames, item.paramValues, item.body, item.retType))); + ret.add(ins(AVM2Instructions.NewFunction, method(true, false, localData.callStack, localData.pkg, item.needsActivation, item.subvariables, 0 /*Set later*/, item.hasRest, item.line, localData.currentClass, null, false, localData, item.paramTypes, item.paramNames, item.paramValues, item.body, item.retType))); if (!item.functionName.isEmpty()) { - ret.add(ins(new DupIns())); - ret.add(ins(new GetScopeObjectIns(), scope)); - ret.add(ins(new SwapIns())); - ret.add(ins(new SetPropertyIns(), abc.constants.getMultinameId(new Multiname(Multiname.QNAME, abc.constants.getStringId(item.functionName, true), abc.constants.getNamespaceId(new Namespace(Namespace.KIND_PACKAGE, abc.constants.getStringId(localData.pkg, true)), 0, true), 0, 0, new ArrayList<>()), true))); - ret.add(ins(new PopScopeIns())); + ret.add(ins(AVM2Instructions.Dup)); + ret.add(ins(AVM2Instructions.GetScopeObject, scope)); + ret.add(ins(AVM2Instructions.Swap)); + ret.add(ins(AVM2Instructions.SetProperty, abc.constants.getMultinameId(new Multiname(Multiname.QNAME, abc.constants.getStringId(item.functionName, true), abc.constants.getNamespaceId(new Namespace(Namespace.KIND_PACKAGE, abc.constants.getStringId(localData.pkg, true)), 0, true), 0, 0, new ArrayList<>()), true))); + ret.add(ins(AVM2Instructions.PopScope)); localData.scopeStack.remove(localData.scopeStack.size() - 1); } return ret; @@ -802,12 +764,12 @@ public class AVM2SourceGenerator implements SourceGenerator { //Reference tempReg=new Reference<>(0); List catchCmd = new ArrayList<>(); - catchCmd.add(ins(new NewCatchIns(), i)); + catchCmd.add(ins(AVM2Instructions.NewCatch, i)); catchCmd.addAll(toInsList(AssignableAVM2Item.dupSetTemp(localData, this, tempReg))); - catchCmd.add(ins(new DupIns())); - catchCmd.add(ins(new PushScopeIns())); - catchCmd.add(ins(new SwapIns())); - catchCmd.add(ins(new SetSlotIns(), 1)); + catchCmd.add(ins(AVM2Instructions.Dup)); + catchCmd.add(ins(AVM2Instructions.PushScope)); + catchCmd.add(ins(AVM2Instructions.Swap)); + catchCmd.add(ins(AVM2Instructions.SetSlot, 1)); for (AssignableAVM2Item a : item.catchVariables.get(c)) { GraphTargetItem r = a; @@ -824,22 +786,22 @@ public class AVM2SourceGenerator implements SourceGenerator { localData.scopeStack.add(new LocalRegAVM2Item(null, tempReg.getVal(), null)); catchCmd.addAll(generateToInsList(localData, item.catchCommands.get(c))); localData.scopeStack.remove(localData.scopeStack.size() - 1); - catchCmd.add(ins(new PopScopeIns())); + catchCmd.add(ins(AVM2Instructions.PopScope)); catchCmd.addAll(toInsList(AssignableAVM2Item.killTemp(localData, this, Arrays.asList(tempReg)))); catchCmds.add(catchCmd); } for (int c = item.catchCommands.size() - 1; c >= 0; c--) { List preCatches = new ArrayList<>(); - /*preCatches.add(ins(new GetLocal0Ins())); - preCatches.add(ins(new PushScopeIns())); + /*preCatches.add(ins(AVM2Instructions.GetLocal0)); + preCatches.add(ins(AVM2Instructions.PushScope)); preCatches.add(AssignableAVM2Item.generateGetLoc(localData.activationReg)); - preCatches.add(ins(new PushScopeIns()));*/ + preCatches.add(ins(AVM2Instructions.PushScope));*/ for (GraphTargetItem s : localData.scopeStack) { preCatches.addAll(toInsList(s.toSource(localData, this))); if (s instanceof WithObjectAVM2Item) { - preCatches.add(ins(new PushWithIns())); + preCatches.add(ins(AVM2Instructions.PushWith)); } else { - preCatches.add(ins(new PushScopeIns())); + preCatches.add(ins(AVM2Instructions.PushScope)); } } @@ -847,7 +809,7 @@ public class AVM2SourceGenerator implements SourceGenerator { preCatches.addAll(catchCmds.get(c)); catches.addAll(0, preCatches); catches.add(0, new ExceptionMarkAVM2Instruction(currentExceptionIds.get(c), MARK_E_TARGET)); - catches.add(0, ins(new JumpIns(), insToBytes(catches).length)); + catches.add(0, ins(AVM2Instructions.Jump, insToBytes(catches).length)); } if (aloneFinallyEx > -1) { @@ -884,23 +846,23 @@ public class AVM2SourceGenerator implements SourceGenerator { for (GraphTargetItem s : localData.scopeStack) { preCatches.addAll(toInsList(s.toSource(localData, this))); if (s instanceof WithObjectAVM2Item) { - preCatches.add(ins(new PushWithIns())); + preCatches.add(ins(AVM2Instructions.PushWith)); } else { - preCatches.add(ins(new PushScopeIns())); + preCatches.add(ins(AVM2Instructions.PushScope)); } } - preCatches.add(ins(new NewCatchIns(), aloneFinallyEx)); + preCatches.add(ins(AVM2Instructions.NewCatch, aloneFinallyEx)); preCatches.addAll(toInsList(AssignableAVM2Item.dupSetTemp(localData, this, tempReg))); - preCatches.add(ins(new PushScopeIns())); - preCatches.add(ins(new ThrowIns())); - preCatches.add(ins(new PopScopeIns())); + preCatches.add(ins(AVM2Instructions.PushScope)); + preCatches.add(ins(AVM2Instructions.Throw)); + preCatches.add(ins(AVM2Instructions.PopScope)); preCatches.addAll(toInsList(AssignableAVM2Item.killTemp(localData, this, Arrays.asList(tempReg)))); - catches.add(ins(new JumpIns(), insToBytes(preCatches).length)); + catches.add(ins(AVM2Instructions.Jump, insToBytes(preCatches).length)); catches.add(new ExceptionMarkAVM2Instruction(aloneFinallyEx, MARK_E_TARGET)); catches.addAll(preCatches); } AVM2Instruction finSwitch = null; - AVM2Instruction pushDefIns = ins(new PushByteIns(), 0); + AVM2Instruction pushDefIns = ins(AVM2Instructions.PushByte, 0); int defPos = 0; if (finallyEx > -1) { @@ -909,49 +871,49 @@ public class AVM2SourceGenerator implements SourceGenerator { for (GraphTargetItem s : localData.scopeStack) { preCatches.addAll(toInsList(s.toSource(localData, this))); if (s instanceof WithObjectAVM2Item) { - preCatches.add(ins(new PushWithIns())); + preCatches.add(ins(AVM2Instructions.PushWith)); } else { - preCatches.add(ins(new PushScopeIns())); + preCatches.add(ins(AVM2Instructions.PushScope)); } } - preCatches.add(ins(new NewCatchIns(), finallyEx)); + preCatches.add(ins(AVM2Instructions.NewCatch, finallyEx)); preCatches.addAll(toInsList(AssignableAVM2Item.dupSetTemp(localData, this, tempReg))); - preCatches.add(ins(new PushScopeIns())); - preCatches.add(ins(new PopScopeIns())); + preCatches.add(ins(AVM2Instructions.PushScope)); + preCatches.add(ins(AVM2Instructions.PopScope)); Reference tempReg2 = new Reference<>(0); - preCatches.add(ins(new KillIns(), tempReg.getVal())); - preCatches.add(ins(new CoerceAIns())); + preCatches.add(ins(AVM2Instructions.Kill, tempReg.getVal())); + preCatches.add(ins(AVM2Instructions.CoerceA)); preCatches.addAll(toInsList(AssignableAVM2Item.setTemp(localData, this, tempReg2))); preCatches.add(pushDefIns); List finallySwitchCmds = new ArrayList<>(); - finSwitch = new AVM2Instruction(0, new LookupSwitchIns(), new int[1 + 1 + 1]); + finSwitch = new AVM2Instruction(0, AVM2Instructions.LookupSwitch, new int[1 + 1 + 1]); finSwitch.operands[0] = finSwitch.getBytesLength(); finSwitch.operands[1] = 0; //switch cnt List preFinallySwitch = new ArrayList<>(); - preFinallySwitch.add(ins(new LabelIns())); - preFinallySwitch.add(ins(new PopIns())); + preFinallySwitch.add(ins(AVM2Instructions.Label)); + preFinallySwitch.add(ins(AVM2Instructions.Pop)); int preFinallySwitchLen = insToBytes(preFinallySwitch).length; - finallySwitchCmds.add(ins(new LabelIns())); + finallySwitchCmds.add(ins(AVM2Instructions.Label)); finallySwitchCmds.addAll(toInsList(AssignableAVM2Item.getTemp(localData, this, tempReg2))); - finallySwitchCmds.add(ins(new KillIns(), tempReg2.getVal())); - finallySwitchCmds.add(ins(new ThrowIns())); - finallySwitchCmds.add(ins(new PushByteIns(), 255)); - finallySwitchCmds.add(ins(new PopScopeIns())); - finallySwitchCmds.add(ins(new KillIns(), tempReg.getVal())); + finallySwitchCmds.add(ins(AVM2Instructions.Kill, tempReg2.getVal())); + finallySwitchCmds.add(ins(AVM2Instructions.Throw)); + finallySwitchCmds.add(ins(AVM2Instructions.PushByte, 255)); + finallySwitchCmds.add(ins(AVM2Instructions.PopScope)); + finallySwitchCmds.add(ins(AVM2Instructions.Kill, tempReg.getVal())); int finSwitchLen = insToBytes(finallySwitchCmds).length; - preCatches.add(ins(new JumpIns(), preFinallySwitchLen + finSwitchLen)); - AVM2Instruction fjump = ins(new JumpIns(), 0); + preCatches.add(ins(AVM2Instructions.Jump, preFinallySwitchLen + finSwitchLen)); + AVM2Instruction fjump = ins(AVM2Instructions.Jump, 0); fjump.operands[0] = insToBytes(preCatches).length + preFinallySwitchLen + finSwitchLen; preCatches.add(0, fjump); preCatches.add(0, new ExceptionMarkAVM2Instruction(finallyEx, MARK_E_END)); - preCatches.add(0, ins(new PushByteIns(), 255)); + preCatches.add(0, ins(AVM2Instructions.PushByte, 255)); finallySwitchCmds.add(new ExceptionMarkAVM2Instruction(finallyEx, MARK_E_FINALLYPART)); @@ -1025,15 +987,15 @@ public class AVM2SourceGenerator implements SourceGenerator { FinallyJumpIns fji = (FinallyJumpIns) ins.definition; if (fji.getClauseId() == finId) { List bet = new ArrayList<>(); - bet.add(ins(new LabelIns())); - bet.add(ins(new PopIns())); + bet.add(ins(AVM2Instructions.Label)); + bet.add(ins(AVM2Instructions.Pop)); int betLen = insToBytes(bet).length; if (wasDef) { ins.operands[0] = 0; } else { ins.operands[0] = finallyPos - (pos + ins.getBytesLength()); } - ins.definition = new JumpIns(); + ins.definition = AVM2Code.instructionSet[AVM2Instructions.Jump]; switchLoc.add(pos + ins.getBytesLength() + betLen - switchPos); } } @@ -1069,11 +1031,11 @@ public class AVM2SourceGenerator implements SourceGenerator { List ret = new ArrayList<>(); ret.addAll(item.value.toSource(localData, this)); if (!localData.finallyCatches.isEmpty()) { - ret.add(ins(new CoerceAIns())); + ret.add(ins(AVM2Instructions.CoerceA)); ret.add(AssignableAVM2Item.generateSetLoc(localData.finallyRegister)); for (int i = localData.finallyCatches.size() - 1; i >= 0; i--) { if (i < localData.finallyCatches.size() - 1) { - ret.add(ins(new LabelIns())); + ret.add(ins(AVM2Instructions.Label)); } int clauseId = localData.finallyCatches.get(i); Integer cnt = localData.finallyCounter.get(clauseId); @@ -1084,14 +1046,14 @@ public class AVM2SourceGenerator implements SourceGenerator { localData.finallyCounter.put(clauseId, cnt); ret.addAll(new IntegerValueAVM2Item(null, (long) cnt).toSource(localData, this)); ret.add(ins(new FinallyJumpIns(clauseId), 0)); - ret.add(ins(new LabelIns())); - ret.add(ins(new PopIns())); + ret.add(ins(AVM2Instructions.Label)); + ret.add(ins(AVM2Instructions.Pop)); } - ret.add(ins(new LabelIns())); + ret.add(ins(AVM2Instructions.Label)); ret.add(AssignableAVM2Item.generateGetLoc(localData.finallyRegister)); - ret.add(ins(new KillIns(), localData.finallyRegister)); + ret.add(ins(AVM2Instructions.Kill, localData.finallyRegister)); } - ret.add(ins(new ReturnValueIns())); + ret.add(ins(AVM2Instructions.ReturnValue)); return ret; } @@ -1101,7 +1063,7 @@ public class AVM2SourceGenerator implements SourceGenerator { for (int i = 0; i < localData.finallyCatches.size(); i++) { if (i > 0) { - ret.add(ins(new LabelIns())); + ret.add(ins(AVM2Instructions.Label)); } int clauseId = localData.finallyCatches.get(i); Integer cnt = localData.finallyCounter.get(clauseId); @@ -1112,19 +1074,19 @@ public class AVM2SourceGenerator implements SourceGenerator { localData.finallyCounter.put(clauseId, cnt); ret.addAll(new IntegerValueAVM2Item(null, (long) cnt).toSource(localData, this)); ret.add(ins(new FinallyJumpIns(clauseId), 0)); - ret.add(ins(new LabelIns())); - ret.add(ins(new PopIns())); + ret.add(ins(AVM2Instructions.Label)); + ret.add(ins(AVM2Instructions.Pop)); } - ret.add(ins(new LabelIns())); + ret.add(ins(AVM2Instructions.Label)); } - ret.add(ins(new ReturnVoidIns())); + ret.add(ins(AVM2Instructions.ReturnVoid)); return ret; } public List generate(SourceGeneratorLocalData localData, ThrowAVM2Item item) throws CompilationException { List ret = new ArrayList<>(); ret.addAll(item.value.toSource(localData, this)); - ret.add(ins(new ThrowIns())); + ret.add(ins(AVM2Instructions.Throw)); return ret; } @@ -1249,16 +1211,16 @@ public class AVM2SourceGenerator implements SourceGenerator { isConst = true; } if (isStatic && val != null) { - sinitcode.add(ins(new FindPropertyIns(), traitName(ns, tname))); + sinitcode.add(ins(AVM2Instructions.FindProperty, traitName(ns, tname))); sinitcode.addAll(toInsList(val.toSource(localData, this))); - sinitcode.add(ins(isConst ? new InitPropertyIns() : new SetPropertyIns(), traitName(ns, tname))); + sinitcode.add(ins(isConst ? AVM2Instructions.InitProperty : AVM2Instructions.SetProperty, traitName(ns, tname))); } if (!isStatic && val != null) { //do not init basic values, that can be stored in trait if (!(val instanceof IntegerValueAVM2Item) && !(val instanceof StringAVM2Item) && !(val instanceof BooleanAVM2Item) && !(val instanceof NullAVM2Item) && !(val instanceof UndefinedAVM2Item)) { - initcode.add(ins(new GetLocal0Ins())); + initcode.add(ins(AVM2Instructions.GetLocal0)); initcode.addAll(toInsList(val.toSource(localData, this))); - initcode.add(ins(isConst ? new InitPropertyIns() : new SetPropertyIns(), traitName(ns, tname))); + initcode.add(ins(isConst ? AVM2Instructions.InitProperty : AVM2Instructions.SetProperty, traitName(ns, tname))); } } } @@ -1720,10 +1682,10 @@ public class AVM2SourceGenerator implements SourceGenerator { } List acts = new ArrayList<>(); - acts.add(ins(new NewActivationIns())); - acts.add(ins(new DupIns())); + acts.add(ins(AVM2Instructions.NewActivation)); + acts.add(ins(AVM2Instructions.Dup)); acts.add(AssignableAVM2Item.generateSetLoc(localData.activationReg)); - acts.add(ins(new PushScopeIns())); + acts.add(ins(AVM2Instructions.PushScope)); mbodyCode.addAll(0, acts); } @@ -1758,8 +1720,8 @@ public class AVM2SourceGenerator implements SourceGenerator { } if (ac == -1) { if (parentConstMinAC == 0) { - mbodyCode.add(0, new AVM2Instruction(0, new GetLocal0Ins(), null)); - mbodyCode.add(1, new AVM2Instruction(0, new ConstructSuperIns(), new int[]{0})); + mbodyCode.add(0, new AVM2Instruction(0, AVM2Instructions.GetLocal0, null)); + mbodyCode.add(1, new AVM2Instruction(0, AVM2Instructions.ConstructSuper, new int[]{0})); } else { throw new CompilationException("Parent constructor must be called", line); @@ -1767,8 +1729,8 @@ public class AVM2SourceGenerator implements SourceGenerator { } } if (className != null && !subMethod) { - mbodyCode.add(0, new AVM2Instruction(0, new GetLocal0Ins(), null)); - mbodyCode.add(1, new AVM2Instruction(0, new PushScopeIns(), null)); + mbodyCode.add(0, new AVM2Instruction(0, AVM2Instructions.GetLocal0, null)); + mbodyCode.add(1, new AVM2Instruction(0, AVM2Instructions.PushScope, null)); } boolean addRet = false; if (!mbodyCode.isEmpty()) { @@ -1781,10 +1743,10 @@ public class AVM2SourceGenerator implements SourceGenerator { } if (addRet) { if (retType.toString().equals("*") || retType.toString().equals("void") || constructor) { - mbodyCode.add(new AVM2Instruction(0, new ReturnVoidIns(), null)); + mbodyCode.add(new AVM2Instruction(0, AVM2Instructions.ReturnVoid, null)); } else { - mbodyCode.add(new AVM2Instruction(0, new PushUndefinedIns(), null)); - mbodyCode.add(new AVM2Instruction(0, new ReturnValueIns(), null)); + mbodyCode.add(new AVM2Instruction(0, AVM2Instructions.PushUndefined, null)); + mbodyCode.add(new AVM2Instruction(0, AVM2Instructions.ReturnValue, null)); } } mbody.exceptions = localData.exceptions.toArray(new ABCException[localData.exceptions.size()]); @@ -2179,8 +2141,8 @@ public class AVM2SourceGenerator implements SourceGenerator { mb.method_info = abc.addMethodInfo(mi); mb.setCode(new AVM2Code()); List mbCode = mb.getCode().code; - mbCode.add(ins(new GetLocal0Ins())); - mbCode.add(ins(new PushScopeIns())); + mbCode.add(ins(AVM2Instructions.GetLocal0)); + mbCode.add(ins(AVM2Instructions.PushScope)); int traitScope = 2; @@ -2191,37 +2153,37 @@ public class AVM2SourceGenerator implements SourceGenerator { TraitClass tc = (TraitClass) t; List parents = new ArrayList<>(); if (localData.documentClass) { - mbCode.add(ins(new GetScopeObjectIns(), 0)); + mbCode.add(ins(AVM2Instructions.GetScopeObject, 0)); traitScope++; } else { NamespaceSet nsset = new NamespaceSet(new int[]{abc.constants.constant_multiname.get(tc.name_index).namespace_index}); - mbCode.add(ins(new FindPropertyStrictIns(), abc.constants.getMultinameId(new Multiname(Multiname.MULTINAME, abc.constants.constant_multiname.get(tc.name_index).name_index, 0, abc.constants.getNamespaceSetId(nsset, true), 0, new ArrayList<>()), true))); + mbCode.add(ins(AVM2Instructions.FindPropertyStrict, abc.constants.getMultinameId(new Multiname(Multiname.MULTINAME, abc.constants.constant_multiname.get(tc.name_index).name_index, 0, abc.constants.getNamespaceSetId(nsset, true), 0, new ArrayList<>()), true))); } if (abc.instance_info.get(tc.class_info).isInterface()) { - mbCode.add(ins(new PushNullIns())); + mbCode.add(ins(AVM2Instructions.PushNull)); } else { parentNamesAddNames(abc, allABCs, abc.instance_info.get(tc.class_info).name_index, parents, new ArrayList<>(), new ArrayList<>()); for (int i = parents.size() - 1; i >= 0; i--) { - mbCode.add(ins(new GetLexIns(), parents.get(i))); - mbCode.add(ins(new PushScopeIns())); + mbCode.add(ins(AVM2Instructions.GetLex, parents.get(i))); + mbCode.add(ins(AVM2Instructions.PushScope)); traitScope++; } - mbCode.add(ins(new GetLexIns(), parents.get(0))); + mbCode.add(ins(AVM2Instructions.GetLex, parents.get(0))); } - mbCode.add(ins(new NewClassIns(), tc.class_info)); + mbCode.add(ins(AVM2Instructions.NewClass, tc.class_info)); if (!abc.instance_info.get(tc.class_info).isInterface()) { for (int i = parents.size() - 1; i >= 1; i--) { - mbCode.add(ins(new PopScopeIns())); + mbCode.add(ins(AVM2Instructions.PopScope)); } } - mbCode.add(ins(new InitPropertyIns(), tc.name_index)); + mbCode.add(ins(AVM2Instructions.InitProperty, tc.name_index)); initScopes.put(t, traitScope); traitScope = 1; } } - mbCode.add(ins(new ReturnVoidIns())); + mbCode.add(ins(AVM2Instructions.ReturnVoid)); mb.autoFillStats(abc, 1, false); abc.addMethodBody(mb); si.init_index = mb.method_info; @@ -2440,9 +2402,9 @@ public class AVM2SourceGenerator implements SourceGenerator { } } } - return GraphTargetItem.toSourceMerge(localData, this, ins(new GetGlobalScopeIns()), ins(new GetSlotIns(), slotId)); + return GraphTargetItem.toSourceMerge(localData, this, ins(AVM2Instructions.GetGlobalScope), ins(AVM2Instructions.GetSlot, slotId)); } else { - return GraphTargetItem.toSourceMerge(localData, this, ins(new GetLexIns(), resolveType(localData, item, abc, allABCs))); + return GraphTargetItem.toSourceMerge(localData, this, ins(AVM2Instructions.GetLex, resolveType(localData, item, abc, allABCs))); } } @@ -2522,7 +2484,7 @@ public class AVM2SourceGenerator implements SourceGenerator { @Override public List generateDiscardValue(SourceGeneratorLocalData localData, GraphTargetItem item) throws CompilationException { List ret = item.toSource(localData, this); - ret.add(ins(new PopIns())); + ret.add(ins(AVM2Instructions.Pop)); return ret; } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AssignableAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AssignableAVM2Item.java index c68b11289..6eadda47e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AssignableAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AssignableAVM2Item.java @@ -1,37 +1,24 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library 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 * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.abc.avm2.parser.script; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.GetLocal0Ins; -import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.GetLocal1Ins; -import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.GetLocal2Ins; -import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.GetLocal3Ins; -import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.GetLocalIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.KillIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.SetLocal0Ins; -import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.SetLocal1Ins; -import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.SetLocal2Ins; -import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.SetLocal3Ins; -import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.SetLocalIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetScopeObjectIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetSlotIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.SetSlotIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.DupIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.GraphSourceItem; @@ -72,7 +59,7 @@ public abstract class AssignableAVM2Item extends AVM2Item { public static List dupSetTemp(SourceGeneratorLocalData localData, SourceGenerator generator, Reference register) { register.setVal(getFreeRegister(localData, generator)); List ret = new ArrayList<>(); - ret.add(ins(new DupIns())); + ret.add(ins(AVM2Instructions.Dup)); ret.add(generateSetLoc(register.getVal())); return ret; } @@ -97,7 +84,7 @@ public abstract class AssignableAVM2Item extends AVM2Item { killRegister(localData, generator, register.getVal()); List ret = new ArrayList<>(); ret.add(generateGetLoc(register.getVal())); - ret.add(ins(new KillIns(), register.getVal())); + ret.add(ins(AVM2Instructions.Kill, register.getVal())); return ret; }*/ public static List killTemp(SourceGeneratorLocalData localData, SourceGenerator generator, List> registers) { @@ -108,7 +95,7 @@ public abstract class AssignableAVM2Item extends AVM2Item { } killRegister(localData, generator, register.getVal()); - ret.add(ins(new KillIns(), register.getVal())); + ret.add(ins(AVM2Instructions.Kill, register.getVal())); } return ret; } @@ -118,15 +105,15 @@ public abstract class AssignableAVM2Item extends AVM2Item { case -1: return null; case 0: - return ins(new SetLocal0Ins()); + return ins(AVM2Instructions.SetLocal0); case 1: - return ins(new SetLocal1Ins()); + return ins(AVM2Instructions.SetLocal1); case 2: - return ins(new SetLocal2Ins()); + return ins(AVM2Instructions.SetLocal2); case 3: - return ins(new SetLocal3Ins()); + return ins(AVM2Instructions.SetLocal3); default: - return ins(new SetLocalIns(), regNumber); + return ins(AVM2Instructions.SetLocal, regNumber); } } @@ -135,15 +122,15 @@ public abstract class AssignableAVM2Item extends AVM2Item { case -1: return null; case 0: - return ins(new GetLocal0Ins()); + return ins(AVM2Instructions.GetLocal0); case 1: - return ins(new GetLocal1Ins()); + return ins(AVM2Instructions.GetLocal1); case 2: - return ins(new GetLocal2Ins()); + return ins(AVM2Instructions.GetLocal2); case 3: - return ins(new GetLocal3Ins()); + return ins(AVM2Instructions.GetLocal3); default: - return ins(new GetLocalIns(), regNumber); + return ins(AVM2Instructions.GetLocal, regNumber); } } @@ -152,8 +139,8 @@ public abstract class AssignableAVM2Item extends AVM2Item { return null; } List ret = new ArrayList<>(); - ret.add(ins(new GetScopeObjectIns(), slotScope)); - ret.add(ins(new GetSlotIns(), slotNumber)); + ret.add(ins(AVM2Instructions.GetScopeObject, slotScope)); + ret.add(ins(AVM2Instructions.GetSlot, slotNumber)); return ret; } @@ -162,9 +149,9 @@ public abstract class AssignableAVM2Item extends AVM2Item { return null; } List ret = new ArrayList<>(); - ret.add(ins(new GetScopeObjectIns(), slotScope)); + ret.add(ins(AVM2Instructions.GetScopeObject, slotScope)); ret.addAll(val.toSource(localData, generator)); - ret.add(ins(new SetSlotIns(), slotNumber)); + ret.add(ins(AVM2Instructions.SetSlot, slotNumber)); return ret; } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/CallAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/CallAVM2Item.java index d289bdd02..d9bc80637 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/CallAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/CallAVM2Item.java @@ -19,14 +19,7 @@ package com.jpexs.decompiler.flash.abc.avm2.parser.script; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.instructions.executing.CallIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.executing.CallPropVoidIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.executing.CallPropertyIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.executing.CallSuperIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.executing.CallSuperVoidIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.FindPropertyStrictIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetGlobalScopeIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item; import com.jpexs.decompiler.flash.abc.types.ValueKind; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; @@ -133,16 +126,16 @@ public class CallAVM2Item extends AVM2Item { if (propIndex != -1) { if (obj == null) { - obj = new AVM2Instruction(0, new FindPropertyStrictIns(), new int[]{propIndex}); + obj = new AVM2Instruction(0, AVM2Instructions.FindPropertyStrict, new int[]{propIndex}); } boolean isSuper = (obj instanceof NameAVM2Item) && "super".equals(((NameAVM2Item) obj).getVariableName()); - InstructionDefinition insDef = isSuper - ? (needsReturn ? new CallSuperIns() : new CallSuperVoidIns()) - : (needsReturn ? new CallPropertyIns() : new CallPropVoidIns()); + int insCode = isSuper + ? (needsReturn ? AVM2Instructions.CallSuper : AVM2Instructions.CallSuperVoid) + : (needsReturn ? AVM2Instructions.CallProperty : AVM2Instructions.CallPropVoid); return toSourceMerge(localData, generator, obj, arguments, - ins(insDef, propIndex, arguments.size()) + ins(insCode, propIndex, arguments.size()) ); } @@ -153,7 +146,7 @@ public class CallAVM2Item extends AVM2Item { return ((NamespacedAVM2Item) callable).toSource(localData, generator, needsReturn, true, arguments, false, false); } - return toSourceMerge(localData, generator, callable, ins(new GetGlobalScopeIns()), arguments, ins(new CallIns(), arguments.size())); + return toSourceMerge(localData, generator, callable, ins(AVM2Instructions.GetGlobalScope), arguments, ins(AVM2Instructions.Call, arguments.size())); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ConstructSomethingAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ConstructSomethingAVM2Item.java index 8a6d515f5..ccd78b8be 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ConstructSomethingAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ConstructSomethingAVM2Item.java @@ -19,9 +19,7 @@ package com.jpexs.decompiler.flash.abc.avm2.parser.script; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.ConstructIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.ConstructPropIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.FindPropertyStrictIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.abc.types.Namespace; import com.jpexs.decompiler.flash.abc.types.NamespaceSet; import com.jpexs.decompiler.graph.CompilationException; @@ -71,20 +69,20 @@ public class ConstructSomethingAVM2Item extends CallAVM2Item { TypeItem prop = (TypeItem) resname; int type_index = AVM2SourceGenerator.resolveType(localData, resname, ((AVM2SourceGenerator) generator).abc, ((AVM2SourceGenerator) generator).allABCs); return toSourceMerge(localData, generator, - new AVM2Instruction(0, new FindPropertyStrictIns(), new int[]{type_index, arguments.size()}), arguments, - new AVM2Instruction(0, new ConstructPropIns(), new int[]{type_index, arguments.size()}) + new AVM2Instruction(0, AVM2Instructions.FindPropertyStrict, new int[]{type_index, arguments.size()}), arguments, + new AVM2Instruction(0, AVM2Instructions.ConstructProp, new int[]{type_index, arguments.size()}) ); } if (resname instanceof PropertyAVM2Item) { PropertyAVM2Item prop = (PropertyAVM2Item) resname; return toSourceMerge(localData, generator, prop.resolveObject(localData, generator), arguments, - ins(new ConstructPropIns(), prop.resolveProperty(localData), arguments.size()) + ins(AVM2Instructions.ConstructProp, prop.resolveProperty(localData), arguments.size()) ); } if (resname instanceof NameAVM2Item) { - return toSourceMerge(localData, generator, resname, arguments, ins(new ConstructIns(), arguments.size())); + return toSourceMerge(localData, generator, resname, arguments, ins(AVM2Instructions.Construct, arguments.size())); } if (resname instanceof IndexAVM2Item) { @@ -94,6 +92,6 @@ public class ConstructSomethingAVM2Item extends CallAVM2Item { if (resname instanceof NamespacedAVM2Item) { return ((NamespacedAVM2Item) resname).toSource(localData, generator, true, false, arguments, false, true); } - return toSourceMerge(localData, generator, resname, arguments, ins(new ConstructIns(), arguments.size())); + return toSourceMerge(localData, generator, resname, arguments, ins(AVM2Instructions.Construct, arguments.size())); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ExceptionMarkAVM2Instruction.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ExceptionMarkAVM2Instruction.java index 6a19fb00c..f56f55c39 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ExceptionMarkAVM2Instruction.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ExceptionMarkAVM2Instruction.java @@ -18,7 +18,6 @@ package com.jpexs.decompiler.flash.abc.avm2.parser.script; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; /** * @@ -34,7 +33,7 @@ public class ExceptionMarkAVM2Instruction extends AVM2Instruction { super(0, null, null); this.markType = markType; this.exceptionId = exceptionId; - this.definition = new InstructionDefinition(0, "--mark", new int[0], false /*?*/); + this.definition = ExceptionMarkIns.getInstance(); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ExceptionMarkIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ExceptionMarkIns.java new file mode 100644 index 000000000..99c83e98e --- /dev/null +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ExceptionMarkIns.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2010-2015 JPEXS, All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. + */ +package com.jpexs.decompiler.flash.abc.avm2.parser.script; + +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; + +/** + * + * @author JPEXS + */ +public class ExceptionMarkIns extends InstructionDefinition { + + private static final ExceptionMarkIns instance = new ExceptionMarkIns(); + + public static final ExceptionMarkIns getInstance() { + return instance; + } + + private ExceptionMarkIns() { + super(0, "--mark", new int[0], false /*?*/); + } +} diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/IndexAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/IndexAVM2Item.java index 6b51fe95e..7168942d0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/IndexAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/IndexAVM2Item.java @@ -18,16 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.parser.script; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.DecrementIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.IncrementIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.ConstructPropIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.executing.CallIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.DeletePropertyIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetPropertyIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.SetPropertyIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.DupIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PopIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.types.ConvertDIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.flash.abc.types.NamespaceSet; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; @@ -102,16 +93,16 @@ public class IndexAVM2Item extends AssignableAVM2Item { return toSourceMerge(localData, generator, object, dupSetTemp(localData, generator, obj_temp), index, dupSetTemp(localData, generator, index_temp), - ins(new GetPropertyIns(), indexPropIndex), - post ? ins(new ConvertDIns()) : null, - (!post) ? (decrement ? ins(new DecrementIns()) : ins(new IncrementIns())) : null, - needsReturn ? ins(new DupIns()) : null, - post ? (decrement ? ins(new DecrementIns()) : ins(new IncrementIns())) : null, + ins(AVM2Instructions.GetProperty, indexPropIndex), + post ? ins(AVM2Instructions.ConvertD) : null, + (!post) ? (decrement ? ins(AVM2Instructions.Decrement) : ins(AVM2Instructions.Increment)) : null, + needsReturn ? ins(AVM2Instructions.Dup) : null, + post ? (decrement ? ins(AVM2Instructions.Decrement) : ins(AVM2Instructions.Increment)) : null, setTemp(localData, generator, val_temp), getTemp(localData, generator, obj_temp), getTemp(localData, generator, index_temp), getTemp(localData, generator, val_temp), - ins(new SetPropertyIns(), indexPropIndex), + ins(AVM2Instructions.SetProperty, indexPropIndex), killTemp(localData, generator, Arrays.asList(val_temp, obj_temp, index_temp)) ); @@ -128,19 +119,19 @@ public class IndexAVM2Item extends AssignableAVM2Item { index, assignedValue, needsReturn ? dupSetTemp(localData, generator, ret_temp) : null, - ins(new SetPropertyIns(), indexPropIndex), + ins(AVM2Instructions.SetProperty, indexPropIndex), needsReturn ? getTemp(localData, generator, ret_temp) : null, killTemp(localData, generator, Arrays.asList(ret_temp))); } else { return toSourceMerge(localData, generator, object, - call ? ins(new DupIns()) : null, + call ? ins(AVM2Instructions.Dup) : null, index, construct ? callargs : null, - ins(construct ? new ConstructPropIns() : delete ? new DeletePropertyIns() : new GetPropertyIns(), indexPropIndex, construct ? callargs.size() : null), + ins(construct ? AVM2Instructions.ConstructProp : delete ? AVM2Instructions.DeleteProperty : AVM2Instructions.GetProperty, indexPropIndex, construct ? callargs.size() : null), call ? callargs : null, - call ? ins(new CallIns(), callargs.size()) : null, - needsReturn ? null : ins(new PopIns())); + call ? ins(AVM2Instructions.Call, callargs.size()) : null, + needsReturn ? null : ins(AVM2Instructions.Pop)); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NameAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NameAVM2Item.java index 2f37ccd59..1f3e72f55 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NameAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NameAVM2Item.java @@ -19,24 +19,7 @@ package com.jpexs.decompiler.flash.abc.avm2.parser.script; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.DecrementIIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.DecrementIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.IncrementIIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.IncrementIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.DecLocalIIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.DecLocalIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.IncLocalIIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.IncLocalIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetScopeObjectIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.SetSlotIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.DupIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PopIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceAIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceSIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.types.ConvertBIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.types.ConvertIIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.types.ConvertUIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.NanAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.NullAVM2Item; @@ -196,27 +179,27 @@ public class NameAVM2Item extends AssignableAVM2Item { } AVM2Instruction ins; if (ttype instanceof UnboundedTypeItem) { - ins = ins(new CoerceAIns()); + ins = ins(AVM2Instructions.CoerceA); } else { switch (ttype.toString()) { case "int": - ins = ins(new ConvertIIns()); + ins = ins(AVM2Instructions.ConvertI); break; case "*": - ins = ins(new CoerceAIns()); + ins = ins(AVM2Instructions.CoerceA); break; case "String": - ins = ins(new CoerceSIns()); + ins = ins(AVM2Instructions.CoerceS); break; case "Boolean": - ins = ins(new ConvertBIns()); + ins = ins(AVM2Instructions.ConvertB); break; case "uint": - ins = ins(new ConvertUIns()); + ins = ins(AVM2Instructions.ConvertU); break; default: int type_index = AVM2SourceGenerator.resolveType(localData, ttype, ((AVM2SourceGenerator) generator).abc, ((AVM2SourceGenerator) generator).allABCs); - ins = ins(new CoerceIns(), type_index); + ins = ins(AVM2Instructions.Coerce, type_index); break; } } @@ -245,21 +228,21 @@ public class NameAVM2Item extends AssignableAVM2Item { List basicTypes = Arrays.asList("int", "Number"); if (slotNumber > -1) { return toSourceMerge(localData, generator, - ins(new GetScopeObjectIns(), slotScope), + ins(AVM2Instructions.GetScopeObject, slotScope), assignedValue, !(("" + assignedValue.returnType()).equals("" + type) && (basicTypes.contains("" + type))) ? generateCoerce(localData, generator, type) : null, needsReturn ? dupSetTemp(localData, generator, ret_temp) : null, generateSetLoc(regNumber), slotNumber > -1 - ? ins(new SetSlotIns(), slotNumber) + ? ins(AVM2Instructions.SetSlot, slotNumber) : null, needsReturn ? getTemp(localData, generator, ret_temp) : null, killTemp(localData, generator, Arrays.asList(ret_temp))); } else { return toSourceMerge(localData, generator, assignedValue, !(("" + assignedValue.returnType()).equals("" + type) && (basicTypes.contains("" + type))) ? generateCoerce(localData, generator, type) : null, needsReturn - ? ins(new DupIns()) : null, generateSetLoc(regNumber)); + ? ins(AVM2Instructions.Dup) : null, generateSetLoc(regNumber)); } } else { return toSourceMerge(localData, generator, generateGetLoc(regNumber), generateGetSlot(slotScope, slotNumber), - needsReturn ? null : ins(new PopIns())); + needsReturn ? null : ins(AVM2Instructions.Pop)); } } @@ -327,29 +310,29 @@ public class NameAVM2Item extends AssignableAVM2Item { if (!needsReturn) { if (slotNumber > -1) { return toSourceMerge(localData, generator, - ins(new GetScopeObjectIns(), slotScope), + ins(AVM2Instructions.GetScopeObject, slotScope), generateGetSlot(slotScope, slotNumber), - (decrement ? ins(isInteger ? new DecrementIIns() : new DecrementIns()) : ins(isInteger ? new IncrementIIns() : new IncrementIns())), - ins(new SetSlotIns(), slotNumber) + (decrement ? ins(isInteger ? AVM2Instructions.DecrementI : AVM2Instructions.Decrement) : ins(isInteger ? AVM2Instructions.IncrementI : AVM2Instructions.Increment)), + ins(AVM2Instructions.SetSlot, slotNumber) ); } else { return toSourceMerge(localData, generator, - (decrement ? ins(isInteger ? new DecLocalIIns() : new DecLocalIns(), regNumber) : ins(isInteger ? new IncLocalIIns() : new IncLocalIns(), regNumber))); + (decrement ? ins(isInteger ? AVM2Instructions.DecLocalI : AVM2Instructions.DecLocal, regNumber) : ins(isInteger ? AVM2Instructions.IncLocalI : AVM2Instructions.IncLocal, regNumber))); } } return toSourceMerge(localData, generator, - slotNumber > -1 ? ins(new GetScopeObjectIns(), slotScope) : null, + slotNumber > -1 ? ins(AVM2Instructions.GetScopeObject, slotScope) : null, //Start get original generateGetLoc(regNumber), generateGetSlot(slotScope, slotNumber), //End get original - //!isInteger ? ins(new ConvertDIns()) : null, + //!isInteger ? ins(AVM2Instructions.ConvertD) : null, //End get original - (!post) ? (decrement ? ins(isInteger ? new DecrementIIns() : new DecrementIns()) : ins(isInteger ? new IncrementIIns() : new IncrementIns())) : null, - needsReturn ? ins(new DupIns()) : null, - (post) ? (decrement ? ins(isInteger ? new DecrementIIns() : new DecrementIns()) : ins(isInteger ? new IncrementIIns() : new IncrementIns())) : null, + (!post) ? (decrement ? ins(isInteger ? AVM2Instructions.DecrementI : AVM2Instructions.Decrement) : ins(isInteger ? AVM2Instructions.IncrementI : AVM2Instructions.Increment)) : null, + needsReturn ? ins(AVM2Instructions.Dup) : null, + (post) ? (decrement ? ins(isInteger ? AVM2Instructions.DecrementI : AVM2Instructions.Decrement) : ins(isInteger ? AVM2Instructions.IncrementI : AVM2Instructions.Increment)) : null, generateCoerce(localData, generator, returnType()), generateSetLoc(regNumber), - slotNumber > -1 ? ins(new SetSlotIns(), slotNumber) : null + slotNumber > -1 ? ins(AVM2Instructions.SetSlot, slotNumber) : null ); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NamespacedAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NamespacedAVM2Item.java index a264d8cfc..c5a3a1aa9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NamespacedAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NamespacedAVM2Item.java @@ -18,20 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.parser.script; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.DecrementIIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.DecrementIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.IncrementIIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.IncrementIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.ConstructPropIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.executing.CallIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.DeletePropertyIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.FindPropertyStrictIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetPropertyIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.SetPropertyIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.DupIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PopIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.types.ConvertDIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.types.ConvertSIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.flash.abc.types.NamespaceSet; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; @@ -96,46 +83,46 @@ public class NamespacedAVM2Item extends AssignableAVM2Item { Reference ret_temp = new Reference<>(-1); /*if (name == null && index != null) { return toSourceMerge(localData, generator, - ns, generateCoerce(generator, new TypeItem("Namespace")), index, ins(new ConvertSIns()), - ins(new FindPropertyStrictIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAMEL, 0, 0, 0, 0, new ArrayList()), true)), + ns, generateCoerce(generator, new TypeItem("Namespace")), index, ins(AVM2Instructions.ConvertS), + ins(AVM2Instructions.FindPropertyStrict, g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAMEL, 0, 0, 0, 0, new ArrayList()), true)), dupSetTemp(localData, generator, name_temp), ns, generateCoerce(generator, new TypeItem("Namespace")), dupSetTemp(localData, generator, ns_temp), - ins(new GetPropertyIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.MULTINAMEL, 0, 0, allNsSet(g.abc), 0, new ArrayList()), true)), - !isInteger ? ins(new ConvertDIns()) : null, + ins(AVM2Instructions.GetProperty, g.abc.constants.getMultinameId(new Multiname(Multiname.MULTINAMEL, 0, 0, allNsSet(g.abc), 0, new ArrayList()), true)), + !isInteger ? ins(AVM2Instructions.ConvertD) : null, //End get original - (!post) ? (decrement ? ins(isInteger ? new DecrementIIns() : new DecrementIns()) : ins(isInteger ? new IncrementIIns() : new IncrementIns())) : null, - needsReturn ? ins(new DupIns()) : null, - (post) ? (decrement ? ins(isInteger ? new DecrementIIns() : new DecrementIns()) : ins(isInteger ? new IncrementIIns() : new IncrementIns())) : null, + (!post) ? (decrement ? ins(isInteger ? AVM2Instructions.DecrementI : AVM2Instructions.Decrement) : ins(isInteger ? AVM2Instructions.IncrementI : AVM2Instructions.Increment())) : null, + needsReturn ? ins(AVM2Instructions.Dup) : null, + (post) ? (decrement ? ins(isInteger ? AVM2Instructions.DecrementI : AVM2Instructions.Decrement) : ins(isInteger ? AVM2Instructions.IncrementI : AVM2Instructions.Increment)) : null, setTemp(localData, generator, ret_temp), getTemp(localData, generator, name_temp), getTemp(localData, generator, ns_temp), getTemp(localData, generator, ret_temp), - ins(new SetPropertyIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.MULTINAMEL, 0, 0, allNsSet(g.abc), 0, new ArrayList()), true)), + ins(AVM2Instructions.SetProperty, g.abc.constants.getMultinameId(new Multiname(Multiname.MULTINAMEL, 0, 0, allNsSet(g.abc), 0, new ArrayList()), true)), killTemp(localData, generator, Arrays.asList(ret_temp, name_temp, ns_temp))); } else */ if (name != null) { return toSourceMerge(localData, generator, ns, NameAVM2Item.generateCoerce(localData, generator, new TypeItem(DottedChain.NAMESPACE)), - ins(new FindPropertyStrictIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAME, g.abc.constants.getStringId(name, true), 0, 0, 0, new ArrayList<>()), true)), + ins(AVM2Instructions.FindPropertyStrict, g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAME, g.abc.constants.getStringId(name, true), 0, 0, 0, new ArrayList<>()), true)), dupSetTemp(localData, generator, name_temp), ns, NameAVM2Item.generateCoerce(localData, generator, new TypeItem(DottedChain.NAMESPACE)), dupSetTemp(localData, generator, ns_temp), //Start get original - //getTemp(localData, generator, ns_temp), generateCoerce(generator, "Namespace"), ins(new FindPropertyStrictIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAME, g.abc.constants.getStringId(variableName, true), 0, 0, 0, new ArrayList()), true)), + //getTemp(localData, generator, ns_temp), generateCoerce(generator, "Namespace"), ins(AVM2Instructions.FindPropertyStrict, g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAME, g.abc.constants.getStringId(variableName, true), 0, 0, 0, new ArrayList()), true)), //getTemp(localData, generator, ns_temp), generateCoerce(generator, "Namespace"), - ins(new GetPropertyIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.MULTINAMEL, 0, 0, allNsSet(g.abc), 0, new ArrayList<>()), true)), - !isInteger ? ins(new ConvertDIns()) : null, + ins(AVM2Instructions.GetProperty, g.abc.constants.getMultinameId(new Multiname(Multiname.MULTINAMEL, 0, 0, allNsSet(g.abc), 0, new ArrayList<>()), true)), + !isInteger ? ins(AVM2Instructions.ConvertD) : null, //End get original - (!post) ? (decrement ? ins(isInteger ? new DecrementIIns() : new DecrementIns()) : ins(isInteger ? new IncrementIIns() : new IncrementIns())) : null, - needsReturn ? ins(new DupIns()) : null, - (post) ? (decrement ? ins(isInteger ? new DecrementIIns() : new DecrementIns()) : ins(isInteger ? new IncrementIIns() : new IncrementIns())) : null, + (!post) ? (decrement ? ins(isInteger ? AVM2Instructions.DecrementI : AVM2Instructions.Decrement) : ins(isInteger ? AVM2Instructions.IncrementI : AVM2Instructions.Increment)) : null, + needsReturn ? ins(AVM2Instructions.Dup) : null, + (post) ? (decrement ? ins(isInteger ? AVM2Instructions.DecrementI : AVM2Instructions.Decrement) : ins(isInteger ? AVM2Instructions.IncrementI : AVM2Instructions.Increment)) : null, setTemp(localData, generator, ret_temp), getTemp(localData, generator, name_temp), getTemp(localData, generator, ns_temp), getTemp(localData, generator, ret_temp), - ins(new SetPropertyIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.MULTINAMEL, 0, 0, allNsSet(g.abc), 0, new ArrayList<>()), true)), + ins(AVM2Instructions.SetProperty, g.abc.constants.getMultinameId(new Multiname(Multiname.MULTINAMEL, 0, 0, allNsSet(g.abc), 0, new ArrayList<>()), true)), killTemp(localData, generator, Arrays.asList(ret_temp, name_temp, ns_temp)) ); } else { @@ -169,48 +156,48 @@ public class NamespacedAVM2Item extends AssignableAVM2Item { if (name == null) { if (assignedValue != null) { return toSourceMerge(localData, generator, - obj == null ? ns : null, obj == null ? NameAVM2Item.generateCoerce(localData, generator, new TypeItem(DottedChain.NAMESPACE)) : null, nameItem, ins(new ConvertSIns()), obj != null ? obj : ins(new FindPropertyStrictIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAMEL, 0, 0, 0, 0, new ArrayList<>()), true)), - ns, NameAVM2Item.generateCoerce(localData, generator, new TypeItem(DottedChain.NAMESPACE)), nameItem, ins(new ConvertSIns()), assignedValue, + obj == null ? ns : null, obj == null ? NameAVM2Item.generateCoerce(localData, generator, new TypeItem(DottedChain.NAMESPACE)) : null, nameItem, ins(AVM2Instructions.ConvertS), obj != null ? obj : ins(AVM2Instructions.FindPropertyStrict, g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAMEL, 0, 0, 0, 0, new ArrayList<>()), true)), + ns, NameAVM2Item.generateCoerce(localData, generator, new TypeItem(DottedChain.NAMESPACE)), nameItem, ins(AVM2Instructions.ConvertS), assignedValue, needsReturn ? dupSetTemp(localData, generator, ret_temp) : null, - ins(new SetPropertyIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAMEL, 0, 0, 0, 0, new ArrayList<>()), true)), + ins(AVM2Instructions.SetProperty, g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAMEL, 0, 0, 0, 0, new ArrayList<>()), true)), needsReturn ? getTemp(localData, generator, ret_temp) : null, killTemp(localData, generator, Arrays.asList(ns_temp, index_temp, ret_temp)) ); } else { return toSourceMerge(localData, generator, - obj == null ? ns : null, obj == null ? NameAVM2Item.generateCoerce(localData, generator, new TypeItem(DottedChain.NAMESPACE)) : null, nameItem, ins(new ConvertSIns()), obj != null ? obj : ins(new FindPropertyStrictIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAMEL, 0, 0, 0, 0, new ArrayList<>()), true)), + obj == null ? ns : null, obj == null ? NameAVM2Item.generateCoerce(localData, generator, new TypeItem(DottedChain.NAMESPACE)) : null, nameItem, ins(AVM2Instructions.ConvertS), obj != null ? obj : ins(AVM2Instructions.FindPropertyStrict, g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAMEL, 0, 0, 0, 0, new ArrayList<>()), true)), call ? dupSetTemp(localData, generator, obj_temp) : null, - ns, NameAVM2Item.generateCoerce(localData, generator, new TypeItem(DottedChain.NAMESPACE)), nameItem, ins(new ConvertSIns()), + ns, NameAVM2Item.generateCoerce(localData, generator, new TypeItem(DottedChain.NAMESPACE)), nameItem, ins(AVM2Instructions.ConvertS), construct ? callargs : null, - ins(construct ? new ConstructPropIns() : delete ? new DeletePropertyIns() : new GetPropertyIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAMEL, 0, 0, 0, 0, new ArrayList<>()), true), construct ? callargs.size() : null), + ins(construct ? AVM2Instructions.ConstructProp : delete ? AVM2Instructions.DeleteProperty : AVM2Instructions.GetProperty, g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAMEL, 0, 0, 0, 0, new ArrayList<>()), true), construct ? callargs.size() : null), call ? getTemp(localData, generator, obj_temp) : null, call ? callargs : null, - call ? ins(new CallIns(), callargs.size()) : null, - needsReturn ? null : ins(new PopIns()), + call ? ins(AVM2Instructions.Call, callargs.size()) : null, + needsReturn ? null : ins(AVM2Instructions.Pop), killTemp(localData, generator, Arrays.asList(obj_temp)) ); } } else { if (assignedValue != null) { return toSourceMerge(localData, generator, - obj == null ? ns : null, obj == null ? NameAVM2Item.generateCoerce(localData, generator, new TypeItem(DottedChain.NAMESPACE)) : null, obj != null ? obj : ins(new FindPropertyStrictIns(), g.abc.constants.getMultinameId(new Multiname(attr ? Multiname.RTQNAMEA : Multiname.RTQNAME, g.abc.constants.getStringId(name, true), 0, 0, 0, new ArrayList<>()), true)), + obj == null ? ns : null, obj == null ? NameAVM2Item.generateCoerce(localData, generator, new TypeItem(DottedChain.NAMESPACE)) : null, obj != null ? obj : ins(AVM2Instructions.FindPropertyStrict, g.abc.constants.getMultinameId(new Multiname(attr ? Multiname.RTQNAMEA : Multiname.RTQNAME, g.abc.constants.getStringId(name, true), 0, 0, 0, new ArrayList<>()), true)), ns, NameAVM2Item.generateCoerce(localData, generator, new TypeItem(DottedChain.NAMESPACE)), assignedValue, needsReturn ? dupSetTemp(localData, generator, ret_temp) : null, - ins(new SetPropertyIns(), g.abc.constants.getMultinameId(new Multiname(attr ? Multiname.RTQNAMEA : Multiname.RTQNAME, g.abc.constants.getStringId(name, true), 0, 0, 0, new ArrayList<>()), true)), + ins(AVM2Instructions.SetProperty, g.abc.constants.getMultinameId(new Multiname(attr ? Multiname.RTQNAMEA : Multiname.RTQNAME, g.abc.constants.getStringId(name, true), 0, 0, 0, new ArrayList<>()), true)), needsReturn ? getTemp(localData, generator, ret_temp) : null, killTemp(localData, generator, Arrays.asList(ns_temp, index_temp, ret_temp)) ); } else { return toSourceMerge(localData, generator, - obj == null ? ns : null, obj == null ? NameAVM2Item.generateCoerce(localData, generator, new TypeItem(DottedChain.NAMESPACE)) : null, obj != null ? obj : ins(new FindPropertyStrictIns(), g.abc.constants.getMultinameId(new Multiname(attr ? Multiname.RTQNAMEA : Multiname.RTQNAME, g.abc.constants.getStringId(name, true), 0, 0, 0, new ArrayList<>()), true)), + obj == null ? ns : null, obj == null ? NameAVM2Item.generateCoerce(localData, generator, new TypeItem(DottedChain.NAMESPACE)) : null, obj != null ? obj : ins(AVM2Instructions.FindPropertyStrict, g.abc.constants.getMultinameId(new Multiname(attr ? Multiname.RTQNAMEA : Multiname.RTQNAME, g.abc.constants.getStringId(name, true), 0, 0, 0, new ArrayList<>()), true)), call ? dupSetTemp(localData, generator, obj_temp) : null, ns, NameAVM2Item.generateCoerce(localData, generator, new TypeItem(DottedChain.NAMESPACE)), construct ? callargs : null, - ins(construct ? new ConstructPropIns() : delete ? new DeletePropertyIns() : new GetPropertyIns(), g.abc.constants.getMultinameId(new Multiname(attr ? Multiname.RTQNAMEA : Multiname.RTQNAME, g.abc.constants.getStringId(name, true), 0, 0, 0, new ArrayList<>()), true), construct ? callargs.size() : null), + ins(construct ? AVM2Instructions.ConstructProp : delete ? AVM2Instructions.DeleteProperty : AVM2Instructions.GetProperty, g.abc.constants.getMultinameId(new Multiname(attr ? Multiname.RTQNAMEA : Multiname.RTQNAME, g.abc.constants.getStringId(name, true), 0, 0, 0, new ArrayList<>()), true), construct ? callargs.size() : null), call ? getTemp(localData, generator, obj_temp) : null, call ? callargs : null, - call ? ins(new CallIns(), callargs.size()) : null, - needsReturn ? null : ins(new PopIns()), + call ? ins(AVM2Instructions.Call, callargs.size()) : null, + needsReturn ? null : ins(AVM2Instructions.Pop), killTemp(localData, generator, Arrays.asList(obj_temp)) ); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java index 24053ae93..79ca435f9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java @@ -20,17 +20,8 @@ import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.DecrementIIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.DecrementIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.IncrementIIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.IncrementIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.abc.avm2.instructions.other.FindPropertyStrictIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetLexIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetPropertyIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.SetPropertyIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.DupIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PopIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.types.ConvertDIns; import com.jpexs.decompiler.flash.abc.avm2.model.ApplyTypeAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.CoerceAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.InitVectorAVM2Item; @@ -585,17 +576,17 @@ public class PropertyAVM2Item extends AssignableAVM2Item { } return toSourceMerge(localData, generator, obj, coerced, needsReturn ? dupSetTemp(localData, generator, ret_temp) : null, - ins(new SetPropertyIns(), propertyId), + ins(AVM2Instructions.SetProperty, propertyId), needsReturn ? getTemp(localData, generator, ret_temp) : null, killTemp(localData, generator, Arrays.asList(ret_temp))); } else { if (obj instanceof AVM2Instruction && (((AVM2Instruction) obj).definition instanceof FindPropertyStrictIns)) { - return toSourceMerge(localData, generator, ins(new GetLexIns(), propertyId), - needsReturn ? null : ins(new PopIns()) + return toSourceMerge(localData, generator, ins(AVM2Instructions.GetLex, propertyId), + needsReturn ? null : ins(AVM2Instructions.Pop) ); } - return toSourceMerge(localData, generator, obj, ins(new GetPropertyIns(), propertyId), - needsReturn ? null : ins(new PopIns()) + return toSourceMerge(localData, generator, obj, ins(AVM2Instructions.GetProperty, propertyId), + needsReturn ? null : ins(AVM2Instructions.Pop) ); } } @@ -646,7 +637,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item { Reference propIndex = new Reference<>(0); Reference propValue = new Reference<>(null); resolve(localData, objType, propType, propIndex, outPropValue); - obj = ins(new FindPropertyStrictIns(), propIndex.getVal()); + obj = ins(AVM2Instructions.FindPropertyStrict, propIndex.getVal()); } } return obj; @@ -673,16 +664,16 @@ public class PropertyAVM2Item extends AssignableAVM2Item { //Start get original //getTemp(localData, generator, obj_temp), //index!=null?getTemp(localData, generator, index_temp):null, - ins(new GetPropertyIns(), propertyId), - (!isInteger && post) ? ins(new ConvertDIns()) : null, + ins(AVM2Instructions.GetProperty, propertyId), + (!isInteger && post) ? ins(AVM2Instructions.ConvertD) : null, //End get original - (!post) ? (decrement ? ins(isInteger ? new DecrementIIns() : new DecrementIns()) : ins(isInteger ? new IncrementIIns() : new IncrementIns())) : null, - needsReturn ? ins(new DupIns()) : null, - (post) ? (decrement ? ins(isInteger ? new DecrementIIns() : new DecrementIns()) : ins(isInteger ? new IncrementIIns() : new IncrementIns())) : null, + (!post) ? (decrement ? ins(isInteger ? AVM2Instructions.DecrementI : AVM2Instructions.Decrement) : ins(isInteger ? AVM2Instructions.IncrementI : AVM2Instructions.Increment)) : null, + needsReturn ? ins(AVM2Instructions.Dup) : null, + (post) ? (decrement ? ins(isInteger ? AVM2Instructions.DecrementI : AVM2Instructions.Decrement) : ins(isInteger ? AVM2Instructions.IncrementI : AVM2Instructions.Increment)) : null, setTemp(localData, generator, ret_temp), getTemp(localData, generator, obj_temp), getTemp(localData, generator, ret_temp), - ins(new SetPropertyIns(), propertyId), + ins(AVM2Instructions.SetProperty, propertyId), //needsReturn?getTemp(localData, generator, ret_temp):null, killTemp(localData, generator, Arrays.asList(ret_temp, obj_temp))); return ret; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/UnresolvedAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/UnresolvedAVM2Item.java index 4760ada8a..60472e6ba 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/UnresolvedAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/UnresolvedAVM2Item.java @@ -19,10 +19,7 @@ package com.jpexs.decompiler.flash.abc.avm2.parser.script; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceAIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceSIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.types.ConvertIIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.abc.avm2.model.InitVectorAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.NanAVM2Item; @@ -212,17 +209,17 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { AVM2Instruction ins; switch (type.toString()) { case "int": - ins = ins(new ConvertIIns()); + ins = ins(AVM2Instructions.ConvertI); break; case "*": - ins = ins(new CoerceAIns()); + ins = ins(AVM2Instructions.CoerceA); break; case "String": - ins = ins(new CoerceSIns()); + ins = ins(AVM2Instructions.CoerceS); break; default: int type_index = AVM2SourceGenerator.resolveType(localData, type, ((AVM2SourceGenerator) generator).abc, ((AVM2SourceGenerator) generator).allABCs); - ins = ins(new CoerceIns(), type_index); + ins = ins(AVM2Instructions.Coerce, type_index); break; } return ins; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/XMLAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/XMLAVM2Item.java index f76d5d811..2af62f970 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/XMLAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/XMLAVM2Item.java @@ -17,8 +17,7 @@ package com.jpexs.decompiler.flash.abc.avm2.parser.script; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; -import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.ConstructIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetLexIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item; import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.flash.abc.types.Namespace; @@ -62,9 +61,9 @@ public class XMLAVM2Item extends AVM2Item { public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { AVM2SourceGenerator g = (AVM2SourceGenerator) generator; return toSourceMerge(localData, generator, - ins(new GetLexIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.QNAME, g.abc.constants.getStringId("XML", true), g.abc.constants.getNamespaceId(new Namespace(Namespace.KIND_PACKAGE, g.abc.constants.getStringId("", true)), 0, true), 0, 0, new ArrayList<>()), true)), + ins(AVM2Instructions.GetLex, g.abc.constants.getMultinameId(new Multiname(Multiname.QNAME, g.abc.constants.getStringId("XML", true), g.abc.constants.getNamespaceId(new Namespace(Namespace.KIND_PACKAGE, g.abc.constants.getStringId("", true)), 0, true), 0, 0, new ArrayList<>()), true)), value, - ins(new ConstructIns(), 1) + ins(AVM2Instructions.Construct, 1) ); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java index bfa466fc7..23166a275 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java @@ -367,6 +367,7 @@ public final class MethodBody implements Cloneable { throw ex; } catch (Throwable ex) { //ignore + logger.log(Level.SEVERE, "Deobfuscation failed in: " + path, ex); body = clone(); code = body.getCode(); code.markMappedOffsets(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionList.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionList.java index 9d37673c3..2e2e277e5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionList.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionList.java @@ -60,6 +60,10 @@ public class ActionList extends ArrayList { ActionListReader.removeAction(this, index, SWF.DEFAULT_VERSION, true); } + public void removeActions(List actionsToRemove) { + ActionListReader.removeActions(this, actionsToRemove, SWF.DEFAULT_VERSION, true); + } + public void removeAction(int index, int count) { if (size() <= index + count - 1) { // Can't remove count elements, only size - index is available diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionListReader.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionListReader.java index feef57f75..3cb87fc5d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionListReader.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionListReader.java @@ -181,9 +181,11 @@ public class ActionListReader { try { new ActionDeobfuscatorSimple().actionListParsed(actions, sis.getSwf()); new ActionDeobfuscator().actionListParsed(actions, sis.getSwf()); - } catch (OutOfMemoryError | StackOverflowError | TranslateException ex) { + } catch (ThreadDeath | InterruptedException ex) { + throw ex; + } catch (Throwable ex) { // keep orignal (not deobfuscated) actions - logger.log(Level.SEVERE, null, ex); + logger.log(Level.SEVERE, "Deobfuscation failed in: " + path, ex); } } @@ -593,6 +595,71 @@ public class ActionListReader { return true; } + /** + * Removes multiple actions from the action list, and updates all references + * This + * method will keep the inner actions of the container when you remove the + * container + * + * @param actions + * @param actionsToRemove + * @param version + * @param removeWhenLast + * @return + */ + public static boolean removeActions(ActionList actions, List actionsToRemove, int version, boolean removeWhenLast) { + + long startIp = actions.get(0).getAddress(); + Action lastAction = actions.get(actions.size() - 1); + long endAddress = lastAction.getAddress() + lastAction.getTotalActionLength(); + + Map> containerLastActions = new HashMap<>(); + getContainerLastActions(actions, containerLastActions); + + Map jumps = new HashMap<>(); + getJumps(actions, jumps); + + for (Action actionToRemove : actionsToRemove) { + int index = actions.indexOf(actionToRemove); + Action prevAction = index > 0 ? actions.get(index - 1) : null; + Action nextAction = index + 1 < actions.size() ? actions.get(index + 1) : null; + for (Action a : containerLastActions.keySet()) { + List lastActions = containerLastActions.get(a); + for (int i = 0; i < lastActions.size(); i++) { + if (lastActions.get(i) == actionToRemove) { + if (!removeWhenLast) { + return false; + } + lastActions.set(i, prevAction); + } + } + } + + for (Action a : jumps.keySet()) { + Action targetAction = jumps.get(a); + if (targetAction == actionToRemove) { + jumps.put(a, nextAction); + } + } + if (containerLastActions.containsKey(actionToRemove)) { + containerLastActions.remove(actionToRemove); + } + if (jumps.containsKey(actionToRemove)) { + jumps.remove(actionToRemove); + } + + actions.remove(index); + } + + updateActionLengths(actions, version); + updateAddresses(actions, startIp); + updateJumps(actions, jumps, containerLastActions, endAddress); + updateActionStores(actions, jumps); + updateContainerSizes(actions, containerLastActions); + + return true; + } + /** * Adds an action to the action list to the specified location, and updates * all references diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscator.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscator.java index 656821caf..63ed33fc3 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscator.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscator.java @@ -234,6 +234,10 @@ public class ActionDeobfuscator extends ActionDeobfuscatorSimple { ActionConstantPool lastConstantPool = null; while (true) { + if (Thread.currentThread().isInterrupted()) { + throw new InterruptedException(); + } + if (idx > endIdx) { break; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscatorSimple.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscatorSimple.java index 971e55869..cecae942f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscatorSimple.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscatorSimple.java @@ -242,19 +242,36 @@ public class ActionDeobfuscatorSimple implements SWFDecompilerListener { } } - boolean result = false; + /*boolean result = false; + for (int i = 0; i < actions.size(); i++) { + if (!reachableActions.contains(actions.get(i))) { + actions.removeAction(i); + i--; + result = true; + } + } + + return result;*/ + List actionsToRemove = null; for (int i = 0; i < actions.size(); i++) { - if (!reachableActions.contains(actions.get(i))) { - actions.removeAction(i); - i--; - result = true; + Action action = actions.get(i); + if (!reachableActions.contains(action)) { + if (actionsToRemove == null) { + actionsToRemove = new ArrayList<>(); + } + + actionsToRemove.add(action); } } - return result; + if (actionsToRemove != null) { + actions.removeActions(actionsToRemove); + } + + return actionsToRemove != null; } - protected boolean removeZeroJumps(ActionList actions) { + protected boolean removeZeroJumpsOld(ActionList actions) { boolean result = false; for (int i = 0; i < actions.size(); i++) { Action action = actions.get(i); @@ -267,6 +284,26 @@ public class ActionDeobfuscatorSimple implements SWFDecompilerListener { return result; } + protected boolean removeZeroJumps(ActionList actions) { + List actionsToRemove = null; + for (int i = 0; i < actions.size(); i++) { + Action action = actions.get(i); + if (action instanceof ActionJump && ((ActionJump) action).getJumpOffset() == 0) { + if (actionsToRemove == null) { + actionsToRemove = new ArrayList<>(); + } + + actionsToRemove.add(action); + } + } + + if (actionsToRemove != null) { + actions.removeActions(actionsToRemove); + } + + return actionsToRemove != null; + } + private void executeActions(ActionList actions, int idx, int endIdx, ExecutionResult result) throws InterruptedException { List output = new ArrayList<>(); ActionLocalData localData = new ActionLocalData(); @@ -274,6 +311,10 @@ public class ActionDeobfuscatorSimple implements SWFDecompilerListener { int instructionsProcessed = 0; while (true) { + if (Thread.currentThread().isInterrupted()) { + throw new InterruptedException(); + } + if (idx > endIdx) { break; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java index de430e94e..603865ffc 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java @@ -583,7 +583,6 @@ public class Graph { if (!newLoopDetection) { getLoops(localData, heads.get(0), loops, null); } else { - List loopHeads = new ArrayList<>(); identifyLoops(localData, loopHeads, heads, allParts); Map> loopBreaks = identifyLoopBreaks(localData, allParts); @@ -594,7 +593,6 @@ public class Graph { } for (int i = 0; i < loopHeads.size(); i++) { if (loopBreaks.containsKey(loopHeads.get(i))) { - loops2.get(i).loopBreak = loopBreaks.get(loopHeads.get(i)).get(0);//getMostCommonPart(localData, loopBreaks.get(loopHeads.get(i)), loops2); } else { loops2.get(i).loopBreak = null; @@ -1224,9 +1222,6 @@ public class Graph { private void getLoops(BaseLocalData localData, GraphPart part, List loops, List stopPart, boolean first, int level, List visited) throws InterruptedException { boolean debugMode = false; - if (stopPart == null) { - stopPart = new ArrayList<>(); - } if (part == null) { return; } @@ -1285,7 +1280,7 @@ public class Graph { } } - if (stopPart.contains(part)) { + if (stopPart != null && stopPart.contains(part)) { return; } part.level = level; @@ -1301,16 +1296,17 @@ public class Graph { if (part.nextParts.size() == 2) { - List nps = new ArrayList<>(part.nextParts); - /*for(int i=0;i nps;/* = new ArrayList<>(part.nextParts); + for(int i=0;i stopPart2 = new ArrayList<>(stopPart); + List stopPart2 = stopPart == null ? new ArrayList<>() : new ArrayList<>(stopPart); if (next != null) { stopPart2.add(next); } @@ -1328,7 +1324,7 @@ public class Graph { GraphPart next = getNextCommonPart(localData, part, loops); for (GraphPart p : part.nextParts) { - List stopPart2 = new ArrayList<>(stopPart); + List stopPart2 = stopPart == null ? new ArrayList<>() : new ArrayList<>(stopPart); if (next != null) { stopPart2.add(next); } diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3AssemblerTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3AssemblerTest.java index 6da87244e..03df7ff69 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3AssemblerTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3AssemblerTest.java @@ -123,7 +123,7 @@ public class ActionScript3AssemblerTest extends ActionScriptTestBase { + "pushtrue\r\n" + "pop\r\n" + "label1:pushfalse\r\n"); - b.getCode().replaceInstruction(getBaseAddr() + 2, new AVM2Instruction(0, new DeobfuscatePopIns(), new int[]{}), b); + b.getCode().replaceInstruction(getBaseAddr() + 2, new AVM2Instruction(0, DeobfuscatePopIns.getInstance(), new int[]{}), b); } @Test @@ -135,6 +135,6 @@ public class ActionScript3AssemblerTest extends ActionScriptTestBase { + "jump label1\r\n" //remove this + "pop\r\n" + "label1:pushfalse\r\n"); - b.getCode().replaceInstruction(getBaseAddr() + 4, new AVM2Instruction(0, new DeobfuscatePopIns(), new int[]{}), b); + b.getCode().replaceInstruction(getBaseAddr() + 4, new AVM2Instruction(0, DeobfuscatePopIns.getInstance(), new int[]{}), b); } } diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java index 81f09eb26..88237c31a 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java @@ -22,9 +22,7 @@ import com.jpexs.decompiler.flash.abc.ClassPath; import com.jpexs.decompiler.flash.abc.ScriptPack; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.GetLocal0Ins; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ReturnVoidIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushScopeIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.abc.avm2.parser.AVM2ParseException; import com.jpexs.decompiler.flash.abc.avm2.parser.script.Reference; import com.jpexs.decompiler.flash.abc.types.ABCException; @@ -824,9 +822,9 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener();