diff --git a/src/com/jpexs/decompiler/flash/SWF.java b/src/com/jpexs/decompiler/flash/SWF.java index 3c2e5176f..4d8a9a1af 100644 --- a/src/com/jpexs/decompiler/flash/SWF.java +++ b/src/com/jpexs/decompiler/flash/SWF.java @@ -146,6 +146,7 @@ import com.jpexs.decompiler.graph.Graph; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphSourceItemContainer; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import com.jpexs.decompiler.graph.model.LocalData; import com.jpexs.helpers.Cache; import com.jpexs.helpers.CancellableWorker; @@ -1674,7 +1675,7 @@ public final class SWF implements TreeItem, Timelined { private final HashMap usageTypes = new HashMap<>(); private final Deobfuscation deobfuscation = new Deobfuscation(); - private static void getVariables(ConstantPool constantPool, BaseLocalData localData, Stack stack, List output, ActionGraphSource code, int ip, List> variables, List functions, HashMap strings, List visited, HashMap usageTypes, String path) throws InterruptedException { + private static void getVariables(ConstantPool constantPool, BaseLocalData localData, TranslateStack stack, List output, ActionGraphSource code, int ip, List> variables, List functions, HashMap strings, List visited, HashMap usageTypes, String path) throws InterruptedException { boolean debugMode = false; while ((ip > -1) && ip < code.size()) { if (visited.contains(ip)) { @@ -1821,8 +1822,7 @@ public final class SWF implements TreeItem, Timelined { visited.add(ip); List branches = ins.getBranches(code); for (int b : branches) { - @SuppressWarnings("unchecked") - Stack brStack = (Stack) stack.clone(); + TranslateStack brStack = (TranslateStack) stack.clone(); if (b >= 0) { getVariables(constantPool, localData, brStack, output, code, b, variables, functions, strings, visited, usageTypes, path); } else { @@ -1840,7 +1840,7 @@ public final class SWF implements TreeItem, Timelined { private static void getVariables(List> variables, List functions, HashMap strings, HashMap usageType, ActionGraphSource code, int addr, String path) throws InterruptedException { ActionLocalData localData = new ActionLocalData(); - getVariables(null, localData, new Stack(), new ArrayList(), code, code.adr2pos(addr), variables, functions, strings, new ArrayList(), usageType, path); + getVariables(null, localData, new TranslateStack(), new ArrayList(), code, code.adr2pos(addr), variables, functions, strings, new ArrayList(), usageType, path); } private List> getVariables(List> variables, List functions, HashMap strings, HashMap usageType, ASMSource src, String path) throws InterruptedException { diff --git a/src/com/jpexs/decompiler/flash/abc/AVM2LocalData.java b/src/com/jpexs/decompiler/flash/abc/AVM2LocalData.java index 5673dcc0e..4528827f6 100644 --- a/src/com/jpexs/decompiler/flash/abc/AVM2LocalData.java +++ b/src/com/jpexs/decompiler/flash/abc/AVM2LocalData.java @@ -1,80 +1,80 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc; - -import com.jpexs.decompiler.flash.BaseLocalData; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.types.ABCException; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -/** - * - * @author JPEXS - */ -public class AVM2LocalData extends BaseLocalData { - - public Boolean isStatic; - public Integer classIndex; - public HashMap localRegs; - public Stack scopeStack; - public ConstantPool constants; - public List methodInfo; - public MethodBody methodBody; - public ABC abc; - public HashMap localRegNames; - public List fullyQualifiedNames; - public ArrayList parsedExceptions; - public ArrayList finallyJumps; - public ArrayList ignoredSwitches; - public Integer scriptIndex; - public HashMap localRegAssignmentIps; - public Integer ip; - public HashMap> refs; - public AVM2Code code; - - public AVM2LocalData() { - - } - - public AVM2LocalData(AVM2LocalData localData) { - isStatic = localData.isStatic; - classIndex = localData.classIndex; - localRegs = localData.localRegs; - scopeStack = localData.scopeStack; - constants = localData.constants; - methodInfo = localData.methodInfo; - methodBody = localData.methodBody; - abc = localData.abc; - localRegNames = localData.localRegNames; - fullyQualifiedNames = localData.fullyQualifiedNames; - parsedExceptions = localData.parsedExceptions; - finallyJumps = localData.finallyJumps; - ignoredSwitches = localData.ignoredSwitches; - scriptIndex = localData.scriptIndex; - localRegAssignmentIps = localData.localRegAssignmentIps; - ip = localData.ip; - refs = localData.refs; - code = localData.code; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc; + +import com.jpexs.decompiler.flash.BaseLocalData; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.types.ABCException; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +/** + * + * @author JPEXS + */ +public class AVM2LocalData extends BaseLocalData { + + public Boolean isStatic; + public Integer classIndex; + public HashMap localRegs; + public ScopeStack scopeStack; + public ConstantPool constants; + public List methodInfo; + public MethodBody methodBody; + public ABC abc; + public HashMap localRegNames; + public List fullyQualifiedNames; + public ArrayList parsedExceptions; + public ArrayList finallyJumps; + public ArrayList ignoredSwitches; + public Integer scriptIndex; + public HashMap localRegAssignmentIps; + public Integer ip; + public HashMap> refs; + public AVM2Code code; + + public AVM2LocalData() { + + } + + public AVM2LocalData(AVM2LocalData localData) { + isStatic = localData.isStatic; + classIndex = localData.classIndex; + localRegs = localData.localRegs; + scopeStack = localData.scopeStack; + constants = localData.constants; + methodInfo = localData.methodInfo; + methodBody = localData.methodBody; + abc = localData.abc; + localRegNames = localData.localRegNames; + fullyQualifiedNames = localData.fullyQualifiedNames; + parsedExceptions = localData.parsedExceptions; + finallyJumps = localData.finallyJumps; + ignoredSwitches = localData.ignoredSwitches; + scriptIndex = localData.scriptIndex; + localRegAssignmentIps = localData.localRegAssignmentIps; + ip = localData.ip; + refs = localData.refs; + code = localData.code; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java b/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java index c909199d6..1ab7b56ff 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java @@ -224,7 +224,9 @@ import com.jpexs.decompiler.graph.GraphPart; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.NotCompileTimeItem; +import com.jpexs.decompiler.graph.ScopeStack; import com.jpexs.decompiler.graph.TranslateException; +import com.jpexs.decompiler.graph.TranslateStack; import com.jpexs.decompiler.graph.TypeItem; import com.jpexs.decompiler.graph.model.LocalData; import com.jpexs.decompiler.graph.model.ScriptEndItem; @@ -243,7 +245,6 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Stack; import java.util.logging.Level; import java.util.logging.Logger; @@ -1254,7 +1255,7 @@ public class AVM2Code implements Serializable { return pos2adr(fixIPAfterDebugLine(adr2pos(addr))); } - public ConvertOutput toSourceOutput(String path, GraphPart part, boolean processJumps, boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ABC abc, ConstantPool constants, List method_info, MethodBody body, int start, int end, HashMap localRegNames, List fullyQualifiedNames, boolean[] visited, HashMap localRegAssigmentIps, HashMap> refs) throws ConvertException, InterruptedException { + public ConvertOutput toSourceOutput(String path, GraphPart part, boolean processJumps, boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ABC abc, ConstantPool constants, List method_info, MethodBody body, int start, int end, HashMap localRegNames, List fullyQualifiedNames, boolean[] visited, HashMap localRegAssigmentIps, HashMap> refs) throws ConvertException, InterruptedException { boolean debugMode = DEBUG_MODE; if (debugMode) { System.out.println("OPEN SubSource:" + start + "-" + end + " " + code.get(start).toString() + " to " + code.get(end).toString()); @@ -1582,7 +1583,7 @@ public class AVM2Code implements Serializable { ignoredIns = new ArrayList<>(); } - public List toGraphTargetItems(String path, boolean isStatic, int scriptIndex, int classIndex, ABC abc, ConstantPool constants, List method_info, MethodBody body, HashMap localRegNames, Stack scopeStack, boolean isStaticInitializer, List fullyQualifiedNames, Traits initTraits, int staticOperation, HashMap localRegAssigmentIps, HashMap> refs) throws InterruptedException { + public List toGraphTargetItems(String path, boolean isStatic, int scriptIndex, int classIndex, ABC abc, ConstantPool constants, List method_info, MethodBody body, HashMap localRegNames, ScopeStack scopeStack, boolean isStaticInitializer, List fullyQualifiedNames, Traits initTraits, int staticOperation, HashMap localRegAssigmentIps, HashMap> refs) throws InterruptedException { initToSource(); List list; HashMap localRegs = new HashMap<>(); @@ -1811,7 +1812,7 @@ public class AVM2Code implements Serializable { ret.isStatic = localData.isStatic; ret.classIndex = localData.classIndex; ret.localRegs = new HashMap<>(localData.localRegs); - ret.scopeStack = (Stack) (localData.scopeStack).clone(); + ret.scopeStack = (ScopeStack) (localData.scopeStack).clone(); ret.constants = localData.constants; ret.methodInfo = localData.methodInfo; ret.methodBody = localData.methodBody; @@ -1835,7 +1836,7 @@ public class AVM2Code implements Serializable { localData.isStatic = isStatic; localData.classIndex = classIndex; localData.localRegs = new HashMap<>(); - localData.scopeStack = new Stack<>(); + localData.scopeStack = new ScopeStack(); localData.constants = abc.constants; localData.methodInfo = abc.method_info; localData.methodBody = body; @@ -1852,7 +1853,7 @@ public class AVM2Code implements Serializable { localData.refs = refs; localData.code = this; int ret = 0; - ret += removeTraps(constants, trait, info, body, localData, new AVM2GraphSource(this, false, -1, -1, new HashMap(), new Stack(), abc, body, new HashMap(), new ArrayList(), new HashMap(), refs), 0, path, refs); + ret += removeTraps(constants, trait, info, body, localData, new AVM2GraphSource(this, false, -1, -1, new HashMap(), new ScopeStack(), abc, body, new HashMap(), new ArrayList(), new HashMap(), refs), 0, path, refs); removeIgnored(constants, trait, info, body); removeDeadCode(constants, trait, info, body); @@ -2603,7 +2604,7 @@ public class AVM2Code implements Serializable { } @SuppressWarnings("unchecked") - private static int removeTraps(HashMap> refs, boolean secondPass, boolean indeterminate, AVM2LocalData localData, Stack stack, List output, AVM2GraphSource code, int ip, HashMap visited, HashMap> visitedStates, HashMap decisions, String path, int recursionLevel) throws InterruptedException { + private static int removeTraps(HashMap> refs, boolean secondPass, boolean indeterminate, AVM2LocalData localData, TranslateStack stack, List output, AVM2GraphSource code, int ip, HashMap visited, HashMap> visitedStates, HashMap decisions, String path, int recursionLevel) throws InterruptedException { if (Thread.currentThread().isInterrupted()) { throw new InterruptedException(); } @@ -2836,7 +2837,7 @@ public class AVM2Code implements Serializable { } for (int b : branches) { - Stack brStack = (Stack) stack.clone(); + TranslateStack brStack = (TranslateStack) stack.clone(); if (b >= 0) { //useVisited || (!ins.isJump()) ret += removeTraps(refs, secondPass, indeterminate, prepareBranchLocalData(localData), brStack, output, code, b, visited, visitedStates, decisions, path, recursionLevel + 1); } else { @@ -2858,7 +2859,7 @@ public class AVM2Code implements Serializable { public static int removeTraps(ConstantPool constants, Trait trait, MethodInfo info, MethodBody body, AVM2LocalData localData, AVM2GraphSource code, int addr, String path, HashMap> refs) throws InterruptedException { HashMap decisions = new HashMap<>(); - removeTraps(refs, false, false, localData, new Stack(), new ArrayList(), code, code.adr2pos(addr), new HashMap(), new HashMap>(), decisions, path, 0); + removeTraps(refs, false, false, localData, new TranslateStack(), new ArrayList(), code, code.adr2pos(addr), new HashMap(), new HashMap>(), decisions, path, 0); int cnt = 0; for (AVM2Instruction src : decisions.keySet()) { Decision dec = decisions.get(src); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/ConvertOutput.java b/src/com/jpexs/decompiler/flash/abc/avm2/ConvertOutput.java index 79250658f..4495dd548 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/ConvertOutput.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/ConvertOutput.java @@ -1,36 +1,36 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2; - -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.List; -import java.util.Stack; - -/** - * - * @author JPEXS - */ -public class ConvertOutput { - - public Stack stack; - public List output; - - public ConvertOutput(Stack stack, List output) { - this.stack = stack; - this.output = output; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2; + +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; +import java.util.List; + +/** + * + * @author JPEXS + */ +public class ConvertOutput { + + public TranslateStack stack; + public List output; + + public ConvertOutput(TranslateStack stack, List output) { + this.stack = stack; + this.output = output; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/UnknownJumpException.java b/src/com/jpexs/decompiler/flash/abc/avm2/UnknownJumpException.java index 99e5f77a1..e830a176b 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/UnknownJumpException.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/UnknownJumpException.java @@ -1,39 +1,39 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2; - -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.List; -import java.util.Stack; - -public class UnknownJumpException extends RuntimeException { - - public Stack stack; - public int ip; - public List output; - - public UnknownJumpException(Stack stack, int ip, List output) { - this.stack = stack; - this.ip = ip; - this.output = output; - } - - @Override - public String toString() { - return "Unknown jump to " + ip; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2; + +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; +import java.util.List; + +public class UnknownJumpException extends RuntimeException { + + public TranslateStack stack; + public int ip; + public List output; + + public UnknownJumpException(TranslateStack stack, int ip, List output) { + this.stack = stack; + this.ip = ip; + this.output = output; + } + + @Override + public String toString() { + return "Unknown jump to " + ip; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java b/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java index f5e32ad50..120209c7f 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java @@ -1,813 +1,814 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.graph; - -import com.jpexs.decompiler.flash.BaseLocalData; -import com.jpexs.decompiler.flash.FinalProcessLocalData; -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.AVM2LocalData; -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.jumps.IfStrictEqIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfStrictNeIns; -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.GetLocalTypeIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.KillIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ReturnValueIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushIntegerTypeIns; -import com.jpexs.decompiler.flash.abc.avm2.model.FilteredCheckAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.HasNextAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.InAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.NextNameAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.NextValueAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.NullAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.ReturnValueAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.ReturnVoidAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.SetLocalAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.SetPropertyAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.SetTypeAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.WithAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.clauses.ExceptionAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.clauses.FilterAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.clauses.ForEachInAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.clauses.ForInAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.clauses.TryAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.StrictEqAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.StrictNeqAVM2Item; -import com.jpexs.decompiler.flash.abc.types.ABCException; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.ecma.EcmaScript; -import com.jpexs.decompiler.graph.Graph; -import com.jpexs.decompiler.graph.GraphPart; -import com.jpexs.decompiler.graph.GraphPartMulti; -import com.jpexs.decompiler.graph.GraphSource; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.decompiler.graph.Loop; -import com.jpexs.decompiler.graph.model.BreakItem; -import com.jpexs.decompiler.graph.model.IfItem; -import com.jpexs.decompiler.graph.model.LoopItem; -import com.jpexs.decompiler.graph.model.NotItem; -import com.jpexs.decompiler.graph.model.SwitchItem; -import com.jpexs.decompiler.graph.model.WhileItem; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -/** - * - * @author JPEXS - */ -public class AVM2Graph extends Graph { - - private final AVM2Code avm2code; - private final ABC abc; - private final MethodBody body; - - public AVM2Code getCode() { - return avm2code; - } - - public AVM2Graph(AVM2Code code, ABC abc, MethodBody body, boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack scopeStack, HashMap localRegNames, List fullyQualifiedNames, HashMap localRegAssigmentIps, HashMap> refs) { - super(new AVM2GraphSource(code, isStatic, scriptIndex, classIndex, localRegs, scopeStack, abc, body, localRegNames, fullyQualifiedNames, localRegAssigmentIps, refs), body.getExceptionEntries()); - this.avm2code = code; - this.abc = abc; - this.body = body; - /*heads = makeGraph(code, new ArrayList(), body); - this.code = code; - this.abc = abc; - this.body = body; - for (GraphPart head : heads) { - fixGraph(head); - makeMulti(head, new ArrayList()); - }*/ - - } - - public static List translateViaGraph(String path, AVM2Code code, ABC abc, MethodBody body, boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack scopeStack, HashMap localRegNames, List fullyQualifiedNames, int staticOperation, HashMap localRegAssigmentIps, HashMap> refs) throws InterruptedException { - AVM2Graph g = new AVM2Graph(code, abc, body, isStatic, scriptIndex, classIndex, localRegs, scopeStack, localRegNames, fullyQualifiedNames, localRegAssigmentIps, refs); - - AVM2LocalData localData = new AVM2LocalData(); - localData.isStatic = isStatic; - localData.classIndex = classIndex; - localData.localRegs = localRegs; - localData.scopeStack = scopeStack; - localData.constants = abc.constants; - localData.methodInfo = abc.method_info; - localData.methodBody = body; - localData.abc = abc; - localData.localRegNames = localRegNames; - localData.fullyQualifiedNames = fullyQualifiedNames; - localData.parsedExceptions = new ArrayList<>(); - localData.finallyJumps = new ArrayList<>(); - localData.ignoredSwitches = new ArrayList<>(); - localData.scriptIndex = scriptIndex; - localData.localRegAssignmentIps = new HashMap<>(); - localData.ip = 0; - localData.refs = refs; - localData.code = code; - g.init(localData); - List allParts = new ArrayList<>(); - for (GraphPart head : g.heads) { - populateParts(head, allParts); - } - return g.translate(localData, staticOperation, path); - } - - @Override - protected void checkGraph(List allBlocks) { - for (ABCException ex : body.exceptions) { - int startIp = avm2code.adr2pos(ex.start); - int endIp = avm2code.adr2pos(ex.end); - int targetIp = avm2code.adr2pos(ex.target); - GraphPart target = null; - for (GraphPart p : allBlocks) { - if (p.start == targetIp) { - target = p; - break; - } - } - for (GraphPart p : allBlocks) { - if (p.start >= startIp && p.end <= endIp) { - p.throwParts.add(target); - target.refs.add(p); - } - } - } - - /*for(ABCException ex:body.exceptions){ - for(GraphPart p:allBlocks){ - boolean next_is_ex_start=false; - for(GraphPart n:p.nextParts){ - if(n.start==code.adr2pos(ex.start)){ - next_is_ex_start = true; - break; - } - } - if(next_is_ex_start){ - for(GraphPart q:allBlocks){ //find target part - if(q.start==code.adr2pos(ex.target)){ - p.nextParts.add(q); - break; - } - } - } - } - }*/ - } - - @Override - protected List check(GraphSource code, BaseLocalData localData, List allParts, Stack stack, GraphPart parent, GraphPart part, List stopPart, List loops, List output, Loop currentLoop, int staticOperation, String path) throws InterruptedException { - List ret = null; - - AVM2LocalData aLocalData = (AVM2LocalData) localData; - List parsedExceptions = aLocalData.parsedExceptions; - List finallyJumps = aLocalData.finallyJumps; - List ignoredSwitches = aLocalData.ignoredSwitches; - int ip = part.start; - int addr = this.avm2code.fixAddrAfterDebugLine(this.avm2code.pos2adr(part.start)); - int maxend = -1; - List catchedExceptions = new ArrayList<>(); - for (int e = 0; e < body.exceptions.length; e++) { - if (addr == this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].start)) { - if (!body.exceptions[e].isFinally()) { - if (((body.exceptions[e].end) > maxend) && (!parsedExceptions.contains(body.exceptions[e]))) { - catchedExceptions.clear(); - maxend = this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].end); - catchedExceptions.add(body.exceptions[e]); - } else if (this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].end) == maxend) { - catchedExceptions.add(body.exceptions[e]); - } - } - } - } - if (catchedExceptions.size() > 0) { - /*if (currentLoop != null) { - //currentLoop.phase=0; - }*/ - parsedExceptions.addAll(catchedExceptions); - int endpos = code.adr2pos(this.avm2code.fixAddrAfterDebugLine(catchedExceptions.get(0).end)); - int endposStartBlock = code.adr2pos(catchedExceptions.get(0).end); - - List> catchedCommands = new ArrayList<>(); - if (this.avm2code.code.get(endpos).definition instanceof JumpIns) { - int afterCatchAddr = this.avm2code.pos2adr(endpos + 1) + this.avm2code.code.get(endpos).operands[0]; - int afterCatchPos = this.avm2code.adr2pos(afterCatchAddr); - final AVM2Graph t = this; - Collections.sort(catchedExceptions, new Comparator() { - @Override - public int compare(ABCException o1, ABCException o2) { - return t.avm2code.fixAddrAfterDebugLine(o1.target) - t.avm2code.fixAddrAfterDebugLine(o2.target); - } - }); - - List finallyCommands = new ArrayList<>(); - int returnPos = afterCatchPos; - for (int e = 0; e < body.exceptions.length; e++) { - if (body.exceptions[e].isFinally()) { - if (addr == this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].start)) { - if (afterCatchPos + 1 == code.adr2pos(this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].end))) { - AVM2Instruction jmpIns = this.avm2code.code.get(code.adr2pos(this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].end))); - - if (jmpIns.definition instanceof JumpIns) { - int finStart = code.adr2pos(this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].end) + jmpIns.getBytes().length + jmpIns.operands[0]); - - GraphPart fpart = null; - for (GraphPart p : allParts) { - if (p.start == finStart) { - fpart = p; - break; - } - } - int swPos = -1; - for (int f = finStart; f < this.avm2code.code.size(); f++) { - if (this.avm2code.code.get(f).definition instanceof LookupSwitchIns) { - AVM2Instruction swins = this.avm2code.code.get(f); - if (swins.operands.length >= 3) { - if (swins.operands[0] == swins.getBytes().length) { - if (code.adr2pos(code.pos2adr(f) + swins.operands[2]) < finStart) { - stack.push(new ExceptionAVM2Item(body.exceptions[e])); - GraphPart fepart = null; - for (GraphPart p : allParts) { - if (p.start == f + 1) { - fepart = p; - break; - } - } - //this.code.code.get(f).ignored = true; - //ignoredSwitches.add(f); - swPos = f; - - List stopPart2 = new ArrayList<>(stopPart); - stopPart2.add(fepart); - //finallyCommands = printGraph(new ArrayList(), localData, stack, allParts, parent, fpart, stopPart2, loops, staticOperation, path); - returnPos = f + 1; - break; - } - } - } - } - } - //ignoredSwitches.add(-1); - //int igs_size=ignoredSwitches.size(); - List oldFinallyJumps = new ArrayList<>(finallyJumps); - finallyJumps.clear(); - ignoredSwitches.add(swPos); - finallyCommands = printGraph(localData, stack, allParts, parent, fpart, null, loops, staticOperation, path); - //ignoredSwitches.remove(igs_size-1); - finallyJumps.addAll(oldFinallyJumps); - finallyJumps.add(finStart); - break; - } - } - } - } - } - - GraphPart retPart = null; - for (GraphPart p : allParts) { - if (p.start == returnPos) { - retPart = p; - break; - } - } - List catchParts = new ArrayList<>(); - for (int e = 0; e < catchedExceptions.size(); e++) { - int eendpos; - if (e < catchedExceptions.size() - 1) { - eendpos = code.adr2pos(this.avm2code.fixAddrAfterDebugLine(catchedExceptions.get(e + 1).target)) - 2; - } else { - eendpos = afterCatchPos - 1; - } - - GraphPart npart = null; - int findpos = code.adr2pos(catchedExceptions.get(e).target); - for (GraphPart p : allParts) { - if (p.start == findpos) { - npart = p; - catchParts.add(p); - break; - } - } - - GraphPart nepart = null; - for (GraphPart p : allParts) { - if (p.start == eendpos + 1) { - nepart = p; - break; - } - } - stack.add(new ExceptionAVM2Item(catchedExceptions.get(e))); - AVM2LocalData localData2 = new AVM2LocalData(aLocalData); - localData2.scopeStack = new Stack<>(); - List stopPart2 = new ArrayList<>(stopPart); - stopPart2.add(nepart); - if (retPart != null) { - stopPart2.add(retPart); - } - catchedCommands.add(printGraph(localData2, stack, allParts, parent, npart, stopPart2, loops, staticOperation, path)); - } - - GraphPart nepart = null; - - for (GraphPart p : allParts) { - if (p.start == endposStartBlock) { - nepart = p; - break; - } - } - List stopPart2 = new ArrayList<>(stopPart); - stopPart2.add(nepart); - stopPart2.addAll(catchParts); - - if (retPart != null) { - stopPart2.add(retPart); - } - List tryCommands = printGraph(localData, stack, allParts, parent, part, stopPart2, loops, staticOperation, path); - - output.clear(); - output.add(new TryAVM2Item(tryCommands, catchedExceptions, catchedCommands, finallyCommands)); - ip = returnPos; - } - - } - - if (ip != part.start) { - part = null; - for (GraphPart p : allParts) { - List ps = p.getSubParts(); - for (GraphPart p2 : ps) { - if (p2.start == ip) { - part = p2; - break; - } - } - } - ret = new ArrayList<>(); - ret.addAll(output); - GraphTargetItem lop = checkLoop(part, stopPart, loops); - if (lop == null) { - ret.addAll(printGraph(localData, stack, allParts, null, part, stopPart, loops, staticOperation, path)); - } else { - ret.add(lop); - } - return ret; - } - - if (part.nextParts.isEmpty()) { - if (this.avm2code.code.get(part.end).definition instanceof ReturnValueIns) { //returns in finally clause - if (part.getHeight() >= 3) { - if (this.avm2code.code.get(part.getPosAt(part.getHeight() - 2)).definition instanceof KillIns) { - if (this.avm2code.code.get(part.getPosAt(part.getHeight() - 3)).definition instanceof GetLocalTypeIns) { - if (output.size() >= 2) { - if (output.get(output.size() - 2) instanceof SetLocalAVM2Item) { - ret = new ArrayList<>(); - ret.addAll(output); - ret.remove(ret.size() - 1); - ret.add(new ReturnValueAVM2Item(this.avm2code.code.get(part.end), ((SetLocalAVM2Item) output.get(output.size() - 2)).value)); - return ret; - } - } - } - } - } - } - } - if ((this.avm2code.code.get(part.end).definition instanceof LookupSwitchIns) && ignoredSwitches.contains(part.end)) { - ret = new ArrayList<>(); - ret.addAll(output); - return ret; - } - if (((part.nextParts.size() == 2) - && (!stack.isEmpty()) - && (stack.peek() instanceof StrictEqAVM2Item) - && (part.nextParts.get(0).getHeight() >= 2) - && (this.avm2code.code.get(this.avm2code.fixIPAfterDebugLine(part.nextParts.get(0).start)).definition instanceof PushIntegerTypeIns) - && (!part.nextParts.get(0).nextParts.isEmpty()) - && (this.avm2code.code.get(part.nextParts.get(0).nextParts.get(0).end).definition instanceof LookupSwitchIns)) - || ((part.nextParts.size() == 2) - && (!stack.isEmpty()) - && (stack.peek() instanceof StrictNeqAVM2Item) - && (part.nextParts.get(1).getHeight() >= 2) - && (this.avm2code.code.get(this.avm2code.fixIPAfterDebugLine(part.nextParts.get(1).start)).definition instanceof PushIntegerTypeIns) - && (!part.nextParts.get(1).nextParts.isEmpty()) - && (this.avm2code.code.get(part.nextParts.get(1).nextParts.get(0).end).definition instanceof LookupSwitchIns))) { - - if (stack.peek() instanceof StrictEqAVM2Item) { - ignoredSwitches.add(part.nextParts.get(0).nextParts.get(0).end); - } else { - ignoredSwitches.add(part.nextParts.get(1).nextParts.get(0).end); - } - ret = new ArrayList<>(); - ret.addAll(output); - boolean reversed = false; - if (stack.peek() instanceof StrictEqAVM2Item) { - reversed = true; - } - GraphTargetItem switchedObject = null; - if (!output.isEmpty()) { - if (output.get(output.size() - 1) instanceof SetLocalAVM2Item) { - switchedObject = ((SetLocalAVM2Item) output.get(output.size() - 1)).value; - } - } - if (switchedObject == null) { - switchedObject = new NullAVM2Item(null); - } - HashMap caseValuesMap = new HashMap<>(); - - GraphTargetItem tar = stack.pop(); - if (tar instanceof StrictEqAVM2Item) { - tar = ((StrictEqAVM2Item) tar).leftSide; - } - if (tar instanceof StrictNeqAVM2Item) { - tar = ((StrictNeqAVM2Item) tar).leftSide; - } - caseValuesMap.put(this.avm2code.code.get(part.nextParts.get(reversed ? 0 : 1).start).operands[0], tar); - - GraphPart switchLoc = part.nextParts.get(reversed ? 0 : 1).nextParts.get(0); - - while ((this.avm2code.code.get(part.nextParts.get(reversed ? 1 : 0).end).definition instanceof IfStrictNeIns) - || (this.avm2code.code.get(part.nextParts.get(reversed ? 1 : 0).end).definition instanceof IfStrictEqIns)) { - part = part.nextParts.get(reversed ? 1 : 0); - translatePart(localData, part, stack, staticOperation, null); - tar = stack.pop(); - if (tar instanceof StrictEqAVM2Item) { - tar = ((StrictEqAVM2Item) tar).leftSide; - } - if (tar instanceof StrictNeqAVM2Item) { - tar = ((StrictNeqAVM2Item) tar).leftSide; - } - if (this.avm2code.code.get(part.end).definition instanceof IfStrictNeIns) { - reversed = false; - } else { - reversed = true; - } - GraphPart numPart = part.nextParts.get(reversed ? 0 : 1); - AVM2Instruction ins = null; - Stack sstack = new Stack<>(); - do { - for (int n = 0; n < numPart.getHeight(); n++) { - ins = this.avm2code.code.get(numPart.getPosAt(n)); - if (ins.definition instanceof LookupSwitchIns) { - break; - } - ins.translate(localData, sstack, new ArrayList(), staticOperation, path); - } - if (numPart.nextParts.size() > 1) { - break; - } else { - numPart = numPart.nextParts.get(0); - } - } while (!(this.avm2code.code.get(numPart.end).definition instanceof LookupSwitchIns)); - GraphTargetItem nt = sstack.peek(); - - if (!(nt instanceof IntegerValueAVM2Item)) { - throw new RuntimeException("Invalid integer value in Switch"); - } - IntegerValueAVM2Item iv = (IntegerValueAVM2Item) nt; - caseValuesMap.put((int) (long) iv.value, tar); - while (this.avm2code.code.get(part.nextParts.get(reversed ? 1 : 0).start).definition instanceof JumpIns) { - reversed = false; - part = part.nextParts.get(reversed ? 1 : 0); - if (part instanceof GraphPartMulti) { - part = ((GraphPartMulti) part).parts.get(0); - } - } - } - boolean hasDefault = false; - GraphPart dp = part.nextParts.get(reversed ? 1 : 0); - while (this.avm2code.code.get(dp.start).definition instanceof JumpIns) { - if (dp instanceof GraphPartMulti) { - dp = ((GraphPartMulti) dp).parts.get(0); - } - dp = dp.nextParts.get(0); - } - - GraphPart numPart = dp; - AVM2Instruction ins = null; - Stack sstack = new Stack<>(); - do { - for (int n = 0; n < numPart.getHeight(); n++) { - ins = this.avm2code.code.get(numPart.getPosAt(n)); - if (ins.definition instanceof LookupSwitchIns) { - break; - } - ins.translate(localData, sstack, new ArrayList(), staticOperation, path); - } - if (numPart.nextParts.size() > 1) { - break; - } else { - numPart = numPart.nextParts.get(0); - } - } while (!(this.avm2code.code.get(numPart.end).definition instanceof LookupSwitchIns)); - GraphTargetItem nt = sstack.peek(); - if (nt instanceof IntegerValueAVM2Item) { - hasDefault = true; - } - List caseValues = new ArrayList<>(); - for (int i = 0; i < switchLoc.nextParts.size() - 1; i++) { - if (caseValuesMap.containsKey(i)) { - caseValues.add(caseValuesMap.get(i)); - } else { - continue; - } - } - - List> caseCommands = new ArrayList<>(); - GraphPart next = null; - - next = getMostCommonPart(localData, switchLoc.nextParts, loops);//getNextPartPath(loopContinues); - currentLoop = new Loop(loops.size(), null, next); - currentLoop.phase = 1; - loops.add(currentLoop); - //switchLoc.getNextPartPath(new ArrayList()); - List valuesMapping = new ArrayList<>(); - List caseBodies = new ArrayList<>(); - for (int i = 0; i < caseValues.size(); i++) { - GraphPart cur = switchLoc.nextParts.get(1 + i); - if (!caseBodies.contains(cur)) { - caseBodies.add(cur); - } - valuesMapping.add(caseBodies.indexOf(cur)); - } - - List defaultCommands = new ArrayList<>(); - GraphPart defaultPart = null; - if (hasDefault) { - defaultPart = switchLoc.nextParts.get(switchLoc.nextParts.size() - 1); - List stopPart2 = new ArrayList<>(stopPart); - stopPart2.add(next); - defaultCommands = printGraph(localData, stack, allParts, switchLoc, defaultPart, stopPart2, loops, staticOperation, path); - if (!defaultCommands.isEmpty()) { - if (defaultCommands.get(defaultCommands.size() - 1) instanceof BreakItem) { - if (((BreakItem) defaultCommands.get(defaultCommands.size() - 1)).loopId == currentLoop.id) { - defaultCommands.remove(defaultCommands.size() - 1); - } - } - } - } - - List ignored = new ArrayList<>(); - for (Loop l : loops) { - ignored.add(l.loopContinue); - } - - for (int i = 0; i < caseBodies.size(); i++) { - List cc = new ArrayList<>(); - List stopPart2 = new ArrayList<>(stopPart); - for (int j = 0; j < caseBodies.size(); j++) { - if (caseBodies.get(j) != caseBodies.get(i)) { - stopPart2.add(caseBodies.get(j)); - } - } - if (hasDefault) { - stopPart2.add(defaultPart); - } - - cc.addAll(0, printGraph(localData, stack, allParts, switchLoc, caseBodies.get(i), stopPart2, loops, staticOperation, path)); - caseCommands.add(cc); - } - - SwitchItem sti = new SwitchItem(null, currentLoop, switchedObject, caseValues, caseCommands, defaultCommands, valuesMapping); - ret.add(sti); - //loops.remove(currentLoop); - if (next != null) { - /*if (ti != null) { - ret.add(ti); - } else {*/ - currentLoop.phase = 2; - ret.addAll(printGraph(localData, stack, allParts, null, next, stopPart, loops, staticOperation, path)); - //} - } - } - return ret; - } - - @Override - protected GraphPart checkPart(Stack stack, BaseLocalData localData, GraphPart next, List allParts) { - AVM2LocalData aLocalData = (AVM2LocalData) localData; - List finallyJumps = aLocalData.finallyJumps; - List ignoredSwitches = aLocalData.ignoredSwitches; - GraphPart ret = next; - for (int f = 0; f < finallyJumps.size(); f++) { - int fip = finallyJumps.get(f); - int swip = ignoredSwitches.get(f); - if (next.start == fip) { - if (stack != null && swip != -1) { - AVM2Instruction swIns = avm2code.code.get(swip); - GraphTargetItem t = stack.pop(); - Double dval = EcmaScript.toNumber(t.getResult()); - int val = (int) (double) dval; - if (swIns.definition instanceof LookupSwitchIns) { - List branches = swIns.getBranches(code); - int nip = branches.get(0); - if (val >= 0 && val < branches.size() - 1) { - nip = branches.get(1 + val); - } - for (GraphPart p : allParts) { - if (p.start == nip) { - return p; - } - } - ret = null; - } - } - ret = null; - } - } - if (ret != next) { - return ret; - } - - int pos = next.start; - int addr = this.avm2code.fixAddrAfterDebugLine(avm2code.pos2adr(pos)); - for (int e = 0; e < body.exceptions.length; e++) { - if (body.exceptions[e].isFinally()) { - if (addr == this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].start)) { - if (true) { //afterCatchPos + 1 == code.adr2pos(this.code.fixAddrAfterDebugLine(body.exceptions[e].end))) { - AVM2Instruction jmpIns = this.avm2code.code.get(avm2code.adr2pos(this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].end))); - if (jmpIns.definition instanceof JumpIns) { - int finStart = avm2code.adr2pos(this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].end) + jmpIns.getBytes().length + jmpIns.operands[0]); - finallyJumps.add(finStart); - ignoredSwitches.add(-1); - break; - } - } - } - } - } - - return next; - } - - @Override - protected GraphTargetItem checkLoop(LoopItem loopItem, BaseLocalData localData, List loops) { - AVM2LocalData aLocalData = (AVM2LocalData) localData; - if (loopItem instanceof WhileItem) { - WhileItem w = (WhileItem) loopItem; - - if ((!w.expression.isEmpty()) && (w.expression.get(w.expression.size() - 1) instanceof HasNextAVM2Item)) { - if (((HasNextAVM2Item) w.expression.get(w.expression.size() - 1)).collection != null) { - if (((HasNextAVM2Item) w.expression.get(w.expression.size() - 1)).collection.getNotCoerced().getThroughRegister() instanceof FilteredCheckAVM2Item) { - //GraphTargetItem gti = ((HasNextAVM2Item) ((HasNextAVM2Item) w.expression.get(w.expression.size() - 1))).collection.getNotCoerced().getThroughRegister(); - if (w.commands.size() >= 3) { //((w.commands.size() == 3) || (w.commands.size() == 4)) { - int pos = 0; - while (w.commands.get(pos) instanceof SetLocalAVM2Item) { - pos++; - } - GraphTargetItem ft = w.commands.get(pos); - if (ft instanceof WithAVM2Item) { - ft = w.commands.get(pos + 1); - if (ft instanceof IfItem) { - IfItem ift = (IfItem) ft; - if (ift.onTrue.size() > 0) { - ft = ift.onTrue.get(0); - if (ft instanceof SetPropertyAVM2Item) { - SetPropertyAVM2Item spt = (SetPropertyAVM2Item) ft; - if (spt.object instanceof LocalRegAVM2Item) { - int regIndex = ((LocalRegAVM2Item) spt.object).regIndex; - HasNextAVM2Item iti = (HasNextAVM2Item) w.expression.get(w.expression.size() - 1); - HashMap localRegs = aLocalData.localRegs; - localRegs.put(regIndex, new FilterAVM2Item(null, iti.collection.getThroughRegister(), ift.expression)); - return null; - } - } - } - } - } - } - } else if (!w.commands.isEmpty()) { - if (w.commands.get(0) instanceof SetTypeAVM2Item) { - SetTypeAVM2Item sti = (SetTypeAVM2Item) w.commands.remove(0); - GraphTargetItem gti = sti.getValue().getNotCoerced(); - if (gti instanceof NextValueAVM2Item) { - return new ForEachInAVM2Item(w.src, w.loop, new InAVM2Item(null, sti.getObject(), ((HasNextAVM2Item) w.expression.get(w.expression.size() - 1)).collection), w.commands); - } else if (gti instanceof NextNameAVM2Item) { - return new ForInAVM2Item(w.src, w.loop, new InAVM2Item(null, sti.getObject(), ((HasNextAVM2Item) w.expression.get(w.expression.size() - 1)).collection), w.commands); - } - } - } - } - } - } - return loopItem; - } - - @Override - protected void finalProcess(List list, int level, FinalProcessLocalData localData) { - if (level == 0) { - if (!list.isEmpty()) { - if (list.get(list.size() - 1) instanceof ReturnVoidAVM2Item) { - list.remove(list.size() - 1); - } - } - } - - /*for (int i = 0; i < list.size(); i++) { - - if (list.get(i) instanceof WhileItem) { - WhileItem w = (WhileItem) list.get(i); - - } - }*/ - List ret = avm2code.clearTemporaryRegisters(list); - if (ret != list) { - list.clear(); - list.addAll(ret); - } - for (int i = 0; i < list.size(); i++) { - if (list.get(i) instanceof SetTypeAVM2Item) { - if (((SetTypeAVM2Item) list.get(i)).getValue() instanceof ExceptionAVM2Item) { - list.remove(i); - i--; - continue; - } - } - if (list.get(i) instanceof IfItem) { - IfItem ifi = (IfItem) list.get(i); - if (((ifi.expression instanceof HasNextAVM2Item) - || ((ifi.expression instanceof NotItem) - && (((NotItem) ifi.expression).getOriginal() instanceof HasNextAVM2Item)))) { - HasNextAVM2Item hnt = null; - List body = new ArrayList<>(); - List nextbody = new ArrayList<>(); - if (ifi.expression instanceof NotItem) { - hnt = (HasNextAVM2Item) ((NotItem) ifi.expression).getOriginal(); - body.addAll(ifi.onFalse); - for (int j = i + 1; j < list.size();) { - body.add(list.remove(i + 1)); - } - nextbody = ifi.onTrue; - } else { - hnt = (HasNextAVM2Item) ifi.expression; - body = ifi.onTrue; - nextbody = ifi.onFalse; - } - if (!body.isEmpty()) { - if (body.get(0) instanceof SetTypeAVM2Item) { - SetTypeAVM2Item sti = (SetTypeAVM2Item) body.remove(0); - GraphTargetItem gti = sti.getValue().getNotCoerced(); - GraphTargetItem repl = null; - - if (gti instanceof NextValueAVM2Item) { - repl = new ForEachInAVM2Item(ifi.src, new Loop(0, null, null), new InAVM2Item(null, sti.getObject(), hnt.collection), body); - } else if (gti instanceof NextNameAVM2Item) { - repl = new ForInAVM2Item(ifi.src, new Loop(0, null, null), new InAVM2Item(null, sti.getObject(), hnt.collection), body); - } - if (repl != null) { - list.remove(i); - list.add(i, repl); - list.addAll(i + 1, nextbody); - } - } - } - } - } - } - } - - @Override - protected boolean isEmpty(List output) { - if (super.isEmpty(output)) { - return true; - } - for (GraphTargetItem i : output) { - if (i instanceof SetLocalAVM2Item) { - if (avm2code.isKilled(((SetLocalAVM2Item) i).regIndex, 0, avm2code.code.size() - 1)) { - continue; - } - } - return false; - } - return true; - } - - @Override - public AVM2LocalData prepareBranchLocalData(BaseLocalData localData) { - AVM2LocalData aLocalData = (AVM2LocalData) localData; - AVM2LocalData ret = new AVM2LocalData(aLocalData); - Stack copyScopeStack = new Stack<>(); - copyScopeStack.addAll(ret.scopeStack); - ret.scopeStack = copyScopeStack; - return ret; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.graph; + +import com.jpexs.decompiler.flash.BaseLocalData; +import com.jpexs.decompiler.flash.FinalProcessLocalData; +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.AVM2LocalData; +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.jumps.IfStrictEqIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfStrictNeIns; +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.GetLocalTypeIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.KillIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ReturnValueIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushIntegerTypeIns; +import com.jpexs.decompiler.flash.abc.avm2.model.FilteredCheckAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.HasNextAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.InAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.NextNameAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.NextValueAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.NullAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.ReturnValueAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.ReturnVoidAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.SetLocalAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.SetPropertyAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.SetTypeAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.WithAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.clauses.ExceptionAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.clauses.FilterAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.clauses.ForEachInAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.clauses.ForInAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.clauses.TryAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.StrictEqAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.StrictNeqAVM2Item; +import com.jpexs.decompiler.flash.abc.types.ABCException; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.ecma.EcmaScript; +import com.jpexs.decompiler.graph.Graph; +import com.jpexs.decompiler.graph.GraphPart; +import com.jpexs.decompiler.graph.GraphPartMulti; +import com.jpexs.decompiler.graph.GraphSource; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.Loop; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; +import com.jpexs.decompiler.graph.model.BreakItem; +import com.jpexs.decompiler.graph.model.IfItem; +import com.jpexs.decompiler.graph.model.LoopItem; +import com.jpexs.decompiler.graph.model.NotItem; +import com.jpexs.decompiler.graph.model.SwitchItem; +import com.jpexs.decompiler.graph.model.WhileItem; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; + +/** + * + * @author JPEXS + */ +public class AVM2Graph extends Graph { + + private final AVM2Code avm2code; + private final ABC abc; + private final MethodBody body; + + public AVM2Code getCode() { + return avm2code; + } + + public AVM2Graph(AVM2Code code, ABC abc, MethodBody body, boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, ScopeStack scopeStack, HashMap localRegNames, List fullyQualifiedNames, HashMap localRegAssigmentIps, HashMap> refs) { + super(new AVM2GraphSource(code, isStatic, scriptIndex, classIndex, localRegs, scopeStack, abc, body, localRegNames, fullyQualifiedNames, localRegAssigmentIps, refs), body.getExceptionEntries()); + this.avm2code = code; + this.abc = abc; + this.body = body; + /*heads = makeGraph(code, new ArrayList(), body); + this.code = code; + this.abc = abc; + this.body = body; + for (GraphPart head : heads) { + fixGraph(head); + makeMulti(head, new ArrayList()); + }*/ + + } + + public static List translateViaGraph(String path, AVM2Code code, ABC abc, MethodBody body, boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, ScopeStack scopeStack, HashMap localRegNames, List fullyQualifiedNames, int staticOperation, HashMap localRegAssigmentIps, HashMap> refs) throws InterruptedException { + AVM2Graph g = new AVM2Graph(code, abc, body, isStatic, scriptIndex, classIndex, localRegs, scopeStack, localRegNames, fullyQualifiedNames, localRegAssigmentIps, refs); + + AVM2LocalData localData = new AVM2LocalData(); + localData.isStatic = isStatic; + localData.classIndex = classIndex; + localData.localRegs = localRegs; + localData.scopeStack = scopeStack; + localData.constants = abc.constants; + localData.methodInfo = abc.method_info; + localData.methodBody = body; + localData.abc = abc; + localData.localRegNames = localRegNames; + localData.fullyQualifiedNames = fullyQualifiedNames; + localData.parsedExceptions = new ArrayList<>(); + localData.finallyJumps = new ArrayList<>(); + localData.ignoredSwitches = new ArrayList<>(); + localData.scriptIndex = scriptIndex; + localData.localRegAssignmentIps = new HashMap<>(); + localData.ip = 0; + localData.refs = refs; + localData.code = code; + g.init(localData); + List allParts = new ArrayList<>(); + for (GraphPart head : g.heads) { + populateParts(head, allParts); + } + return g.translate(localData, staticOperation, path); + } + + @Override + protected void checkGraph(List allBlocks) { + for (ABCException ex : body.exceptions) { + int startIp = avm2code.adr2pos(ex.start); + int endIp = avm2code.adr2pos(ex.end); + int targetIp = avm2code.adr2pos(ex.target); + GraphPart target = null; + for (GraphPart p : allBlocks) { + if (p.start == targetIp) { + target = p; + break; + } + } + for (GraphPart p : allBlocks) { + if (p.start >= startIp && p.end <= endIp) { + p.throwParts.add(target); + target.refs.add(p); + } + } + } + + /*for(ABCException ex:body.exceptions){ + for(GraphPart p:allBlocks){ + boolean next_is_ex_start=false; + for(GraphPart n:p.nextParts){ + if(n.start==code.adr2pos(ex.start)){ + next_is_ex_start = true; + break; + } + } + if(next_is_ex_start){ + for(GraphPart q:allBlocks){ //find target part + if(q.start==code.adr2pos(ex.target)){ + p.nextParts.add(q); + break; + } + } + } + } + }*/ + } + + @Override + protected List check(GraphSource code, BaseLocalData localData, List allParts, TranslateStack stack, GraphPart parent, GraphPart part, List stopPart, List loops, List output, Loop currentLoop, int staticOperation, String path) throws InterruptedException { + List ret = null; + + AVM2LocalData aLocalData = (AVM2LocalData) localData; + List parsedExceptions = aLocalData.parsedExceptions; + List finallyJumps = aLocalData.finallyJumps; + List ignoredSwitches = aLocalData.ignoredSwitches; + int ip = part.start; + int addr = this.avm2code.fixAddrAfterDebugLine(this.avm2code.pos2adr(part.start)); + int maxend = -1; + List catchedExceptions = new ArrayList<>(); + for (int e = 0; e < body.exceptions.length; e++) { + if (addr == this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].start)) { + if (!body.exceptions[e].isFinally()) { + if (((body.exceptions[e].end) > maxend) && (!parsedExceptions.contains(body.exceptions[e]))) { + catchedExceptions.clear(); + maxend = this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].end); + catchedExceptions.add(body.exceptions[e]); + } else if (this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].end) == maxend) { + catchedExceptions.add(body.exceptions[e]); + } + } + } + } + if (catchedExceptions.size() > 0) { + /*if (currentLoop != null) { + //currentLoop.phase=0; + }*/ + parsedExceptions.addAll(catchedExceptions); + int endpos = code.adr2pos(this.avm2code.fixAddrAfterDebugLine(catchedExceptions.get(0).end)); + int endposStartBlock = code.adr2pos(catchedExceptions.get(0).end); + + List> catchedCommands = new ArrayList<>(); + if (this.avm2code.code.get(endpos).definition instanceof JumpIns) { + int afterCatchAddr = this.avm2code.pos2adr(endpos + 1) + this.avm2code.code.get(endpos).operands[0]; + int afterCatchPos = this.avm2code.adr2pos(afterCatchAddr); + final AVM2Graph t = this; + Collections.sort(catchedExceptions, new Comparator() { + @Override + public int compare(ABCException o1, ABCException o2) { + return t.avm2code.fixAddrAfterDebugLine(o1.target) - t.avm2code.fixAddrAfterDebugLine(o2.target); + } + }); + + List finallyCommands = new ArrayList<>(); + int returnPos = afterCatchPos; + for (int e = 0; e < body.exceptions.length; e++) { + if (body.exceptions[e].isFinally()) { + if (addr == this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].start)) { + if (afterCatchPos + 1 == code.adr2pos(this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].end))) { + AVM2Instruction jmpIns = this.avm2code.code.get(code.adr2pos(this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].end))); + + if (jmpIns.definition instanceof JumpIns) { + int finStart = code.adr2pos(this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].end) + jmpIns.getBytes().length + jmpIns.operands[0]); + + GraphPart fpart = null; + for (GraphPart p : allParts) { + if (p.start == finStart) { + fpart = p; + break; + } + } + int swPos = -1; + for (int f = finStart; f < this.avm2code.code.size(); f++) { + if (this.avm2code.code.get(f).definition instanceof LookupSwitchIns) { + AVM2Instruction swins = this.avm2code.code.get(f); + if (swins.operands.length >= 3) { + if (swins.operands[0] == swins.getBytes().length) { + if (code.adr2pos(code.pos2adr(f) + swins.operands[2]) < finStart) { + stack.push(new ExceptionAVM2Item(body.exceptions[e])); + GraphPart fepart = null; + for (GraphPart p : allParts) { + if (p.start == f + 1) { + fepart = p; + break; + } + } + //this.code.code.get(f).ignored = true; + //ignoredSwitches.add(f); + swPos = f; + + List stopPart2 = new ArrayList<>(stopPart); + stopPart2.add(fepart); + //finallyCommands = printGraph(new ArrayList(), localData, stack, allParts, parent, fpart, stopPart2, loops, staticOperation, path); + returnPos = f + 1; + break; + } + } + } + } + } + //ignoredSwitches.add(-1); + //int igs_size=ignoredSwitches.size(); + List oldFinallyJumps = new ArrayList<>(finallyJumps); + finallyJumps.clear(); + ignoredSwitches.add(swPos); + finallyCommands = printGraph(localData, stack, allParts, parent, fpart, null, loops, staticOperation, path); + //ignoredSwitches.remove(igs_size-1); + finallyJumps.addAll(oldFinallyJumps); + finallyJumps.add(finStart); + break; + } + } + } + } + } + + GraphPart retPart = null; + for (GraphPart p : allParts) { + if (p.start == returnPos) { + retPart = p; + break; + } + } + List catchParts = new ArrayList<>(); + for (int e = 0; e < catchedExceptions.size(); e++) { + int eendpos; + if (e < catchedExceptions.size() - 1) { + eendpos = code.adr2pos(this.avm2code.fixAddrAfterDebugLine(catchedExceptions.get(e + 1).target)) - 2; + } else { + eendpos = afterCatchPos - 1; + } + + GraphPart npart = null; + int findpos = code.adr2pos(catchedExceptions.get(e).target); + for (GraphPart p : allParts) { + if (p.start == findpos) { + npart = p; + catchParts.add(p); + break; + } + } + + GraphPart nepart = null; + for (GraphPart p : allParts) { + if (p.start == eendpos + 1) { + nepart = p; + break; + } + } + stack.add(new ExceptionAVM2Item(catchedExceptions.get(e))); + AVM2LocalData localData2 = new AVM2LocalData(aLocalData); + localData2.scopeStack = new ScopeStack(); + List stopPart2 = new ArrayList<>(stopPart); + stopPart2.add(nepart); + if (retPart != null) { + stopPart2.add(retPart); + } + catchedCommands.add(printGraph(localData2, stack, allParts, parent, npart, stopPart2, loops, staticOperation, path)); + } + + GraphPart nepart = null; + + for (GraphPart p : allParts) { + if (p.start == endposStartBlock) { + nepart = p; + break; + } + } + List stopPart2 = new ArrayList<>(stopPart); + stopPart2.add(nepart); + stopPart2.addAll(catchParts); + + if (retPart != null) { + stopPart2.add(retPart); + } + List tryCommands = printGraph(localData, stack, allParts, parent, part, stopPart2, loops, staticOperation, path); + + output.clear(); + output.add(new TryAVM2Item(tryCommands, catchedExceptions, catchedCommands, finallyCommands)); + ip = returnPos; + } + + } + + if (ip != part.start) { + part = null; + for (GraphPart p : allParts) { + List ps = p.getSubParts(); + for (GraphPart p2 : ps) { + if (p2.start == ip) { + part = p2; + break; + } + } + } + ret = new ArrayList<>(); + ret.addAll(output); + GraphTargetItem lop = checkLoop(part, stopPart, loops); + if (lop == null) { + ret.addAll(printGraph(localData, stack, allParts, null, part, stopPart, loops, staticOperation, path)); + } else { + ret.add(lop); + } + return ret; + } + + if (part.nextParts.isEmpty()) { + if (this.avm2code.code.get(part.end).definition instanceof ReturnValueIns) { //returns in finally clause + if (part.getHeight() >= 3) { + if (this.avm2code.code.get(part.getPosAt(part.getHeight() - 2)).definition instanceof KillIns) { + if (this.avm2code.code.get(part.getPosAt(part.getHeight() - 3)).definition instanceof GetLocalTypeIns) { + if (output.size() >= 2) { + if (output.get(output.size() - 2) instanceof SetLocalAVM2Item) { + ret = new ArrayList<>(); + ret.addAll(output); + ret.remove(ret.size() - 1); + ret.add(new ReturnValueAVM2Item(this.avm2code.code.get(part.end), ((SetLocalAVM2Item) output.get(output.size() - 2)).value)); + return ret; + } + } + } + } + } + } + } + if ((this.avm2code.code.get(part.end).definition instanceof LookupSwitchIns) && ignoredSwitches.contains(part.end)) { + ret = new ArrayList<>(); + ret.addAll(output); + return ret; + } + if (((part.nextParts.size() == 2) + && (!stack.isEmpty()) + && (stack.peek() instanceof StrictEqAVM2Item) + && (part.nextParts.get(0).getHeight() >= 2) + && (this.avm2code.code.get(this.avm2code.fixIPAfterDebugLine(part.nextParts.get(0).start)).definition instanceof PushIntegerTypeIns) + && (!part.nextParts.get(0).nextParts.isEmpty()) + && (this.avm2code.code.get(part.nextParts.get(0).nextParts.get(0).end).definition instanceof LookupSwitchIns)) + || ((part.nextParts.size() == 2) + && (!stack.isEmpty()) + && (stack.peek() instanceof StrictNeqAVM2Item) + && (part.nextParts.get(1).getHeight() >= 2) + && (this.avm2code.code.get(this.avm2code.fixIPAfterDebugLine(part.nextParts.get(1).start)).definition instanceof PushIntegerTypeIns) + && (!part.nextParts.get(1).nextParts.isEmpty()) + && (this.avm2code.code.get(part.nextParts.get(1).nextParts.get(0).end).definition instanceof LookupSwitchIns))) { + + if (stack.peek() instanceof StrictEqAVM2Item) { + ignoredSwitches.add(part.nextParts.get(0).nextParts.get(0).end); + } else { + ignoredSwitches.add(part.nextParts.get(1).nextParts.get(0).end); + } + ret = new ArrayList<>(); + ret.addAll(output); + boolean reversed = false; + if (stack.peek() instanceof StrictEqAVM2Item) { + reversed = true; + } + GraphTargetItem switchedObject = null; + if (!output.isEmpty()) { + if (output.get(output.size() - 1) instanceof SetLocalAVM2Item) { + switchedObject = ((SetLocalAVM2Item) output.get(output.size() - 1)).value; + } + } + if (switchedObject == null) { + switchedObject = new NullAVM2Item(null); + } + HashMap caseValuesMap = new HashMap<>(); + + GraphTargetItem tar = stack.pop(); + if (tar instanceof StrictEqAVM2Item) { + tar = ((StrictEqAVM2Item) tar).leftSide; + } + if (tar instanceof StrictNeqAVM2Item) { + tar = ((StrictNeqAVM2Item) tar).leftSide; + } + caseValuesMap.put(this.avm2code.code.get(part.nextParts.get(reversed ? 0 : 1).start).operands[0], tar); + + GraphPart switchLoc = part.nextParts.get(reversed ? 0 : 1).nextParts.get(0); + + while ((this.avm2code.code.get(part.nextParts.get(reversed ? 1 : 0).end).definition instanceof IfStrictNeIns) + || (this.avm2code.code.get(part.nextParts.get(reversed ? 1 : 0).end).definition instanceof IfStrictEqIns)) { + part = part.nextParts.get(reversed ? 1 : 0); + translatePart(localData, part, stack, staticOperation, null); + tar = stack.pop(); + if (tar instanceof StrictEqAVM2Item) { + tar = ((StrictEqAVM2Item) tar).leftSide; + } + if (tar instanceof StrictNeqAVM2Item) { + tar = ((StrictNeqAVM2Item) tar).leftSide; + } + if (this.avm2code.code.get(part.end).definition instanceof IfStrictNeIns) { + reversed = false; + } else { + reversed = true; + } + GraphPart numPart = part.nextParts.get(reversed ? 0 : 1); + AVM2Instruction ins = null; + TranslateStack sstack = new TranslateStack(); + do { + for (int n = 0; n < numPart.getHeight(); n++) { + ins = this.avm2code.code.get(numPart.getPosAt(n)); + if (ins.definition instanceof LookupSwitchIns) { + break; + } + ins.translate(localData, sstack, new ArrayList(), staticOperation, path); + } + if (numPart.nextParts.size() > 1) { + break; + } else { + numPart = numPart.nextParts.get(0); + } + } while (!(this.avm2code.code.get(numPart.end).definition instanceof LookupSwitchIns)); + GraphTargetItem nt = sstack.peek(); + + if (!(nt instanceof IntegerValueAVM2Item)) { + throw new RuntimeException("Invalid integer value in Switch"); + } + IntegerValueAVM2Item iv = (IntegerValueAVM2Item) nt; + caseValuesMap.put((int) (long) iv.value, tar); + while (this.avm2code.code.get(part.nextParts.get(reversed ? 1 : 0).start).definition instanceof JumpIns) { + reversed = false; + part = part.nextParts.get(reversed ? 1 : 0); + if (part instanceof GraphPartMulti) { + part = ((GraphPartMulti) part).parts.get(0); + } + } + } + boolean hasDefault = false; + GraphPart dp = part.nextParts.get(reversed ? 1 : 0); + while (this.avm2code.code.get(dp.start).definition instanceof JumpIns) { + if (dp instanceof GraphPartMulti) { + dp = ((GraphPartMulti) dp).parts.get(0); + } + dp = dp.nextParts.get(0); + } + + GraphPart numPart = dp; + AVM2Instruction ins = null; + TranslateStack sstack = new TranslateStack(); + do { + for (int n = 0; n < numPart.getHeight(); n++) { + ins = this.avm2code.code.get(numPart.getPosAt(n)); + if (ins.definition instanceof LookupSwitchIns) { + break; + } + ins.translate(localData, sstack, new ArrayList(), staticOperation, path); + } + if (numPart.nextParts.size() > 1) { + break; + } else { + numPart = numPart.nextParts.get(0); + } + } while (!(this.avm2code.code.get(numPart.end).definition instanceof LookupSwitchIns)); + GraphTargetItem nt = sstack.peek(); + if (nt instanceof IntegerValueAVM2Item) { + hasDefault = true; + } + List caseValues = new ArrayList<>(); + for (int i = 0; i < switchLoc.nextParts.size() - 1; i++) { + if (caseValuesMap.containsKey(i)) { + caseValues.add(caseValuesMap.get(i)); + } else { + continue; + } + } + + List> caseCommands = new ArrayList<>(); + GraphPart next = null; + + next = getMostCommonPart(localData, switchLoc.nextParts, loops);//getNextPartPath(loopContinues); + currentLoop = new Loop(loops.size(), null, next); + currentLoop.phase = 1; + loops.add(currentLoop); + //switchLoc.getNextPartPath(new ArrayList()); + List valuesMapping = new ArrayList<>(); + List caseBodies = new ArrayList<>(); + for (int i = 0; i < caseValues.size(); i++) { + GraphPart cur = switchLoc.nextParts.get(1 + i); + if (!caseBodies.contains(cur)) { + caseBodies.add(cur); + } + valuesMapping.add(caseBodies.indexOf(cur)); + } + + List defaultCommands = new ArrayList<>(); + GraphPart defaultPart = null; + if (hasDefault) { + defaultPart = switchLoc.nextParts.get(switchLoc.nextParts.size() - 1); + List stopPart2 = new ArrayList<>(stopPart); + stopPart2.add(next); + defaultCommands = printGraph(localData, stack, allParts, switchLoc, defaultPart, stopPart2, loops, staticOperation, path); + if (!defaultCommands.isEmpty()) { + if (defaultCommands.get(defaultCommands.size() - 1) instanceof BreakItem) { + if (((BreakItem) defaultCommands.get(defaultCommands.size() - 1)).loopId == currentLoop.id) { + defaultCommands.remove(defaultCommands.size() - 1); + } + } + } + } + + List ignored = new ArrayList<>(); + for (Loop l : loops) { + ignored.add(l.loopContinue); + } + + for (int i = 0; i < caseBodies.size(); i++) { + List cc = new ArrayList<>(); + List stopPart2 = new ArrayList<>(stopPart); + for (int j = 0; j < caseBodies.size(); j++) { + if (caseBodies.get(j) != caseBodies.get(i)) { + stopPart2.add(caseBodies.get(j)); + } + } + if (hasDefault) { + stopPart2.add(defaultPart); + } + + cc.addAll(0, printGraph(localData, stack, allParts, switchLoc, caseBodies.get(i), stopPart2, loops, staticOperation, path)); + caseCommands.add(cc); + } + + SwitchItem sti = new SwitchItem(null, currentLoop, switchedObject, caseValues, caseCommands, defaultCommands, valuesMapping); + ret.add(sti); + //loops.remove(currentLoop); + if (next != null) { + /*if (ti != null) { + ret.add(ti); + } else {*/ + currentLoop.phase = 2; + ret.addAll(printGraph(localData, stack, allParts, null, next, stopPart, loops, staticOperation, path)); + //} + } + } + return ret; + } + + @Override + protected GraphPart checkPart(TranslateStack stack, BaseLocalData localData, GraphPart next, List allParts) { + AVM2LocalData aLocalData = (AVM2LocalData) localData; + List finallyJumps = aLocalData.finallyJumps; + List ignoredSwitches = aLocalData.ignoredSwitches; + GraphPart ret = next; + for (int f = 0; f < finallyJumps.size(); f++) { + int fip = finallyJumps.get(f); + int swip = ignoredSwitches.get(f); + if (next.start == fip) { + if (stack != null && swip != -1) { + AVM2Instruction swIns = avm2code.code.get(swip); + GraphTargetItem t = stack.pop(); + Double dval = EcmaScript.toNumber(t.getResult()); + int val = (int) (double) dval; + if (swIns.definition instanceof LookupSwitchIns) { + List branches = swIns.getBranches(code); + int nip = branches.get(0); + if (val >= 0 && val < branches.size() - 1) { + nip = branches.get(1 + val); + } + for (GraphPart p : allParts) { + if (p.start == nip) { + return p; + } + } + ret = null; + } + } + ret = null; + } + } + if (ret != next) { + return ret; + } + + int pos = next.start; + int addr = this.avm2code.fixAddrAfterDebugLine(avm2code.pos2adr(pos)); + for (int e = 0; e < body.exceptions.length; e++) { + if (body.exceptions[e].isFinally()) { + if (addr == this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].start)) { + if (true) { //afterCatchPos + 1 == code.adr2pos(this.code.fixAddrAfterDebugLine(body.exceptions[e].end))) { + AVM2Instruction jmpIns = this.avm2code.code.get(avm2code.adr2pos(this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].end))); + if (jmpIns.definition instanceof JumpIns) { + int finStart = avm2code.adr2pos(this.avm2code.fixAddrAfterDebugLine(body.exceptions[e].end) + jmpIns.getBytes().length + jmpIns.operands[0]); + finallyJumps.add(finStart); + ignoredSwitches.add(-1); + break; + } + } + } + } + } + + return next; + } + + @Override + protected GraphTargetItem checkLoop(LoopItem loopItem, BaseLocalData localData, List loops) { + AVM2LocalData aLocalData = (AVM2LocalData) localData; + if (loopItem instanceof WhileItem) { + WhileItem w = (WhileItem) loopItem; + + if ((!w.expression.isEmpty()) && (w.expression.get(w.expression.size() - 1) instanceof HasNextAVM2Item)) { + if (((HasNextAVM2Item) w.expression.get(w.expression.size() - 1)).collection != null) { + if (((HasNextAVM2Item) w.expression.get(w.expression.size() - 1)).collection.getNotCoerced().getThroughRegister() instanceof FilteredCheckAVM2Item) { + //GraphTargetItem gti = ((HasNextAVM2Item) ((HasNextAVM2Item) w.expression.get(w.expression.size() - 1))).collection.getNotCoerced().getThroughRegister(); + if (w.commands.size() >= 3) { //((w.commands.size() == 3) || (w.commands.size() == 4)) { + int pos = 0; + while (w.commands.get(pos) instanceof SetLocalAVM2Item) { + pos++; + } + GraphTargetItem ft = w.commands.get(pos); + if (ft instanceof WithAVM2Item) { + ft = w.commands.get(pos + 1); + if (ft instanceof IfItem) { + IfItem ift = (IfItem) ft; + if (ift.onTrue.size() > 0) { + ft = ift.onTrue.get(0); + if (ft instanceof SetPropertyAVM2Item) { + SetPropertyAVM2Item spt = (SetPropertyAVM2Item) ft; + if (spt.object instanceof LocalRegAVM2Item) { + int regIndex = ((LocalRegAVM2Item) spt.object).regIndex; + HasNextAVM2Item iti = (HasNextAVM2Item) w.expression.get(w.expression.size() - 1); + HashMap localRegs = aLocalData.localRegs; + localRegs.put(regIndex, new FilterAVM2Item(null, iti.collection.getThroughRegister(), ift.expression)); + return null; + } + } + } + } + } + } + } else if (!w.commands.isEmpty()) { + if (w.commands.get(0) instanceof SetTypeAVM2Item) { + SetTypeAVM2Item sti = (SetTypeAVM2Item) w.commands.remove(0); + GraphTargetItem gti = sti.getValue().getNotCoerced(); + if (gti instanceof NextValueAVM2Item) { + return new ForEachInAVM2Item(w.src, w.loop, new InAVM2Item(null, sti.getObject(), ((HasNextAVM2Item) w.expression.get(w.expression.size() - 1)).collection), w.commands); + } else if (gti instanceof NextNameAVM2Item) { + return new ForInAVM2Item(w.src, w.loop, new InAVM2Item(null, sti.getObject(), ((HasNextAVM2Item) w.expression.get(w.expression.size() - 1)).collection), w.commands); + } + } + } + } + } + } + return loopItem; + } + + @Override + protected void finalProcess(List list, int level, FinalProcessLocalData localData) { + if (level == 0) { + if (!list.isEmpty()) { + if (list.get(list.size() - 1) instanceof ReturnVoidAVM2Item) { + list.remove(list.size() - 1); + } + } + } + + /*for (int i = 0; i < list.size(); i++) { + + if (list.get(i) instanceof WhileItem) { + WhileItem w = (WhileItem) list.get(i); + + } + }*/ + List ret = avm2code.clearTemporaryRegisters(list); + if (ret != list) { + list.clear(); + list.addAll(ret); + } + for (int i = 0; i < list.size(); i++) { + if (list.get(i) instanceof SetTypeAVM2Item) { + if (((SetTypeAVM2Item) list.get(i)).getValue() instanceof ExceptionAVM2Item) { + list.remove(i); + i--; + continue; + } + } + if (list.get(i) instanceof IfItem) { + IfItem ifi = (IfItem) list.get(i); + if (((ifi.expression instanceof HasNextAVM2Item) + || ((ifi.expression instanceof NotItem) + && (((NotItem) ifi.expression).getOriginal() instanceof HasNextAVM2Item)))) { + HasNextAVM2Item hnt = null; + List body = new ArrayList<>(); + List nextbody = new ArrayList<>(); + if (ifi.expression instanceof NotItem) { + hnt = (HasNextAVM2Item) ((NotItem) ifi.expression).getOriginal(); + body.addAll(ifi.onFalse); + for (int j = i + 1; j < list.size();) { + body.add(list.remove(i + 1)); + } + nextbody = ifi.onTrue; + } else { + hnt = (HasNextAVM2Item) ifi.expression; + body = ifi.onTrue; + nextbody = ifi.onFalse; + } + if (!body.isEmpty()) { + if (body.get(0) instanceof SetTypeAVM2Item) { + SetTypeAVM2Item sti = (SetTypeAVM2Item) body.remove(0); + GraphTargetItem gti = sti.getValue().getNotCoerced(); + GraphTargetItem repl = null; + + if (gti instanceof NextValueAVM2Item) { + repl = new ForEachInAVM2Item(ifi.src, new Loop(0, null, null), new InAVM2Item(null, sti.getObject(), hnt.collection), body); + } else if (gti instanceof NextNameAVM2Item) { + repl = new ForInAVM2Item(ifi.src, new Loop(0, null, null), new InAVM2Item(null, sti.getObject(), hnt.collection), body); + } + if (repl != null) { + list.remove(i); + list.add(i, repl); + list.addAll(i + 1, nextbody); + } + } + } + } + } + } + } + + @Override + protected boolean isEmpty(List output) { + if (super.isEmpty(output)) { + return true; + } + for (GraphTargetItem i : output) { + if (i instanceof SetLocalAVM2Item) { + if (avm2code.isKilled(((SetLocalAVM2Item) i).regIndex, 0, avm2code.code.size() - 1)) { + continue; + } + } + return false; + } + return true; + } + + @Override + public AVM2LocalData prepareBranchLocalData(BaseLocalData localData) { + AVM2LocalData aLocalData = (AVM2LocalData) localData; + AVM2LocalData ret = new AVM2LocalData(aLocalData); + ScopeStack copyScopeStack = new ScopeStack(); + copyScopeStack.addAll(ret.scopeStack); + ret.scopeStack = copyScopeStack; + return ret; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2GraphSource.java b/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2GraphSource.java index f7cd19433..77b1cbcb0 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2GraphSource.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2GraphSource.java @@ -1,105 +1,106 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.graph; - -import com.jpexs.decompiler.flash.BaseLocalData; -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.AVM2LocalData; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConvertOutput; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.graph.GraphPart; -import com.jpexs.decompiler.graph.GraphSource; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -/** - * - * @author JPEXS - */ -public class AVM2GraphSource extends GraphSource { - - private final AVM2Code code; - boolean isStatic; - int classIndex; - int scriptIndex; - HashMap localRegs; - Stack scopeStack; - ABC abc; - MethodBody body; - HashMap localRegNames; - List fullyQualifiedNames; - HashMap localRegAssigmentIps; - HashMap> refs; - - public AVM2Code getCode() { - return code; - } - - public AVM2GraphSource(AVM2Code code, boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack scopeStack, ABC abc, MethodBody body, HashMap localRegNames, List fullyQualifiedNames, HashMap localRegAssigmentIp, HashMap> refs) { - this.code = code; - this.isStatic = isStatic; - this.classIndex = classIndex; - this.localRegs = localRegs; - this.scopeStack = scopeStack; - this.abc = abc; - this.body = body; - this.localRegNames = localRegNames; - this.fullyQualifiedNames = fullyQualifiedNames; - this.scriptIndex = scriptIndex; - this.localRegAssigmentIps = localRegAssigmentIp; - this.refs = refs; - } - - @Override - public int size() { - return code.code.size(); - } - - @Override - public AVM2Instruction get(int pos) { - return code.code.get(pos); - } - - @Override - public boolean isEmpty() { - return code.code.isEmpty(); - } - - @Override - public List translatePart(GraphPart part, BaseLocalData localData, Stack stack, int start, int end, int staticOperation, String path) throws InterruptedException { - List ret = new ArrayList<>(); - Stack newstack = ((AVM2LocalData) localData).scopeStack; - ConvertOutput co = code.toSourceOutput(path, part, false, isStatic, scriptIndex, classIndex, localRegs, stack, newstack, abc, abc.constants, abc.method_info, body, start, end, localRegNames, fullyQualifiedNames, new boolean[size()], localRegAssigmentIps, refs); - ret.addAll(co.output); - return ret; - } - - @Override - public int adr2pos(long adr) { - return code.adr2pos(adr); - } - - @Override - public long pos2adr(int pos) { - return code.pos2adr(pos); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.graph; + +import com.jpexs.decompiler.flash.BaseLocalData; +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.AVM2LocalData; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConvertOutput; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.graph.GraphPart; +import com.jpexs.decompiler.graph.GraphSource; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +/** + * + * @author JPEXS + */ +public class AVM2GraphSource extends GraphSource { + + private final AVM2Code code; + boolean isStatic; + int classIndex; + int scriptIndex; + HashMap localRegs; + ScopeStack scopeStack; + ABC abc; + MethodBody body; + HashMap localRegNames; + List fullyQualifiedNames; + HashMap localRegAssigmentIps; + HashMap> refs; + + public AVM2Code getCode() { + return code; + } + + public AVM2GraphSource(AVM2Code code, boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, ScopeStack scopeStack, ABC abc, MethodBody body, HashMap localRegNames, List fullyQualifiedNames, HashMap localRegAssigmentIp, HashMap> refs) { + this.code = code; + this.isStatic = isStatic; + this.classIndex = classIndex; + this.localRegs = localRegs; + this.scopeStack = scopeStack; + this.abc = abc; + this.body = body; + this.localRegNames = localRegNames; + this.fullyQualifiedNames = fullyQualifiedNames; + this.scriptIndex = scriptIndex; + this.localRegAssigmentIps = localRegAssigmentIp; + this.refs = refs; + } + + @Override + public int size() { + return code.code.size(); + } + + @Override + public AVM2Instruction get(int pos) { + return code.code.get(pos); + } + + @Override + public boolean isEmpty() { + return code.code.isEmpty(); + } + + @Override + public List translatePart(GraphPart part, BaseLocalData localData, TranslateStack stack, int start, int end, int staticOperation, String path) throws InterruptedException { + List ret = new ArrayList<>(); + ScopeStack newstack = ((AVM2LocalData) localData).scopeStack; + ConvertOutput co = code.toSourceOutput(path, part, false, isStatic, scriptIndex, classIndex, localRegs, stack, newstack, abc, abc.constants, abc.method_info, body, start, end, localRegNames, fullyQualifiedNames, new boolean[size()], localRegAssigmentIps, refs); + ret.addAll(co.output); + return ret; + } + + @Override + public int adr2pos(long adr) { + return code.adr2pos(adr); + } + + @Override + public long pos2adr(int pos) { + return code.pos2adr(pos); + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java index 13f92994f..f2bbfdf70 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java @@ -1,364 +1,364 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions; - -import com.jpexs.decompiler.flash.BaseLocalData; -import com.jpexs.decompiler.flash.abc.ABCOutputStream; -import com.jpexs.decompiler.flash.abc.AVM2LocalData; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.other.ReturnValueIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ReturnVoidIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ThrowIns; -import com.jpexs.decompiler.flash.helpers.GraphTextWriter; -import com.jpexs.decompiler.graph.GraphSource; -import com.jpexs.decompiler.graph.GraphSourceItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.decompiler.graph.model.LocalData; -import com.jpexs.helpers.Helper; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; -import java.util.Stack; - -public class AVM2Instruction implements Serializable, GraphSourceItem { - - public static final long serialVersionUID = 1L; - public InstructionDefinition definition; - public int[] operands; - public long offset; - public byte[] bytes; - public String comment; - public boolean ignored = false; - public String labelname; - public long mappedOffset = -1; - public int changeJumpTo = -1; - - public AVM2Instruction(long offset, InstructionDefinition definition, int[] operands, byte[] bytes) { - this.definition = definition; - this.operands = operands; - this.offset = offset; - this.bytes = bytes; - } - - public byte[] getBytes() { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - try { - ABCOutputStream aos = new ABCOutputStream(bos); - aos.write(definition.instructionCode); - for (int i = 0; i < definition.operands.length; i++) { - int opt = definition.operands[i] & 0xff00; - switch (opt) { - case AVM2Code.OPT_S24: - aos.writeS24(operands[i]); - break; - case AVM2Code.OPT_U30: - aos.writeU30(operands[i]); - break; - case AVM2Code.OPT_U8: - aos.writeU8(operands[i]); - break; - case AVM2Code.OPT_BYTE: - aos.writeU8(0xff & operands[i]); - break; - case AVM2Code.OPT_CASE_OFFSETS: - - aos.writeU30(operands[i]); //case count - for (int j = i + 1; j < operands.length; j++) { - aos.writeS24(operands[j]); - } - break; - } - } - } catch (IOException ex) { - //ignored - } - return bos.toByteArray(); - } - - @Override - public String toString() { - StringBuilder s = new StringBuilder(); - s.append(definition.instructionName); - for (int i = 0; i < operands.length; i++) { - s.append(" "); - s.append(operands[i]); - } - return s.toString(); - } - - public List getOffsets() { - List ret = new ArrayList<>(); - String s = ""; - for (int i = 0; i < definition.operands.length; i++) { - switch (definition.operands[i]) { - case AVM2Code.DAT_OFFSET: - ret.add(offset + operands[i] + getBytes().length); - break; - case AVM2Code.DAT_CASE_BASEOFFSET: - ret.add(offset + operands[i]); - break; - case AVM2Code.OPT_CASE_OFFSETS: - for (int j = i + 1; j < operands.length; j++) { - ret.add(offset + operands[j]); - } - break; - } - - } - return ret; - } - - public List getParamsAsList(ConstantPool constants) { - List s = new ArrayList<>(); - for (int i = 0; i < definition.operands.length; i++) { - switch (definition.operands[i]) { - case AVM2Code.DAT_MULTINAME_INDEX: - s.add(constants.getMultiname(operands[i])); - break; - case AVM2Code.DAT_STRING_INDEX: - s.add(constants.getString(operands[i])); - break; - case AVM2Code.DAT_INT_INDEX: - s.add(Long.valueOf(constants.getInt(operands[i]))); - break; - case AVM2Code.DAT_UINT_INDEX: - s.add(new Long(constants.getUInt(operands[i]))); - break; - case AVM2Code.DAT_DOUBLE_INDEX: - s.add(Double.valueOf(constants.getDouble(operands[i]))); - break; - case AVM2Code.DAT_OFFSET: - s.add(new Long(offset + operands[i] + getBytes().length)); - break; - case AVM2Code.DAT_CASE_BASEOFFSET: - s.add(new Long(offset + operands[i])); - break; - case AVM2Code.OPT_CASE_OFFSETS: - s.add(new Long(operands[i])); - for (int j = i + 1; j < operands.length; j++) { - s.add(new Long(offset + operands[j])); - } - break; - default: - s.add(new Long(operands[i])); - } - - } - return s; - } - - public String getParams(ConstantPool constants, List fullyQualifiedNames) { - StringBuilder s = new StringBuilder(); - for (int i = 0; i < definition.operands.length; i++) { - switch (definition.operands[i]) { - case AVM2Code.DAT_MULTINAME_INDEX: - if (operands[i] == 0) { - s.append(" null"); - } else { - s.append(" "); - s.append(constants.getMultiname(operands[i]).toString(constants, fullyQualifiedNames)); - } - /*s.append(" m["); - s.append(operands[i]); - s.append("]\""); - if (constants.constant_multiname[operands[i]] == null) { - s.append(""); - } else { - s.append(Helper.escapeString(constants.constant_multiname[operands[i]].toString(constants, fullyQualifiedNames))); - } - s.append("\"");*/ - break; - case AVM2Code.DAT_STRING_INDEX: - if (operands[i] == 0) { - s.append(" null"); - } else { - s.append(" \""); - s.append(Helper.escapeString(constants.getString(operands[i]))); - s.append("\""); - } - break; - case AVM2Code.DAT_INT_INDEX: - if (operands[i] == 0) { - s.append(" null"); - } else { - s.append(" "); - s.append(constants.getInt(operands[i])); - } - break; - case AVM2Code.DAT_UINT_INDEX: - if (operands[i] == 0) { - s.append(" null"); - } else { - s.append(" "); - s.append(constants.getUInt(operands[i])); - } - break; - case AVM2Code.DAT_DOUBLE_INDEX: - if (operands[i] == 0) { - s.append(" null"); - } else { - s.append(" "); - s.append(constants.getDouble(operands[i])); - } - break; - case AVM2Code.DAT_OFFSET: - s.append(" "); - s.append("ofs"); - s.append(Helper.formatAddress(offset + operands[i] + getBytes().length)); - break; - case AVM2Code.DAT_CASE_BASEOFFSET: - s.append(" "); - s.append("ofs"); - s.append(Helper.formatAddress(offset + operands[i])); - break; - case AVM2Code.OPT_CASE_OFFSETS: - s.append(" "); - s.append(operands[i]); - for (int j = i + 1; j < operands.length; j++) { - s.append(" "); - s.append("ofs"); - s.append(Helper.formatAddress(offset + operands[j])); - } - break; - default: - s.append(" "); - s.append(operands[i]); - } - - } - return s.toString(); - } - - public String getComment() { - if (ignored) { - return " ;ignored"; - } - if ((comment == null) || comment.isEmpty()) { - return ""; - } - return " ;" + comment; - } - - @Override - public boolean isIgnored() { - return ignored; - } - - public GraphTextWriter toString(GraphTextWriter writer, LocalData localData) { - writer.appendNoHilight(Helper.formatAddress(offset) + " " + Helper.padSpaceRight(Helper.byteArrToString(getBytes()), 30) + definition.instructionName); - writer.appendNoHilight(getParams(localData.constantsAvm2, localData.fullyQualifiedNames) + getComment()); - return writer; - } - - public String toStringNoAddress(ConstantPool constants, List fullyQualifiedNames) { - String s = definition.instructionName; - s += getParams(constants, fullyQualifiedNames) + getComment(); - return s; - } - public List replaceWith; - - @Override - public void translate(BaseLocalData localData, Stack stack, List output, int staticOperation, String path) throws InterruptedException { - AVM2LocalData aLocalData = (AVM2LocalData) localData; - definition.translate(aLocalData.isStatic, - aLocalData.scriptIndex, - aLocalData.classIndex, - aLocalData.localRegs, - stack, - aLocalData.scopeStack, - aLocalData.constants, this, aLocalData.methodInfo, output, aLocalData.methodBody, aLocalData.abc, aLocalData.localRegNames, aLocalData.fullyQualifiedNames, null, aLocalData.localRegAssignmentIps, aLocalData.ip, aLocalData.refs, aLocalData.code); - } - - @Override - public boolean isJump() { - return (definition instanceof JumpIns) || (fixedBranch > -1); - } - - @Override - public boolean isBranch() { - if (fixedBranch > -1) { - return false; - } - return (definition instanceof IfTypeIns) || (definition instanceof LookupSwitchIns); - } - - @Override - public boolean isExit() { - return (definition instanceof ReturnValueIns) || (definition instanceof ReturnVoidIns) || (definition instanceof ThrowIns); - } - - @Override - public long getOffset() { - return mappedOffset > -1 ? mappedOffset : offset; - } - - @Override - public List getBranches(GraphSource code) { - List ret = new ArrayList<>(); - if (definition instanceof IfTypeIns) { - - if (fixedBranch == -1 || fixedBranch == 0) { - ret.add(code.adr2pos(offset + getBytes().length + operands[0])); - } - if (!(definition instanceof JumpIns)) { - if (fixedBranch == -1 || fixedBranch == 1) { - ret.add(code.adr2pos(offset + getBytes().length)); - } - } - } - if (definition instanceof LookupSwitchIns) { - if (fixedBranch == -1 || fixedBranch == 0) { - ret.add(code.adr2pos(offset + operands[0])); - } - for (int k = 2; k < operands.length; k++) { - if (fixedBranch == -1 || fixedBranch == k - 1) { - ret.add(code.adr2pos(offset + operands[k])); - } - } - } - return ret; - } - - @Override - public boolean ignoredLoops() { - return false; - } - - @Override - public void setIgnored(boolean ignored, int pos) { - this.ignored = ignored; - } - - public void setFixBranch(int pos) { - this.fixedBranch = pos; - } - private int fixedBranch = -1; - - public int getFixBranch() { - return fixedBranch; - } - - @Override - public boolean isDeobfuscatePop() { - return definition instanceof DeobfuscatePopIns; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions; + +import com.jpexs.decompiler.flash.BaseLocalData; +import com.jpexs.decompiler.flash.abc.ABCOutputStream; +import com.jpexs.decompiler.flash.abc.AVM2LocalData; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.other.ReturnValueIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ReturnVoidIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ThrowIns; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.graph.GraphSource; +import com.jpexs.decompiler.graph.GraphSourceItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; +import com.jpexs.decompiler.graph.model.LocalData; +import com.jpexs.helpers.Helper; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +public class AVM2Instruction implements Serializable, GraphSourceItem { + + public static final long serialVersionUID = 1L; + public InstructionDefinition definition; + public int[] operands; + public long offset; + public byte[] bytes; + public String comment; + public boolean ignored = false; + public String labelname; + public long mappedOffset = -1; + public int changeJumpTo = -1; + + public AVM2Instruction(long offset, InstructionDefinition definition, int[] operands, byte[] bytes) { + this.definition = definition; + this.operands = operands; + this.offset = offset; + this.bytes = bytes; + } + + public byte[] getBytes() { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + try { + ABCOutputStream aos = new ABCOutputStream(bos); + aos.write(definition.instructionCode); + for (int i = 0; i < definition.operands.length; i++) { + int opt = definition.operands[i] & 0xff00; + switch (opt) { + case AVM2Code.OPT_S24: + aos.writeS24(operands[i]); + break; + case AVM2Code.OPT_U30: + aos.writeU30(operands[i]); + break; + case AVM2Code.OPT_U8: + aos.writeU8(operands[i]); + break; + case AVM2Code.OPT_BYTE: + aos.writeU8(0xff & operands[i]); + break; + case AVM2Code.OPT_CASE_OFFSETS: + + aos.writeU30(operands[i]); //case count + for (int j = i + 1; j < operands.length; j++) { + aos.writeS24(operands[j]); + } + break; + } + } + } catch (IOException ex) { + //ignored + } + return bos.toByteArray(); + } + + @Override + public String toString() { + StringBuilder s = new StringBuilder(); + s.append(definition.instructionName); + for (int i = 0; i < operands.length; i++) { + s.append(" "); + s.append(operands[i]); + } + return s.toString(); + } + + public List getOffsets() { + List ret = new ArrayList<>(); + String s = ""; + for (int i = 0; i < definition.operands.length; i++) { + switch (definition.operands[i]) { + case AVM2Code.DAT_OFFSET: + ret.add(offset + operands[i] + getBytes().length); + break; + case AVM2Code.DAT_CASE_BASEOFFSET: + ret.add(offset + operands[i]); + break; + case AVM2Code.OPT_CASE_OFFSETS: + for (int j = i + 1; j < operands.length; j++) { + ret.add(offset + operands[j]); + } + break; + } + + } + return ret; + } + + public List getParamsAsList(ConstantPool constants) { + List s = new ArrayList<>(); + for (int i = 0; i < definition.operands.length; i++) { + switch (definition.operands[i]) { + case AVM2Code.DAT_MULTINAME_INDEX: + s.add(constants.getMultiname(operands[i])); + break; + case AVM2Code.DAT_STRING_INDEX: + s.add(constants.getString(operands[i])); + break; + case AVM2Code.DAT_INT_INDEX: + s.add(Long.valueOf(constants.getInt(operands[i]))); + break; + case AVM2Code.DAT_UINT_INDEX: + s.add(new Long(constants.getUInt(operands[i]))); + break; + case AVM2Code.DAT_DOUBLE_INDEX: + s.add(Double.valueOf(constants.getDouble(operands[i]))); + break; + case AVM2Code.DAT_OFFSET: + s.add(new Long(offset + operands[i] + getBytes().length)); + break; + case AVM2Code.DAT_CASE_BASEOFFSET: + s.add(new Long(offset + operands[i])); + break; + case AVM2Code.OPT_CASE_OFFSETS: + s.add(new Long(operands[i])); + for (int j = i + 1; j < operands.length; j++) { + s.add(new Long(offset + operands[j])); + } + break; + default: + s.add(new Long(operands[i])); + } + + } + return s; + } + + public String getParams(ConstantPool constants, List fullyQualifiedNames) { + StringBuilder s = new StringBuilder(); + for (int i = 0; i < definition.operands.length; i++) { + switch (definition.operands[i]) { + case AVM2Code.DAT_MULTINAME_INDEX: + if (operands[i] == 0) { + s.append(" null"); + } else { + s.append(" "); + s.append(constants.getMultiname(operands[i]).toString(constants, fullyQualifiedNames)); + } + /*s.append(" m["); + s.append(operands[i]); + s.append("]\""); + if (constants.constant_multiname[operands[i]] == null) { + s.append(""); + } else { + s.append(Helper.escapeString(constants.constant_multiname[operands[i]].toString(constants, fullyQualifiedNames))); + } + s.append("\"");*/ + break; + case AVM2Code.DAT_STRING_INDEX: + if (operands[i] == 0) { + s.append(" null"); + } else { + s.append(" \""); + s.append(Helper.escapeString(constants.getString(operands[i]))); + s.append("\""); + } + break; + case AVM2Code.DAT_INT_INDEX: + if (operands[i] == 0) { + s.append(" null"); + } else { + s.append(" "); + s.append(constants.getInt(operands[i])); + } + break; + case AVM2Code.DAT_UINT_INDEX: + if (operands[i] == 0) { + s.append(" null"); + } else { + s.append(" "); + s.append(constants.getUInt(operands[i])); + } + break; + case AVM2Code.DAT_DOUBLE_INDEX: + if (operands[i] == 0) { + s.append(" null"); + } else { + s.append(" "); + s.append(constants.getDouble(operands[i])); + } + break; + case AVM2Code.DAT_OFFSET: + s.append(" "); + s.append("ofs"); + s.append(Helper.formatAddress(offset + operands[i] + getBytes().length)); + break; + case AVM2Code.DAT_CASE_BASEOFFSET: + s.append(" "); + s.append("ofs"); + s.append(Helper.formatAddress(offset + operands[i])); + break; + case AVM2Code.OPT_CASE_OFFSETS: + s.append(" "); + s.append(operands[i]); + for (int j = i + 1; j < operands.length; j++) { + s.append(" "); + s.append("ofs"); + s.append(Helper.formatAddress(offset + operands[j])); + } + break; + default: + s.append(" "); + s.append(operands[i]); + } + + } + return s.toString(); + } + + public String getComment() { + if (ignored) { + return " ;ignored"; + } + if ((comment == null) || comment.isEmpty()) { + return ""; + } + return " ;" + comment; + } + + @Override + public boolean isIgnored() { + return ignored; + } + + public GraphTextWriter toString(GraphTextWriter writer, LocalData localData) { + writer.appendNoHilight(Helper.formatAddress(offset) + " " + Helper.padSpaceRight(Helper.byteArrToString(getBytes()), 30) + definition.instructionName); + writer.appendNoHilight(getParams(localData.constantsAvm2, localData.fullyQualifiedNames) + getComment()); + return writer; + } + + public String toStringNoAddress(ConstantPool constants, List fullyQualifiedNames) { + String s = definition.instructionName; + s += getParams(constants, fullyQualifiedNames) + getComment(); + return s; + } + public List replaceWith; + + @Override + public void translate(BaseLocalData localData, TranslateStack stack, List output, int staticOperation, String path) throws InterruptedException { + AVM2LocalData aLocalData = (AVM2LocalData) localData; + definition.translate(aLocalData.isStatic, + aLocalData.scriptIndex, + aLocalData.classIndex, + aLocalData.localRegs, + stack, + aLocalData.scopeStack, + aLocalData.constants, this, aLocalData.methodInfo, output, aLocalData.methodBody, aLocalData.abc, aLocalData.localRegNames, aLocalData.fullyQualifiedNames, null, aLocalData.localRegAssignmentIps, aLocalData.ip, aLocalData.refs, aLocalData.code); + } + + @Override + public boolean isJump() { + return (definition instanceof JumpIns) || (fixedBranch > -1); + } + + @Override + public boolean isBranch() { + if (fixedBranch > -1) { + return false; + } + return (definition instanceof IfTypeIns) || (definition instanceof LookupSwitchIns); + } + + @Override + public boolean isExit() { + return (definition instanceof ReturnValueIns) || (definition instanceof ReturnVoidIns) || (definition instanceof ThrowIns); + } + + @Override + public long getOffset() { + return mappedOffset > -1 ? mappedOffset : offset; + } + + @Override + public List getBranches(GraphSource code) { + List ret = new ArrayList<>(); + if (definition instanceof IfTypeIns) { + + if (fixedBranch == -1 || fixedBranch == 0) { + ret.add(code.adr2pos(offset + getBytes().length + operands[0])); + } + if (!(definition instanceof JumpIns)) { + if (fixedBranch == -1 || fixedBranch == 1) { + ret.add(code.adr2pos(offset + getBytes().length)); + } + } + } + if (definition instanceof LookupSwitchIns) { + if (fixedBranch == -1 || fixedBranch == 0) { + ret.add(code.adr2pos(offset + operands[0])); + } + for (int k = 2; k < operands.length; k++) { + if (fixedBranch == -1 || fixedBranch == k - 1) { + ret.add(code.adr2pos(offset + operands[k])); + } + } + } + return ret; + } + + @Override + public boolean ignoredLoops() { + return false; + } + + @Override + public void setIgnored(boolean ignored, int pos) { + this.ignored = ignored; + } + + public void setFixBranch(int pos) { + this.fixedBranch = pos; + } + private int fixedBranch = -1; + + public int getFixBranch() { + return fixedBranch; + } + + @Override + public boolean isDeobfuscatePop() { + return definition instanceof DeobfuscatePopIns; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/InstructionDefinition.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/InstructionDefinition.java index c5e68a5fb..2a5de4b2c 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/InstructionDefinition.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/InstructionDefinition.java @@ -31,6 +31,8 @@ import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.io.Serializable; import java.util.HashMap; import java.util.HashSet; @@ -80,10 +82,10 @@ public class InstructionDefinition implements Serializable { throw new UnsupportedOperationException("Instruction " + instructionName + " not implemented"); } - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) throws InterruptedException { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) throws InterruptedException { } - protected FullMultinameAVM2Item resolveMultiname(Stack stack, ConstantPool constants, int multinameIndex, AVM2Instruction ins) { + protected FullMultinameAVM2Item resolveMultiname(TranslateStack stack, ConstantPool constants, int multinameIndex, AVM2Instruction ins) { GraphTargetItem ns = null; GraphTargetItem name = null; if (constants.getMultiname(multinameIndex).needsName()) { diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Lf32Ins.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Lf32Ins.java index eaf77380f..07942d5b7 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Lf32Ins.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Lf32Ins.java @@ -1,57 +1,58 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.model.AlchemyLoadAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -/** - * - * @author JPEXS - */ -public class Lf32Ins extends InstructionDefinition { - - public Lf32Ins() { - super(0x38, "lf32", new int[]{}); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1 - 1; - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - return 0; - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem ofs = stack.pop(); - stack.push(new AlchemyLoadAVM2Item(ins, ofs, instructionName)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.model.AlchemyLoadAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; +import java.util.HashMap; +import java.util.List; + +/** + * + * @author JPEXS + */ +public class Lf32Ins extends InstructionDefinition { + + public Lf32Ins() { + super(0x38, "lf32", new int[]{}); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1 - 1; + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + return 0; + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem ofs = stack.pop(); + stack.push(new AlchemyLoadAVM2Item(ins, ofs, instructionName)); + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Lf64Ins.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Lf64Ins.java index 35b53d940..c15978ae8 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Lf64Ins.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Lf64Ins.java @@ -1,57 +1,58 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.model.AlchemyLoadAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -/** - * - * @author JPEXS - */ -public class Lf64Ins extends InstructionDefinition { - - public Lf64Ins() { - super(0x39, "lf64", new int[]{}); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1 - 1; - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - return 0; - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem ofs = stack.pop(); - stack.push(new AlchemyLoadAVM2Item(ins, ofs, instructionName)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.model.AlchemyLoadAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; +import java.util.HashMap; +import java.util.List; + +/** + * + * @author JPEXS + */ +public class Lf64Ins extends InstructionDefinition { + + public Lf64Ins() { + super(0x39, "lf64", new int[]{}); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1 - 1; + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + return 0; + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem ofs = stack.pop(); + stack.push(new AlchemyLoadAVM2Item(ins, ofs, instructionName)); + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Li16Ins.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Li16Ins.java index de5d3185b..508db45e9 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Li16Ins.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Li16Ins.java @@ -1,57 +1,58 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.model.AlchemyLoadAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -/** - * - * @author JPEXS - */ -public class Li16Ins extends InstructionDefinition { - - public Li16Ins() { - super(0x36, "li16", new int[]{}); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1 - 1; - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - return 0; - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem ofs = stack.pop(); - stack.push(new AlchemyLoadAVM2Item(ins, ofs, instructionName)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.model.AlchemyLoadAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; +import java.util.HashMap; +import java.util.List; + +/** + * + * @author JPEXS + */ +public class Li16Ins extends InstructionDefinition { + + public Li16Ins() { + super(0x36, "li16", new int[]{}); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1 - 1; + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + return 0; + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem ofs = stack.pop(); + stack.push(new AlchemyLoadAVM2Item(ins, ofs, instructionName)); + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Li32Ins.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Li32Ins.java index 229ea75bd..7e6a6db2c 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Li32Ins.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Li32Ins.java @@ -1,57 +1,58 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.model.AlchemyLoadAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -/** - * - * @author JPEXS - */ -public class Li32Ins extends InstructionDefinition { - - public Li32Ins() { - super(0x37, "li32", new int[]{}); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1 - 1; - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - return 0; - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem ofs = stack.pop(); - stack.push(new AlchemyLoadAVM2Item(ins, ofs, instructionName)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.model.AlchemyLoadAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; +import java.util.HashMap; +import java.util.List; + +/** + * + * @author JPEXS + */ +public class Li32Ins extends InstructionDefinition { + + public Li32Ins() { + super(0x37, "li32", new int[]{}); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1 - 1; + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + return 0; + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem ofs = stack.pop(); + stack.push(new AlchemyLoadAVM2Item(ins, ofs, instructionName)); + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Li8Ins.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Li8Ins.java index 94bf7a76d..d90954e35 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Li8Ins.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Li8Ins.java @@ -1,57 +1,58 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.model.AlchemyLoadAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -/** - * - * @author JPEXS - */ -public class Li8Ins extends InstructionDefinition { - - public Li8Ins() { - super(0x35, "li8", new int[]{}); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1 - 1; - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - return 0; - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem ofs = stack.pop(); - stack.push(new AlchemyLoadAVM2Item(ins, ofs, instructionName)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.model.AlchemyLoadAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; +import java.util.HashMap; +import java.util.List; + +/** + * + * @author JPEXS + */ +public class Li8Ins extends InstructionDefinition { + + public Li8Ins() { + super(0x35, "li8", new int[]{}); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1 - 1; + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + return 0; + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem ofs = stack.pop(); + stack.push(new AlchemyLoadAVM2Item(ins, ofs, instructionName)); + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sf32Ins.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sf32Ins.java index 1f66543f7..d66bf0f6f 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sf32Ins.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sf32Ins.java @@ -1,58 +1,59 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.model.AlchemyStoreAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -/** - * - * @author JPEXS - */ -public class Sf32Ins extends InstructionDefinition { - - public Sf32Ins() { - super(0x3D, "sf32", new int[]{}); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2; - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - return 0; - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem ofs = stack.pop(); - GraphTargetItem value = stack.pop(); - stack.push(new AlchemyStoreAVM2Item(ins, value, ofs, instructionName)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.model.AlchemyStoreAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; +import java.util.HashMap; +import java.util.List; + +/** + * + * @author JPEXS + */ +public class Sf32Ins extends InstructionDefinition { + + public Sf32Ins() { + super(0x3D, "sf32", new int[]{}); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2; + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + return 0; + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem ofs = stack.pop(); + GraphTargetItem value = stack.pop(); + stack.push(new AlchemyStoreAVM2Item(ins, value, ofs, instructionName)); + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sf64Ins.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sf64Ins.java index 84761285e..8d02c7ef0 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sf64Ins.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sf64Ins.java @@ -1,58 +1,59 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.model.AlchemyStoreAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -/** - * - * @author JPEXS - */ -public class Sf64Ins extends InstructionDefinition { - - public Sf64Ins() { - super(0x3E, "sf64", new int[]{}); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2; - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - return 0; - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem ofs = stack.pop(); - GraphTargetItem value = stack.pop(); - stack.push(new AlchemyStoreAVM2Item(ins, value, ofs, instructionName)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.model.AlchemyStoreAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; +import java.util.HashMap; +import java.util.List; + +/** + * + * @author JPEXS + */ +public class Sf64Ins extends InstructionDefinition { + + public Sf64Ins() { + super(0x3E, "sf64", new int[]{}); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2; + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + return 0; + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem ofs = stack.pop(); + GraphTargetItem value = stack.pop(); + stack.push(new AlchemyStoreAVM2Item(ins, value, ofs, instructionName)); + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Si16Ins.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Si16Ins.java index 93e58ce9b..6e6f429d1 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Si16Ins.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Si16Ins.java @@ -1,58 +1,59 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.model.AlchemyStoreAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -/** - * - * @author JPEXS - */ -public class Si16Ins extends InstructionDefinition { - - public Si16Ins() { - super(0x3B, "si16", new int[]{}); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2; - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - return 0; - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem ofs = stack.pop(); - GraphTargetItem value = stack.pop(); - stack.push(new AlchemyStoreAVM2Item(ins, value, ofs, instructionName)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.model.AlchemyStoreAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; +import java.util.HashMap; +import java.util.List; + +/** + * + * @author JPEXS + */ +public class Si16Ins extends InstructionDefinition { + + public Si16Ins() { + super(0x3B, "si16", new int[]{}); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2; + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + return 0; + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem ofs = stack.pop(); + GraphTargetItem value = stack.pop(); + stack.push(new AlchemyStoreAVM2Item(ins, value, ofs, instructionName)); + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Si32Ins.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Si32Ins.java index aaa309166..677bbef60 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Si32Ins.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Si32Ins.java @@ -1,58 +1,59 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.model.AlchemyStoreAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -/** - * - * @author JPEXS - */ -public class Si32Ins extends InstructionDefinition { - - public Si32Ins() { - super(0x3C, "si32", new int[]{}); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2; - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - return 0; - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem ofs = stack.pop(); - GraphTargetItem value = stack.pop(); - stack.push(new AlchemyStoreAVM2Item(ins, value, ofs, instructionName)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.model.AlchemyStoreAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; +import java.util.HashMap; +import java.util.List; + +/** + * + * @author JPEXS + */ +public class Si32Ins extends InstructionDefinition { + + public Si32Ins() { + super(0x3C, "si32", new int[]{}); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2; + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + return 0; + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem ofs = stack.pop(); + GraphTargetItem value = stack.pop(); + stack.push(new AlchemyStoreAVM2Item(ins, value, ofs, instructionName)); + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Si8Ins.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Si8Ins.java index 5976abcc9..068d51c4d 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Si8Ins.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Si8Ins.java @@ -1,58 +1,59 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.model.AlchemyStoreAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -/** - * - * @author JPEXS - */ -public class Si8Ins extends InstructionDefinition { - - public Si8Ins() { - super(0x3A, "si8", new int[]{}); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2; - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - return 0; - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem ofs = stack.pop(); - GraphTargetItem value = stack.pop(); - stack.push(new AlchemyStoreAVM2Item(ins, value, ofs, instructionName)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.model.AlchemyStoreAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; +import java.util.HashMap; +import java.util.List; + +/** + * + * @author JPEXS + */ +public class Si8Ins extends InstructionDefinition { + + public Si8Ins() { + super(0x3A, "si8", new int[]{}); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2; + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + return 0; + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem ofs = stack.pop(); + GraphTargetItem value = stack.pop(); + stack.push(new AlchemyStoreAVM2Item(ins, value, ofs, instructionName)); + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sxi16Ins.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sxi16Ins.java index 011073cbc..9ed08da47 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sxi16Ins.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sxi16Ins.java @@ -1,57 +1,58 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.model.AlchemySignExtendAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -/** - * - * @author JPEXS - */ -public class Sxi16Ins extends InstructionDefinition { - - public Sxi16Ins() { - super(0x52, "sxi_16", new int[]{}); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1 - 1; - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - return 0; - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem value = stack.pop(); - stack.push(new AlchemySignExtendAVM2Item(ins, value, instructionName)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.model.AlchemySignExtendAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; +import java.util.HashMap; +import java.util.List; + +/** + * + * @author JPEXS + */ +public class Sxi16Ins extends InstructionDefinition { + + public Sxi16Ins() { + super(0x52, "sxi_16", new int[]{}); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1 - 1; + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + return 0; + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem value = stack.pop(); + stack.push(new AlchemySignExtendAVM2Item(ins, value, instructionName)); + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sxi1Ins.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sxi1Ins.java index 7198b5a60..74194f77c 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sxi1Ins.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sxi1Ins.java @@ -1,57 +1,58 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.model.AlchemySignExtendAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -/** - * - * @author JPEXS - */ -public class Sxi1Ins extends InstructionDefinition { - - public Sxi1Ins() { - super(0x50, "sxi_1", new int[]{}); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1 - 1; - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - return 0; - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem value = stack.pop(); - stack.push(new AlchemySignExtendAVM2Item(ins, value, instructionName)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.model.AlchemySignExtendAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; +import java.util.HashMap; +import java.util.List; + +/** + * + * @author JPEXS + */ +public class Sxi1Ins extends InstructionDefinition { + + public Sxi1Ins() { + super(0x50, "sxi_1", new int[]{}); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1 - 1; + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + return 0; + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem value = stack.pop(); + stack.push(new AlchemySignExtendAVM2Item(ins, value, instructionName)); + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sxi8Ins.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sxi8Ins.java index 6a6fb17b5..657257dd3 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sxi8Ins.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sxi8Ins.java @@ -1,57 +1,58 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.model.AlchemySignExtendAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -/** - * - * @author JPEXS - */ -public class Sxi8Ins extends InstructionDefinition { - - public Sxi8Ins() { - super(0x51, "sxi_8", new int[]{}); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1 - 1; - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - return 0; - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem value = stack.pop(); - stack.push(new AlchemySignExtendAVM2Item(ins, value, instructionName)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.model.AlchemySignExtendAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; +import java.util.HashMap; +import java.util.List; + +/** + * + * @author JPEXS + */ +public class Sxi8Ins extends InstructionDefinition { + + public Sxi8Ins() { + super(0x51, "sxi_8", new int[]{}); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1 - 1; + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + return 0; + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem value = stack.pop(); + stack.push(new AlchemySignExtendAVM2Item(ins, value, instructionName)); + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIIns.java index 84c785513..263f2d708 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIIns.java @@ -24,9 +24,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.AddAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class AddIIns extends AddIns { @@ -36,7 +37,7 @@ public class AddIIns extends AddIns { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v2 = stack.pop(); GraphTargetItem v1 = stack.pop(); stack.push(new AddAVM2Item(ins, v1, v2)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIns.java index dfaedf40c..04a9c753f 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIns.java @@ -26,9 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.AddAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class AddIns extends InstructionDefinition { @@ -59,7 +60,7 @@ public class AddIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v2 = stack.pop(); GraphTargetItem v1 = stack.pop(); stack.push(new AddAVM2Item(ins, v1, v2)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIIns.java index 4d1b6663b..4ae7b76c6 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIIns.java @@ -26,9 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.DecrementAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class DecrementIIns extends InstructionDefinition { @@ -55,7 +56,7 @@ public class DecrementIIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { stack.push(new DecrementAVM2Item(ins, stack.pop())); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIns.java index 66a57966c..45188268c 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIns.java @@ -26,9 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.DecrementAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class DecrementIns extends InstructionDefinition { @@ -55,7 +56,7 @@ public class DecrementIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { stack.push(new DecrementAVM2Item(ins, stack.pop())); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DivideIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DivideIns.java index 54c8b601f..a93985653 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DivideIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DivideIns.java @@ -26,9 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.DivideAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class DivideIns extends InstructionDefinition { @@ -58,7 +59,7 @@ public class DivideIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v2 = stack.pop(); GraphTargetItem v1 = stack.pop(); stack.push(new DivideAVM2Item(ins, v1, v2)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/IncrementIIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/IncrementIIns.java index 3660c6d63..81201a2b9 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/IncrementIIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/IncrementIIns.java @@ -25,9 +25,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.IncrementAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class IncrementIIns extends InstructionDefinition { @@ -36,7 +37,7 @@ public class IncrementIIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { stack.push(new IncrementAVM2Item(ins, stack.pop())); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/IncrementIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/IncrementIns.java index 8af671e81..022d7925a 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/IncrementIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/IncrementIns.java @@ -25,9 +25,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.IncrementAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class IncrementIns extends InstructionDefinition { @@ -36,7 +37,7 @@ public class IncrementIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { stack.push(new IncrementAVM2Item(ins, stack.pop())); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/ModuloIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/ModuloIns.java index 5657c7341..e5a0f3c63 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/ModuloIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/ModuloIns.java @@ -26,9 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.ModuloAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ModuloIns extends InstructionDefinition { @@ -50,7 +51,7 @@ public class ModuloIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v2 = stack.pop(); GraphTargetItem v1 = stack.pop(); stack.push(new ModuloAVM2Item(ins, v1, v2)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/MultiplyIIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/MultiplyIIns.java index 337091b34..ebbf96a6d 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/MultiplyIIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/MultiplyIIns.java @@ -25,9 +25,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.MultiplyAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class MultiplyIIns extends InstructionDefinition { @@ -36,7 +37,7 @@ public class MultiplyIIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v2 = stack.pop(); GraphTargetItem v1 = stack.pop(); stack.push(new MultiplyAVM2Item(ins, v1, v2)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/MultiplyIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/MultiplyIns.java index eaf5425ab..00bd0ef01 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/MultiplyIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/MultiplyIns.java @@ -26,9 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.MultiplyAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class MultiplyIns extends InstructionDefinition { @@ -58,7 +59,7 @@ public class MultiplyIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v2 = stack.pop(); GraphTargetItem v1 = stack.pop(); stack.push(new MultiplyAVM2Item(ins, v1, v2)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NegateIIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NegateIIns.java index b92a57d00..af23a6589 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NegateIIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NegateIIns.java @@ -25,9 +25,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.NegAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class NegateIIns extends InstructionDefinition { @@ -36,7 +37,7 @@ public class NegateIIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v = stack.pop(); stack.push(new NegAVM2Item(ins, v)); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NegateIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NegateIns.java index 7ae3a98d1..14f4ef6d0 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NegateIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NegateIns.java @@ -25,9 +25,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.NegAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class NegateIns extends InstructionDefinition { @@ -36,7 +37,7 @@ public class NegateIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v = stack.pop(); stack.push(new NegAVM2Item(ins, v)); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NotIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NotIns.java index 54f22a7d4..753271b92 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NotIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NotIns.java @@ -24,10 +24,11 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import com.jpexs.decompiler.graph.model.NotItem; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class NotIns extends InstructionDefinition { @@ -36,7 +37,7 @@ public class NotIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v = stack.pop(); stack.push(new NotItem(ins, v)); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/SubtractIIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/SubtractIIns.java index fe8ce5ddb..bb2dd1c6a 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/SubtractIIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/SubtractIIns.java @@ -25,9 +25,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.SubtractAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class SubtractIIns extends InstructionDefinition { @@ -36,7 +37,7 @@ public class SubtractIIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v2 = stack.pop(); GraphTargetItem v1 = stack.pop(); stack.push(new SubtractAVM2Item(ins, v1, v2)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/SubtractIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/SubtractIns.java index 5bbe09b8e..48add6e15 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/SubtractIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/SubtractIns.java @@ -25,9 +25,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.SubtractAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class SubtractIns extends InstructionDefinition { @@ -36,7 +37,7 @@ public class SubtractIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v2 = stack.pop(); GraphTargetItem v1 = stack.pop(); stack.push(new SubtractAVM2Item(ins, v1, v2)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitAndIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitAndIns.java index 44fdca8eb..cbf7fbff4 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitAndIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitAndIns.java @@ -26,9 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.BitAndAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class BitAndIns extends InstructionDefinition { @@ -45,7 +46,7 @@ public class BitAndIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v2 = stack.pop(); GraphTargetItem v1 = stack.pop(); stack.push(new BitAndAVM2Item(ins, v1, v2)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitNotIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitNotIns.java index a55e1dff6..05757cc7f 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitNotIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitNotIns.java @@ -26,9 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.BitNotAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class BitNotIns extends InstructionDefinition { @@ -44,7 +45,7 @@ public class BitNotIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v = stack.pop(); stack.push(new BitNotAVM2Item(ins, v)); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitOrIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitOrIns.java index 426236016..3a0396e97 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitOrIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitOrIns.java @@ -26,9 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.BitOrAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class BitOrIns extends InstructionDefinition { @@ -45,7 +46,7 @@ public class BitOrIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v2 = stack.pop(); GraphTargetItem v1 = stack.pop(); stack.push(new BitOrAVM2Item(ins, v1, v2)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitXorIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitXorIns.java index 615734e38..ab7ea9890 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitXorIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitXorIns.java @@ -26,9 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.BitXorAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class BitXorIns extends InstructionDefinition { @@ -45,7 +46,7 @@ public class BitXorIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v2 = stack.pop(); GraphTargetItem v1 = stack.pop(); stack.push(new BitXorAVM2Item(ins, v1, v2)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/LShiftIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/LShiftIns.java index 04a13116a..b3a6ad0f2 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/LShiftIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/LShiftIns.java @@ -25,9 +25,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.LShiftAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class LShiftIns extends InstructionDefinition { @@ -36,7 +37,7 @@ public class LShiftIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v2 = stack.pop(); GraphTargetItem v1 = stack.pop(); stack.push(new LShiftAVM2Item(ins, v1, v2)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/RShiftIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/RShiftIns.java index d88746129..8502d9827 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/RShiftIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/RShiftIns.java @@ -25,9 +25,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.RShiftAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class RShiftIns extends InstructionDefinition { @@ -36,7 +37,7 @@ public class RShiftIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v2 = stack.pop(); GraphTargetItem v1 = stack.pop(); stack.push(new RShiftAVM2Item(ins, v1, v2)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/URShiftIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/URShiftIns.java index 53a037a85..f916d5583 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/URShiftIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/URShiftIns.java @@ -25,9 +25,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.URShiftAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class URShiftIns extends InstructionDefinition { @@ -36,7 +37,7 @@ public class URShiftIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v2 = stack.pop(); GraphTargetItem v1 = stack.pop(); stack.push(new URShiftAVM2Item(ins, v1, v2)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/EqualsIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/EqualsIns.java index e1f4a3f9e..9c2f4eb31 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/EqualsIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/EqualsIns.java @@ -26,9 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.EqAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class EqualsIns extends InstructionDefinition { @@ -45,7 +46,7 @@ public class EqualsIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v2 = stack.pop(); GraphTargetItem v1 = stack.pop(); stack.push(new EqAVM2Item(ins, v1, v2)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/GreaterEqualsIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/GreaterEqualsIns.java index 95fb8513d..c81564660 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/GreaterEqualsIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/GreaterEqualsIns.java @@ -25,9 +25,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.GeAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class GreaterEqualsIns extends InstructionDefinition { @@ -36,7 +37,7 @@ public class GreaterEqualsIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v2 = stack.pop(); GraphTargetItem v1 = stack.pop(); stack.push(new GeAVM2Item(ins, v1, v2)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/GreaterThanIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/GreaterThanIns.java index 5efddfddc..9508ae123 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/GreaterThanIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/GreaterThanIns.java @@ -25,9 +25,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.GtAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class GreaterThanIns extends InstructionDefinition { @@ -36,7 +37,7 @@ public class GreaterThanIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v2 = stack.pop(); GraphTargetItem v1 = stack.pop(); stack.push(new GtAVM2Item(ins, v1, v2)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/LessEqualsIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/LessEqualsIns.java index a8a11b0d0..77d121f9b 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/LessEqualsIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/LessEqualsIns.java @@ -25,9 +25,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.LeAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class LessEqualsIns extends InstructionDefinition { @@ -36,7 +37,7 @@ public class LessEqualsIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v2 = stack.pop(); GraphTargetItem v1 = stack.pop(); stack.push(new LeAVM2Item(ins, v1, v2)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/LessThanIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/LessThanIns.java index b5d8c99c3..d447861e0 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/LessThanIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/LessThanIns.java @@ -25,9 +25,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.LtAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class LessThanIns extends InstructionDefinition { @@ -36,7 +37,7 @@ public class LessThanIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v2 = stack.pop(); GraphTargetItem v1 = stack.pop(); stack.push(new LtAVM2Item(ins, v1, v2)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/StrictEqualsIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/StrictEqualsIns.java index 67d0d2ea6..e5ad0ca79 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/StrictEqualsIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/StrictEqualsIns.java @@ -25,9 +25,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.StrictEqAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class StrictEqualsIns extends InstructionDefinition { @@ -36,7 +37,7 @@ public class StrictEqualsIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v2 = stack.pop(); GraphTargetItem v1 = stack.pop(); stack.push(new StrictEqAVM2Item(ins, v1, v2)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructIns.java index 9d77fe333..aa61ca175 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructIns.java @@ -35,10 +35,11 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.AddAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ConstructIns extends InstructionDefinition { @@ -75,7 +76,7 @@ public class ConstructIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) throws InterruptedException { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) throws InterruptedException { int argCount = ins.operands[0]; List args = new ArrayList<>(); for (int a = 0; a < argCount; a++) { diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructPropIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructPropIns.java index 6ef59124f..c6831a535 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructPropIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructPropIns.java @@ -28,10 +28,11 @@ import com.jpexs.decompiler.flash.abc.avm2.model.XMLAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ConstructPropIns extends InstructionDefinition { @@ -55,7 +56,7 @@ public class ConstructPropIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) throws InterruptedException { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) throws InterruptedException { int multinameIndex = ins.operands[0]; int argCount = ins.operands[1]; List args = new ArrayList<>(); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructSuperIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructSuperIns.java index d2f5c1efd..9904a4729 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructSuperIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructSuperIns.java @@ -26,10 +26,11 @@ import com.jpexs.decompiler.flash.abc.avm2.model.ConstructSuperAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ConstructSuperIns extends InstructionDefinition { @@ -51,7 +52,7 @@ public class ConstructSuperIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { int argCount = ins.operands[0]; List args = new ArrayList<>(); for (int a = 0; a < argCount; a++) { diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewActivationIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewActivationIns.java index a6034b3ef..1288a302b 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewActivationIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewActivationIns.java @@ -25,9 +25,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.NewActivationAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class NewActivationIns extends InstructionDefinition { @@ -36,7 +37,7 @@ public class NewActivationIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { stack.push(new NewActivationAVM2Item(ins)); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewArrayIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewArrayIns.java index e4c0d6326..cb81df29a 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewArrayIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewArrayIns.java @@ -25,10 +25,11 @@ import com.jpexs.decompiler.flash.abc.avm2.model.NewArrayAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class NewArrayIns extends InstructionDefinition { @@ -37,7 +38,7 @@ public class NewArrayIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { int argCount = ins.operands[0]; List args = new ArrayList<>(); for (int a = 0; a < argCount; a++) { diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewCatchIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewCatchIns.java index a0651488f..15889b306 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewCatchIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewCatchIns.java @@ -25,9 +25,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.clauses.ExceptionAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class NewCatchIns extends InstructionDefinition { @@ -36,7 +37,7 @@ public class NewCatchIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { int exInfo = ins.operands[0]; stack.push(new ExceptionAVM2Item(body.exceptions[exInfo])); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewClassIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewClassIns.java index 64eb4cced..88b632b26 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewClassIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewClassIns.java @@ -27,10 +27,11 @@ import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import com.jpexs.decompiler.graph.model.LocalData; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class NewClassIns extends InstructionDefinition { @@ -39,7 +40,7 @@ public class NewClassIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) throws InterruptedException { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) throws InterruptedException { int clsIndex = ins.operands[0]; HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false); stack.pop().toString(writer, LocalData.create(constants, localRegNames, fullyQualifiedNames)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewFunctionIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewFunctionIns.java index 02536e177..789036b85 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewFunctionIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewFunctionIns.java @@ -25,9 +25,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.NewFunctionAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class NewFunctionIns extends InstructionDefinition { @@ -36,7 +37,7 @@ public class NewFunctionIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { int methodIndex = ins.operands[0]; NewFunctionAVM2Item function = new NewFunctionAVM2Item(ins, "", path, isStatic, scriptIndex, classIndex, abc, fullyQualifiedNames, constants, method_info, methodIndex); stack.push(function); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewObjectIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewObjectIns.java index 783b15fac..939a0db76 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewObjectIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewObjectIns.java @@ -26,10 +26,11 @@ import com.jpexs.decompiler.flash.abc.avm2.model.NewObjectAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class NewObjectIns extends InstructionDefinition { @@ -38,7 +39,7 @@ public class NewObjectIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { int argCount = ins.operands[0]; List args = new ArrayList<>(); for (int a = 0; a < argCount; a++) { diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallIns.java index d02d98019..0eec99b14 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallIns.java @@ -26,10 +26,11 @@ import com.jpexs.decompiler.flash.abc.avm2.model.CallAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class CallIns extends InstructionDefinition { @@ -51,7 +52,7 @@ public class CallIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { int argCount = ins.operands[0]; List args = new ArrayList<>(); for (int a = 0; a < argCount; a++) { diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallMethodIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallMethodIns.java index 2da91c42c..eeba28db0 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallMethodIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallMethodIns.java @@ -26,10 +26,11 @@ import com.jpexs.decompiler.flash.abc.avm2.model.CallMethodAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class CallMethodIns extends InstructionDefinition { @@ -51,7 +52,7 @@ public class CallMethodIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { int methodIndex = ins.operands[0]; int argCount = ins.operands[1]; List args = new ArrayList<>(); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropLexIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropLexIns.java index 1e854e01c..02cb9e48a 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropLexIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropLexIns.java @@ -25,10 +25,11 @@ import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class CallPropLexIns extends CallPropertyIns { @@ -38,7 +39,7 @@ public class CallPropLexIns extends CallPropertyIns { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { int multinameIndex = ins.operands[0]; int argCount = ins.operands[1]; List args = new ArrayList<>(); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropVoidIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropVoidIns.java index bd3ccf9cf..34fa78e47 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropVoidIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropVoidIns.java @@ -27,10 +27,11 @@ import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class CallPropVoidIns extends InstructionDefinition { @@ -56,7 +57,7 @@ public class CallPropVoidIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { int multinameIndex = ins.operands[0]; int argCount = ins.operands[1]; List args = new ArrayList<>(); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropertyIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropertyIns.java index af1d96229..99d55d4ec 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropertyIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropertyIns.java @@ -27,10 +27,11 @@ import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class CallPropertyIns extends InstructionDefinition { @@ -54,7 +55,7 @@ public class CallPropertyIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { int multinameIndex = ins.operands[0]; int argCount = ins.operands[1]; List args = new ArrayList<>(); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallStaticIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallStaticIns.java index a5b00b0c4..f97d1ffd5 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallStaticIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallStaticIns.java @@ -26,10 +26,11 @@ import com.jpexs.decompiler.flash.abc.avm2.model.CallStaticAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class CallStaticIns extends InstructionDefinition { @@ -51,7 +52,7 @@ public class CallStaticIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { int methodIndex = ins.operands[0]; int argCount = ins.operands[1]; List args = new ArrayList<>(); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallSuperIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallSuperIns.java index e155b95e6..21915d67d 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallSuperIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallSuperIns.java @@ -27,10 +27,11 @@ import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class CallSuperIns extends InstructionDefinition { @@ -54,7 +55,7 @@ public class CallSuperIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { int multinameIndex = ins.operands[0]; int argCount = ins.operands[1]; List args = new ArrayList<>(); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallSuperVoidIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallSuperVoidIns.java index c1ce5923d..dfa3cbbfc 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallSuperVoidIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallSuperVoidIns.java @@ -27,10 +27,11 @@ import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class CallSuperVoidIns extends InstructionDefinition { @@ -54,7 +55,7 @@ public class CallSuperVoidIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { int multinameIndex = ins.operands[0]; int argCount = ins.operands[1]; List args = new ArrayList<>(); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfEqIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfEqIns.java index 2d13a9da3..073fc88f5 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfEqIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfEqIns.java @@ -27,6 +27,8 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.NeqAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -38,7 +40,7 @@ public class IfEqIns extends InstructionDefinition implements IfTypeIns { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v2 = stack.pop(); GraphTargetItem v1 = stack.pop(); stack.push(new EqAVM2Item(ins, v1, v2)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfFalseIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfFalseIns.java index 3a3cf0b44..b111a11d0 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfFalseIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfFalseIns.java @@ -25,6 +25,8 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import com.jpexs.decompiler.graph.model.NotItem; import java.util.HashMap; import java.util.List; @@ -37,7 +39,7 @@ public class IfFalseIns extends InstructionDefinition implements IfTypeIns { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v1 = stack.pop(); stack.push(new NotItem(ins, v1)); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfGeIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfGeIns.java index 91451be75..2caf5b6fe 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfGeIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfGeIns.java @@ -27,6 +27,8 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.LtAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -38,7 +40,7 @@ public class IfGeIns extends InstructionDefinition implements IfTypeIns { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v2 = stack.pop(); GraphTargetItem v1 = stack.pop(); stack.push(new GeAVM2Item(ins, v1, v2)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfGtIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfGtIns.java index a76331ff7..9afe2fc8b 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfGtIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfGtIns.java @@ -27,6 +27,8 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.LeAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -38,7 +40,7 @@ public class IfGtIns extends InstructionDefinition implements IfTypeIns { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v2 = stack.pop(); GraphTargetItem v1 = stack.pop(); stack.push(new GtAVM2Item(ins, v1, v2)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfLeIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfLeIns.java index aac40399c..b11c24263 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfLeIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfLeIns.java @@ -27,6 +27,8 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.LeAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -38,7 +40,7 @@ public class IfLeIns extends InstructionDefinition implements IfTypeIns { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v2 = stack.pop(); GraphTargetItem v1 = stack.pop(); stack.push(new LeAVM2Item(ins, v1, v2)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfLtIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfLtIns.java index e41e27ecb..5c4e29a37 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfLtIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfLtIns.java @@ -27,6 +27,8 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.LtAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -38,7 +40,7 @@ public class IfLtIns extends InstructionDefinition implements IfTypeIns { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v2 = stack.pop(); GraphTargetItem v1 = stack.pop(); stack.push(new LtAVM2Item(ins, v1, v2)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNGeIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNGeIns.java index 02ab8c9dd..8af869642 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNGeIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNGeIns.java @@ -27,6 +27,8 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.LtAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -38,7 +40,7 @@ public class IfNGeIns extends InstructionDefinition implements IfTypeIns { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v2 = stack.pop(); GraphTargetItem v1 = stack.pop(); stack.push(new LtAVM2Item(ins, v1, v2)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNGtIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNGtIns.java index 165142d88..87169db35 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNGtIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNGtIns.java @@ -27,6 +27,8 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.LeAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -38,7 +40,7 @@ public class IfNGtIns extends InstructionDefinition implements IfTypeIns { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v2 = stack.pop(); GraphTargetItem v1 = stack.pop(); stack.push(new LeAVM2Item(ins, v1, v2)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNLeIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNLeIns.java index e8aed6c41..11680303c 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNLeIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNLeIns.java @@ -27,6 +27,8 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.LeAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -38,7 +40,7 @@ public class IfNLeIns extends InstructionDefinition implements IfTypeIns { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v2 = stack.pop(); GraphTargetItem v1 = stack.pop(); stack.push(new GtAVM2Item(ins, v1, v2)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNLtIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNLtIns.java index 24e6653d9..9463182dd 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNLtIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNLtIns.java @@ -27,6 +27,8 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.LtAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -38,7 +40,7 @@ public class IfNLtIns extends InstructionDefinition implements IfTypeIns { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v2 = stack.pop(); GraphTargetItem v1 = stack.pop(); stack.push(new GeAVM2Item(ins, v1, v2)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNeIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNeIns.java index 7ece860b2..7a9432e63 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNeIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNeIns.java @@ -27,6 +27,8 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.NeqAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -38,7 +40,7 @@ public class IfNeIns extends InstructionDefinition implements IfTypeIns { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v2 = stack.pop(); GraphTargetItem v1 = stack.pop(); stack.push(new NeqAVM2Item(ins, v1, v2)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfStrictEqIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfStrictEqIns.java index 3c928a191..4bc7728bb 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfStrictEqIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfStrictEqIns.java @@ -27,6 +27,8 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.StrictNeqAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -38,7 +40,7 @@ public class IfStrictEqIns extends InstructionDefinition implements IfTypeIns { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v2 = stack.pop(); GraphTargetItem v1 = stack.pop(); stack.push(new StrictEqAVM2Item(ins, v1, v2)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfStrictNeIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfStrictNeIns.java index ed263d428..40f1e5249 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfStrictNeIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfStrictNeIns.java @@ -27,6 +27,8 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.StrictNeqAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -38,7 +40,7 @@ public class IfStrictNeIns extends InstructionDefinition implements IfTypeIns { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v2 = stack.pop(); GraphTargetItem v1 = stack.pop(); stack.push(new StrictNeqAVM2Item(ins, v1, v2)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfTrueIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfTrueIns.java index 06db86277..12df56876 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfTrueIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfTrueIns.java @@ -25,6 +25,8 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import com.jpexs.decompiler.graph.model.NotItem; import java.util.HashMap; import java.util.List; @@ -37,7 +39,7 @@ public class IfTrueIns extends InstructionDefinition implements IfTypeIns { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { //String v1 = stack.pop().toString(); //stack.push("(" + v1 + ")"); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/JumpIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/JumpIns.java index 9a4f67e2d..70f730095 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/JumpIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/JumpIns.java @@ -25,6 +25,8 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -36,7 +38,7 @@ public class JumpIns extends InstructionDefinition implements IfTypeIns { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { //stack.push(new BooleanAVM2Item(ins, Boolean.TRUE));// + ins.operands[0]); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/LookupSwitchIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/LookupSwitchIns.java index 1c7883a3b..432f6f731 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/LookupSwitchIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/LookupSwitchIns.java @@ -24,9 +24,10 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class LookupSwitchIns extends InstructionDefinition { @@ -35,7 +36,7 @@ public class LookupSwitchIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { //int defaultOffset = ins.operands[0]; //int caseCount = ins.operands[1]; //stack.push("switch(...)"); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIIns.java index 757631768..db2437b2b 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIIns.java @@ -28,9 +28,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.SubtractAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class DecLocalIIns extends InstructionDefinition { @@ -58,7 +59,7 @@ public class DecLocalIIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap regAssignCount, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap regAssignCount, int ip, HashMap> refs, AVM2Code code) { int regId = ins.operands[0]; output.add(new DecLocalAVM2Item(ins, regId)); if (localRegs.containsKey(regId)) { diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIns.java index 21a6d603e..503568cd9 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIns.java @@ -28,9 +28,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.SubtractAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class DecLocalIns extends InstructionDefinition { @@ -58,7 +59,7 @@ public class DecLocalIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap regAssignCount, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap regAssignCount, int ip, HashMap> refs, AVM2Code code) { int regId = ins.operands[0]; output.add(new DecLocalAVM2Item(ins, regId)); if (localRegs.containsKey(regId)) { diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal0Ins.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal0Ins.java index 38fb24c1d..9a8c9014e 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal0Ins.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal0Ins.java @@ -27,9 +27,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.ThisAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class GetLocal0Ins extends GetLocalTypeIns { @@ -43,7 +44,7 @@ public class GetLocal0Ins extends GetLocalTypeIns { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { if ((classIndex >= abc.instance_info.size()) || classIndex < 0) { stack.push(new ScriptAVM2Item(scriptIndex)); return; diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java index 1a186eaf9..39c5622b1 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java @@ -26,9 +26,10 @@ import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.NotCompileTimeItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public abstract class GetLocalTypeIns extends InstructionDefinition { @@ -37,7 +38,7 @@ public abstract class GetLocalTypeIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap regAssignCount, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap regAssignCount, int ip, HashMap> refs, AVM2Code code) { int regId = getRegisterId(ins); GraphTargetItem computedValue = localRegs.get(regId); int assignCount = 0; diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIIns.java index 3745cdf93..e1a4c81c7 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIIns.java @@ -27,9 +27,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.AddAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class IncLocalIIns extends InstructionDefinition { @@ -38,7 +39,7 @@ public class IncLocalIIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap regAssignCount, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap regAssignCount, int ip, HashMap> refs, AVM2Code code) { int regId = ins.operands[0]; output.add(new IncLocalAVM2Item(ins, regId)); if (localRegs.containsKey(regId)) { diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIns.java index 802f32257..9d8b46ea6 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIns.java @@ -27,9 +27,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.AddAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class IncLocalIns extends InstructionDefinition { @@ -38,7 +39,7 @@ public class IncLocalIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap regAssignCount, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap regAssignCount, int ip, HashMap> refs, AVM2Code code) { int regId = ins.operands[0]; output.add(new IncLocalAVM2Item(ins, regId)); if (localRegs.containsKey(regId)) { diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/KillIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/KillIns.java index fd3416b56..287f60553 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/KillIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/KillIns.java @@ -24,9 +24,10 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class KillIns extends InstructionDefinition { @@ -35,7 +36,7 @@ public class KillIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { //kill local register } } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocalTypeIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocalTypeIns.java index e96f0cad3..957226f13 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocalTypeIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocalTypeIns.java @@ -36,6 +36,8 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.PreIncrementAVM2Item import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -47,7 +49,7 @@ public abstract class SetLocalTypeIns extends InstructionDefinition implements S } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap regAssignCount, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap regAssignCount, int ip, HashMap> refs, AVM2Code code) { int regId = getRegisterId(ins); GraphTargetItem value = stack.pop(); /*if (localRegs.containsKey(regId)) { diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/DeletePropertyIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/DeletePropertyIns.java index f57a48968..9004d5f8e 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/DeletePropertyIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/DeletePropertyIns.java @@ -28,9 +28,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.DeletePropertyAVM2It import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class DeletePropertyIns extends InstructionDefinition { @@ -50,7 +51,7 @@ public class DeletePropertyIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { int multinameIndex = ins.operands[0]; FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins); GraphTargetItem obj = stack.pop(); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindDefIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindDefIns.java index 77d638624..e62a5583b 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindDefIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindDefIns.java @@ -26,9 +26,10 @@ import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class FindDefIns extends InstructionDefinition { @@ -37,7 +38,7 @@ public class FindDefIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { int multinameIndex = ins.operands[0]; Multiname multiname = constants.getMultiname(multinameIndex); stack.push(new FindDefAVM2Item(ins, multiname)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindPropertyIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindPropertyIns.java index 0e3a3f4f0..482a74045 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindPropertyIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindPropertyIns.java @@ -27,9 +27,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class FindPropertyIns extends InstructionDefinition { @@ -47,7 +48,7 @@ public class FindPropertyIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { int multinameIndex = ins.operands[0]; FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins); stack.push(new FindPropertyAVM2Item(ins, multiname)); //resolve right object diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindPropertyStrictIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindPropertyStrictIns.java index 16e404837..55a2e8739 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindPropertyStrictIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindPropertyStrictIns.java @@ -27,9 +27,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class FindPropertyStrictIns extends InstructionDefinition { @@ -46,7 +47,7 @@ public class FindPropertyStrictIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { int multinameIndex = ins.operands[0]; FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins); stack.push(new FindPropertyAVM2Item(ins, multiname)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetDescendantsIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetDescendantsIns.java index 5b87806cf..4d8cdf688 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetDescendantsIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetDescendantsIns.java @@ -27,9 +27,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.GetDescendantsAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class GetDescendantsIns extends InstructionDefinition { @@ -47,7 +48,7 @@ public class GetDescendantsIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { int multinameIndex = ins.operands[0]; FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins); GraphTargetItem obj = stack.pop(); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalScopeIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalScopeIns.java index 5ee495e77..e313e0f30 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalScopeIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalScopeIns.java @@ -27,9 +27,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.ScriptAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class GetGlobalScopeIns extends InstructionDefinition { @@ -43,7 +44,7 @@ public class GetGlobalScopeIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { if (scopeStack.isEmpty()) { if (classIndex == -1) { stack.push(new ScriptAVM2Item(scriptIndex)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalSlotIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalSlotIns.java index b98dd89ad..fa2fa06c8 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalSlotIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalSlotIns.java @@ -28,9 +28,10 @@ import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class GetGlobalSlotIns extends InstructionDefinition { @@ -39,7 +40,7 @@ public class GetGlobalSlotIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { int slotIndex = ins.operands[0]; GraphTargetItem obj = scopeStack.get(0); //scope Multiname slotname = null; diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetLexIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetLexIns.java index 97c4d05f4..76b196dce 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetLexIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetLexIns.java @@ -26,9 +26,10 @@ import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class GetLexIns extends InstructionDefinition { @@ -37,7 +38,7 @@ public class GetLexIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { int multinameIndex = ins.operands[0]; Multiname multiname = constants.getMultiname(multinameIndex); stack.push(new GetLexAVM2Item(ins, multiname)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java index 7853cd4f0..c9230d250 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java @@ -26,9 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.GetPropertyAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class GetPropertyIns extends InstructionDefinition { @@ -37,7 +38,7 @@ public class GetPropertyIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { int multinameIndex = ins.operands[0]; FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins); GraphTargetItem obj = stack.pop(); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetScopeObjectIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetScopeObjectIns.java index 190e50cdb..c14ee9d23 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetScopeObjectIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetScopeObjectIns.java @@ -24,9 +24,10 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class GetScopeObjectIns extends InstructionDefinition { @@ -35,7 +36,7 @@ public class GetScopeObjectIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { int index = ins.operands[0]; stack.push(scopeStack.get(index)); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSlotIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSlotIns.java index a26fb17c6..672e64a37 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSlotIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSlotIns.java @@ -33,9 +33,10 @@ import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.abc.types.traits.TraitWithSlot; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class GetSlotIns extends InstructionDefinition { @@ -44,7 +45,7 @@ public class GetSlotIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { int slotIndex = ins.operands[0]; GraphTargetItem obj = stack.pop(); //scope obj = obj.getThroughRegister(); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSuperIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSuperIns.java index 1202bc2f0..6935776c8 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSuperIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSuperIns.java @@ -26,9 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.GetSuperAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class GetSuperIns extends InstructionDefinition { @@ -37,7 +38,7 @@ public class GetSuperIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { int multinameIndex = ins.operands[0]; FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins); GraphTargetItem obj = stack.pop(); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/HasNext2Ins.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/HasNext2Ins.java index 41f229df2..793d74f0e 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/HasNext2Ins.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/HasNext2Ins.java @@ -26,9 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class HasNext2Ins extends InstructionDefinition { @@ -37,7 +38,7 @@ public class HasNext2Ins extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { int objectReg = ins.operands[0]; int indexReg = ins.operands[1]; //stack.push("_loc_" + objectReg + ".hasNext(cnt=_loc_" + indexReg + ")"); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/HasNextIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/HasNextIns.java index 8cba888f9..3a2985488 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/HasNextIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/HasNextIns.java @@ -25,9 +25,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.HasNextAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class HasNextIns extends InstructionDefinition { @@ -36,7 +37,7 @@ public class HasNextIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem curIndex = stack.pop(); GraphTargetItem obj = stack.pop(); stack.push(new HasNextAVM2Item(ins, curIndex, obj)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/InIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/InIns.java index fcbccc91c..eac8032fc 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/InIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/InIns.java @@ -25,9 +25,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.InAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class InIns extends InstructionDefinition { @@ -36,7 +37,7 @@ public class InIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem obj = stack.pop(); GraphTargetItem name = stack.pop(); stack.push(new InAVM2Item(ins, name, obj)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/InitPropertyIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/InitPropertyIns.java index f2ef6d8b7..85a198522 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/InitPropertyIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/InitPropertyIns.java @@ -26,9 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.InitPropertyAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class InitPropertyIns extends InstructionDefinition { @@ -37,7 +38,7 @@ public class InitPropertyIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { int multinameIndex = ins.operands[0]; GraphTargetItem val = stack.pop(); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/NextNameIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/NextNameIns.java index 91fb92946..dbd5ec4a6 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/NextNameIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/NextNameIns.java @@ -25,9 +25,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.NextNameAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class NextNameIns extends InstructionDefinition { @@ -36,7 +37,7 @@ public class NextNameIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem index = stack.pop(); GraphTargetItem obj = stack.pop(); stack.push(new NextNameAVM2Item(ins, index, obj)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/NextValueIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/NextValueIns.java index 1381be249..af06872b5 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/NextValueIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/NextValueIns.java @@ -25,9 +25,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.NextValueAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class NextValueIns extends InstructionDefinition { @@ -36,7 +37,7 @@ public class NextValueIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem index = stack.pop(); GraphTargetItem obj = stack.pop(); stack.push(new NextValueAVM2Item(ins, index, obj)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ReturnValueIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ReturnValueIns.java index c5a436e44..16185f400 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ReturnValueIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ReturnValueIns.java @@ -25,9 +25,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.ReturnValueAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ReturnValueIns extends InstructionDefinition { @@ -36,7 +37,7 @@ public class ReturnValueIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { output.add(new ReturnValueAVM2Item(ins, stack.pop())); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ReturnVoidIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ReturnVoidIns.java index f5336da17..b34c547c8 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ReturnVoidIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ReturnVoidIns.java @@ -25,9 +25,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.ReturnVoidAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ReturnVoidIns extends InstructionDefinition { @@ -36,7 +37,7 @@ public class ReturnVoidIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { output.add(new ReturnVoidAVM2Item(ins)); } } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetGlobalSlotIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetGlobalSlotIns.java index 9680d76ae..3773b3d54 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetGlobalSlotIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetGlobalSlotIns.java @@ -27,6 +27,8 @@ import com.jpexs.decompiler.flash.abc.avm2.model.SetGlobalSlotAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -38,7 +40,7 @@ public class SetGlobalSlotIns extends InstructionDefinition implements SetTypeIn } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { output.add(new SetGlobalSlotAVM2Item(ins, ins.operands[0], stack.pop())); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetPropertyIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetPropertyIns.java index 366864104..df9a83783 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetPropertyIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetPropertyIns.java @@ -39,6 +39,8 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.PreIncrementAVM2Item import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -51,7 +53,7 @@ public class SetPropertyIns extends InstructionDefinition implements SetTypeIns } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { int multinameIndex = ins.operands[0]; GraphTargetItem value = stack.pop(); FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSlotIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSlotIns.java index 649f278cd..2a8a676d2 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSlotIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSlotIns.java @@ -44,6 +44,8 @@ import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst; import com.jpexs.decompiler.flash.abc.types.traits.TraitWithSlot; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -55,7 +57,7 @@ public class SetSlotIns extends InstructionDefinition implements SetTypeIns { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { int slotIndex = ins.operands[0]; GraphTargetItem value = stack.pop(); GraphTargetItem obj = stack.pop(); //scopeId diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSuperIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSuperIns.java index 7009dfad9..3838c3593 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSuperIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSuperIns.java @@ -30,6 +30,8 @@ import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import com.jpexs.decompiler.graph.model.LocalData; import java.util.HashMap; import java.util.List; @@ -42,7 +44,7 @@ public class SetSuperIns extends InstructionDefinition implements SetTypeIns { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { int multinameIndex = ins.operands[0]; GraphTargetItem value = stack.pop(); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ThrowIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ThrowIns.java index 904aafffe..d9be45d19 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ThrowIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ThrowIns.java @@ -25,9 +25,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.ThrowAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ThrowIns extends InstructionDefinition { @@ -36,7 +37,7 @@ public class ThrowIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { output.add(new ThrowAVM2Item(ins, stack.pop())); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/DupIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/DupIns.java index 069a343ef..22a0f85e7 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/DupIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/DupIns.java @@ -25,10 +25,11 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import com.jpexs.decompiler.graph.model.DuplicateItem; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class DupIns extends InstructionDefinition { @@ -44,7 +45,7 @@ public class DupIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem v = stack.pop(); stack.push(v); stack.push(new DuplicateItem(ins, v)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PopIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PopIns.java index 101f3dc38..97a3840c1 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PopIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PopIns.java @@ -26,9 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class PopIns extends InstructionDefinition { @@ -42,7 +43,7 @@ public class PopIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { if (stack.size() > 0) { GraphTargetItem top = stack.pop(); //Note: Commands like "5;" - numbers are unsupported as it collide with try..finally block decompilation. TODO: allow this somehow diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PopScopeIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PopScopeIns.java index ac5cff751..56c33c5d0 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PopScopeIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PopScopeIns.java @@ -27,9 +27,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.WithObjectAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class PopScopeIns extends InstructionDefinition { @@ -43,7 +44,7 @@ public class PopScopeIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem scope = scopeStack.pop(); if (scope instanceof WithObjectAVM2Item) { scope = ((WithObjectAVM2Item) scope).scope; diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushByteIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushByteIns.java index 727cab0db..222258a59 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushByteIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushByteIns.java @@ -26,9 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class PushByteIns extends InstructionDefinition implements PushIntegerTypeIns { @@ -42,7 +43,7 @@ public class PushByteIns extends InstructionDefinition implements PushIntegerTyp } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { stack.push(new IntegerValueAVM2Item(ins, Long.valueOf(ins.operands[0]))); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushDoubleIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushDoubleIns.java index 45a01e171..36ab7b4c3 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushDoubleIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushDoubleIns.java @@ -26,9 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.FloatValueAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class PushDoubleIns extends InstructionDefinition { @@ -42,7 +43,7 @@ public class PushDoubleIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { stack.push(new FloatValueAVM2Item(ins, constants.getDouble(ins.operands[0]))); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushFalseIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushFalseIns.java index 02f642eb2..2ce908986 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushFalseIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushFalseIns.java @@ -26,9 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.BooleanAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class PushFalseIns extends InstructionDefinition { @@ -42,7 +43,7 @@ public class PushFalseIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { stack.push(new BooleanAVM2Item(ins, Boolean.FALSE)); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushIntIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushIntIns.java index 34bee82cb..e4ff5b65e 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushIntIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushIntIns.java @@ -26,9 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class PushIntIns extends InstructionDefinition implements PushIntegerTypeIns { @@ -42,7 +43,7 @@ public class PushIntIns extends InstructionDefinition implements PushIntegerType } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { stack.push(new IntegerValueAVM2Item(ins, constants.getInt(ins.operands[0]))); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNamespaceIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNamespaceIns.java index dd11f57f3..aee4dd7d2 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNamespaceIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNamespaceIns.java @@ -25,9 +25,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.NameSpaceAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class PushNamespaceIns extends InstructionDefinition { @@ -36,7 +37,7 @@ public class PushNamespaceIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { stack.push(new NameSpaceAVM2Item(ins, ins.operands[0])); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNanIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNanIns.java index 65b4c2235..acf01f0e3 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNanIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNanIns.java @@ -25,9 +25,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.NanAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class PushNanIns extends InstructionDefinition { @@ -36,7 +37,7 @@ public class PushNanIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { stack.push(new NanAVM2Item(ins)); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNullIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNullIns.java index e692d30b5..4f46562a1 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNullIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNullIns.java @@ -25,9 +25,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.NullAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class PushNullIns extends InstructionDefinition { @@ -36,7 +37,7 @@ public class PushNullIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { stack.push(new NullAVM2Item(ins)); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushScopeIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushScopeIns.java index 97a9867f6..891d31958 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushScopeIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushScopeIns.java @@ -25,9 +25,10 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class PushScopeIns extends InstructionDefinition { @@ -41,7 +42,7 @@ public class PushScopeIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { scopeStack.push(stack.pop()); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushShortIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushShortIns.java index bc2b8a0f0..5e9000e9f 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushShortIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushShortIns.java @@ -26,9 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class PushShortIns extends InstructionDefinition implements PushIntegerTypeIns { @@ -42,7 +43,7 @@ public class PushShortIns extends InstructionDefinition implements PushIntegerTy } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { stack.push(new IntegerValueAVM2Item(ins, Long.valueOf((long) (short) ins.operands[0]))); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushStringIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushStringIns.java index e28fd7312..3b7be1bbe 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushStringIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushStringIns.java @@ -26,9 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.StringAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class PushStringIns extends InstructionDefinition { @@ -42,7 +43,7 @@ public class PushStringIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { stack.push(new StringAVM2Item(ins, constants.getString(ins.operands[0]))); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushTrueIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushTrueIns.java index d096365ae..53f1db5ec 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushTrueIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushTrueIns.java @@ -26,9 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.BooleanAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class PushTrueIns extends InstructionDefinition { @@ -42,7 +43,7 @@ public class PushTrueIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { stack.push(new BooleanAVM2Item(ins, Boolean.TRUE)); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushUIntIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushUIntIns.java index c63e32c94..cfad84d42 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushUIntIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushUIntIns.java @@ -26,9 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class PushUIntIns extends InstructionDefinition implements PushIntegerTypeIns { @@ -42,7 +43,7 @@ public class PushUIntIns extends InstructionDefinition implements PushIntegerTyp } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { stack.push(new IntegerValueAVM2Item(ins, constants.getUInt(ins.operands[0]))); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushUndefinedIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushUndefinedIns.java index 7666e1dd4..9193a87b8 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushUndefinedIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushUndefinedIns.java @@ -25,9 +25,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.UndefinedAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class PushUndefinedIns extends InstructionDefinition { @@ -36,7 +37,7 @@ public class PushUndefinedIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { stack.push(new UndefinedAVM2Item(ins)); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushWithIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushWithIns.java index 3c98155e1..971714bde 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushWithIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushWithIns.java @@ -26,9 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.WithObjectAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class PushWithIns extends InstructionDefinition { @@ -37,7 +38,7 @@ public class PushWithIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem w = stack.pop(); WithObjectAVM2Item wot = new WithObjectAVM2Item(ins, w); scopeStack.push(wot); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/SwapIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/SwapIns.java index 40b41cd52..576d50041 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/SwapIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/SwapIns.java @@ -26,9 +26,10 @@ import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphSourceItemPos; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class SwapIns extends InstructionDefinition { @@ -45,7 +46,7 @@ public class SwapIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem o1 = stack.pop(); GraphTargetItem o2 = stack.pop(); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ApplyTypeIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ApplyTypeIns.java index 306e88edf..0c9cbee29 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ApplyTypeIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ApplyTypeIns.java @@ -26,11 +26,12 @@ import com.jpexs.decompiler.flash.abc.avm2.model.ApplyTypeAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ApplyTypeIns extends InstructionDefinition { @@ -50,7 +51,7 @@ public class ApplyTypeIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { int argCount = ins.operands[0]; List params = new ArrayList<>(); for (int i = 0; i < argCount; i++) { diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/AsTypeIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/AsTypeIns.java index 6bf83269a..b31479f6c 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/AsTypeIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/AsTypeIns.java @@ -27,9 +27,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.AsTypeAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class AsTypeIns extends InstructionDefinition { @@ -48,7 +49,7 @@ public class AsTypeIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem val = stack.pop(); stack.push(new AsTypeAVM2Item(ins, val, new FullMultinameAVM2Item(ins, ins.operands[0]))); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/AsTypeLateIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/AsTypeLateIns.java index d17d1258b..efe87b6c9 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/AsTypeLateIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/AsTypeLateIns.java @@ -26,9 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.AsTypeAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class AsTypeLateIns extends InstructionDefinition { @@ -46,7 +47,7 @@ public class AsTypeLateIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem cls = stack.pop(); GraphTargetItem val = stack.pop(); stack.push(new AsTypeAVM2Item(ins, val, cls)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceAIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceAIns.java index 539a7a93c..e7742ba38 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceAIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceAIns.java @@ -26,10 +26,11 @@ import com.jpexs.decompiler.flash.abc.avm2.model.CoerceAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import com.jpexs.decompiler.graph.TypeItem; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class CoerceAIns extends InstructionDefinition implements CoerceOrConvertTypeIns { @@ -47,7 +48,7 @@ public class CoerceAIns extends InstructionDefinition implements CoerceOrConvert } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { stack.push(new CoerceAVM2Item(ins, stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceIns.java index 7dbfe2b12..244c61521 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceIns.java @@ -27,9 +27,10 @@ import com.jpexs.decompiler.flash.abc.avm2.parser.script.PropertyAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class CoerceIns extends InstructionDefinition implements CoerceOrConvertTypeIns { @@ -44,7 +45,7 @@ public class CoerceIns extends InstructionDefinition implements CoerceOrConvertT } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { int multinameIndex = ins.operands[0]; stack.push(new CoerceAVM2Item(ins, stack.pop(), PropertyAVM2Item.multinameToType(multinameIndex, constants))); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceSIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceSIns.java index 23151202f..5d0b4ceab 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceSIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceSIns.java @@ -26,10 +26,11 @@ import com.jpexs.decompiler.flash.abc.avm2.model.CoerceAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import com.jpexs.decompiler.graph.TypeItem; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class CoerceSIns extends InstructionDefinition implements CoerceOrConvertTypeIns { @@ -44,7 +45,7 @@ public class CoerceSIns extends InstructionDefinition implements CoerceOrConvert } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { stack.push(new CoerceAVM2Item(ins, stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertBIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertBIns.java index 4870d770e..aa8960db2 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertBIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertBIns.java @@ -26,10 +26,11 @@ import com.jpexs.decompiler.flash.abc.avm2.model.ConvertAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import com.jpexs.decompiler.graph.TypeItem; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ConvertBIns extends InstructionDefinition implements CoerceOrConvertTypeIns { @@ -54,7 +55,7 @@ public class ConvertBIns extends InstructionDefinition implements CoerceOrConver } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { stack.push(new ConvertAVM2Item(ins, stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertDIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertDIns.java index 295211781..15fbd1572 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertDIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertDIns.java @@ -26,10 +26,11 @@ import com.jpexs.decompiler.flash.abc.avm2.model.ConvertAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import com.jpexs.decompiler.graph.TypeItem; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ConvertDIns extends InstructionDefinition implements CoerceOrConvertTypeIns { @@ -62,7 +63,7 @@ public class ConvertDIns extends InstructionDefinition implements CoerceOrConver } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { stack.push(new ConvertAVM2Item(ins, stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertIIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertIIns.java index 9b6d51cd2..c2c7b56e9 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertIIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertIIns.java @@ -26,10 +26,11 @@ import com.jpexs.decompiler.flash.abc.avm2.model.ConvertAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import com.jpexs.decompiler.graph.TypeItem; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ConvertIIns extends InstructionDefinition implements CoerceOrConvertTypeIns { @@ -60,7 +61,7 @@ public class ConvertIIns extends InstructionDefinition implements CoerceOrConver } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { stack.push(new ConvertAVM2Item(ins, stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertOIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertOIns.java index 1b8aaf2c6..a842aa4e8 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertOIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertOIns.java @@ -26,10 +26,11 @@ import com.jpexs.decompiler.flash.abc.avm2.model.ConvertAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import com.jpexs.decompiler.graph.TypeItem; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ConvertOIns extends InstructionDefinition implements CoerceOrConvertTypeIns { @@ -43,7 +44,7 @@ public class ConvertOIns extends InstructionDefinition implements CoerceOrConver } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { stack.push(new ConvertAVM2Item(ins, stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertSIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertSIns.java index fbf5355b7..9547dc2ab 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertSIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertSIns.java @@ -26,10 +26,11 @@ import com.jpexs.decompiler.flash.abc.avm2.model.ConvertAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import com.jpexs.decompiler.graph.TypeItem; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ConvertSIns extends InstructionDefinition implements CoerceOrConvertTypeIns { @@ -44,7 +45,7 @@ public class ConvertSIns extends InstructionDefinition implements CoerceOrConver } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { stack.push(new ConvertAVM2Item(ins, stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertUIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertUIns.java index 851f55c76..447b4e695 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertUIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertUIns.java @@ -26,10 +26,11 @@ import com.jpexs.decompiler.flash.abc.avm2.model.ConvertAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import com.jpexs.decompiler.graph.TypeItem; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ConvertUIns extends InstructionDefinition implements CoerceOrConvertTypeIns { @@ -43,7 +44,7 @@ public class ConvertUIns extends InstructionDefinition implements CoerceOrConver } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { stack.push(new ConvertAVM2Item(ins, stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/InstanceOfIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/InstanceOfIns.java index 79749b797..f1f24d8c2 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/InstanceOfIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/InstanceOfIns.java @@ -25,9 +25,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.InstanceOfAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class InstanceOfIns extends InstructionDefinition { @@ -36,7 +37,7 @@ public class InstanceOfIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem type = stack.pop(); GraphTargetItem value = stack.pop(); stack.push(new InstanceOfAVM2Item(ins, value, type)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/IsTypeIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/IsTypeIns.java index 68f0bda20..eb41a70f6 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/IsTypeIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/IsTypeIns.java @@ -26,9 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.IsTypeAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class IsTypeIns extends InstructionDefinition { @@ -37,7 +38,7 @@ public class IsTypeIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { int multinameIndex = ins.operands[0]; GraphTargetItem value = stack.pop(); stack.push(new IsTypeAVM2Item(ins, value, new FullMultinameAVM2Item(ins, multinameIndex))); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/IsTypeLateIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/IsTypeLateIns.java index 0545c511d..f75610fed 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/IsTypeLateIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/IsTypeLateIns.java @@ -25,9 +25,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.IsTypeAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class IsTypeLateIns extends InstructionDefinition { @@ -36,7 +37,7 @@ public class IsTypeLateIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem type = stack.pop(); GraphTargetItem value = stack.pop(); stack.push(new IsTypeAVM2Item(ins, value, type)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/TypeOfIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/TypeOfIns.java index 2ec2dc9f3..d04b066ed 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/TypeOfIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/TypeOfIns.java @@ -25,9 +25,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.TypeOfAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class TypeOfIns extends InstructionDefinition { @@ -36,7 +37,7 @@ public class TypeOfIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { stack.push(new TypeOfAVM2Item(ins, stack.pop())); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/CheckFilterIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/CheckFilterIns.java index a2a4afd78..280b92d6b 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/CheckFilterIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/CheckFilterIns.java @@ -26,9 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.FilteredCheckAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class CheckFilterIns extends InstructionDefinition { @@ -42,7 +43,7 @@ public class CheckFilterIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem obj = stack.pop(); stack.push(new FilteredCheckAVM2Item(ins, obj)); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/DXNSIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/DXNSIns.java index c2dae4322..98e5fe7bc 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/DXNSIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/DXNSIns.java @@ -1,53 +1,54 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.xml; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; -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.model.DefaultXMLNamespace; -import com.jpexs.decompiler.flash.abc.avm2.model.StringAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class DXNSIns extends InstructionDefinition { - - public DXNSIns() { - super(0x06, "dxns", new int[]{AVM2Code.DAT_STRING_INDEX}); - } - - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - int strIndex = (int) ((Long) arguments.get(0)).longValue(); - String s = constants.getString(strIndex); - System.out.println("Set default XML space " + s); - - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - //FIXME!!! - search namespace - output.add(new DefaultXMLNamespace(ins, new StringAVM2Item(ins, constants.getString(ins.operands[0])))); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.xml; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; +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.model.DefaultXMLNamespace; +import com.jpexs.decompiler.flash.abc.avm2.model.StringAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; +import java.util.HashMap; +import java.util.List; + +public class DXNSIns extends InstructionDefinition { + + public DXNSIns() { + super(0x06, "dxns", new int[]{AVM2Code.DAT_STRING_INDEX}); + } + + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + int strIndex = (int) ((Long) arguments.get(0)).longValue(); + String s = constants.getString(strIndex); + System.out.println("Set default XML space " + s); + + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + //FIXME!!! - search namespace + output.add(new DefaultXMLNamespace(ins, new StringAVM2Item(ins, constants.getString(ins.operands[0])))); + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/DXNSLateIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/DXNSLateIns.java index 4d571dd9b..207f51fb4 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/DXNSLateIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/DXNSLateIns.java @@ -26,9 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.DefaultXMLNamespace; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class DXNSLateIns extends InstructionDefinition { @@ -43,7 +44,7 @@ public class DXNSLateIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { GraphTargetItem xmlns = stack.pop(); output.add(new DefaultXMLNamespace(ins, xmlns)); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/EscXAttrIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/EscXAttrIns.java index 624ac21cd..8beab2475 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/EscXAttrIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/EscXAttrIns.java @@ -26,9 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.EscapeXAttrAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class EscXAttrIns extends InstructionDefinition { @@ -44,7 +45,7 @@ public class EscXAttrIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { stack.push(new EscapeXAttrAVM2Item(ins, stack.pop())); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/EscXElemIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/EscXElemIns.java index f338a3fbd..3b8912046 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/EscXElemIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/EscXElemIns.java @@ -26,9 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.model.EscapeXElemAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class EscXElemIns extends InstructionDefinition { @@ -44,7 +45,7 @@ public class EscXElemIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { stack.push(new EscapeXElemAVM2Item(ins, stack.pop())); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java b/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java index 5496fadd8..c141b7c93 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java @@ -25,10 +25,10 @@ import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.helpers.NulWriter; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; import com.jpexs.decompiler.graph.TypeItem; import com.jpexs.decompiler.graph.model.LocalData; import java.util.List; -import java.util.Stack; public class NewFunctionAVM2Item extends AVM2Item { @@ -70,9 +70,9 @@ public class NewFunctionAVM2Item extends AVM2Item { writer.startBlock(); if (body != null) { if (writer instanceof NulWriter) { - body.convert(path + "/inner", ScriptExportMode.AS, isStatic, scriptIndex, classIndex, abc, null, constants, methodInfo, new Stack()/*scopeStack*/, false, writer, fullyQualifiedNames, null, false); + body.convert(path + "/inner", ScriptExportMode.AS, isStatic, scriptIndex, classIndex, abc, null, constants, methodInfo, new ScopeStack(), false, writer, fullyQualifiedNames, null, false); } else { - body.toString(path + "/inner", ScriptExportMode.AS, isStatic, scriptIndex, classIndex, abc, null, constants, methodInfo, new Stack()/*scopeStack*/, false, writer, fullyQualifiedNames, null); + body.toString(path + "/inner", ScriptExportMode.AS, abc, null, constants, methodInfo, writer, fullyQualifiedNames); } } writer.endBlock(); diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AssignableAVM2Item.java b/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AssignableAVM2Item.java index a1d8781c6..9b66d7ab8 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AssignableAVM2Item.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AssignableAVM2Item.java @@ -1,172 +1,172 @@ -/* - * Copyright (C) 2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.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.model.AVM2Item; -import com.jpexs.decompiler.graph.CompilationException; -import com.jpexs.decompiler.graph.GraphSourceItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.decompiler.graph.SourceGenerator; -import java.util.ArrayList; -import java.util.List; - -/** - * - * @author JPEXS - */ -public abstract class AssignableAVM2Item extends AVM2Item { - - protected GraphTargetItem assignedValue; - - public AssignableAVM2Item() { - this(null); - } - - public abstract AssignableAVM2Item copy(); - - public AssignableAVM2Item(GraphTargetItem storeValue) { - super(null, PRECEDENCE_PRIMARY); - this.assignedValue = storeValue; - } - - public abstract List toSourceChange(SourceGeneratorLocalData localData, SourceGenerator generator, boolean post, boolean decrement, boolean needsReturn) throws CompilationException; - - public GraphTargetItem getAssignedValue() { - return assignedValue; - } - - public void setAssignedValue(GraphTargetItem storeValue) { - this.assignedValue = storeValue; - } - - 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(generateSetLoc(register.getVal())); - return ret; - } - - public static List setTemp(SourceGeneratorLocalData localData, SourceGenerator generator, Reference register) { - register.setVal(getFreeRegister(localData, generator)); - List ret = new ArrayList<>(); - ret.add(generateSetLoc(register.getVal())); - return ret; - } - - public static List getTemp(SourceGeneratorLocalData localData, SourceGenerator generator, Reference register) { - if (register.getVal() < 0) { - return new ArrayList<>(); - } - List ret = new ArrayList<>(); - ret.add(generateGetLoc(register.getVal())); - return ret; - } - - /*protected List getAndKillTemp(SourceGeneratorLocalData localData, SourceGenerator generator, Reference register) { - killRegister(localData, generator, register.getVal()); - List ret = new ArrayList<>(); - ret.add(generateGetLoc(register.getVal())); - ret.add(ins(new KillIns(), register.getVal())); - return ret; - }*/ - @SuppressWarnings("unchecked") - public static List killTemp(SourceGeneratorLocalData localData, SourceGenerator generator, List> registers) { - List ret = new ArrayList<>(); - for (Reference register : registers) { - if (register.getVal() < 0) { - continue; - } - killRegister(localData, generator, register.getVal()); - - ret.add(ins(new KillIns(), register.getVal())); - } - return ret; - } - - public static AVM2Instruction generateSetLoc(int regNumber) { - switch (regNumber) { - case -1: - return null; - case 0: - return ins(new SetLocal0Ins()); - case 1: - return ins(new SetLocal1Ins()); - case 2: - return ins(new SetLocal2Ins()); - case 3: - return ins(new SetLocal3Ins()); - default: - return ins(new SetLocalIns(), regNumber); - } - } - - public static AVM2Instruction generateGetLoc(int regNumber) { - switch (regNumber) { - case -1: - return null; - case 0: - return ins(new GetLocal0Ins()); - case 1: - return ins(new GetLocal1Ins()); - case 2: - return ins(new GetLocal2Ins()); - case 3: - return ins(new GetLocal3Ins()); - default: - return ins(new GetLocalIns(), regNumber); - } - } - - public static List generateGetSlot(int slotScope, int slotNumber) { - if (slotNumber == -1) { - return null; - } - List ret = new ArrayList<>(); - ret.add(ins(new GetScopeObjectIns(), slotScope)); - ret.add(ins(new GetSlotIns(), slotNumber)); - return ret; - } - - public static List generateSetSlot(SourceGeneratorLocalData localData, SourceGenerator generator, GraphTargetItem val, int slotScope, int slotNumber) throws CompilationException { - if (slotNumber == -1) { - return null; - } - List ret = new ArrayList<>(); - ret.add(ins(new GetScopeObjectIns(), slotScope)); - ret.addAll(val.toSource(localData, generator)); - ret.add(ins(new SetSlotIns(), slotNumber)); - return ret; - } -} +/* + * Copyright (C) 2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.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.model.AVM2Item; +import com.jpexs.decompiler.graph.CompilationException; +import com.jpexs.decompiler.graph.GraphSourceItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; +import java.util.ArrayList; +import java.util.List; + +/** + * + * @author JPEXS + */ +public abstract class AssignableAVM2Item extends AVM2Item { + + protected GraphTargetItem assignedValue; + + public AssignableAVM2Item() { + this(null); + } + + public abstract AssignableAVM2Item copy(); + + public AssignableAVM2Item(GraphTargetItem storeValue) { + super(null, PRECEDENCE_PRIMARY); + this.assignedValue = storeValue; + } + + public abstract List toSourceChange(SourceGeneratorLocalData localData, SourceGenerator generator, boolean post, boolean decrement, boolean needsReturn) throws CompilationException; + + public GraphTargetItem getAssignedValue() { + return assignedValue; + } + + public void setAssignedValue(GraphTargetItem storeValue) { + this.assignedValue = storeValue; + } + + 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(generateSetLoc(register.getVal())); + return ret; + } + + public static List setTemp(SourceGeneratorLocalData localData, SourceGenerator generator, Reference register) { + register.setVal(getFreeRegister(localData, generator)); + List ret = new ArrayList<>(); + ret.add(generateSetLoc(register.getVal())); + return ret; + } + + public static List getTemp(SourceGeneratorLocalData localData, SourceGenerator generator, Reference register) { + if (register.getVal() < 0) { + return new ArrayList<>(); + } + List ret = new ArrayList<>(); + ret.add(generateGetLoc(register.getVal())); + return ret; + } + + /*protected List getAndKillTemp(SourceGeneratorLocalData localData, SourceGenerator generator, Reference register) { + killRegister(localData, generator, register.getVal()); + List ret = new ArrayList<>(); + ret.add(generateGetLoc(register.getVal())); + ret.add(ins(new KillIns(), register.getVal())); + return ret; + }*/ + //@SuppressWarnings("unchecked") + public static List killTemp(SourceGeneratorLocalData localData, SourceGenerator generator, List> registers) { + List ret = new ArrayList<>(); + for (Reference register : registers) { + if (register.getVal() < 0) { + continue; + } + killRegister(localData, generator, register.getVal()); + + ret.add(ins(new KillIns(), register.getVal())); + } + return ret; + } + + public static AVM2Instruction generateSetLoc(int regNumber) { + switch (regNumber) { + case -1: + return null; + case 0: + return ins(new SetLocal0Ins()); + case 1: + return ins(new SetLocal1Ins()); + case 2: + return ins(new SetLocal2Ins()); + case 3: + return ins(new SetLocal3Ins()); + default: + return ins(new SetLocalIns(), regNumber); + } + } + + public static AVM2Instruction generateGetLoc(int regNumber) { + switch (regNumber) { + case -1: + return null; + case 0: + return ins(new GetLocal0Ins()); + case 1: + return ins(new GetLocal1Ins()); + case 2: + return ins(new GetLocal2Ins()); + case 3: + return ins(new GetLocal3Ins()); + default: + return ins(new GetLocalIns(), regNumber); + } + } + + public static List generateGetSlot(int slotScope, int slotNumber) { + if (slotNumber == -1) { + return null; + } + List ret = new ArrayList<>(); + ret.add(ins(new GetScopeObjectIns(), slotScope)); + ret.add(ins(new GetSlotIns(), slotNumber)); + return ret; + } + + public static List generateSetSlot(SourceGeneratorLocalData localData, SourceGenerator generator, GraphTargetItem val, int slotScope, int slotNumber) throws CompilationException { + if (slotNumber == -1) { + return null; + } + List ret = new ArrayList<>(); + ret.add(ins(new GetScopeObjectIns(), slotScope)); + ret.addAll(val.toSource(localData, generator)); + ret.add(ins(new SetSlotIns(), slotNumber)); + return ret; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java b/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java index efc408535..128076430 100644 --- a/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java +++ b/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java @@ -28,6 +28,7 @@ import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.Graph; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; import com.jpexs.decompiler.graph.model.LocalData; import com.jpexs.helpers.CancellableWorker; import com.jpexs.helpers.Helper; @@ -35,7 +36,6 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Stack; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; @@ -123,7 +123,7 @@ public class MethodBody implements Cloneable, Serializable { return ret; } - public void convert(final String path, ScriptExportMode exportMode, final boolean isStatic, final int scriptIndex, final int classIndex, final ABC abc, final Trait trait, final ConstantPool constants, final List method_info, final Stack scopeStack, final boolean isStaticInitializer, final GraphTextWriter writer, final List fullyQualifiedNames, final Traits initTraits, boolean firstLevel) throws InterruptedException { + public void convert(final String path, ScriptExportMode exportMode, final boolean isStatic, final int scriptIndex, final int classIndex, final ABC abc, final Trait trait, final ConstantPool constants, final List method_info, final ScopeStack scopeStack, final boolean isStaticInitializer, final GraphTextWriter writer, final List fullyQualifiedNames, final Traits initTraits, boolean firstLevel) throws InterruptedException { if (debugMode) { System.err.println("Decompiling " + path); } @@ -163,7 +163,7 @@ public class MethodBody implements Cloneable, Serializable { } } - public GraphTextWriter toString(final String path, ScriptExportMode exportMode, final boolean isStatic, final int scriptIndex, final int classIndex, final ABC abc, final Trait trait, final ConstantPool constants, final List method_info, final Stack scopeStack, final boolean isStaticInitializer, final GraphTextWriter writer, final List fullyQualifiedNames, final Traits initTraits) throws InterruptedException { + public GraphTextWriter toString(final String path, ScriptExportMode exportMode, final ABC abc, final Trait trait, final ConstantPool constants, final List method_info, final GraphTextWriter writer, final List fullyQualifiedNames) throws InterruptedException { if (exportMode != ScriptExportMode.AS) { code.toASMSource(constants, trait, method_info.get(this.method_info), this, exportMode, writer); } else { @@ -191,7 +191,7 @@ public class MethodBody implements Cloneable, Serializable { return writer; } - public MethodBody convertMethodBody(String path, boolean isStatic, int scriptIndex, int classIndex, ABC abc, Trait trait, ConstantPool constants, List method_info, Stack scopeStack, boolean isStaticInitializer, List fullyQualifiedNames, Traits initTraits) throws InterruptedException { + public MethodBody convertMethodBody(String path, boolean isStatic, int scriptIndex, int classIndex, ABC abc, Trait trait, ConstantPool constants, List method_info, ScopeStack scopeStack, boolean isStaticInitializer, List fullyQualifiedNames, Traits initTraits) throws InterruptedException { MethodBody b = Helper.deepCopy(this); AVM2Code deobfuscated = b.code; deobfuscated.markMappedOffsets(); diff --git a/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java b/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java index 4c6917f1b..af527777e 100644 --- a/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java +++ b/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java @@ -35,11 +35,10 @@ import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.helpers.NulWriter; import com.jpexs.decompiler.flash.tags.ABCContainerTag; -import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; import com.jpexs.helpers.Helper; import java.util.ArrayList; import java.util.List; -import java.util.Stack; public class TraitClass extends Trait implements TraitWithSlot { @@ -460,7 +459,7 @@ public class TraitClass extends Trait implements TraitWithSlot { writer.newLine(); writer.startTrait(abc.class_info.get(class_info).static_traits.traits.size() + abc.instance_info.get(class_info).instance_traits.traits.size() + 1); writer.appendNoHilight("{").newLine(); - abc.bodies.get(bodyIndex).toString(path +/*packageName +*/ "/" + abc.instance_info.get(class_info).getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".staticinitializer", exportMode, true, scriptIndex, class_info, abc, this, abc.constants, abc.method_info, new Stack(), true, writer, fullyQualifiedNames, abc.class_info.get(class_info).static_traits); + abc.bodies.get(bodyIndex).toString(path +/*packageName +*/ "/" + abc.instance_info.get(class_info).getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".staticinitializer", exportMode, abc, this, abc.constants, abc.method_info, writer, fullyQualifiedNames); writer.appendNoHilight("}").newLine(); writer.endTrait(); } @@ -499,7 +498,7 @@ public class TraitClass extends Trait implements TraitWithSlot { } writer.appendNoHilight(")").startBlock(); if (bodyIndex != -1) { - abc.bodies.get(bodyIndex).toString(path +/*packageName +*/ "/" + abc.instance_info.get(class_info).getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".initializer", exportMode, false, scriptIndex, class_info, abc, this, abc.constants, abc.method_info, new Stack(), false, writer, fullyQualifiedNames, abc.instance_info.get(class_info).instance_traits); + abc.bodies.get(bodyIndex).toString(path +/*packageName +*/ "/" + abc.instance_info.get(class_info).getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".initializer", exportMode, abc, this, abc.constants, abc.method_info, writer, fullyQualifiedNames); } writer.endBlock().newLine(); writer.endTrait(); @@ -524,7 +523,7 @@ public class TraitClass extends Trait implements TraitWithSlot { int bodyIndex = abc.findBodyIndex(abc.class_info.get(class_info).cinit_index); if (bodyIndex != -1) { writer.mark(); - abc.bodies.get(bodyIndex).convert(path +/*packageName +*/ "/" + abc.instance_info.get(class_info).getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".staticinitializer", exportMode, true, scriptIndex, class_info, abc, this, abc.constants, abc.method_info, new Stack(), true, writer, fullyQualifiedNames, abc.class_info.get(class_info).static_traits, true); + abc.bodies.get(bodyIndex).convert(path +/*packageName +*/ "/" + abc.instance_info.get(class_info).getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".staticinitializer", exportMode, true, scriptIndex, class_info, abc, this, abc.constants, abc.method_info, new ScopeStack(), true, writer, fullyQualifiedNames, abc.class_info.get(class_info).static_traits, true); classInitializerIsEmpty = !writer.getMark(); } @@ -532,7 +531,7 @@ public class TraitClass extends Trait implements TraitWithSlot { if (!abc.instance_info.get(class_info).isInterface()) { bodyIndex = abc.findBodyIndex(abc.instance_info.get(class_info).iinit_index); if (bodyIndex != -1) { - abc.bodies.get(bodyIndex).convert(path +/*packageName +*/ "/" + abc.instance_info.get(class_info).getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".initializer", exportMode, false, scriptIndex, class_info, abc, this, abc.constants, abc.method_info, new Stack(), false, writer, fullyQualifiedNames, abc.instance_info.get(class_info).instance_traits, true); + abc.bodies.get(bodyIndex).convert(path +/*packageName +*/ "/" + abc.instance_info.get(class_info).getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".initializer", exportMode, false, scriptIndex, class_info, abc, this, abc.constants, abc.method_info, new ScopeStack(), false, writer, fullyQualifiedNames, abc.instance_info.get(class_info).instance_traits, true); } } diff --git a/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java b/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java index 3017c3504..93c1a19ce 100644 --- a/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java +++ b/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java @@ -22,10 +22,9 @@ import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.helpers.NulWriter; import com.jpexs.decompiler.flash.tags.ABCContainerTag; -import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; import com.jpexs.helpers.Helper; import java.util.List; -import java.util.Stack; public class TraitFunction extends Trait implements TraitWithSlot { @@ -81,7 +80,7 @@ public class TraitFunction extends Trait implements TraitWithSlot { writer.appendNoHilight(" {").newLine(); int bodyIndex = abc.findBodyIndex(method_info); if (bodyIndex != -1) { - abc.bodies.get(bodyIndex).toString(path + "." + abc.constants.getMultiname(name_index).getName(abc.constants, fullyQualifiedNames), exportMode, isStatic, scriptIndex, classIndex, abc, this, abc.constants, abc.method_info, new Stack(), false, writer, fullyQualifiedNames, null); + abc.bodies.get(bodyIndex).toString(path + "." + abc.constants.getMultiname(name_index).getName(abc.constants, fullyQualifiedNames), exportMode, abc, this, abc.constants, abc.method_info, writer, fullyQualifiedNames); } writer.newLine(); writer.appendNoHilight("}"); @@ -96,7 +95,7 @@ public class TraitFunction extends Trait implements TraitWithSlot { if (!abc.instance_info.get(classIndex).isInterface()) { int bodyIndex = abc.findBodyIndex(method_info); if (bodyIndex != -1) { - abc.bodies.get(bodyIndex).convert(path + "." + abc.constants.getMultiname(name_index).getName(abc.constants, fullyQualifiedNames), exportMode, isStatic, scriptIndex, classIndex, abc, this, abc.constants, abc.method_info, new Stack(), false, writer, fullyQualifiedNames, null, true); + abc.bodies.get(bodyIndex).convert(path + "." + abc.constants.getMultiname(name_index).getName(abc.constants, fullyQualifiedNames), exportMode, isStatic, scriptIndex, classIndex, abc, this, abc.constants, abc.method_info, new ScopeStack(), false, writer, fullyQualifiedNames, null, true); } } } diff --git a/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java b/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java index f9ff43a88..01437f8f6 100644 --- a/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java +++ b/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java @@ -22,10 +22,9 @@ import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.helpers.NulWriter; import com.jpexs.decompiler.flash.tags.ABCContainerTag; -import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; import com.jpexs.helpers.Helper; import java.util.List; -import java.util.Stack; public class TraitMethodGetterSetter extends Trait { @@ -83,7 +82,7 @@ public class TraitMethodGetterSetter extends Trait { int bodyIndex = abc.findBodyIndex(method_info); if (!(classIndex != -1 && abc.instance_info.get(classIndex).isInterface() || bodyIndex == -1)) { if (bodyIndex != -1) { - abc.bodies.get(bodyIndex).convert(path, exportMode, isStatic, scriptIndex, classIndex, abc, this, abc.constants, abc.method_info, new Stack(), false, writer, fullyQualifiedNames, null, true); + abc.bodies.get(bodyIndex).convert(path, exportMode, isStatic, scriptIndex, classIndex, abc, this, abc.constants, abc.method_info, new ScopeStack(), false, writer, fullyQualifiedNames, null, true); } } } @@ -98,7 +97,7 @@ public class TraitMethodGetterSetter extends Trait { } else { writer.startBlock(); if (bodyIndex != -1) { - abc.bodies.get(bodyIndex).toString(path, exportMode, isStatic, scriptIndex, classIndex, abc, this, abc.constants, abc.method_info, new Stack(), false, writer, fullyQualifiedNames, null); + abc.bodies.get(bodyIndex).toString(path, exportMode, abc, this, abc.constants, abc.method_info, writer, fullyQualifiedNames); } writer.endBlock(); } diff --git a/src/com/jpexs/decompiler/flash/action/Action.java b/src/com/jpexs/decompiler/flash/action/Action.java index 5344d0d8f..33f9ed198 100644 --- a/src/com/jpexs/decompiler/flash/action/Action.java +++ b/src/com/jpexs/decompiler/flash/action/Action.java @@ -65,6 +65,7 @@ import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphSourceItemContainer; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateException; +import com.jpexs.decompiler.graph.TranslateStack; import com.jpexs.decompiler.graph.model.CommentItem; import com.jpexs.decompiler.graph.model.IfItem; import com.jpexs.decompiler.graph.model.LocalData; @@ -79,7 +80,6 @@ import java.util.Arrays; import java.util.EmptyStackException; import java.util.HashMap; import java.util.List; -import java.util.Stack; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; @@ -598,7 +598,7 @@ public class Action implements GraphSourceItem { * @param path the value of path * @throws java.lang.InterruptedException */ - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) throws InterruptedException { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) throws InterruptedException { } /** @@ -607,7 +607,7 @@ public class Action implements GraphSourceItem { * @param stack Stack * @return long value */ - protected long popLong(Stack stack) { + protected long popLong(TranslateStack stack) { GraphTargetItem item = stack.pop(); if (item instanceof DirectValueActionItem) { if (((DirectValueActionItem) item).value instanceof Long) { @@ -735,7 +735,7 @@ public class Action implements GraphSourceItem { } @Override - public void translate(BaseLocalData localData, Stack stack, List output, int staticOperation, String path) throws InterruptedException { + public void translate(BaseLocalData localData, TranslateStack stack, List output, int staticOperation, String path) throws InterruptedException { ActionLocalData aLocalData = (ActionLocalData) localData; translate(stack, output, aLocalData.regNames, aLocalData.variables, aLocalData.functions, staticOperation, path); } @@ -797,7 +797,7 @@ public class Action implements GraphSourceItem { logger.fine(s); } - public static List actionsPartToTree(HashMap registerNames, HashMap variables, HashMap functions, Stack stack, List actions, int start, int end, int version, int staticOperation, String path) throws InterruptedException { + public static List actionsPartToTree(HashMap registerNames, HashMap variables, HashMap functions, TranslateStack stack, List actions, int start, int end, int version, int staticOperation, String path) throws InterruptedException { if (start < actions.size() && (end > 0) && (start > 0)) { log("Entering " + start + "-" + end + (actions.size() > 0 ? (" (" + actions.get(start).toString() + " - " + actions.get(end == actions.size() ? end - 1 : end) + ")") : "")); } diff --git a/src/com/jpexs/decompiler/flash/action/ActionDeobfuscator.java b/src/com/jpexs/decompiler/flash/action/ActionDeobfuscator.java index 2868a1654..96114f594 100644 --- a/src/com/jpexs/decompiler/flash/action/ActionDeobfuscator.java +++ b/src/com/jpexs/decompiler/flash/action/ActionDeobfuscator.java @@ -42,12 +42,12 @@ import com.jpexs.decompiler.flash.action.swf5.ActionDefineLocal; import com.jpexs.decompiler.flash.action.swf5.ActionModulo; import com.jpexs.decompiler.flash.action.swf5.ActionReturn; import com.jpexs.decompiler.flash.ecma.EcmaScript; -import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.SWFDecompilerListener; import com.jpexs.decompiler.graph.Graph; import com.jpexs.decompiler.graph.GraphSourceItemContainer; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateException; +import com.jpexs.decompiler.graph.TranslateStack; import java.io.IOException; import java.util.ArrayList; import java.util.EmptyStackException; @@ -56,7 +56,6 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Stack; import java.util.logging.Level; import java.util.logging.Logger; @@ -240,7 +239,7 @@ public class ActionDeobfuscator implements SWFDecompilerListener { jump.setJumpOffset((int) (target.getAddress() - jump.getAddress() - jump.getTotalActionLength())); actions.addAction(i++, jump); - return true; + //return true; } } } catch (EmptyStackException | TranslateException | InterruptedException ex) { @@ -253,7 +252,7 @@ public class ActionDeobfuscator implements SWFDecompilerListener { private void executeActions(ActionList actions, int idx, int endIdx, ExecutionResult result, Map fakeFunctions) throws InterruptedException { List output = new ArrayList<>(); ActionLocalData localData = new ActionLocalData(); - Stack stack = new Stack<>(); + TranslateStack stack = new TranslateStack(); int instructionsProcessed = 0; ActionConstantPool constantPool = null; @@ -354,7 +353,7 @@ public class ActionDeobfuscator implements SWFDecompilerListener { long address = jump.getAddress() + jump.getTotalActionLength() + jump.getJumpOffset(); idx = actions.indexOf(actions.getByAddress(address)); if (idx == -1) { - int a = 1; + throw new TranslateException("Jump target not found: " + address); } } @@ -365,7 +364,7 @@ public class ActionDeobfuscator implements SWFDecompilerListener { long address = aif.getAddress() + aif.getTotalActionLength() + aif.getJumpOffset(); idx = actions.indexOf(actions.getByAddress(address)); if (idx == -1) { - int a = 1; + throw new TranslateException("If target not found: " + address); } } } @@ -376,7 +375,7 @@ public class ActionDeobfuscator implements SWFDecompilerListener { idx = lastActionIdx != -1 ? lastActionIdx + 1 : -1; } - if (/*localData.variables.size() == 1 && */stack.empty() || action instanceof ActionEnd) { + if (/*localData.variables.size() == 1 && */stack.isEmpty() || action instanceof ActionEnd) { result.idx = idx == actions.size() ? idx - 1 : idx; result.instructionsProcessed = instructionsProcessed; result.constantPool = constantPool; diff --git a/src/com/jpexs/decompiler/flash/action/ActionGraph.java b/src/com/jpexs/decompiler/flash/action/ActionGraph.java index 16fd51628..e8d30cdb6 100644 --- a/src/com/jpexs/decompiler/flash/action/ActionGraph.java +++ b/src/com/jpexs/decompiler/flash/action/ActionGraph.java @@ -1,487 +1,487 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action; - -import com.jpexs.decompiler.flash.BaseLocalData; -import com.jpexs.decompiler.flash.FinalProcessLocalData; -import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; -import com.jpexs.decompiler.flash.action.model.EnumerateActionItem; -import com.jpexs.decompiler.flash.action.model.FunctionActionItem; -import com.jpexs.decompiler.flash.action.model.SetTarget2ActionItem; -import com.jpexs.decompiler.flash.action.model.SetTargetActionItem; -import com.jpexs.decompiler.flash.action.model.SetTypeActionItem; -import com.jpexs.decompiler.flash.action.model.StoreRegisterActionItem; -import com.jpexs.decompiler.flash.action.model.clauses.ForInActionItem; -import com.jpexs.decompiler.flash.action.model.clauses.TellTargetActionItem; -import com.jpexs.decompiler.flash.action.model.operations.NeqActionItem; -import com.jpexs.decompiler.flash.action.model.operations.StrictEqActionItem; -import com.jpexs.decompiler.flash.action.swf4.ActionEquals; -import com.jpexs.decompiler.flash.action.swf4.ActionIf; -import com.jpexs.decompiler.flash.action.swf4.ActionNot; -import com.jpexs.decompiler.flash.action.swf4.ActionPush; -import com.jpexs.decompiler.flash.action.swf4.RegisterNumber; -import com.jpexs.decompiler.flash.action.swf5.ActionEquals2; -import com.jpexs.decompiler.flash.action.swf5.ActionStoreRegister; -import com.jpexs.decompiler.flash.action.swf6.ActionStrictEquals; -import com.jpexs.decompiler.flash.ecma.Null; -import com.jpexs.decompiler.graph.Graph; -import com.jpexs.decompiler.graph.GraphPart; -import com.jpexs.decompiler.graph.GraphSource; -import com.jpexs.decompiler.graph.GraphSourceItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.decompiler.graph.Loop; -import com.jpexs.decompiler.graph.model.BreakItem; -import com.jpexs.decompiler.graph.model.ContinueItem; -import com.jpexs.decompiler.graph.model.SwitchItem; -import com.jpexs.decompiler.graph.model.WhileItem; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -/** - * - * @author JPEXS - */ -public class ActionGraph extends Graph { - - public ActionGraph(List code, HashMap registerNames, HashMap variables, HashMap functions, int version) { - super(new ActionGraphSource(code, version, registerNames, variables, functions), new ArrayList()); - //this.version = version; - /*heads = makeGraph(code, new ArrayList()); - for (GraphPart head : heads) { - fixGraph(head); - makeMulti(head, new ArrayList()); - }*/ - } - - public static List translateViaGraph(HashMap registerNames, HashMap variables, HashMap functions, List code, int version, int staticOperation, String path) throws InterruptedException { - - ActionGraph g = new ActionGraph(code, registerNames, variables, functions, version); - ActionLocalData localData = new ActionLocalData(registerNames); - g.init(localData); - return g.translate(localData, staticOperation, path); - } - - @Override - public void finalProcessStack(Stack stack, List output) { - if (stack.size() > 0) { - for (int i = stack.size() - 1; i >= 0; i--) { - //System.err.println(stack.get(i)); - if (stack.get(i) instanceof FunctionActionItem) { - FunctionActionItem f = (FunctionActionItem) stack.remove(i); - if (!output.contains(f)) { - output.add(0, f); - } - } - } - } - } - - @Override - protected void finalProcess(List list, int level, FinalProcessLocalData localData) { - - List ret = Action.checkClass(list); - if (ret != list) { - list.clear(); - list.addAll(ret); - } - int targetStart; - int targetEnd; - - boolean again; - do { - again = false; - targetStart = -1; - targetEnd = -1; - GraphTargetItem targetStartItem = null; - GraphTargetItem target = null; - for (int t = 0; t < list.size(); t++) { - GraphTargetItem it = list.get(t); - if (it instanceof SetTargetActionItem) { - SetTargetActionItem st = (SetTargetActionItem) it; - if (st.target.isEmpty()) { - if (targetStart > -1) { - targetEnd = t; - break; - } - } else { - target = new DirectValueActionItem(null, 0, st.target, new ArrayList()); - targetStart = t; - targetStartItem = it; - } - } - if (it instanceof SetTarget2ActionItem) { - SetTarget2ActionItem st = (SetTarget2ActionItem) it; - if ((st.target instanceof DirectValueActionItem) && st.target.getResult().equals("")) { - if (targetStart > -1) { - targetEnd = t; - break; - } - } else { - targetStart = t; - target = st.target; - targetStartItem = it; - } - } - } - if ((targetStart > -1) && (targetEnd > -1)) { - List newlist = new ArrayList<>(); - for (int i = 0; i < targetStart; i++) { - newlist.add(list.get(i)); - } - List tellist = new ArrayList<>(); - for (int i = targetStart + 1; i < targetEnd; i++) { - tellist.add(list.get(i)); - } - newlist.add(new TellTargetActionItem(targetStartItem.src, target, tellist)); - for (int i = targetEnd + 1; i < list.size(); i++) { - newlist.add(list.get(i)); - } - list.clear(); - list.addAll(newlist); - again = true; - } - } while (again); - for (int t = 0; t < list.size(); t++) { - GraphTargetItem it = list.get(t); - - if (it instanceof WhileItem) { - WhileItem wi = (WhileItem) it; - if ((!wi.commands.isEmpty()) && (wi.commands.get(0) instanceof SetTypeActionItem)) { - SetTypeActionItem sti = (SetTypeActionItem) wi.commands.get(0); - if (wi.expression.get(wi.expression.size() - 1) instanceof NeqActionItem) { - NeqActionItem ne = (NeqActionItem) wi.expression.get(wi.expression.size() - 1); - if (ne.rightSide instanceof DirectValueActionItem) { - DirectValueActionItem dv = (DirectValueActionItem) ne.rightSide; - if (dv.value instanceof Null) { - GraphTargetItem en = ne.leftSide; - if (en instanceof StoreRegisterActionItem) { - en = ((StoreRegisterActionItem) en).value; - } - if (en instanceof EnumerateActionItem) { - EnumerateActionItem eti = (EnumerateActionItem) en; - list.remove(t); - wi.commands.remove(0); - list.add(t, new ForInActionItem(null, wi.loop, sti.getObject(), eti.object, wi.commands)); - } - } - } - } - } - - } - } - //detectChained(list, temporaryRegisters); - } - - @Override - protected List checkPrecoNextParts(GraphPart part) { - List items = getPartItems(part); - part = makeMultiPart(part); - if (items.size() > 1) { - if (items.get(items.size() - 1) instanceof ActionIf) { - if (items.get(items.size() - 2) instanceof ActionStrictEquals) { - List storeRegisters = new ArrayList<>(); - for (GraphSourceItem s : items) { - if (s instanceof ActionStoreRegister) { - ActionStoreRegister sr = (ActionStoreRegister) s; - storeRegisters.add(sr.registerNumber); - } - } - if (!storeRegisters.isEmpty()) { - List caseBodies = new ArrayList<>(); - boolean proceed = false; - do { - proceed = false; - caseBodies.add(part.nextParts.get(0)); //jump - part = part.nextParts.get(1); //nojump - items = getPartItems(part); - part = makeMultiPart(part); - if (!items.isEmpty()) { - if (items.get(0) instanceof ActionPush) { - ActionPush pu = (ActionPush) items.get(0); - if (!pu.values.isEmpty()) { - if (pu.values.get(0) instanceof RegisterNumber) { - RegisterNumber rn = (RegisterNumber) pu.values.get(0); - if (storeRegisters.contains(rn.number)) { - storeRegisters.clear(); - storeRegisters.add(rn.number); - if (items.get(items.size() - 1) instanceof ActionIf) { - if (items.size() > 1) { - if (items.get(items.size() - 2) instanceof ActionStrictEquals) { - proceed = true; - } - } - } - } - } - } - } - } - } while (proceed); - - if (caseBodies.size() > 1) { - caseBodies.add(part); //TODO: properly detect default clause (?) - return caseBodies; - } - } - } - } - } - return null; - } - - @Override - protected List check(GraphSource code, BaseLocalData localData, List allParts, Stack stack, GraphPart parent, GraphPart part, List stopPart, List loops, List output, Loop currentLoop, int staticOperation, String path) throws InterruptedException { - if (!output.isEmpty()) { - if (output.get(output.size() - 1) instanceof StoreRegisterActionItem) { - StoreRegisterActionItem str = (StoreRegisterActionItem) output.get(output.size() - 1); - if (str.value instanceof EnumerateActionItem) { - output.remove(output.size() - 1); - } - } - } - List ret = null; - if ((part.nextParts.size() == 2) && (!stack.isEmpty()) && (stack.peek() instanceof StrictEqActionItem)) { - - GraphTargetItem switchedObject = null; - if (!output.isEmpty()) { - if (output.get(output.size() - 1) instanceof StoreRegisterActionItem) { - switchedObject = ((StoreRegisterActionItem) output.get(output.size() - 1)).value; - } - } - if (switchedObject == null) { - switchedObject = new DirectValueActionItem(null, -1, new Null(), null); - } - HashMap caseValuesMap = new HashMap<>(); - - int pos = 0; - StrictEqActionItem set = (StrictEqActionItem) stack.pop(); - caseValuesMap.put(pos, set.rightSide); - if (set.leftSide instanceof StoreRegisterActionItem) { - switchedObject = ((StoreRegisterActionItem) set.leftSide).value; - } - //GraphPart switchLoc = part.nextParts.get(1).nextParts.get(0); - List caseBodyParts = new ArrayList<>(); - caseBodyParts.add(part.nextParts.get(0)); - GraphTargetItem top = null; - int cnt = 1; - while (part.nextParts.size() > 1 - && part.nextParts.get(1).getHeight() > 1 - && code.get(part.nextParts.get(1).end >= code.size() ? code.size() - 1 : part.nextParts.get(1).end) instanceof ActionIf - && ((top = translatePartGetStack(localData, part.nextParts.get(1), stack, staticOperation)) instanceof StrictEqActionItem)) { - cnt++; - part = part.nextParts.get(1); - pos++; - caseBodyParts.add(part.nextParts.get(0)); - - set = (StrictEqActionItem) top; - caseValuesMap.put(pos, set.rightSide); - } - if (cnt == 1) { - stack.push(set); - } else { - part = part.nextParts.get(1); - - GraphPart defaultPart = part; //21-21 - //caseBodyParts.add(defaultPart); - - List defaultAndLastPart = new ArrayList<>(); - defaultAndLastPart.add(defaultPart); - defaultAndLastPart.add(caseBodyParts.get(caseBodyParts.size() - 1)); - - GraphPart defaultPart2 = getCommonPart(localData, defaultAndLastPart, loops);//34-37 - - List defaultCommands = new ArrayList<>(); - List stopPart2 = new ArrayList<>(stopPart); - stopPart2.add(defaultPart2); - defaultCommands = printGraph(localData, stack, allParts, null, defaultPart, stopPart2, loops, staticOperation, path); - - List loopContinues = new ArrayList<>(); - for (Loop l : loops) { - if (l.loopContinue != null) { - loopContinues.add(l.loopContinue); - } - } - - List breakParts = new ArrayList<>(); - /*for (int g = 0; g < caseBodyParts.size(); g++) { - if (g < caseBodyParts.size() - 1) { - if (caseBodyParts.get(g).leadsTo(code, caseBodyParts.get(g + 1), loops)) { - continue; - } - } - GraphPart nsp = caseBodyParts.get(g).getNextSuperPartPath(loopContinues); - if (nsp != null) { - breakParts.add(nsp); - } - } - Collections.sort(breakParts, new Comparator() { - @Override - public int compare(GraphPart o1, GraphPart o2) { - return o2.path.length() - o1.path.length(); - } - });*/ - - //GraphPart breakPart = breakParts.isEmpty() ? null : breakParts.get(0); - List mcp = new ArrayList<>(); - mcp.addAll(caseBodyParts); - if (defaultPart2 != null) { - mcp.add(defaultPart2); - } - GraphPart breakPart = getMostCommonPart(localData, mcp, loops); - if ((defaultPart2 != breakPart) && (defaultCommands.isEmpty())) { - defaultPart = defaultPart2; - } - - List caseValues = new ArrayList<>(); - for (int i = 0; i < caseBodyParts.size(); i++) { - if (caseValuesMap.containsKey(i)) { - caseValues.add(caseValuesMap.get(i)); - } else { - continue; - } - } - - List> caseCommands = new ArrayList<>(); - GraphPart next = null; - - next = breakPart; - - GraphTargetItem ti = checkLoop(next, stopPart, loops); - currentLoop = new Loop(loops.size(), null, next); - currentLoop.phase = 1; - loops.add(currentLoop); - //switchLoc.getNextPartPath(new ArrayList()); - List valuesMapping = new ArrayList<>(); - List caseBodies = new ArrayList<>(); - for (int i = 0; i < caseValues.size(); i++) { - GraphPart cur = caseBodyParts.get(i); - if (!caseBodies.contains(cur)) { - caseBodies.add(cur); - } - valuesMapping.add(caseBodies.indexOf(cur)); - } - - if (defaultPart == breakPart) { - defaultPart = null; - } - if ((defaultPart != null) && (defaultCommands.isEmpty())) { - List stopPart2x = new ArrayList<>(stopPart); - stopPart2x.add(next); - defaultCommands = printGraph(localData, stack, allParts, null, defaultPart, stopPart2x, loops, staticOperation, path); - } - - if (!defaultCommands.isEmpty()) { - if (defaultCommands.get(defaultCommands.size() - 1) instanceof BreakItem) { - BreakItem bi = (BreakItem) defaultCommands.get(defaultCommands.size() - 1); - if (bi.loopId == currentLoop.id) { - defaultCommands.remove(defaultCommands.size() - 1); - } - } - } - - List ignored = new ArrayList<>(); - for (Loop l : loops) { - ignored.add(l.loopContinue); - } - - for (int i = 0; i < caseBodies.size(); i++) { - List cc = new ArrayList<>(); - GraphPart nextCase = null; - nextCase = next; - if (next != null) { - if (i < caseBodies.size() - 1) { - if (!caseBodies.get(i).leadsTo(localData, this, code, caseBodies.get(i + 1), loops)) { - cc.add(new BreakItem(null, currentLoop.id)); - } else { - nextCase = caseBodies.get(i + 1); - } - } else if (!defaultCommands.isEmpty()) { - if (!caseBodies.get(i).leadsTo(localData, this, code, defaultPart, loops)) { - cc.add(new BreakItem(null, currentLoop.id)); - } else { - nextCase = defaultPart; - } - } - } - List stopPart2x = new ArrayList<>(stopPart); - //stopPart2.add(nextCase); - for (GraphPart b : caseBodies) { - if (b != caseBodies.get(i)) { - stopPart2x.add(b); - } - } - if (defaultPart != null) { - stopPart2x.add(defaultPart); - } - if (breakPart != null) { - stopPart2x.add(breakPart); - } - cc.addAll(0, printGraph(localData, stack, allParts, null, caseBodies.get(i), stopPart2x, loops, staticOperation, path)); - if (cc.size() >= 2) { - if (cc.get(cc.size() - 1) instanceof BreakItem) { - if ((cc.get(cc.size() - 2) instanceof ContinueItem) || (cc.get(cc.size() - 2) instanceof BreakItem)) { - cc.remove(cc.size() - 1); - } - } - } - caseCommands.add(cc); - } - ret = new ArrayList<>(); - ret.addAll(output); - SwitchItem sti = new SwitchItem(null, currentLoop, switchedObject, caseValues, caseCommands, defaultCommands, valuesMapping); - ret.add(sti); - currentLoop.phase = 2; - if (next != null) { - if (ti != null) { - ret.add(ti); - } else { - ret.addAll(printGraph(localData, stack, allParts, null, next, stopPart, loops, staticOperation, path)); - } - } - } - } - return ret; - } - - @Override - protected int checkIp(int ip) { - int oldIp = ip; - //return in for..in - GraphSourceItem action = code.get(ip); - if ((action instanceof ActionPush) && (((ActionPush) action).values.size() == 1) && (((ActionPush) action).values.get(0) instanceof Null)) { - if (ip + 3 < code.size()) { - if ((code.get(ip + 1) instanceof ActionEquals) || (code.get(ip + 1) instanceof ActionEquals2)) { - if (code.get(ip + 2) instanceof ActionNot) { - if (code.get(ip + 3) instanceof ActionIf) { - ActionIf aif = (ActionIf) code.get(ip + 3); - if (code.adr2pos(code.pos2adr(ip + 4) + aif.getJumpOffset()) == ip) { - ip += 4; - } - } - } - } - } - } - if (oldIp != ip) { - return checkIp(ip); - } - return ip; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action; + +import com.jpexs.decompiler.flash.BaseLocalData; +import com.jpexs.decompiler.flash.FinalProcessLocalData; +import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; +import com.jpexs.decompiler.flash.action.model.EnumerateActionItem; +import com.jpexs.decompiler.flash.action.model.FunctionActionItem; +import com.jpexs.decompiler.flash.action.model.SetTarget2ActionItem; +import com.jpexs.decompiler.flash.action.model.SetTargetActionItem; +import com.jpexs.decompiler.flash.action.model.SetTypeActionItem; +import com.jpexs.decompiler.flash.action.model.StoreRegisterActionItem; +import com.jpexs.decompiler.flash.action.model.clauses.ForInActionItem; +import com.jpexs.decompiler.flash.action.model.clauses.TellTargetActionItem; +import com.jpexs.decompiler.flash.action.model.operations.NeqActionItem; +import com.jpexs.decompiler.flash.action.model.operations.StrictEqActionItem; +import com.jpexs.decompiler.flash.action.swf4.ActionEquals; +import com.jpexs.decompiler.flash.action.swf4.ActionIf; +import com.jpexs.decompiler.flash.action.swf4.ActionNot; +import com.jpexs.decompiler.flash.action.swf4.ActionPush; +import com.jpexs.decompiler.flash.action.swf4.RegisterNumber; +import com.jpexs.decompiler.flash.action.swf5.ActionEquals2; +import com.jpexs.decompiler.flash.action.swf5.ActionStoreRegister; +import com.jpexs.decompiler.flash.action.swf6.ActionStrictEquals; +import com.jpexs.decompiler.flash.ecma.Null; +import com.jpexs.decompiler.graph.Graph; +import com.jpexs.decompiler.graph.GraphPart; +import com.jpexs.decompiler.graph.GraphSource; +import com.jpexs.decompiler.graph.GraphSourceItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.Loop; +import com.jpexs.decompiler.graph.TranslateStack; +import com.jpexs.decompiler.graph.model.BreakItem; +import com.jpexs.decompiler.graph.model.ContinueItem; +import com.jpexs.decompiler.graph.model.SwitchItem; +import com.jpexs.decompiler.graph.model.WhileItem; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +/** + * + * @author JPEXS + */ +public class ActionGraph extends Graph { + + public ActionGraph(List code, HashMap registerNames, HashMap variables, HashMap functions, int version) { + super(new ActionGraphSource(code, version, registerNames, variables, functions), new ArrayList()); + //this.version = version; + /*heads = makeGraph(code, new ArrayList()); + for (GraphPart head : heads) { + fixGraph(head); + makeMulti(head, new ArrayList()); + }*/ + } + + public static List translateViaGraph(HashMap registerNames, HashMap variables, HashMap functions, List code, int version, int staticOperation, String path) throws InterruptedException { + + ActionGraph g = new ActionGraph(code, registerNames, variables, functions, version); + ActionLocalData localData = new ActionLocalData(registerNames); + g.init(localData); + return g.translate(localData, staticOperation, path); + } + + @Override + public void finalProcessStack(TranslateStack stack, List output) { + if (stack.size() > 0) { + for (int i = stack.size() - 1; i >= 0; i--) { + //System.err.println(stack.get(i)); + if (stack.get(i) instanceof FunctionActionItem) { + FunctionActionItem f = (FunctionActionItem) stack.remove(i); + if (!output.contains(f)) { + output.add(0, f); + } + } + } + } + } + + @Override + protected void finalProcess(List list, int level, FinalProcessLocalData localData) { + + List ret = Action.checkClass(list); + if (ret != list) { + list.clear(); + list.addAll(ret); + } + int targetStart; + int targetEnd; + + boolean again; + do { + again = false; + targetStart = -1; + targetEnd = -1; + GraphTargetItem targetStartItem = null; + GraphTargetItem target = null; + for (int t = 0; t < list.size(); t++) { + GraphTargetItem it = list.get(t); + if (it instanceof SetTargetActionItem) { + SetTargetActionItem st = (SetTargetActionItem) it; + if (st.target.isEmpty()) { + if (targetStart > -1) { + targetEnd = t; + break; + } + } else { + target = new DirectValueActionItem(null, 0, st.target, new ArrayList()); + targetStart = t; + targetStartItem = it; + } + } + if (it instanceof SetTarget2ActionItem) { + SetTarget2ActionItem st = (SetTarget2ActionItem) it; + if ((st.target instanceof DirectValueActionItem) && st.target.getResult().equals("")) { + if (targetStart > -1) { + targetEnd = t; + break; + } + } else { + targetStart = t; + target = st.target; + targetStartItem = it; + } + } + } + if ((targetStart > -1) && (targetEnd > -1)) { + List newlist = new ArrayList<>(); + for (int i = 0; i < targetStart; i++) { + newlist.add(list.get(i)); + } + List tellist = new ArrayList<>(); + for (int i = targetStart + 1; i < targetEnd; i++) { + tellist.add(list.get(i)); + } + newlist.add(new TellTargetActionItem(targetStartItem.src, target, tellist)); + for (int i = targetEnd + 1; i < list.size(); i++) { + newlist.add(list.get(i)); + } + list.clear(); + list.addAll(newlist); + again = true; + } + } while (again); + for (int t = 0; t < list.size(); t++) { + GraphTargetItem it = list.get(t); + + if (it instanceof WhileItem) { + WhileItem wi = (WhileItem) it; + if ((!wi.commands.isEmpty()) && (wi.commands.get(0) instanceof SetTypeActionItem)) { + SetTypeActionItem sti = (SetTypeActionItem) wi.commands.get(0); + if (wi.expression.get(wi.expression.size() - 1) instanceof NeqActionItem) { + NeqActionItem ne = (NeqActionItem) wi.expression.get(wi.expression.size() - 1); + if (ne.rightSide instanceof DirectValueActionItem) { + DirectValueActionItem dv = (DirectValueActionItem) ne.rightSide; + if (dv.value instanceof Null) { + GraphTargetItem en = ne.leftSide; + if (en instanceof StoreRegisterActionItem) { + en = ((StoreRegisterActionItem) en).value; + } + if (en instanceof EnumerateActionItem) { + EnumerateActionItem eti = (EnumerateActionItem) en; + list.remove(t); + wi.commands.remove(0); + list.add(t, new ForInActionItem(null, wi.loop, sti.getObject(), eti.object, wi.commands)); + } + } + } + } + } + + } + } + //detectChained(list, temporaryRegisters); + } + + @Override + protected List checkPrecoNextParts(GraphPart part) { + List items = getPartItems(part); + part = makeMultiPart(part); + if (items.size() > 1) { + if (items.get(items.size() - 1) instanceof ActionIf) { + if (items.get(items.size() - 2) instanceof ActionStrictEquals) { + List storeRegisters = new ArrayList<>(); + for (GraphSourceItem s : items) { + if (s instanceof ActionStoreRegister) { + ActionStoreRegister sr = (ActionStoreRegister) s; + storeRegisters.add(sr.registerNumber); + } + } + if (!storeRegisters.isEmpty()) { + List caseBodies = new ArrayList<>(); + boolean proceed = false; + do { + proceed = false; + caseBodies.add(part.nextParts.get(0)); //jump + part = part.nextParts.get(1); //nojump + items = getPartItems(part); + part = makeMultiPart(part); + if (!items.isEmpty()) { + if (items.get(0) instanceof ActionPush) { + ActionPush pu = (ActionPush) items.get(0); + if (!pu.values.isEmpty()) { + if (pu.values.get(0) instanceof RegisterNumber) { + RegisterNumber rn = (RegisterNumber) pu.values.get(0); + if (storeRegisters.contains(rn.number)) { + storeRegisters.clear(); + storeRegisters.add(rn.number); + if (items.get(items.size() - 1) instanceof ActionIf) { + if (items.size() > 1) { + if (items.get(items.size() - 2) instanceof ActionStrictEquals) { + proceed = true; + } + } + } + } + } + } + } + } + } while (proceed); + + if (caseBodies.size() > 1) { + caseBodies.add(part); //TODO: properly detect default clause (?) + return caseBodies; + } + } + } + } + } + return null; + } + + @Override + protected List check(GraphSource code, BaseLocalData localData, List allParts, TranslateStack stack, GraphPart parent, GraphPart part, List stopPart, List loops, List output, Loop currentLoop, int staticOperation, String path) throws InterruptedException { + if (!output.isEmpty()) { + if (output.get(output.size() - 1) instanceof StoreRegisterActionItem) { + StoreRegisterActionItem str = (StoreRegisterActionItem) output.get(output.size() - 1); + if (str.value instanceof EnumerateActionItem) { + output.remove(output.size() - 1); + } + } + } + List ret = null; + if ((part.nextParts.size() == 2) && (!stack.isEmpty()) && (stack.peek() instanceof StrictEqActionItem)) { + + GraphTargetItem switchedObject = null; + if (!output.isEmpty()) { + if (output.get(output.size() - 1) instanceof StoreRegisterActionItem) { + switchedObject = ((StoreRegisterActionItem) output.get(output.size() - 1)).value; + } + } + if (switchedObject == null) { + switchedObject = new DirectValueActionItem(null, -1, new Null(), null); + } + HashMap caseValuesMap = new HashMap<>(); + + int pos = 0; + StrictEqActionItem set = (StrictEqActionItem) stack.pop(); + caseValuesMap.put(pos, set.rightSide); + if (set.leftSide instanceof StoreRegisterActionItem) { + switchedObject = ((StoreRegisterActionItem) set.leftSide).value; + } + //GraphPart switchLoc = part.nextParts.get(1).nextParts.get(0); + List caseBodyParts = new ArrayList<>(); + caseBodyParts.add(part.nextParts.get(0)); + GraphTargetItem top = null; + int cnt = 1; + while (part.nextParts.size() > 1 + && part.nextParts.get(1).getHeight() > 1 + && code.get(part.nextParts.get(1).end >= code.size() ? code.size() - 1 : part.nextParts.get(1).end) instanceof ActionIf + && ((top = translatePartGetStack(localData, part.nextParts.get(1), stack, staticOperation)) instanceof StrictEqActionItem)) { + cnt++; + part = part.nextParts.get(1); + pos++; + caseBodyParts.add(part.nextParts.get(0)); + + set = (StrictEqActionItem) top; + caseValuesMap.put(pos, set.rightSide); + } + if (cnt == 1) { + stack.push(set); + } else { + part = part.nextParts.get(1); + + GraphPart defaultPart = part; //21-21 + //caseBodyParts.add(defaultPart); + + List defaultAndLastPart = new ArrayList<>(); + defaultAndLastPart.add(defaultPart); + defaultAndLastPart.add(caseBodyParts.get(caseBodyParts.size() - 1)); + + GraphPart defaultPart2 = getCommonPart(localData, defaultAndLastPart, loops);//34-37 + + List defaultCommands = new ArrayList<>(); + List stopPart2 = new ArrayList<>(stopPart); + stopPart2.add(defaultPart2); + defaultCommands = printGraph(localData, stack, allParts, null, defaultPart, stopPart2, loops, staticOperation, path); + + List loopContinues = new ArrayList<>(); + for (Loop l : loops) { + if (l.loopContinue != null) { + loopContinues.add(l.loopContinue); + } + } + + List breakParts = new ArrayList<>(); + /*for (int g = 0; g < caseBodyParts.size(); g++) { + if (g < caseBodyParts.size() - 1) { + if (caseBodyParts.get(g).leadsTo(code, caseBodyParts.get(g + 1), loops)) { + continue; + } + } + GraphPart nsp = caseBodyParts.get(g).getNextSuperPartPath(loopContinues); + if (nsp != null) { + breakParts.add(nsp); + } + } + Collections.sort(breakParts, new Comparator() { + @Override + public int compare(GraphPart o1, GraphPart o2) { + return o2.path.length() - o1.path.length(); + } + });*/ + + //GraphPart breakPart = breakParts.isEmpty() ? null : breakParts.get(0); + List mcp = new ArrayList<>(); + mcp.addAll(caseBodyParts); + if (defaultPart2 != null) { + mcp.add(defaultPart2); + } + GraphPart breakPart = getMostCommonPart(localData, mcp, loops); + if ((defaultPart2 != breakPart) && (defaultCommands.isEmpty())) { + defaultPart = defaultPart2; + } + + List caseValues = new ArrayList<>(); + for (int i = 0; i < caseBodyParts.size(); i++) { + if (caseValuesMap.containsKey(i)) { + caseValues.add(caseValuesMap.get(i)); + } else { + continue; + } + } + + List> caseCommands = new ArrayList<>(); + GraphPart next = null; + + next = breakPart; + + GraphTargetItem ti = checkLoop(next, stopPart, loops); + currentLoop = new Loop(loops.size(), null, next); + currentLoop.phase = 1; + loops.add(currentLoop); + //switchLoc.getNextPartPath(new ArrayList()); + List valuesMapping = new ArrayList<>(); + List caseBodies = new ArrayList<>(); + for (int i = 0; i < caseValues.size(); i++) { + GraphPart cur = caseBodyParts.get(i); + if (!caseBodies.contains(cur)) { + caseBodies.add(cur); + } + valuesMapping.add(caseBodies.indexOf(cur)); + } + + if (defaultPart == breakPart) { + defaultPart = null; + } + if ((defaultPart != null) && (defaultCommands.isEmpty())) { + List stopPart2x = new ArrayList<>(stopPart); + stopPart2x.add(next); + defaultCommands = printGraph(localData, stack, allParts, null, defaultPart, stopPart2x, loops, staticOperation, path); + } + + if (!defaultCommands.isEmpty()) { + if (defaultCommands.get(defaultCommands.size() - 1) instanceof BreakItem) { + BreakItem bi = (BreakItem) defaultCommands.get(defaultCommands.size() - 1); + if (bi.loopId == currentLoop.id) { + defaultCommands.remove(defaultCommands.size() - 1); + } + } + } + + List ignored = new ArrayList<>(); + for (Loop l : loops) { + ignored.add(l.loopContinue); + } + + for (int i = 0; i < caseBodies.size(); i++) { + List cc = new ArrayList<>(); + GraphPart nextCase = null; + nextCase = next; + if (next != null) { + if (i < caseBodies.size() - 1) { + if (!caseBodies.get(i).leadsTo(localData, this, code, caseBodies.get(i + 1), loops)) { + cc.add(new BreakItem(null, currentLoop.id)); + } else { + nextCase = caseBodies.get(i + 1); + } + } else if (!defaultCommands.isEmpty()) { + if (!caseBodies.get(i).leadsTo(localData, this, code, defaultPart, loops)) { + cc.add(new BreakItem(null, currentLoop.id)); + } else { + nextCase = defaultPart; + } + } + } + List stopPart2x = new ArrayList<>(stopPart); + //stopPart2.add(nextCase); + for (GraphPart b : caseBodies) { + if (b != caseBodies.get(i)) { + stopPart2x.add(b); + } + } + if (defaultPart != null) { + stopPart2x.add(defaultPart); + } + if (breakPart != null) { + stopPart2x.add(breakPart); + } + cc.addAll(0, printGraph(localData, stack, allParts, null, caseBodies.get(i), stopPart2x, loops, staticOperation, path)); + if (cc.size() >= 2) { + if (cc.get(cc.size() - 1) instanceof BreakItem) { + if ((cc.get(cc.size() - 2) instanceof ContinueItem) || (cc.get(cc.size() - 2) instanceof BreakItem)) { + cc.remove(cc.size() - 1); + } + } + } + caseCommands.add(cc); + } + ret = new ArrayList<>(); + ret.addAll(output); + SwitchItem sti = new SwitchItem(null, currentLoop, switchedObject, caseValues, caseCommands, defaultCommands, valuesMapping); + ret.add(sti); + currentLoop.phase = 2; + if (next != null) { + if (ti != null) { + ret.add(ti); + } else { + ret.addAll(printGraph(localData, stack, allParts, null, next, stopPart, loops, staticOperation, path)); + } + } + } + } + return ret; + } + + @Override + protected int checkIp(int ip) { + int oldIp = ip; + //return in for..in + GraphSourceItem action = code.get(ip); + if ((action instanceof ActionPush) && (((ActionPush) action).values.size() == 1) && (((ActionPush) action).values.get(0) instanceof Null)) { + if (ip + 3 < code.size()) { + if ((code.get(ip + 1) instanceof ActionEquals) || (code.get(ip + 1) instanceof ActionEquals2)) { + if (code.get(ip + 2) instanceof ActionNot) { + if (code.get(ip + 3) instanceof ActionIf) { + ActionIf aif = (ActionIf) code.get(ip + 3); + if (code.adr2pos(code.pos2adr(ip + 4) + aif.getJumpOffset()) == ip) { + ip += 4; + } + } + } + } + } + } + if (oldIp != ip) { + return checkIp(ip); + } + return ip; + } +} diff --git a/src/com/jpexs/decompiler/flash/action/ActionGraphSource.java b/src/com/jpexs/decompiler/flash/action/ActionGraphSource.java index 52b7c62c2..ac7cb20f7 100644 --- a/src/com/jpexs/decompiler/flash/action/ActionGraphSource.java +++ b/src/com/jpexs/decompiler/flash/action/ActionGraphSource.java @@ -1,168 +1,168 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action; - -import com.jpexs.decompiler.flash.BaseLocalData; -import com.jpexs.decompiler.graph.GraphPart; -import com.jpexs.decompiler.graph.GraphSource; -import com.jpexs.decompiler.graph.GraphSourceItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.helpers.Helper; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * - * @author JPEXS - */ -public class ActionGraphSource extends GraphSource { - - private final List actions; - public int version; - private final HashMap registerNames; - private final HashMap variables; - private final HashMap functions; - - public List getActions() { - return actions; - } - - public ActionGraphSource(List actions, int version, HashMap registerNames, HashMap variables, HashMap functions) { - this.actions = actions; - this.version = version; - this.registerNames = registerNames; - this.variables = variables; - this.functions = functions; - } - - @Override - public int size() { - return actions.size(); - } - - @Override - public GraphSourceItem get(int pos) { - return actions.get(pos); - } - - public void set(int pos, Action t) { - actions.set(pos, t); - } - - @Override - public boolean isEmpty() { - return actions.isEmpty(); - } - - @Override - public List translatePart(GraphPart part, BaseLocalData localData, Stack stack, int start, int end, int staticOperation, String path) throws InterruptedException { - return (Action.actionsPartToTree(registerNames, variables, functions, stack, actions, start, end, version, staticOperation, path)); - } - private List posCache = null; - - private void rebuildCache() { - posCache = new ArrayList<>(); - for (int i = 0; i < size(); i++) { - posCache.add(pos2adr(i)); - } - } - - /* public int adr2posInside(long addr){ - long lastAddr=0; - if(addr==0){ - return 0; - } - for(int i=0;iaddr){ - System.err.println("lastAddr="+lastAddr+" addr="+addr+" curAddr="+curAdr); - int contPos=adr2pos(lastAddr); - System.err.println("/insadr2po"); - GraphSourceItem src=get(contPos); - if(src instanceof ActionContainer){ - ActionContainer cnt=(ActionContainer)src; - return new ActionGraphSource(cnt.getActions(), version, registerNames, variables, functions).adr2pos(addr); - }else{ - return -1; - } - } - lastAddr=curAdr; - } - return -1; - }*/ - @Override - public int adr2pos(long adr) { - if (posCache == null) { - rebuildCache(); - } - if (adr == 0) { - return 0; - } - int ret = posCache.indexOf((Long) adr); - if (ret == -1) { - if (!posCache.isEmpty() && (adr > posCache.get(posCache.size() - 1))) { - return size(); - } - //ret = adr2posInside(adr); - if (ret == -1) { - Logger.getLogger(ActionGraphSource.class.getName()).log(Level.SEVERE, "Address loc" + Helper.formatAddress(adr) + " not found"); - /*System.err.println("Addr loc"+Helper.formatAddress(adr)+" not found"); - int pos=0; - for(long l:posCache){ - System.err.println("ip "+pos+" action "+get(pos).toString()+" loc"+Helper.formatAddress(l)); - pos++; - }*/ - } - } - return ret; - /*int pos = 0; - long lastAddr = 0; - for (Action a : actions) { - lastAddr = a.getAddress(); - System.err.println("ip "+pos+" addr "+Helper.formatAddress(lastAddr)); - if (lastAddr == adr) { - return pos; - } - - pos++; - } - if (adr > lastAddr) { - return actions.size(); - } - if (adr == 0) { - return 0; - } - //throw new RuntimeException("Address "+Helper.formatAddress(adr)+" not found"); - return -1;*/ - } - - @Override - public long pos2adr(int pos) { - GraphSourceItem si = actions.get(pos); - if (si instanceof Action) { - return ((Action) si).getAddress();//Action.ip2adr(actions, pos, version); - } - return 0; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action; + +import com.jpexs.decompiler.flash.BaseLocalData; +import com.jpexs.decompiler.graph.GraphPart; +import com.jpexs.decompiler.graph.GraphSource; +import com.jpexs.decompiler.graph.GraphSourceItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; +import com.jpexs.helpers.Helper; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author JPEXS + */ +public class ActionGraphSource extends GraphSource { + + private final List actions; + public int version; + private final HashMap registerNames; + private final HashMap variables; + private final HashMap functions; + + public List getActions() { + return actions; + } + + public ActionGraphSource(List actions, int version, HashMap registerNames, HashMap variables, HashMap functions) { + this.actions = actions; + this.version = version; + this.registerNames = registerNames; + this.variables = variables; + this.functions = functions; + } + + @Override + public int size() { + return actions.size(); + } + + @Override + public GraphSourceItem get(int pos) { + return actions.get(pos); + } + + public void set(int pos, Action t) { + actions.set(pos, t); + } + + @Override + public boolean isEmpty() { + return actions.isEmpty(); + } + + @Override + public List translatePart(GraphPart part, BaseLocalData localData, TranslateStack stack, int start, int end, int staticOperation, String path) throws InterruptedException { + return (Action.actionsPartToTree(registerNames, variables, functions, stack, actions, start, end, version, staticOperation, path)); + } + private List posCache = null; + + private void rebuildCache() { + posCache = new ArrayList<>(); + for (int i = 0; i < size(); i++) { + posCache.add(pos2adr(i)); + } + } + + /* public int adr2posInside(long addr){ + long lastAddr=0; + if(addr==0){ + return 0; + } + for(int i=0;iaddr){ + System.err.println("lastAddr="+lastAddr+" addr="+addr+" curAddr="+curAdr); + int contPos=adr2pos(lastAddr); + System.err.println("/insadr2po"); + GraphSourceItem src=get(contPos); + if(src instanceof ActionContainer){ + ActionContainer cnt=(ActionContainer)src; + return new ActionGraphSource(cnt.getActions(), version, registerNames, variables, functions).adr2pos(addr); + }else{ + return -1; + } + } + lastAddr=curAdr; + } + return -1; + }*/ + @Override + public int adr2pos(long adr) { + if (posCache == null) { + rebuildCache(); + } + if (adr == 0) { + return 0; + } + int ret = posCache.indexOf((Long) adr); + if (ret == -1) { + if (!posCache.isEmpty() && (adr > posCache.get(posCache.size() - 1))) { + return size(); + } + //ret = adr2posInside(adr); + if (ret == -1) { + Logger.getLogger(ActionGraphSource.class.getName()).log(Level.SEVERE, "Address loc" + Helper.formatAddress(adr) + " not found"); + /*System.err.println("Addr loc"+Helper.formatAddress(adr)+" not found"); + int pos=0; + for(long l:posCache){ + System.err.println("ip "+pos+" action "+get(pos).toString()+" loc"+Helper.formatAddress(l)); + pos++; + }*/ + } + } + return ret; + /*int pos = 0; + long lastAddr = 0; + for (Action a : actions) { + lastAddr = a.getAddress(); + System.err.println("ip "+pos+" addr "+Helper.formatAddress(lastAddr)); + if (lastAddr == adr) { + return pos; + } + + pos++; + } + if (adr > lastAddr) { + return actions.size(); + } + if (adr == 0) { + return 0; + } + //throw new RuntimeException("Address "+Helper.formatAddress(adr)+" not found"); + return -1;*/ + } + + @Override + public long pos2adr(int pos) { + GraphSourceItem si = actions.get(pos); + if (si instanceof Action) { + return ((Action) si).getAddress();//Action.ip2adr(actions, pos, version); + } + return 0; + } +} diff --git a/src/com/jpexs/decompiler/flash/action/ActionListReader.java b/src/com/jpexs/decompiler/flash/action/ActionListReader.java index 5307d0a09..8b84326f0 100644 --- a/src/com/jpexs/decompiler/flash/action/ActionListReader.java +++ b/src/com/jpexs/decompiler/flash/action/ActionListReader.java @@ -45,6 +45,7 @@ import com.jpexs.decompiler.graph.GraphSourceItemContainer; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.NotCompileTimeItem; import com.jpexs.decompiler.graph.TranslateException; +import com.jpexs.decompiler.graph.TranslateStack; import com.jpexs.decompiler.graph.model.LocalData; import com.jpexs.helpers.CancellableWorker; import com.jpexs.helpers.Helper; @@ -56,7 +57,6 @@ import java.util.List; import java.util.Map; import java.util.Queue; import java.util.Scanner; -import java.util.Stack; import java.util.TreeMap; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; @@ -299,7 +299,7 @@ public class ActionListReader { new ArrayList(), new HashMap>(), new ActionLocalData(), - new Stack(), + new TranslateStack(), new ConstantPool(), actionMap, ip, retMap, ip, endIp, path, new HashMap(), false, @@ -769,7 +769,7 @@ public class ActionListReader { return entryAction; } - private static void deobfustaceActionListAtPosRecursive(List listeners, List output, HashMap> containers, ActionLocalData localData, Stack stack, ConstantPool cpool, List actions, int ip, List ret, int startIp, int endip, String path, Map visited, boolean indeterminate, Map> decisionStates, int version, int recursionLevel, int maxRecursionLevel) throws IOException, InterruptedException { + private static void deobfustaceActionListAtPosRecursive(List listeners, List output, HashMap> containers, ActionLocalData localData, TranslateStack stack, ConstantPool cpool, List actions, int ip, List ret, int startIp, int endip, String path, Map visited, boolean indeterminate, Map> decisionStates, int version, int recursionLevel, int maxRecursionLevel) throws IOException, InterruptedException { boolean debugMode = false; boolean decideBranch = false; @@ -931,7 +931,7 @@ public class ActionListReader { } else { localData2 = localData; } - deobfustaceActionListAtPosRecursive(listeners, output2, containers, localData2, new Stack(), cpool, actions, (int) endAddr, ret, startIp, (int) (endAddr + size), path + (cntName == null ? "" : "/" + cntName), visited, indeterminate, decisionStates, version, recursionLevel + 1, maxRecursionLevel); + deobfustaceActionListAtPosRecursive(listeners, output2, containers, localData2, new TranslateStack(), cpool, actions, (int) endAddr, ret, startIp, (int) (endAddr + size), path + (cntName == null ? "" : "/" + cntName), visited, indeterminate, decisionStates, version, recursionLevel + 1, maxRecursionLevel); output2s.add(output2); endAddr += size; } @@ -989,8 +989,7 @@ public class ActionListReader { break loopip; } - @SuppressWarnings("unchecked") - Stack subStack = (Stack) stack.clone(); + TranslateStack subStack = (TranslateStack) stack.clone(); ActionLocalData subLocalData = new ActionLocalData(new HashMap<>(localData.regNames), new HashMap<>(localData.variables), new HashMap<>(localData.functions)); deobfustaceActionListAtPosRecursive(listeners, output, containers, subLocalData, subStack, cpool, actions, ip + actionLen + aif.getJumpOffset(), ret, startIp, endip, path, visited, indeterminate, decisionStates, version, recursionLevel + 1, maxRecursionLevel); diff --git a/src/com/jpexs/decompiler/flash/action/StoreTypeAction.java b/src/com/jpexs/decompiler/flash/action/StoreTypeAction.java index bd6a7f25e..b2a277653 100644 --- a/src/com/jpexs/decompiler/flash/action/StoreTypeAction.java +++ b/src/com/jpexs/decompiler/flash/action/StoreTypeAction.java @@ -1,30 +1,29 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action; - -import com.jpexs.decompiler.flash.action.model.ConstantPool; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.Stack; - -/** - * - * @author JPEXS - */ -public interface StoreTypeAction { - - public String getVariableName(Stack stack, ConstantPool cpool); -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action; + +import com.jpexs.decompiler.flash.action.model.ConstantPool; +import com.jpexs.decompiler.graph.TranslateStack; + +/** + * + * @author JPEXS + */ +public interface StoreTypeAction { + + public String getVariableName(TranslateStack stack, ConstantPool cpool); +} diff --git a/src/com/jpexs/decompiler/flash/action/flashlite/ActionFSCommand2.java b/src/com/jpexs/decompiler/flash/action/flashlite/ActionFSCommand2.java index 69fdc5511..a8aef49b2 100644 --- a/src/com/jpexs/decompiler/flash/action/flashlite/ActionFSCommand2.java +++ b/src/com/jpexs/decompiler/flash/action/flashlite/ActionFSCommand2.java @@ -19,10 +19,10 @@ package com.jpexs.decompiler.flash.action.flashlite; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.FSCommand2ActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionFSCommand2 extends Action { @@ -36,7 +36,7 @@ public class ActionFSCommand2 extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { long numArgs = popLong(stack); GraphTargetItem command = stack.pop(); List args = new ArrayList<>(); diff --git a/src/com/jpexs/decompiler/flash/action/flashlite/ActionStrictMode.java b/src/com/jpexs/decompiler/flash/action/flashlite/ActionStrictMode.java index e6a055de6..f4cd1b047 100644 --- a/src/com/jpexs/decompiler/flash/action/flashlite/ActionStrictMode.java +++ b/src/com/jpexs/decompiler/flash/action/flashlite/ActionStrictMode.java @@ -23,11 +23,11 @@ import com.jpexs.decompiler.flash.action.model.StrictModeActionItem; import com.jpexs.decompiler.flash.action.parser.ParseException; import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionStrictMode extends Action { @@ -61,7 +61,7 @@ public class ActionStrictMode extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { output.add(new StrictModeActionItem(this, mode)); } } diff --git a/src/com/jpexs/decompiler/flash/action/special/ActionDeobfuscatePop.java b/src/com/jpexs/decompiler/flash/action/special/ActionDeobfuscatePop.java index f361e2b59..712efd643 100644 --- a/src/com/jpexs/decompiler/flash/action/special/ActionDeobfuscatePop.java +++ b/src/com/jpexs/decompiler/flash/action/special/ActionDeobfuscatePop.java @@ -1,51 +1,51 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.special; - -import com.jpexs.decompiler.flash.BaseLocalData; -import com.jpexs.decompiler.flash.action.swf4.ActionPop; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.List; -import java.util.Stack; - -/** - * - * @author JPEXS - */ -public class ActionDeobfuscatePop extends ActionPop { - - public ActionDeobfuscatePop() { - } - - @Override - public String toString() { - return "FFDec_DeobfuscatePop"; - } - - @Override - public void translate(BaseLocalData localData, Stack stack, List output, int staticOperation, String path) { - if (stack.isEmpty()) { - return; - } - GraphTargetItem val = stack.pop(); - } - - @Override - public boolean isDeobfuscatePop() { - return true; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.special; + +import com.jpexs.decompiler.flash.BaseLocalData; +import com.jpexs.decompiler.flash.action.swf4.ActionPop; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; +import java.util.List; + +/** + * + * @author JPEXS + */ +public class ActionDeobfuscatePop extends ActionPop { + + public ActionDeobfuscatePop() { + } + + @Override + public String toString() { + return "FFDec_DeobfuscatePop"; + } + + @Override + public void translate(BaseLocalData localData, TranslateStack stack, List output, int staticOperation, String path) { + if (stack.isEmpty()) { + return; + } + GraphTargetItem val = stack.pop(); + } + + @Override + public boolean isDeobfuscatePop() { + return true; + } +} diff --git a/src/com/jpexs/decompiler/flash/action/special/ActionEnd.java b/src/com/jpexs/decompiler/flash/action/special/ActionEnd.java index f993cf2b3..09b57680b 100644 --- a/src/com/jpexs/decompiler/flash/action/special/ActionEnd.java +++ b/src/com/jpexs/decompiler/flash/action/special/ActionEnd.java @@ -18,9 +18,9 @@ package com.jpexs.decompiler.flash.action.special; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionEnd extends Action { @@ -40,7 +40,7 @@ public class ActionEnd extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { //output.add(new SimpleActionTreeItem(this, "end()")); } } diff --git a/src/com/jpexs/decompiler/flash/action/special/ActionNop.java b/src/com/jpexs/decompiler/flash/action/special/ActionNop.java index f0eebdc5f..27de9410c 100644 --- a/src/com/jpexs/decompiler/flash/action/special/ActionNop.java +++ b/src/com/jpexs/decompiler/flash/action/special/ActionNop.java @@ -18,9 +18,9 @@ package com.jpexs.decompiler.flash.action.special; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionNop extends Action { @@ -34,7 +34,7 @@ public class ActionNop extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { //output.add(new SimpleActionTreeItem(this, "nop();")); } } diff --git a/src/com/jpexs/decompiler/flash/action/swf3/ActionGetURL.java b/src/com/jpexs/decompiler/flash/action/swf3/ActionGetURL.java index 4180ce4ca..f3fabf601 100644 --- a/src/com/jpexs/decompiler/flash/action/swf3/ActionGetURL.java +++ b/src/com/jpexs/decompiler/flash/action/swf3/ActionGetURL.java @@ -28,13 +28,13 @@ import com.jpexs.decompiler.flash.action.model.UnLoadMovieNumActionItem; import com.jpexs.decompiler.flash.action.parser.ParseException; import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import com.jpexs.helpers.Helper; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionGetURL extends Action { @@ -80,7 +80,7 @@ public class ActionGetURL extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { String fsCommandPrefix = "FSCommand:"; if (urlString.startsWith(fsCommandPrefix) && targetString.isEmpty()) { String command = urlString.substring(fsCommandPrefix.length()); diff --git a/src/com/jpexs/decompiler/flash/action/swf3/ActionGoToLabel.java b/src/com/jpexs/decompiler/flash/action/swf3/ActionGoToLabel.java index 73d400d51..99df52ef7 100644 --- a/src/com/jpexs/decompiler/flash/action/swf3/ActionGoToLabel.java +++ b/src/com/jpexs/decompiler/flash/action/swf3/ActionGoToLabel.java @@ -23,12 +23,12 @@ import com.jpexs.decompiler.flash.action.model.GotoLabelActionItem; import com.jpexs.decompiler.flash.action.parser.ParseException; import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import com.jpexs.helpers.Helper; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionGoToLabel extends Action { @@ -69,7 +69,7 @@ public class ActionGoToLabel extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { output.add(new GotoLabelActionItem(this, label)); } } diff --git a/src/com/jpexs/decompiler/flash/action/swf3/ActionGotoFrame.java b/src/com/jpexs/decompiler/flash/action/swf3/ActionGotoFrame.java index 1fa2f3fff..5284dd49a 100644 --- a/src/com/jpexs/decompiler/flash/action/swf3/ActionGotoFrame.java +++ b/src/com/jpexs/decompiler/flash/action/swf3/ActionGotoFrame.java @@ -23,11 +23,11 @@ import com.jpexs.decompiler.flash.action.model.GotoFrameActionItem; import com.jpexs.decompiler.flash.action.parser.ParseException; import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionGotoFrame extends Action { @@ -66,7 +66,7 @@ public class ActionGotoFrame extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { output.add(new GotoFrameActionItem(this, frame)); } } diff --git a/src/com/jpexs/decompiler/flash/action/swf3/ActionNextFrame.java b/src/com/jpexs/decompiler/flash/action/swf3/ActionNextFrame.java index 9a6c5a467..9f24afce1 100644 --- a/src/com/jpexs/decompiler/flash/action/swf3/ActionNextFrame.java +++ b/src/com/jpexs/decompiler/flash/action/swf3/ActionNextFrame.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf3; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.NextFrameActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionNextFrame extends Action { @@ -35,7 +35,7 @@ public class ActionNextFrame extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { output.add(new NextFrameActionItem(this)); } } diff --git a/src/com/jpexs/decompiler/flash/action/swf3/ActionPlay.java b/src/com/jpexs/decompiler/flash/action/swf3/ActionPlay.java index ab3794fab..1448852b3 100644 --- a/src/com/jpexs/decompiler/flash/action/swf3/ActionPlay.java +++ b/src/com/jpexs/decompiler/flash/action/swf3/ActionPlay.java @@ -22,9 +22,9 @@ import com.jpexs.decompiler.flash.action.model.GotoFrame2ActionItem; import com.jpexs.decompiler.flash.action.model.GotoFrameActionItem; import com.jpexs.decompiler.flash.action.model.PlayActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionPlay extends Action { @@ -38,7 +38,7 @@ public class ActionPlay extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { if (!output.isEmpty() && (output.get(output.size() - 1) instanceof GotoFrameActionItem)) { GotoFrameActionItem gta = (GotoFrameActionItem) output.remove(output.size() - 1); output.add(new GotoFrame2ActionItem(this, new DirectValueActionItem(gta.frame + 1), false, true, 0)); diff --git a/src/com/jpexs/decompiler/flash/action/swf3/ActionPrevFrame.java b/src/com/jpexs/decompiler/flash/action/swf3/ActionPrevFrame.java index 149f55875..1524e47ef 100644 --- a/src/com/jpexs/decompiler/flash/action/swf3/ActionPrevFrame.java +++ b/src/com/jpexs/decompiler/flash/action/swf3/ActionPrevFrame.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf3; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.PrevFrameActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionPrevFrame extends Action { @@ -35,7 +35,7 @@ public class ActionPrevFrame extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { output.add(new PrevFrameActionItem(this)); } } diff --git a/src/com/jpexs/decompiler/flash/action/swf3/ActionSetTarget.java b/src/com/jpexs/decompiler/flash/action/swf3/ActionSetTarget.java index 42968eadb..086e83ae9 100644 --- a/src/com/jpexs/decompiler/flash/action/swf3/ActionSetTarget.java +++ b/src/com/jpexs/decompiler/flash/action/swf3/ActionSetTarget.java @@ -23,12 +23,12 @@ import com.jpexs.decompiler.flash.action.model.SetTargetActionItem; import com.jpexs.decompiler.flash.action.parser.ParseException; import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import com.jpexs.helpers.Helper; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionSetTarget extends Action { @@ -69,7 +69,7 @@ public class ActionSetTarget extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { output.add(new SetTargetActionItem(this, targetName)); } } diff --git a/src/com/jpexs/decompiler/flash/action/swf3/ActionStop.java b/src/com/jpexs/decompiler/flash/action/swf3/ActionStop.java index 4f91c2043..a2e37aa1c 100644 --- a/src/com/jpexs/decompiler/flash/action/swf3/ActionStop.java +++ b/src/com/jpexs/decompiler/flash/action/swf3/ActionStop.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf3; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.StopActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionStop extends Action { @@ -35,7 +35,7 @@ public class ActionStop extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { output.add(new StopActionItem(this)); } } diff --git a/src/com/jpexs/decompiler/flash/action/swf3/ActionStopSounds.java b/src/com/jpexs/decompiler/flash/action/swf3/ActionStopSounds.java index badf7908a..9c0eae203 100644 --- a/src/com/jpexs/decompiler/flash/action/swf3/ActionStopSounds.java +++ b/src/com/jpexs/decompiler/flash/action/swf3/ActionStopSounds.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf3; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.StopAllSoundsActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionStopSounds extends Action { @@ -35,7 +35,7 @@ public class ActionStopSounds extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { output.add(new StopAllSoundsActionItem(this)); } } diff --git a/src/com/jpexs/decompiler/flash/action/swf3/ActionToggleQuality.java b/src/com/jpexs/decompiler/flash/action/swf3/ActionToggleQuality.java index 34737382f..4bfb54b04 100644 --- a/src/com/jpexs/decompiler/flash/action/swf3/ActionToggleQuality.java +++ b/src/com/jpexs/decompiler/flash/action/swf3/ActionToggleQuality.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf3; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.ToggleHighQualityActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionToggleQuality extends Action { @@ -35,7 +35,7 @@ public class ActionToggleQuality extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { output.add(new ToggleHighQualityActionItem(this)); } } diff --git a/src/com/jpexs/decompiler/flash/action/swf3/ActionWaitForFrame.java b/src/com/jpexs/decompiler/flash/action/swf3/ActionWaitForFrame.java index b47e3350a..7a516a7ba 100644 --- a/src/com/jpexs/decompiler/flash/action/swf3/ActionWaitForFrame.java +++ b/src/com/jpexs/decompiler/flash/action/swf3/ActionWaitForFrame.java @@ -30,12 +30,12 @@ import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; import com.jpexs.decompiler.flash.action.special.ActionStore; import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionWaitForFrame extends Action implements ActionStore { @@ -82,7 +82,7 @@ public class ActionWaitForFrame extends Action implements ActionStore { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) throws InterruptedException { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) throws InterruptedException { GraphTargetItem frameTi = new DirectValueActionItem(null, 0, new Long(frame), new ArrayList()); List body = ActionGraph.translateViaGraph(regNames, variables, functions, skipped, SWF.DEFAULT_VERSION, staticOperation, path); output.add(new IfFrameLoadedActionItem(frameTi, body, this)); diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionAdd.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionAdd.java index 86404f8b5..8a6734c43 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionAdd.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionAdd.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.AddActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionAdd extends Action { @@ -35,7 +35,7 @@ public class ActionAdd extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new AddActionItem(this, b, a, false)); diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionAnd.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionAnd.java index 8e85084cb..8581753d0 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionAnd.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionAnd.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.AndActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionAnd extends Action { @@ -35,7 +35,7 @@ public class ActionAnd extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new AndActionItem(this, b, a)); diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionAsciiToChar.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionAsciiToChar.java index 77fc9f270..f6c4af7b2 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionAsciiToChar.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionAsciiToChar.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.AsciiToCharActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionAsciiToChar extends Action { @@ -35,7 +35,7 @@ public class ActionAsciiToChar extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); stack.push(new AsciiToCharActionItem(this, a)); } diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionCall.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionCall.java index 849b13cf3..513fc9274 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionCall.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionCall.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.CallActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionCall extends Action { @@ -39,7 +39,7 @@ public class ActionCall extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { output.add(new CallActionItem(this, stack.pop())); } } diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionCharToAscii.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionCharToAscii.java index 8a1812ac2..0835fe89e 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionCharToAscii.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionCharToAscii.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.CharToAsciiActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionCharToAscii extends Action { @@ -35,7 +35,7 @@ public class ActionCharToAscii extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); stack.push(new CharToAsciiActionItem(this, a)); } diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionCloneSprite.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionCloneSprite.java index ade72a29b..2527f7405 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionCloneSprite.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionCloneSprite.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.CloneSpriteActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionCloneSprite extends Action { @@ -35,7 +35,7 @@ public class ActionCloneSprite extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem depth = stack.pop(); GraphTargetItem source = stack.pop(); GraphTargetItem target = stack.pop(); diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionDivide.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionDivide.java index aa2ba21be..b409eadcf 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionDivide.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionDivide.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.DivideActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionDivide extends Action { @@ -35,7 +35,7 @@ public class ActionDivide extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new DivideActionItem(this, b, a)); diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionEndDrag.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionEndDrag.java index a7b5c890d..40a539118 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionEndDrag.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionEndDrag.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.StopDragActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionEndDrag extends Action { @@ -35,7 +35,7 @@ public class ActionEndDrag extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { output.add(new StopDragActionItem(this)); } } diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionEquals.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionEquals.java index 6a4896308..9c6197260 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionEquals.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionEquals.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.EqActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionEquals extends Action { @@ -35,7 +35,7 @@ public class ActionEquals extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new EqActionItem(this, b, a, false)); diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionGetProperty.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionGetProperty.java index 09a16cadf..4da079478 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionGetProperty.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionGetProperty.java @@ -20,9 +20,9 @@ import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; import com.jpexs.decompiler.flash.action.model.GetPropertyActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionGetProperty extends Action { @@ -36,7 +36,7 @@ public class ActionGetProperty extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem index = stack.pop(); GraphTargetItem target = stack.pop(); int indexInt = 0; diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionGetTime.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionGetTime.java index 499c78140..c63c6f255 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionGetTime.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionGetTime.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.GetTimeActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionGetTime extends Action { @@ -35,7 +35,7 @@ public class ActionGetTime extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { stack.push(new GetTimeActionItem(this)); } } diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionGetURL2.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionGetURL2.java index a91448ca3..9fc61ce37 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionGetURL2.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionGetURL2.java @@ -34,12 +34,12 @@ import com.jpexs.decompiler.flash.action.model.UnLoadMovieNumActionItem; import com.jpexs.decompiler.flash.action.parser.ParseException; import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionGetURL2 extends Action { @@ -93,7 +93,7 @@ public class ActionGetURL2 extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem targetString = stack.pop(); GraphTargetItem urlString = stack.pop(); Integer num = null; diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionGetVariable.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionGetVariable.java index 34f5d1f43..a42838709 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionGetVariable.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionGetVariable.java @@ -22,10 +22,10 @@ import com.jpexs.decompiler.flash.action.model.EvalActionItem; import com.jpexs.decompiler.flash.action.model.GetVariableActionItem; import com.jpexs.decompiler.flash.action.model.GetVersionActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import com.jpexs.decompiler.graph.model.LocalData; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionGetVariable extends Action { @@ -39,7 +39,7 @@ public class ActionGetVariable extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem name = stack.pop(); GraphTargetItem computedVal = variables.get(name.toStringNoQuotes(LocalData.empty)); if (name instanceof DirectValueActionItem && ((DirectValueActionItem) name).value.equals("/:$version")) { diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionGotoFrame2.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionGotoFrame2.java index ad1e9c714..1c87bea16 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionGotoFrame2.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionGotoFrame2.java @@ -23,11 +23,11 @@ import com.jpexs.decompiler.flash.action.model.GotoFrame2ActionItem; import com.jpexs.decompiler.flash.action.parser.ParseException; import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionGotoFrame2 extends Action { @@ -85,7 +85,7 @@ public class ActionGotoFrame2 extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem frame = stack.pop(); output.add(new GotoFrame2ActionItem(this, frame, sceneBiasFlag, playFlag, sceneBias)); } diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionLess.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionLess.java index 82c81d6cc..f3ef7b8a6 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionLess.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionLess.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.LtActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionLess extends Action { @@ -35,7 +35,7 @@ public class ActionLess extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new LtActionItem(this, b, a, false)); diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionMBAsciiToChar.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionMBAsciiToChar.java index 12886323a..4348d3c87 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionMBAsciiToChar.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionMBAsciiToChar.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.MBAsciiToCharActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionMBAsciiToChar extends Action { @@ -35,7 +35,7 @@ public class ActionMBAsciiToChar extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); stack.push(new MBAsciiToCharActionItem(this, a)); } diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionMBCharToAscii.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionMBCharToAscii.java index 0ab3e4533..03c210027 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionMBCharToAscii.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionMBCharToAscii.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.MBCharToAsciiActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionMBCharToAscii extends Action { @@ -35,7 +35,7 @@ public class ActionMBCharToAscii extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); stack.push(new MBCharToAsciiActionItem(this, a)); } diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionMBStringExtract.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionMBStringExtract.java index f5bb13c6f..58918e011 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionMBStringExtract.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionMBStringExtract.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.MBStringExtractActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionMBStringExtract extends Action { @@ -35,7 +35,7 @@ public class ActionMBStringExtract extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem count = stack.pop(); GraphTargetItem index = stack.pop(); GraphTargetItem value = stack.pop(); diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionMBStringLength.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionMBStringLength.java index 03a6febb0..640e3dff9 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionMBStringLength.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionMBStringLength.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.MBStringLengthActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionMBStringLength extends Action { @@ -35,7 +35,7 @@ public class ActionMBStringLength extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); stack.push(new MBStringLengthActionItem(this, a)); } diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionMultiply.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionMultiply.java index 3be11ecae..7d08fcdfe 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionMultiply.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionMultiply.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.MultiplyActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionMultiply extends Action { @@ -35,7 +35,7 @@ public class ActionMultiply extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new MultiplyActionItem(this, b, a)); diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionNot.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionNot.java index e1ecec0b8..c67d70e3f 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionNot.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionNot.java @@ -18,10 +18,10 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import com.jpexs.decompiler.graph.model.NotItem; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionNot extends Action { @@ -35,7 +35,7 @@ public class ActionNot extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); stack.push(new NotItem(this, a)); } diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionOr.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionOr.java index 3bc12c513..c84369978 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionOr.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionOr.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.OrActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionOr extends Action { @@ -35,7 +35,7 @@ public class ActionOr extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new OrActionItem(this, b, a)); diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionPop.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionPop.java index d42940615..4db559609 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionPop.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionPop.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionPop extends Action { @@ -35,7 +35,7 @@ public class ActionPop extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { if (stack.isEmpty()) { return; } diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java index 1a684322d..0b8a1fc8a 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java @@ -35,13 +35,13 @@ import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import com.jpexs.helpers.Helper; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Stack; import java.util.logging.Level; import java.util.logging.Logger; @@ -313,7 +313,7 @@ public class ActionPush extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { int pos = 0; for (Object o : values) { if (ignoredParts.contains(pos)) { diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionRandomNumber.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionRandomNumber.java index 37cd3a283..c3ea7ed07 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionRandomNumber.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionRandomNumber.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.RandomNumberActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionRandomNumber extends Action { @@ -35,7 +35,7 @@ public class ActionRandomNumber extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem maximum = stack.pop(); stack.push(new RandomNumberActionItem(this, maximum)); } diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionRemoveSprite.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionRemoveSprite.java index aa380e8f4..819a852cc 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionRemoveSprite.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionRemoveSprite.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.RemoveSpriteActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionRemoveSprite extends Action { @@ -35,7 +35,7 @@ public class ActionRemoveSprite extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem target = stack.pop(); output.add(new RemoveSpriteActionItem(this, target)); } diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionSetProperty.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionSetProperty.java index 11d1e4549..35a0ba9d7 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionSetProperty.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionSetProperty.java @@ -29,9 +29,9 @@ import com.jpexs.decompiler.flash.action.model.TemporaryRegister; import com.jpexs.decompiler.flash.action.model.operations.PreDecrementActionItem; import com.jpexs.decompiler.flash.action.model.operations.PreIncrementActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionSetProperty extends Action { @@ -45,7 +45,7 @@ public class ActionSetProperty extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem value = stack.pop().getThroughDuplicate(); GraphTargetItem index = stack.pop().getThroughDuplicate(); GraphTargetItem target = stack.pop().getThroughDuplicate(); diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionSetTarget2.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionSetTarget2.java index 68e90b77b..708bc345e 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionSetTarget2.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionSetTarget2.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.SetTarget2ActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionSetTarget2 extends Action { @@ -35,7 +35,7 @@ public class ActionSetTarget2 extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem target = stack.pop(); output.add(new SetTarget2ActionItem(this, target)); } diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionSetVariable.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionSetVariable.java index ce7c789b4..1ecb1c441 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionSetVariable.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionSetVariable.java @@ -30,10 +30,10 @@ import com.jpexs.decompiler.flash.action.model.TemporaryRegister; import com.jpexs.decompiler.flash.action.model.operations.PreDecrementActionItem; import com.jpexs.decompiler.flash.action.model.operations.PreIncrementActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import com.jpexs.decompiler.graph.model.LocalData; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionSetVariable extends Action implements StoreTypeAction { @@ -47,7 +47,7 @@ public class ActionSetVariable extends Action implements StoreTypeAction { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem value = stack.pop().getThroughDuplicate(); GraphTargetItem name = stack.pop(); variables.put(name.toStringNoQuotes(LocalData.empty), value); @@ -121,7 +121,7 @@ public class ActionSetVariable extends Action implements StoreTypeAction { } @Override - public String getVariableName(Stack stack, ConstantPool cpool) { + public String getVariableName(TranslateStack stack, ConstantPool cpool) { if (stack.size() < 2) { return null; } diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionStartDrag.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionStartDrag.java index 5d0019ee4..283140522 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionStartDrag.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionStartDrag.java @@ -21,9 +21,9 @@ import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; import com.jpexs.decompiler.flash.action.model.StartDragActionItem; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionStartDrag extends Action { @@ -37,7 +37,7 @@ public class ActionStartDrag extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem target = stack.pop(); GraphTargetItem lockCenter = stack.pop(); GraphTargetItem constrain = stack.pop(); diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionStringAdd.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionStringAdd.java index c74b61116..784d75ced 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionStringAdd.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionStringAdd.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.StringAddActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionStringAdd extends Action { @@ -35,7 +35,7 @@ public class ActionStringAdd extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new StringAddActionItem(this, b, a)); diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionStringEquals.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionStringEquals.java index e2ffa6f37..455553c51 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionStringEquals.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionStringEquals.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.StringEqActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionStringEquals extends Action { @@ -35,7 +35,7 @@ public class ActionStringEquals extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new StringEqActionItem(this, b, a)); diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionStringExtract.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionStringExtract.java index 37ba9e233..02a3f0339 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionStringExtract.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionStringExtract.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.StringExtractActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionStringExtract extends Action { @@ -35,7 +35,7 @@ public class ActionStringExtract extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem count = stack.pop(); GraphTargetItem index = stack.pop(); GraphTargetItem value = stack.pop(); diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionStringLength.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionStringLength.java index 98ca04cd0..065b14915 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionStringLength.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionStringLength.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.StringLengthActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionStringLength extends Action { @@ -35,7 +35,7 @@ public class ActionStringLength extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); stack.push(new StringLengthActionItem(this, a)); } diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionStringLess.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionStringLess.java index 2c9586113..37fd08cde 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionStringLess.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionStringLess.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.StringLtActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionStringLess extends Action { @@ -35,7 +35,7 @@ public class ActionStringLess extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new StringLtActionItem(this, b, a)); diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionSubtract.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionSubtract.java index 53e26d44b..a34a0ba2a 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionSubtract.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionSubtract.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.SubtractActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionSubtract extends Action { @@ -35,7 +35,7 @@ public class ActionSubtract extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new SubtractActionItem(this, b, a)); diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionToInteger.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionToInteger.java index 8bd46046c..fdb075fc8 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionToInteger.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionToInteger.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.ToIntegerActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionToInteger extends Action { @@ -35,7 +35,7 @@ public class ActionToInteger extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); stack.push(new ToIntegerActionItem(this, a)); } diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionTrace.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionTrace.java index 1616214d3..3f3bbd84e 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionTrace.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionTrace.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.TraceActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionTrace extends Action { @@ -35,7 +35,7 @@ public class ActionTrace extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem value = stack.pop(); output.add(new TraceActionItem(this, value)); } diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionWaitForFrame2.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionWaitForFrame2.java index 04e15e1bc..b77bfef02 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionWaitForFrame2.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionWaitForFrame2.java @@ -29,12 +29,12 @@ import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; import com.jpexs.decompiler.flash.action.special.ActionStore; import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionWaitForFrame2 extends Action implements ActionStore { @@ -128,7 +128,7 @@ public class ActionWaitForFrame2 extends Action implements ActionStore { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) throws InterruptedException { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) throws InterruptedException { GraphTargetItem frame = stack.pop(); List body = ActionGraph.translateViaGraph(regNames, variables, functions, skipped, SWF.DEFAULT_VERSION, staticOperation, path); output.add(new IfFrameLoadedActionItem(frame, body, this)); diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionAdd2.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionAdd2.java index af27cbbe9..5900adeea 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionAdd2.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionAdd2.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.AddActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionAdd2 extends Action { @@ -35,7 +35,7 @@ public class ActionAdd2 extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new AddActionItem(this, b, a, true)); diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionBitAnd.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionBitAnd.java index 5745e8766..a86dea780 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionBitAnd.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionBitAnd.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.BitAndActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionBitAnd extends Action { @@ -35,7 +35,7 @@ public class ActionBitAnd extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new BitAndActionItem(this, b, a)); diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionBitLShift.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionBitLShift.java index d964ea1d1..7fc71b7fc 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionBitLShift.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionBitLShift.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.LShiftActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionBitLShift extends Action { @@ -35,7 +35,7 @@ public class ActionBitLShift extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new LShiftActionItem(this, b, a)); diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionBitOr.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionBitOr.java index bc37878f6..5c1e2e5b2 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionBitOr.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionBitOr.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.BitOrActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionBitOr extends Action { @@ -35,7 +35,7 @@ public class ActionBitOr extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new BitOrActionItem(this, b, a)); diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionBitRShift.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionBitRShift.java index a7bc9d623..4d19de1a2 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionBitRShift.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionBitRShift.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.RShiftActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionBitRShift extends Action { @@ -35,7 +35,7 @@ public class ActionBitRShift extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new RShiftActionItem(this, b, a)); diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionBitURShift.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionBitURShift.java index c97ba68e2..26e88dc59 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionBitURShift.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionBitURShift.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.URShiftActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionBitURShift extends Action { @@ -35,7 +35,7 @@ public class ActionBitURShift extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new URShiftActionItem(this, b, a)); diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionBitXor.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionBitXor.java index afa02d6e3..87830f355 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionBitXor.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionBitXor.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.BitXorActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionBitXor extends Action { @@ -35,7 +35,7 @@ public class ActionBitXor extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new BitXorActionItem(this, b, a)); diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionCallFunction.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionCallFunction.java index 5fa0865aa..ad5371f31 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionCallFunction.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionCallFunction.java @@ -19,11 +19,11 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.CallFunctionActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import com.jpexs.decompiler.graph.model.LocalData; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionCallFunction extends Action { @@ -37,7 +37,7 @@ public class ActionCallFunction extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem functionName = stack.pop(); long numArgs = popLong(stack); List args = new ArrayList<>(); diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionCallMethod.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionCallMethod.java index ce242e360..16d8deec5 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionCallMethod.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionCallMethod.java @@ -19,10 +19,10 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.CallMethodActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionCallMethod extends Action { @@ -36,7 +36,7 @@ public class ActionCallMethod extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem methodName = stack.pop(); GraphTargetItem scriptObject = stack.pop(); long numArgs = popLong(stack); diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionConstantPool.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionConstantPool.java index 18df6997b..75af5297c 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionConstantPool.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionConstantPool.java @@ -23,13 +23,13 @@ import com.jpexs.decompiler.flash.action.parser.ParseException; import com.jpexs.decompiler.flash.action.parser.pcode.ASMParsedSymbol; import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import com.jpexs.helpers.Helper; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionConstantPool extends Action { @@ -90,6 +90,6 @@ public class ActionConstantPool extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { } } diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionDecrement.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionDecrement.java index 89c74f2db..5e320db5f 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionDecrement.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionDecrement.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.DecrementActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionDecrement extends Action { @@ -35,7 +35,7 @@ public class ActionDecrement extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); stack.push(new DecrementActionItem(this, a)); } diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineFunction.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineFunction.java index f0553ee1d..095ab6e1e 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineFunction.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineFunction.java @@ -28,13 +28,13 @@ import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.GraphSourceItemContainer; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import com.jpexs.helpers.Helper; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionDefineFunction extends Action implements GraphSourceItemContainer { @@ -174,7 +174,7 @@ public class ActionDefineFunction extends Action implements GraphSourceItemConta } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { } @Override @@ -183,7 +183,7 @@ public class ActionDefineFunction extends Action implements GraphSourceItemConta } @Override - public void translateContainer(List> content, Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions) { + public void translateContainer(List> content, TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions) { FunctionActionItem fti = new FunctionActionItem(this, functionName, paramNames, content.get(0), constantPool, 1, new ArrayList()); //ActionGraph.translateViaGraph(regNames, variables, functions, code, version) stack.push(fti); diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineLocal.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineLocal.java index 7055fd611..59151e6f4 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineLocal.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineLocal.java @@ -19,10 +19,10 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.DefineLocalActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import com.jpexs.decompiler.graph.model.LocalData; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionDefineLocal extends Action { @@ -36,7 +36,7 @@ public class ActionDefineLocal extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem value = stack.pop(); GraphTargetItem name = stack.pop(); variables.put(name.toStringNoQuotes(LocalData.empty), value); diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineLocal2.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineLocal2.java index c301ef54f..9351614db 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineLocal2.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineLocal2.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.DefineLocalActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionDefineLocal2 extends Action { @@ -35,7 +35,7 @@ public class ActionDefineLocal2 extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem name = stack.pop(); output.add(new DefineLocalActionItem(this, name, null)); } diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionDelete.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionDelete.java index e23ac10c1..2c0e0b18c 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionDelete.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionDelete.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.DeleteActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionDelete extends Action { @@ -35,7 +35,7 @@ public class ActionDelete extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem propertyName = stack.pop(); GraphTargetItem object = stack.pop(); diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionDelete2.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionDelete2.java index d3112d2bf..f1cf01c97 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionDelete2.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionDelete2.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.DeleteActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionDelete2 extends Action { @@ -35,7 +35,7 @@ public class ActionDelete2 extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem propertyName = stack.pop(); stack.push(new DeleteActionItem(this, null, propertyName)); diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionEnumerate.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionEnumerate.java index e539d8ba7..632276698 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionEnumerate.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionEnumerate.java @@ -21,10 +21,10 @@ import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; import com.jpexs.decompiler.flash.action.model.EnumerateActionItem; import com.jpexs.decompiler.flash.ecma.Null; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionEnumerate extends Action { @@ -38,7 +38,7 @@ public class ActionEnumerate extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem object = stack.pop(); stack.push(new DirectValueActionItem(null, 0, new Null(), new ArrayList())); stack.push(new EnumerateActionItem(this, object)); diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionEquals2.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionEquals2.java index c84fb850d..c15e1fa8a 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionEquals2.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionEquals2.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.EqActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionEquals2 extends Action { @@ -35,7 +35,7 @@ public class ActionEquals2 extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new EqActionItem(this, b, a, true)); diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionGetMember.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionGetMember.java index 49866b85d..087aa4d1d 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionGetMember.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionGetMember.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.GetMemberActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionGetMember extends Action { @@ -35,7 +35,7 @@ public class ActionGetMember extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem functionName = stack.pop(); GraphTargetItem object = stack.pop(); stack.push(new GetMemberActionItem(this, object, functionName)); diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionIncrement.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionIncrement.java index de5d67a4e..c03d78600 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionIncrement.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionIncrement.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.IncrementActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionIncrement extends Action { @@ -35,7 +35,7 @@ public class ActionIncrement extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); stack.push(new IncrementActionItem(this, a)); } diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionInitArray.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionInitArray.java index c298a84e8..db3b0c987 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionInitArray.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionInitArray.java @@ -19,10 +19,10 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.InitArrayActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionInitArray extends Action { @@ -31,7 +31,7 @@ public class ActionInitArray extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { long numArgs = popLong(stack); List args = new ArrayList<>(); for (int l = 0; l < numArgs; l++) { diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionInitObject.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionInitObject.java index 36613cf2a..b18d3f19c 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionInitObject.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionInitObject.java @@ -19,10 +19,10 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.InitObjectActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionInitObject extends Action { @@ -36,7 +36,7 @@ public class ActionInitObject extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { long numArgs = popLong(stack); List values = new ArrayList<>(); List names = new ArrayList<>(); diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionLess2.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionLess2.java index 41767dae7..7260dfdf9 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionLess2.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionLess2.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.LtActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionLess2 extends Action { @@ -35,7 +35,7 @@ public class ActionLess2 extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new LtActionItem(this, b, a, true)); diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionModulo.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionModulo.java index 5c982679d..c1d43a716 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionModulo.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionModulo.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.ModuloActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionModulo extends Action { @@ -35,7 +35,7 @@ public class ActionModulo extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new ModuloActionItem(this, b, a)); diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionNewMethod.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionNewMethod.java index 917e82343..5955d9935 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionNewMethod.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionNewMethod.java @@ -19,10 +19,10 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.NewMethodActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionNewMethod extends Action { @@ -36,7 +36,7 @@ public class ActionNewMethod extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem methodName = stack.pop(); GraphTargetItem scriptObject = stack.pop(); long numArgs = popLong(stack); diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionNewObject.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionNewObject.java index fee61c908..be3d371cf 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionNewObject.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionNewObject.java @@ -19,10 +19,10 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.NewObjectActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionNewObject extends Action { @@ -36,7 +36,7 @@ public class ActionNewObject extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem objectName = stack.pop(); long numArgs = popLong(stack); List args = new ArrayList<>(); diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionPushDuplicate.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionPushDuplicate.java index 2e429d695..d3dae4d12 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionPushDuplicate.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionPushDuplicate.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.graph.GraphSourceItemPos; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionPushDuplicate extends Action { @@ -35,7 +35,7 @@ public class ActionPushDuplicate extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem value = stack.pop(); stack.push(value); stack.push(value); diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionReturn.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionReturn.java index b642bc2e4..61074d3b8 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionReturn.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionReturn.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.ReturnActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionReturn extends Action { @@ -35,7 +35,7 @@ public class ActionReturn extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem value = stack.pop(); output.add(new ReturnActionItem(this, value)); } diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionSetMember.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionSetMember.java index b2864a81f..73e4146f6 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionSetMember.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionSetMember.java @@ -28,9 +28,9 @@ import com.jpexs.decompiler.flash.action.model.TemporaryRegister; import com.jpexs.decompiler.flash.action.model.operations.PreDecrementActionItem; import com.jpexs.decompiler.flash.action.model.operations.PreIncrementActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionSetMember extends Action { @@ -44,7 +44,7 @@ public class ActionSetMember extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem value = stack.pop().getThroughDuplicate(); GraphTargetItem memberName = stack.pop(); GraphTargetItem object = stack.pop(); diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionStackSwap.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionStackSwap.java index d1a5bb2cf..e3a144a63 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionStackSwap.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionStackSwap.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.graph.GraphSourceItemPos; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionStackSwap extends Action { @@ -35,7 +35,7 @@ public class ActionStackSwap extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(a); diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionStoreRegister.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionStoreRegister.java index ffedde4de..0ed9cd085 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionStoreRegister.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionStoreRegister.java @@ -33,11 +33,11 @@ import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; import com.jpexs.decompiler.flash.action.swf4.RegisterNumber; import com.jpexs.decompiler.graph.GraphSourceItemPos; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionStoreRegister extends Action implements StoreTypeAction { @@ -76,7 +76,7 @@ public class ActionStoreRegister extends Action implements StoreTypeAction { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem value = stack.pop(); RegisterNumber rn = new RegisterNumber(registerNumber); if (regNames.containsKey(registerNumber)) { @@ -134,7 +134,7 @@ public class ActionStoreRegister extends Action implements StoreTypeAction { } @Override - public String getVariableName(Stack stack, ConstantPool cpool) { + public String getVariableName(TranslateStack stack, ConstantPool cpool) { return "__register" + registerNumber; } } diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionTargetPath.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionTargetPath.java index 4f9818ed7..93bdbcfb7 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionTargetPath.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionTargetPath.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.TargetPathActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionTargetPath extends Action { @@ -35,7 +35,7 @@ public class ActionTargetPath extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem object = stack.pop(); stack.push(new TargetPathActionItem(this, object)); } diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionToNumber.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionToNumber.java index 484876423..1e4fac05f 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionToNumber.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionToNumber.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.ToNumberActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionToNumber extends Action { @@ -35,7 +35,7 @@ public class ActionToNumber extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem object = stack.pop(); stack.push(new ToNumberActionItem(this, object)); } diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionToString.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionToString.java index bd8045f0b..b1b5bc151 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionToString.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionToString.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.ToStringActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionToString extends Action { @@ -35,7 +35,7 @@ public class ActionToString extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem object = stack.pop(); stack.push(new ToStringActionItem(this, object)); } diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionTypeOf.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionTypeOf.java index a0a00a11e..be8d5633d 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionTypeOf.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionTypeOf.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.TypeOfActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionTypeOf extends Action { @@ -35,7 +35,7 @@ public class ActionTypeOf extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem object = stack.pop(); stack.push(new TypeOfActionItem(this, object)); } diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionWith.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionWith.java index 4919dff8d..459650a7c 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionWith.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionWith.java @@ -26,12 +26,12 @@ import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.graph.GraphSourceItemContainer; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionWith extends Action implements GraphSourceItemContainer { @@ -80,7 +80,7 @@ public class ActionWith extends Action implements GraphSourceItemContainer { } @Override - public void translateContainer(List> content, Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions) { + public void translateContainer(List> content, TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions) { output.add(new WithActionItem(this, stack.pop(), content.get(0))); } diff --git a/src/com/jpexs/decompiler/flash/action/swf6/ActionEnumerate2.java b/src/com/jpexs/decompiler/flash/action/swf6/ActionEnumerate2.java index e98dbea05..f2a85d6f2 100644 --- a/src/com/jpexs/decompiler/flash/action/swf6/ActionEnumerate2.java +++ b/src/com/jpexs/decompiler/flash/action/swf6/ActionEnumerate2.java @@ -21,10 +21,10 @@ import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; import com.jpexs.decompiler.flash.action.model.EnumerateActionItem; import com.jpexs.decompiler.flash.ecma.Null; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionEnumerate2 extends Action { @@ -38,7 +38,7 @@ public class ActionEnumerate2 extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem object = stack.pop(); stack.push(new DirectValueActionItem(null, 0, new Null(), new ArrayList())); stack.push(new EnumerateActionItem(this, object)); diff --git a/src/com/jpexs/decompiler/flash/action/swf6/ActionGreater.java b/src/com/jpexs/decompiler/flash/action/swf6/ActionGreater.java index e889bfedf..e0527901b 100644 --- a/src/com/jpexs/decompiler/flash/action/swf6/ActionGreater.java +++ b/src/com/jpexs/decompiler/flash/action/swf6/ActionGreater.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf6; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.GtActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionGreater extends Action { @@ -35,7 +35,7 @@ public class ActionGreater extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new GtActionItem(this, b, a)); diff --git a/src/com/jpexs/decompiler/flash/action/swf6/ActionInstanceOf.java b/src/com/jpexs/decompiler/flash/action/swf6/ActionInstanceOf.java index 4c359d85b..fd0e5ec16 100644 --- a/src/com/jpexs/decompiler/flash/action/swf6/ActionInstanceOf.java +++ b/src/com/jpexs/decompiler/flash/action/swf6/ActionInstanceOf.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf6; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.InstanceOfActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionInstanceOf extends Action { @@ -35,7 +35,7 @@ public class ActionInstanceOf extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new InstanceOfActionItem(this, b, a)); diff --git a/src/com/jpexs/decompiler/flash/action/swf6/ActionStrictEquals.java b/src/com/jpexs/decompiler/flash/action/swf6/ActionStrictEquals.java index bbe18998b..be4829a70 100644 --- a/src/com/jpexs/decompiler/flash/action/swf6/ActionStrictEquals.java +++ b/src/com/jpexs/decompiler/flash/action/swf6/ActionStrictEquals.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf6; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.StrictEqActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionStrictEquals extends Action { @@ -35,7 +35,7 @@ public class ActionStrictEquals extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new StrictEqActionItem(this, b, a)); diff --git a/src/com/jpexs/decompiler/flash/action/swf6/ActionStringGreater.java b/src/com/jpexs/decompiler/flash/action/swf6/ActionStringGreater.java index 285807605..fd67280ba 100644 --- a/src/com/jpexs/decompiler/flash/action/swf6/ActionStringGreater.java +++ b/src/com/jpexs/decompiler/flash/action/swf6/ActionStringGreater.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf6; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.StringGtActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionStringGreater extends Action { @@ -35,7 +35,7 @@ public class ActionStringGreater extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new StringGtActionItem(this, b, a)); diff --git a/src/com/jpexs/decompiler/flash/action/swf7/ActionCastOp.java b/src/com/jpexs/decompiler/flash/action/swf7/ActionCastOp.java index 7d983d311..66d267b21 100644 --- a/src/com/jpexs/decompiler/flash/action/swf7/ActionCastOp.java +++ b/src/com/jpexs/decompiler/flash/action/swf7/ActionCastOp.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf7; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.CastOpActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionCastOp extends Action { @@ -35,7 +35,7 @@ public class ActionCastOp extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem object = stack.pop(); GraphTargetItem constructor = stack.pop(); stack.push(new CastOpActionItem(this, constructor, object)); diff --git a/src/com/jpexs/decompiler/flash/action/swf7/ActionDefineFunction2.java b/src/com/jpexs/decompiler/flash/action/swf7/ActionDefineFunction2.java index 504e8a26e..6f27138ec 100644 --- a/src/com/jpexs/decompiler/flash/action/swf7/ActionDefineFunction2.java +++ b/src/com/jpexs/decompiler/flash/action/swf7/ActionDefineFunction2.java @@ -28,13 +28,13 @@ import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.GraphSourceItemContainer; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import com.jpexs.helpers.Helper; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionDefineFunction2 extends Action implements GraphSourceItemContainer { @@ -291,7 +291,7 @@ public class ActionDefineFunction2 extends Action implements GraphSourceItemCont } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { } @Override @@ -332,7 +332,7 @@ public class ActionDefineFunction2 extends Action implements GraphSourceItemCont } @Override - public void translateContainer(List> content, Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions) { + public void translateContainer(List> content, TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions) { FunctionActionItem fti = new FunctionActionItem(this, functionName, paramNames, content.get(0), constantPool, getFirstRegister(), new ArrayList()); functions.put(functionName, fti); stack.push(fti); diff --git a/src/com/jpexs/decompiler/flash/action/swf7/ActionExtends.java b/src/com/jpexs/decompiler/flash/action/swf7/ActionExtends.java index 446565c8a..09ddcdf73 100644 --- a/src/com/jpexs/decompiler/flash/action/swf7/ActionExtends.java +++ b/src/com/jpexs/decompiler/flash/action/swf7/ActionExtends.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf7; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.ExtendsActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionExtends extends Action { @@ -35,7 +35,7 @@ public class ActionExtends extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem superclass = stack.pop(); GraphTargetItem subclass = stack.pop(); output.add(new ExtendsActionItem(this, subclass, superclass)); diff --git a/src/com/jpexs/decompiler/flash/action/swf7/ActionImplementsOp.java b/src/com/jpexs/decompiler/flash/action/swf7/ActionImplementsOp.java index 1127050f4..61e36038a 100644 --- a/src/com/jpexs/decompiler/flash/action/swf7/ActionImplementsOp.java +++ b/src/com/jpexs/decompiler/flash/action/swf7/ActionImplementsOp.java @@ -19,10 +19,10 @@ package com.jpexs.decompiler.flash.action.swf7; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.ImplementsOpActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionImplementsOp extends Action { @@ -36,7 +36,7 @@ public class ActionImplementsOp extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem subclass = stack.pop(); long inCount = popLong(stack); List superclasses = new ArrayList<>(); diff --git a/src/com/jpexs/decompiler/flash/action/swf7/ActionThrow.java b/src/com/jpexs/decompiler/flash/action/swf7/ActionThrow.java index ad3e3d4a5..28a1251bd 100644 --- a/src/com/jpexs/decompiler/flash/action/swf7/ActionThrow.java +++ b/src/com/jpexs/decompiler/flash/action/swf7/ActionThrow.java @@ -19,9 +19,9 @@ package com.jpexs.decompiler.flash.action.swf7; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.ThrowActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionThrow extends Action { @@ -35,7 +35,7 @@ public class ActionThrow extends Action { } @Override - public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem object = stack.pop(); output.add(new ThrowActionItem(this, object)); } diff --git a/src/com/jpexs/decompiler/flash/action/swf7/ActionTry.java b/src/com/jpexs/decompiler/flash/action/swf7/ActionTry.java index a6e1cbb8f..8345e8bfa 100644 --- a/src/com/jpexs/decompiler/flash/action/swf7/ActionTry.java +++ b/src/com/jpexs/decompiler/flash/action/swf7/ActionTry.java @@ -30,13 +30,13 @@ import com.jpexs.decompiler.flash.action.swf4.RegisterNumber; import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.graph.GraphSourceItemContainer; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import com.jpexs.helpers.Helper; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Stack; public class ActionTry extends Action implements GraphSourceItemContainer { @@ -265,7 +265,7 @@ public class ActionTry extends Action implements GraphSourceItemContainer { } @Override - public void translateContainer(List> contents, Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions) { + public void translateContainer(List> contents, TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions) { List tryCommands = contents.get(0); ActionItem catchName; if (catchInRegisterFlag) { diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java b/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java index abd723b5a..14f868928 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java @@ -36,6 +36,7 @@ import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; import com.jpexs.decompiler.flash.helpers.hilight.Highlighting; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; import com.jpexs.helpers.Helper; import com.jpexs.helpers.MemoryInputStream; import java.io.IOException; @@ -43,7 +44,6 @@ import java.io.StringReader; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Stack; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.event.CaretEvent; @@ -172,7 +172,7 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi public void graph() { try { - AVM2Graph gr = new AVM2Graph(abc.bodies.get(bodyIndex).code, abc, abc.bodies.get(bodyIndex), false, -1, -1, new HashMap(), new Stack(), new HashMap(), new ArrayList(), new HashMap(), abc.bodies.get(bodyIndex).code.visitCode(abc.bodies.get(bodyIndex))); + AVM2Graph gr = new AVM2Graph(abc.bodies.get(bodyIndex).code, abc, abc.bodies.get(bodyIndex), false, -1, -1, new HashMap(), new ScopeStack(), new HashMap(), new ArrayList(), new HashMap(), abc.bodies.get(bodyIndex).code.visitCode(abc.bodies.get(bodyIndex))); (new GraphDialog(getAbcPanel().getMainPanel().getMainFrame().getWindow(), gr, name)).setVisible(true); } catch (InterruptedException ex) { Logger.getLogger(ASMSourceEditorPane.class.getName()).log(Level.SEVERE, null, ex); diff --git a/src/com/jpexs/decompiler/graph/Graph.java b/src/com/jpexs/decompiler/graph/Graph.java index a71cd4145..9007fa32f 100644 --- a/src/com/jpexs/decompiler/graph/Graph.java +++ b/src/com/jpexs/decompiler/graph/Graph.java @@ -1,2047 +1,2045 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.graph; - -import com.jpexs.decompiler.flash.BaseLocalData; -import com.jpexs.decompiler.flash.FinalProcessLocalData; -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.ecma.EcmaScript; -import com.jpexs.decompiler.flash.helpers.GraphTextWriter; -import com.jpexs.decompiler.graph.model.AndItem; -import com.jpexs.decompiler.graph.model.BreakItem; -import com.jpexs.decompiler.graph.model.ContinueItem; -import com.jpexs.decompiler.graph.model.DoWhileItem; -import com.jpexs.decompiler.graph.model.ExitItem; -import com.jpexs.decompiler.graph.model.ForItem; -import com.jpexs.decompiler.graph.model.IfItem; -import com.jpexs.decompiler.graph.model.IntegerValueItem; -import com.jpexs.decompiler.graph.model.LocalData; -import com.jpexs.decompiler.graph.model.LogicalOpItem; -import com.jpexs.decompiler.graph.model.LoopItem; -import com.jpexs.decompiler.graph.model.NotItem; -import com.jpexs.decompiler.graph.model.OrItem; -import com.jpexs.decompiler.graph.model.ScriptEndItem; -import com.jpexs.decompiler.graph.model.SwitchItem; -import com.jpexs.decompiler.graph.model.TernarOpItem; -import com.jpexs.decompiler.graph.model.UniversalLoopItem; -import com.jpexs.decompiler.graph.model.WhileItem; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Stack; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * - * @author JPEXS - */ -public class Graph { - - public List heads; - protected GraphSource code; - private final List alternateEntries; - public static final int SOP_USE_STATIC = 0; - public static final int SOP_SKIP_STATIC = 1; - public static final int SOP_REMOVE_STATIC = 2; - - public Graph(GraphSource code, List alternateEntries) { - this.code = code; - this.alternateEntries = alternateEntries; - - } - - public void init(BaseLocalData localData) throws InterruptedException { - if (heads != null) { - return; - } - heads = makeGraph(code, new ArrayList(), alternateEntries); - int time = 1; - List ordered = new ArrayList<>(); - List visited = new ArrayList<>(); - for (GraphPart head : heads) { - time = head.setTime(time, ordered, visited); - } - } - - protected static void populateParts(GraphPart part, List allParts) { - if (allParts.contains(part)) { - return; - } - allParts.add(part); - for (GraphPart p : part.nextParts) { - populateParts(p, allParts); - } - } - - public GraphPart deepCopy(GraphPart part, List visited, List copies) { - if (visited == null) { - visited = new ArrayList<>(); - } - if (copies == null) { - copies = new ArrayList<>(); - } - if (visited.contains(part)) { - return copies.get(visited.indexOf(part)); - } - visited.add(part); - GraphPart copy = new GraphPart(part.start, part.end); - copy.path = part.path; - copies.add(copy); - copy.nextParts = new ArrayList<>(); - for (int i = 0; i < part.nextParts.size(); i++) { - copy.nextParts.add(deepCopy(part.nextParts.get(i), visited, copies)); - } - for (int i = 0; i < part.refs.size(); i++) { - copy.refs.add(deepCopy(part.refs.get(i), visited, copies)); - } - return copy; - } - - public void resetGraph(GraphPart part, List visited) { - if (visited.contains(part)) { - return; - } - visited.add(part); - int pos = 0; - for (GraphPart p : part.nextParts) { - if (!visited.contains(p)) { - p.path = part.path.sub(pos, p.end); - } - resetGraph(p, visited); - pos++; - } - } - - private void getReachableParts(GraphPart part, List ret, List loops) { - getReachableParts(part, ret, loops, true); - } - - private void getReachableParts(GraphPart part, List ret, List loops, boolean first) { - - if (first) { - for (Loop l : loops) { - l.reachableMark = 0; - } - } - Loop currentLoop = null; - - for (Loop l : loops) { - if ((l.phase == 1) || (l.reachableMark == 1)) { - if (l.loopContinue == part) { - return; - } - if (l.loopBreak == part) { - return; - } - if (l.loopPreContinue == part) { - return; - } - } - if (l.reachableMark == 0) { - if (l.loopContinue == part) { - l.reachableMark = 1; - currentLoop = l; - } - } - } - - List newparts = new ArrayList<>(); - loopnext: - for (GraphPart next : part.nextParts) { - for (Loop l : loops) { - if ((l.phase == 1) || (l.reachableMark == 1)) { - if (l.loopContinue == next) { - continue loopnext; - } - if (l.loopBreak == next) { - continue loopnext; - } - if (l.loopPreContinue == next) { - continue loopnext; - } - } - - } - if (!ret.contains(next)) { - newparts.add(next); - } - } - - ret.addAll(newparts); - for (GraphPart next : newparts) { - getReachableParts(next, ret, loops); - } - - if (currentLoop != null) { - if (currentLoop.loopBreak != null) { - if (!ret.contains(currentLoop.loopBreak)) { - ret.add(currentLoop.loopBreak); - currentLoop.reachableMark = 2; - getReachableParts(currentLoop.loopBreak, ret, loops); - } - } - } - } - - /* public GraphPart getNextCommonPart(GraphPart part, List loops) { - return getNextCommonPart(part, new ArrayList(),loops); - }*/ - public GraphPart getNextCommonPart(BaseLocalData localData, GraphPart part, List loops) throws InterruptedException { - return getCommonPart(localData, part.nextParts, loops); - } - - public GraphPart getCommonPart(BaseLocalData localData, List parts, List loops) throws InterruptedException { - if (parts.isEmpty()) { - return null; - } - - List loopContinues = new ArrayList<>();//getLoopsContinues(loops); - for (Loop l : loops) { - if (l.phase == 1) { - loopContinues.add(l.loopContinue); - } - } - - for (GraphPart p : parts) { - if (loopContinues.contains(p)) { - break; - } - boolean common = true; - for (GraphPart q : parts) { - if (q == p) { - continue; - } - if (!q.leadsTo(localData, this, code, p, loops)) { - common = false; - break; - } - } - if (common) { - return p; - } - } - List> reachable = new ArrayList<>(); - for (GraphPart p : parts) { - List r1 = new ArrayList<>(); - getReachableParts(p, r1, loops); - r1.add(p); - reachable.add(r1); - } - List first = reachable.get(0); - for (GraphPart p : first) { - /*if (ignored.contains(p)) { - continue; - }*/ - p = checkPart(null, localData, p, null); - if (p == null) { - continue; - } - boolean common = true; - for (List r : reachable) { - if (!r.contains(p)) { - common = false; - break; - } - } - if (common) { - return p; - } - } - return null; - } - - public GraphPart getMostCommonPart(BaseLocalData localData, List parts, List loops) throws InterruptedException { - if (parts.isEmpty()) { - return null; - } - - Set s = new HashSet<>(parts); //unique - parts = new ArrayList<>(s); //make local copy - - List loopContinues = new ArrayList<>();//getLoopsContinues(loops); - for (Loop l : loops) { - if (l.phase == 1) { - loopContinues.add(l.loopContinue); - loopContinues.add(l.loopPreContinue); - } - } - - for (GraphPart p : parts) { - if (loopContinues.contains(p)) { - break; - } - boolean common = true; - for (GraphPart q : parts) { - if (q == p) { - continue; - } - if (!q.leadsTo(localData, this, code, p, loops)) { - common = false; - break; - } - } - if (common) { - return p; - } - } - - loopi: - for (int i = 0; i < parts.size(); i++) { - for (int j = 0; j < parts.size(); j++) { - if (j == i) { - continue; - } - if (parts.get(i).leadsTo(localData, this, code, parts.get(j), loops)) { - parts.remove(i); - i--; - continue loopi; - } - } - } - List> reachable = new ArrayList<>(); - for (GraphPart p : parts) { - List r1 = new ArrayList<>(); - getReachableParts(p, r1, loops); - r1.add(0, p); - reachable.add(r1); - } - ///List first = reachable.get(0); - int commonLevel; - Map levelMap = new HashMap<>(); - for (List first : reachable) { - int maxclevel = 0; - Set visited = new HashSet<>(); - for (GraphPart p : first) { - if (loopContinues.contains(p)) { - break; - } - if (visited.contains(p)) { - continue; - } - visited.add(p); - boolean common = true; - commonLevel = 1; - for (List r : reachable) { - if (r == first) { - continue; - } - if (r.contains(p)) { - commonLevel++; - } - } - if (commonLevel <= maxclevel) { - continue; - } - maxclevel = commonLevel; - if (levelMap.containsKey(p)) { - if (levelMap.get(p) > commonLevel) { - commonLevel = levelMap.get(p); - } - } - levelMap.put(p, commonLevel); - if (common) { - //return p; - } - } - } - for (int i = reachable.size() - 1; i >= 2; i--) { - for (GraphPart p : levelMap.keySet()) { - if (levelMap.get(p) == i) { - return p; - } - } - } - for (GraphPart p : levelMap.keySet()) { - if (levelMap.get(p) == parts.size()) { - return p; - } - } - return null; - } - - public GraphPart getNextNoJump(GraphPart part, BaseLocalData localData) { - while (code.get(part.start).isJump()) { - part = part.getSubParts().get(0).nextParts.get(0); - } - /*localData = prepareBranchLocalData(localData); - Stack st = new Stack<>(); - List output=new ArrayList<>(); - GraphPart startPart = part; - for (int i = part.start; i <= part.end; i++) { - GraphSourceItem src = code.get(i); - if (src.isJump()) { - part = part.nextParts.get(0); - if(st.isEmpty()){ - startPart = part; - } - i = part.start - 1; - continue; - } - try{ - src.translate(localData, st, output, SOP_USE_STATIC, ""); - }catch(Exception ex){ - return startPart; - } - if(!output.isEmpty()){ - return startPart; - } - }*/ - return part; - } - - public static List translateViaGraph(BaseLocalData localData, String path, GraphSource code, List alternateEntries, int staticOperation) throws InterruptedException { - Graph g = new Graph(code, alternateEntries); - g.init(localData); - return g.translate(localData, staticOperation, path); - } - - public List translate(BaseLocalData localData, int staticOperation, String path) throws InterruptedException { - List allParts = new ArrayList<>(); - for (GraphPart head : heads) { - populateParts(head, allParts); - } - Stack stack = new Stack<>(); - List loops = new ArrayList<>(); - getLoops(localData, heads.get(0), loops, null); - /*System.out.println(""); - for (Loop el : loops) { - System.out.println(el); - } - System.out.println("");*/ - getPrecontinues(path, localData, null, heads.get(0), allParts, loops, null); - /*System.err.println(""); - for (Loop el : loops) { - System.err.println(el); - } - System.err.println("");//*/ - - List ret = printGraph(localData, stack, allParts, null, heads.get(0), null, loops, staticOperation, path); - processIfs(ret); - finalProcessStack(stack, ret); - finalProcessAll(ret, 0, new FinalProcessLocalData()); - return ret; - - } - - public void finalProcessStack(Stack stack, List output) { - } - - private void finalProcessAll(List list, int level, FinalProcessLocalData localData) { - finalProcess(list, level, localData); - for (GraphTargetItem item : list) { - if (item instanceof Block) { - List> subs = ((Block) item).getSubs(); - for (List sub : subs) { - finalProcessAll(sub, level + 1, localData); - } - } - } - } - - protected void finalProcess(List list, int level, FinalProcessLocalData localData) { - } - - private void processIfs(List list) { - //if(true) return; - for (int i = 0; i < list.size(); i++) { - GraphTargetItem item = list.get(i); - if (item instanceof Block) { - List> subs = ((Block) item).getSubs(); - for (List sub : subs) { - processIfs(sub); - } - } - if ((item instanceof LoopItem) && (item instanceof Block)) { - List> subs = ((Block) item).getSubs(); - for (List sub : subs) { - processIfs(sub); - checkContinueAtTheEnd(sub, ((LoopItem) item).loop); - } - } - if (item instanceof IfItem) { - IfItem ifi = (IfItem) item; - List onTrue = ifi.onTrue; - List onFalse = ifi.onFalse; - if ((!onTrue.isEmpty()) && (!onFalse.isEmpty())) { - if (onTrue.get(onTrue.size() - 1) instanceof ContinueItem) { - if (onFalse.get(onFalse.size() - 1) instanceof ContinueItem) { - if (((ContinueItem) onTrue.get(onTrue.size() - 1)).loopId == ((ContinueItem) onFalse.get(onFalse.size() - 1)).loopId) { - onTrue.remove(onTrue.size() - 1); - list.add(i + 1, onFalse.remove(onFalse.size() - 1)); - } - } - } - } - - if ((!onTrue.isEmpty()) && (!onFalse.isEmpty())) { - GraphTargetItem last = onTrue.get(onTrue.size() - 1); - if ((last instanceof ExitItem) || (last instanceof ContinueItem) || (last instanceof BreakItem)) { - list.addAll(i + 1, onFalse); - onFalse.clear(); - } - } - - if ((!onTrue.isEmpty()) && (!onFalse.isEmpty())) { - if (onFalse.get(onFalse.size() - 1) instanceof ExitItem) { - if (onTrue.get(onTrue.size() - 1) instanceof ContinueItem) { - list.add(i + 1, onTrue.remove(onTrue.size() - 1)); - } - } - } - } - } - - //Same continues in onTrue and onFalse gets continue on parent level - } - - protected List getLoopsContinuesPreAndBreaks(List loops) { - List ret = new ArrayList<>(); - for (Loop l : loops) { - if (l.loopContinue != null) { - ret.add(l.loopContinue); - } - if (l.loopPreContinue != null) { - ret.add(l.loopPreContinue); - } - if (l.loopBreak != null) { - ret.add(l.loopBreak); - } - } - return ret; - } - - protected List getLoopsContinuesAndPre(List loops) { - List ret = new ArrayList<>(); - for (Loop l : loops) { - if (l.loopContinue != null) { - ret.add(l.loopContinue); - } - if (l.loopPreContinue != null) { - ret.add(l.loopPreContinue); - } - } - return ret; - } - - protected List getLoopsContinues(List loops) { - List ret = new ArrayList<>(); - for (Loop l : loops) { - if (l.loopContinue != null) { - ret.add(l.loopContinue); - } - /*if (l.loopPreContinue != null) { - ret.add(l.loopPreContinue); - }*/ - } - return ret; - } - - protected GraphTargetItem checkLoop(GraphPart part, List stopPart, List loops) { - if (stopPart.contains(part)) { - return null; - } - for (Loop l : loops) { - if (l.loopContinue == part) { - return (new ContinueItem(null, l.id)); - } - if (l.loopBreak == part) { - return (new BreakItem(null, l.id)); - } - } - return null; - } - - private void checkContinueAtTheEnd(List commands, Loop loop) { - if (!commands.isEmpty()) { - int i = commands.size() - 1; - for (; i >= 0; i--) { - if (commands.get(i) instanceof ContinueItem) { - continue; - } - if (commands.get(i) instanceof BreakItem) { - continue; - } - break; - } - if (i < commands.size() - 1) { - for (int k = i + 2; k < commands.size(); k++) { - commands.remove(k); - } - } - if (commands.get(commands.size() - 1) instanceof ContinueItem) { - if (((ContinueItem) commands.get(commands.size() - 1)).loopId == loop.id) { - commands.remove(commands.size() - 1); - } - } - } - } - - protected boolean isEmpty(List output) { - if (output.isEmpty()) { - return true; - } - if (output.size() == 1) { - if (output.get(0) instanceof MarkItem) { - return true; - } - } - return false; - } - - protected List check(GraphSource code, BaseLocalData localData, List allParts, Stack stack, GraphPart parent, GraphPart part, List stopPart, List loops, List output, Loop currentLoop, int staticOperation, String path) throws InterruptedException { - return null; - } - - protected GraphPart checkPart(Stack stack, BaseLocalData localData, GraphPart part, List allParts) { - return part; - } - - @SuppressWarnings("unchecked") - protected GraphTargetItem translatePartGetStack(BaseLocalData localData, GraphPart part, Stack stack, int staticOperation) throws InterruptedException { - stack = (Stack) stack.clone(); - translatePart(localData, part, stack, staticOperation, null); - return stack.pop(); - } - - protected List translatePart(BaseLocalData localData, GraphPart part, Stack stack, int staticOperation, String path) throws InterruptedException { - List sub = part.getSubParts(); - List ret = new ArrayList<>(); - int end; - for (GraphPart p : sub) { - if (p.end == -1) { - p.end = code.size() - 1; - } - if (p.start == code.size()) { - continue; - } else if (p.end == code.size()) { - p.end--; - } - end = p.end; - int start = p.start; - ret.addAll(code.translatePart(part, localData, stack, start, end, staticOperation, path)); - } - return ret; - } - - private void markBranchEnd(List items) { - if (!items.isEmpty()) { - if (items.get(items.size() - 1) instanceof BreakItem) { - return; - } - if (items.get(items.size() - 1) instanceof ContinueItem) { - return; - } - if (items.get(items.size() - 1) instanceof ExitItem) { - return; - } - } - items.add(new MarkItem("finish")); - } - - private static GraphTargetItem getLastNoEnd(List list) { - if (list.isEmpty()) { - return null; - } - if (list.get(list.size() - 1) instanceof ScriptEndItem) { - if (list.size() >= 2) { - return list.get(list.size() - 2); - } - return list.get(list.size() - 1); - } - return list.get(list.size() - 1); - } - - private static void removeLastNoEnd(List list) { - if (list.isEmpty()) { - return; - } - if (list.get(list.size() - 1) instanceof ScriptEndItem) { - if (list.size() >= 2) { - list.remove(list.size() - 2); - } - return; - } - list.remove(list.size() - 1); - } - - protected List printGraph(BaseLocalData localData, Stack stack, List allParts, GraphPart parent, GraphPart part, List stopPart, List loops, int staticOperation, String path) throws InterruptedException { - List visited = new ArrayList<>(); - return printGraph(visited, localData, stack, allParts, parent, part, stopPart, loops, null, staticOperation, path, 0); - } - - protected GraphTargetItem checkLoop(LoopItem loopItem, BaseLocalData localData, List loops) { - return loopItem; - } - - private void getPrecontinues(String path, BaseLocalData localData, GraphPart parent, GraphPart part, List allParts, List loops, List stopPart) throws InterruptedException { - markLevels(path, localData, part, allParts, loops); - //Note: this also marks part as precontinue when there is if - /* - while(k<10){ - if(k==7){ - trace(a); - }else{ - trace(b); - } - //precontinue - k++; - } - - */ - looploops: - for (Loop l : loops) { - if (l.loopContinue != null) { - Set uniqueRefs = new HashSet<>(); - uniqueRefs.addAll(l.loopContinue.refs); - if (uniqueRefs.size() == 2) { //only one path - from precontinue - List uniqueRefsList = new ArrayList<>(uniqueRefs); - if (uniqueRefsList.get(0).discoveredTime > uniqueRefsList.get(1).discoveredTime) { //latch node is discovered later - part = uniqueRefsList.get(0); - } else { - part = uniqueRefsList.get(1); - } - if (part == l.loopContinue) { - continue looploops; - } - - while (part.refs.size() == 1) { - if (part.refs.get(0).nextParts.size() != 1) { - continue looploops; - } - - part = part.refs.get(0); - if (part == l.loopContinue) { - break; - } - } - if (part.level == 0 && part != l.loopContinue) { - l.loopPreContinue = part; - } - } - } - } - /*clearLoops(loops); - getPrecontinues(parent, part, loops, stopPart, 0, new ArrayList()); - clearLoops(loops);*/ - } - - private void markLevels(String path, BaseLocalData localData, GraphPart part, List allParts, List loops) throws InterruptedException { - clearLoops(loops); - markLevels(path, localData, part, allParts, loops, new ArrayList(), 1, new ArrayList(), 0); - clearLoops(loops); - } - - private void markLevels(String path, BaseLocalData localData, GraphPart part, List allParts, List loops, List stopPart, int level, List visited, int recursionLevel) throws InterruptedException { - boolean debugMode = false; - if (stopPart == null) { - stopPart = new ArrayList<>(); - } - if (recursionLevel > allParts.size() + 1) { - Logger.getLogger(Graph.class.getName()).log(Level.WARNING, "{0} : markLevels max recursion level reached", path); - return; - } - - if (debugMode) { - System.err.println("markLevels " + part); - } - if (stopPart.contains(part)) { - return; - } - for (Loop el : loops) { - if ((el.phase == 2) && (el.loopContinue == part)) { - return; - } - if (el.phase != 1) { - if (debugMode) { - //System.err.println("ignoring "+el); - } - continue; - } - if (el.loopContinue == part) { - return; - } - if (el.loopPreContinue == part) { - return; - } - if (el.loopBreak == part) { - return; - } - } - - if (visited.contains(part)) { - part.level = 0; - } else { - visited.add(part); - part.level = level; - } - - boolean isLoop = false; - Loop currentLoop = null; - for (Loop el : loops) { - if ((el.phase == 0) && (el.loopContinue == part)) { - isLoop = true; - currentLoop = el; - el.phase = 1; - break; - } - } - - List nextParts = checkPrecoNextParts(part); - if (nextParts == null) { - nextParts = part.nextParts; - } - - if (nextParts.size() == 2) { - GraphPart next = getCommonPart(localData, nextParts, loops);//part.getNextPartPath(new ArrayList()); - List stopParts2 = new ArrayList<>(); //stopPart); - if (next != null) { - stopParts2.add(next); - } else if (!stopPart.isEmpty()) { - stopParts2.add(stopPart.get(stopPart.size() - 1)); - } - if (next != nextParts.get(0)) { - markLevels(path, localData, nextParts.get(0), allParts, loops, next == null ? stopPart : stopParts2, level + 1, visited, recursionLevel + 1); - } - if (next != nextParts.get(1)) { - markLevels(path, localData, nextParts.get(1), allParts, loops, next == null ? stopPart : stopParts2, level + 1, visited, recursionLevel + 1); - } - if (next != null) { - markLevels(path, localData, next, allParts, loops, stopPart, level, visited, recursionLevel + 1); - } - } - - if (nextParts.size() > 2) { - GraphPart next = getMostCommonPart(localData, nextParts, loops); - List vis = new ArrayList<>(); - for (GraphPart p : nextParts) { - if (vis.contains(p)) { - continue; - } - List stopPart2 = new ArrayList<>(); //(stopPart); - if (next != null) { - stopPart2.add(next); - } else if (!stopPart.isEmpty()) { - stopPart2.add(stopPart.get(stopPart.size() - 1)); - } - for (GraphPart p2 : nextParts) { - if (p2 == p) { - continue; - } - if (!stopPart2.contains(p2)) { - stopPart2.add(p2); - } - } - if (next != p) { - markLevels(path, localData, p, allParts, loops, stopPart2, level + 1, visited, recursionLevel + 1); - vis.add(p); - } - } - if (next != null) { - markLevels(path, localData, next, allParts, loops, stopPart, level, visited, recursionLevel + 1); - } - } - - if (nextParts.size() == 1) { - markLevels(path, localData, nextParts.get(0), allParts, loops, stopPart, level, visited, recursionLevel + 1); - } - - for (GraphPart t : part.throwParts) { - if (!visited.contains(t)) { - List stopPart2 = new ArrayList<>(); - List cmn = new ArrayList<>(); - cmn.add(part); - cmn.add(t); - GraphPart next = getCommonPart(localData, cmn, loops); - if (next != null) { - stopPart2.add(next); - } else { - stopPart2 = stopPart; - } - - markLevels(path, localData, t, allParts, loops, stopPart2, level, visited, recursionLevel + 1); - } - } - - if (isLoop) { - if (currentLoop.loopBreak != null) { - currentLoop.phase = 2; - markLevels(path, localData, currentLoop.loopBreak, allParts, loops, stopPart, level, visited, recursionLevel + 1); - } - } - } - - private void clearLoops(List loops) { - for (Loop l : loops) { - l.phase = 0; - } - } - - private void getLoops(BaseLocalData localData, GraphPart part, List loops, List stopPart) throws InterruptedException { - clearLoops(loops); - getLoops(localData, part, loops, stopPart, true, 1, new ArrayList()); - clearLoops(loops); - } - - 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; - } - - part = checkPart(null, localData, part, null); - if (part == null) { - return; - } - if (!visited.contains(part)) { - visited.add(part); - } - - if (debugMode) { - System.err.println("getloops: " + part); - } - List loopContinues = getLoopsContinues(loops); - Loop lastP1 = null; - for (Loop el : loops) { - if ((el.phase == 1) && el.loopBreak == null) { //break not found yet - if (el.loopContinue != part) { - lastP1 = el; - - } else { - lastP1 = null; - } - - } - } - if (lastP1 != null) { - if (lastP1.breakCandidates.contains(part)) { - lastP1.breakCandidates.add(part); - lastP1.breakCandidatesLevels.add(level); - return; - } else { - List loopContinues2 = new ArrayList<>(loopContinues); - loopContinues2.remove(lastP1.loopContinue); - List loops2 = new ArrayList<>(loops); - loops2.remove(lastP1); - if (!part.leadsTo(localData, this, code, lastP1.loopContinue, loops2)) { - if (lastP1.breakCandidatesLocked == 0) { - if (debugMode) { - System.err.println("added breakCandidate " + part + " to " + lastP1); - } - - lastP1.breakCandidates.add(part); - lastP1.breakCandidatesLevels.add(level); - return; - } - } - } - } - - for (Loop el : loops) { - if (el.loopContinue == part) { - return; - } - } - - if (stopPart.contains(part)) { - return; - } - part.level = level; - - boolean isLoop = part.leadsTo(localData, this, code, part, loops); - Loop currentLoop = null; - if (isLoop) { - currentLoop = new Loop(loops.size(), part, null); - currentLoop.phase = 1; - loops.add(currentLoop); - loopContinues.add(part); - } - - if (part.nextParts.size() == 2) { - - List nps = new ArrayList<>(part.nextParts); - /*for(int i=0;i stopPart2 = new ArrayList<>(stopPart); - if (next != null) { - stopPart2.add(next); - } - if (next != nps.get(0)) { - getLoops(localData, nps.get(0), loops, stopPart2, false, level + 1, visited); - } - if (next != nps.get(1)) { - getLoops(localData, nps.get(1), loops, stopPart2, false, level + 1, visited); - } - if (next != null) { - getLoops(localData, next, loops, stopPart, false, level, visited); - } - } - if (part.nextParts.size() > 2) { - GraphPart next = getNextCommonPart(localData, part, loops); - - for (GraphPart p : part.nextParts) { - List stopPart2 = new ArrayList<>(stopPart); - if (next != null) { - stopPart2.add(next); - } - for (GraphPart p2 : part.nextParts) { - if (p2 == p) { - continue; - } - if (!stopPart2.contains(p2)) { - stopPart2.add(p2); - } - } - if (next != p) { - getLoops(localData, p, loops, stopPart2, false, level + 1, visited); - } - } - if (next != null) { - getLoops(localData, next, loops, stopPart, false, level, visited); - } - } - if (part.nextParts.size() == 1) { - getLoops(localData, part.nextParts.get(0), loops, stopPart, false, level, visited); - } - - List loops2 = new ArrayList<>(loops); - for (Loop l : loops2) { - l.breakCandidatesLocked++; - } - for (GraphPart t : part.throwParts) { - if (!visited.contains(t)) { - getLoops(localData, t, loops, stopPart, false, level, visited); - } - } - for (Loop l : loops2) { - l.breakCandidatesLocked--; - } - - if (isLoop) { - GraphPart found; - Map removed = new HashMap<>(); - do { - found = null; - for (int i = 0; i < currentLoop.breakCandidates.size(); i++) { - GraphPart ch = checkPart(null, localData, currentLoop.breakCandidates.get(i), null); - if (ch == null) { - currentLoop.breakCandidates.remove(i); - i--; - } - } - loopcand: - for (GraphPart cand : currentLoop.breakCandidates) { - for (GraphPart cand2 : currentLoop.breakCandidates) { - if (cand == cand2) { - continue; - } - if (cand.leadsTo(localData, this, code, cand2, loops)) { - int lev1 = Integer.MAX_VALUE; - int lev2 = Integer.MAX_VALUE; - for (int i = 0; i < currentLoop.breakCandidates.size(); i++) { - if (currentLoop.breakCandidates.get(i) == cand) { - if (currentLoop.breakCandidatesLevels.get(i) < lev1) { - lev1 = currentLoop.breakCandidatesLevels.get(i); - } - } - if (currentLoop.breakCandidates.get(i) == cand2) { - if (currentLoop.breakCandidatesLevels.get(i) < lev2) { - lev2 = currentLoop.breakCandidatesLevels.get(i); - } - } - } - if (lev1 <= lev2) { - found = cand2; - } else { - found = cand; - } - break loopcand; - } - } - } - if (found != null) { - int maxlevel = 0; - while (currentLoop.breakCandidates.contains(found)) { - int ind = currentLoop.breakCandidates.indexOf(found); - currentLoop.breakCandidates.remove(ind); - int lev = currentLoop.breakCandidatesLevels.remove(ind); - if (lev > maxlevel) { - maxlevel = lev; - } - } - if (removed.containsKey(found)) { - if (removed.get(found) > maxlevel) { - maxlevel = removed.get(found); - } - } - removed.put(found, maxlevel); - } - } while ((found != null) && (currentLoop.breakCandidates.size() > 1)); - - Map count = new HashMap<>(); - GraphPart winner = null; - int winnerCount = 0; - for (GraphPart cand : currentLoop.breakCandidates) { - - if (!count.containsKey(cand)) { - count.put(cand, 0); - } - count.put(cand, count.get(cand) + 1); - boolean otherBreakCandidate = false; - for (Loop el : loops) { - if (el == currentLoop) { - continue; - } - if (el.breakCandidates.contains(cand)) { - otherBreakCandidate = true; - break; - } - } - if (otherBreakCandidate) { - } else if (count.get(cand) > winnerCount) { - winnerCount = count.get(cand); - winner = cand; - } else if (count.get(cand) == winnerCount) { - if (cand.path.length() < winner.path.length()) { - winner = cand; - } - } - } - for (int i = 0; i < currentLoop.breakCandidates.size(); i++) { - GraphPart cand = currentLoop.breakCandidates.get(i); - if (cand != winner) { - int lev = currentLoop.breakCandidatesLevels.get(i); - if (removed.containsKey(cand)) { - if (removed.get(cand) > lev) { - lev = removed.get(cand); - } - } - removed.put(cand, lev); - } - } - currentLoop.loopBreak = winner; - currentLoop.phase = 2; - boolean start = false; - for (int l = 0; l < loops.size(); l++) { - Loop el = loops.get(l); - if (start) { - el.phase = 1; - } - if (el == currentLoop) { - start = true; - } - } - List removedVisited = new ArrayList<>(); - for (GraphPart r : removed.keySet()) { - if (removedVisited.contains(r)) { - continue; - } - getLoops(localData, r, loops, stopPart, false, removed.get(r), visited); - removedVisited.add(r); - } - start = false; - for (int l = 0; l < loops.size(); l++) { - Loop el = loops.get(l); - if (el == currentLoop) { - start = true; - } - if (start) { - el.phase = 2; - } - } - getLoops(localData, currentLoop.loopBreak, loops, stopPart, false, level, visited); - } - } - - protected List printGraph(List visited, BaseLocalData localData, Stack stack, List allParts, GraphPart parent, GraphPart part, List stopPart, List loops, List ret, int staticOperation, String path, int recursionLevel) throws InterruptedException { - if (Thread.currentThread().isInterrupted()) { - throw new InterruptedException(); - } - if (stopPart == null) { - stopPart = new ArrayList<>(); - } - if (recursionLevel > allParts.size() + 1) { - throw new TranslateException("printGraph max recursion level reached."); - } - if (visited.contains(part)) { - //return new ArrayList(); - } else { - visited.add(part); - } - if (ret == null) { - ret = new ArrayList<>(); - } - //try { - boolean debugMode = false; - - if (debugMode) { - System.err.println("PART " + part + " nextsize:" + part.nextParts.size()); - } - - /*while (((part != null) && (part.getHeight() == 1)) && (code.size() > part.start) && (code.get(part.start).isJump())) { //Parts with only jump in it gets ignored - - if (part == stopPart) { - return ret; - } - GraphTargetItem lop = checkLoop(part.nextParts.get(0), stopPart, loops); - if (lop == null) { - part = part.nextParts.get(0); - } else { - break; - } - }*/ - if (part == null) { - return ret; - } - part = checkPart(stack, localData, part, allParts); - if (part == null) { - return ret; - } - - if (part.ignored) { - return ret; - } - - List loopContinues = getLoopsContinues(loops); - boolean isLoop = false; - Loop currentLoop = null; - for (Loop el : loops) { - if ((el.loopContinue == part) && (el.phase == 0)) { - currentLoop = el; - currentLoop.phase = 1; - isLoop = true; - break; - } - } - - if (debugMode) { - System.err.println("loopsize:" + loops.size()); - } - for (int l = loops.size() - 1; l >= 0; l--) { - Loop el = loops.get(l); - if (el == currentLoop) { - if (debugMode) { - System.err.println("ignoring current loop " + el); - } - continue; - } - if (el.phase != 1) { - if (debugMode) { - //System.err.println("ignoring loop "+el); - } - continue; - } - if (el.loopBreak == part) { - if (currentLoop != null) { - currentLoop.phase = 0; - } - if (debugMode) { - System.err.println("Adding break"); - } - ret.add(new BreakItem(null, el.id)); - return ret; - } - if (el.loopPreContinue == part) { - if (currentLoop != null) { - currentLoop.phase = 0; - } - if (debugMode) { - System.err.println("Adding precontinue"); - } - ret.add(new ContinueItem(null, el.id)); - return ret; - } - if (el.loopContinue == part) { - if (currentLoop != null) { - currentLoop.phase = 0; - } - if (debugMode) { - System.err.println("Adding continue"); - } - ret.add(new ContinueItem(null, el.id)); - return ret; - } - } - - if (stopPart.contains(part)) { - if (currentLoop != null) { - currentLoop.phase = 0; - } - return ret; - } - - if ((part != null) && (code.size() <= part.start)) { - ret.add(new ScriptEndItem()); - return ret; - } - List currentRet = ret; - UniversalLoopItem loopItem = null; - if (isLoop) { - loopItem = new UniversalLoopItem(null, currentLoop); - //loopItem.commands=printGraph(visited, localData, stack, allParts, parent, part, stopPart, loops); - currentRet.add(loopItem); - loopItem.commands = new ArrayList<>(); - currentRet = loopItem.commands; - //return ret; - } - - boolean parseNext = true; - - //****************************DECOMPILING PART************* - List output = new ArrayList<>(); - - List parts = new ArrayList<>(); - if (part instanceof GraphPartMulti) { - parts = ((GraphPartMulti) part).parts; - } else { - parts.add(part); - } - for (GraphPart p : parts) { - int end = p.end; - int start = p.start; - - output.addAll(code.translatePart(p, localData, stack, start, end, staticOperation, path)); - if ((end >= code.size() - 1) && p.nextParts.isEmpty()) { - output.add(new ScriptEndItem()); - } - } - - //Assuming part with two nextparts is an IF - - /* //If with both branches empty - if (part.nextParts.size() == 2) { - if (part.nextParts.get(0) == part.nextParts.get(1)) { - if (!stack.isEmpty()) { - GraphTargetItem expr = stack.pop(); - if (expr instanceof LogicalOpItem) { - expr = ((LogicalOpItem) expr).invert(); - } else { - expr = new NotItem(null, expr); - } - output.add(new IfItem(null, expr, new ArrayList(), new ArrayList())); - } - part.nextParts.remove(0); - } - }*/ - if (parseNext) { - List retCheck = check(code, localData, allParts, stack, parent, part, stopPart, loops, output, currentLoop, staticOperation, path); - if (retCheck != null) { - if (!retCheck.isEmpty()) { - currentRet.addAll(retCheck); - } - parseNext = false; - //return ret; - } else { - currentRet.addAll(output); - } - } - - /** - * AND / OR detection - */ - if (parseNext && part.nextParts.size() == 2) { - if ((stack.size() >= 2) && (stack.get(stack.size() - 1) instanceof NotItem) && (((NotItem) (stack.get(stack.size() - 1))).getOriginal().getNotCoerced() == stack.get(stack.size() - 2).getNotCoerced())) { - GraphPart sp0 = getNextNoJump(part.nextParts.get(0), localData); - GraphPart sp1 = getNextNoJump(part.nextParts.get(1), localData); - boolean reversed = false; - loopContinues = getLoopsContinues(loops); - loopContinues.add(part);//??? - if (sp1.leadsTo(localData, this, code, sp0, loops)) { - } else if (sp0.leadsTo(localData, this, code, sp1, loops)) { - reversed = true; - } - GraphPart next = reversed ? sp0 : sp1; - GraphTargetItem ti; - if ((ti = checkLoop(next, stopPart, loops)) != null) { - currentRet.add(ti); - } else { - List stopPart2 = new ArrayList<>(stopPart); - stopPart2.add(reversed ? sp1 : sp0); - printGraph(visited, localData, stack, allParts, parent, next, stopPart2, loops, null, staticOperation, path, recursionLevel + 1); - GraphTargetItem second = stack.pop(); - GraphTargetItem first = stack.pop(); - - if (!reversed) { - AndItem a = new AndItem(null, first, second); - stack.push(a); - a.firstPart = part; - if (second instanceof AndItem) { - a.firstPart = ((AndItem) second).firstPart; - } - if (second instanceof OrItem) { - a.firstPart = ((OrItem) second).firstPart; - } - } else { - OrItem o = new OrItem(null, first, second); - stack.push(o); - o.firstPart = part; - if (second instanceof AndItem) { - o.firstPart = ((AndItem) second).firstPart; - } - if (second instanceof OrItem) { - o.firstPart = ((OrItem) second).firstPart; - } - } - next = reversed ? sp1 : sp0; - if ((ti = checkLoop(next, stopPart, loops)) != null) { - currentRet.add(ti); - } else { - currentRet.addAll(printGraph(visited, localData, stack, allParts, parent, next, stopPart, loops, null, staticOperation, path, recursionLevel + 1)); - } - } - parseNext = false; - //return ret; - } else if ((stack.size() >= 2) && (stack.get(stack.size() - 1).getNotCoerced() == stack.get(stack.size() - 2).getNotCoerced())) { - GraphPart sp0 = getNextNoJump(part.nextParts.get(0), localData); - GraphPart sp1 = getNextNoJump(part.nextParts.get(1), localData); - boolean reversed = false; - loopContinues = getLoopsContinues(loops); - loopContinues.add(part);//??? - if (sp1.leadsTo(localData, this, code, sp0, loops)) { - } else if (sp0.leadsTo(localData, this, code, sp1, loops)) { - reversed = true; - } - GraphPart next = reversed ? sp0 : sp1; - GraphTargetItem ti; - if ((ti = checkLoop(next, stopPart, loops)) != null) { - currentRet.add(ti); - } else { - List stopPart2 = new ArrayList<>(stopPart); - stopPart2.add(reversed ? sp1 : sp0); - printGraph(visited, localData, stack, allParts, parent, next, stopPart2, loops, null, staticOperation, path, recursionLevel + 1); - GraphTargetItem second = stack.pop(); - GraphTargetItem first = stack.pop(); - - if (reversed) { - AndItem a = new AndItem(null, first, second); - stack.push(a); - a.firstPart = part; - if (second instanceof AndItem) { - a.firstPart = ((AndItem) second).firstPart; - } - if (second instanceof OrItem) { - a.firstPart = ((AndItem) second).firstPart; - } - } else { - OrItem o = new OrItem(null, first, second); - stack.push(o); - o.firstPart = part; - if (second instanceof OrItem) { - o.firstPart = ((OrItem) second).firstPart; - } - if (second instanceof OrItem) { - o.firstPart = ((OrItem) second).firstPart; - } - } - - next = reversed ? sp1 : sp0; - if ((ti = checkLoop(next, stopPart, loops)) != null) { - currentRet.add(ti); - } else { - currentRet.addAll(printGraph(visited, localData, stack, allParts, parent, next, stopPart, loops, null, staticOperation, path, recursionLevel + 1)); - } - } - parseNext = false; - //return ret; - } - } -//********************************END PART DECOMPILING - - if (parseNext) { - - if (false && part.nextParts.size() > 2) {//alchemy direct switch - GraphPart next = getMostCommonPart(localData, part.nextParts, loops); - List vis = new ArrayList<>(); - GraphTargetItem switchedItem = stack.pop(); - List caseValues = new ArrayList<>(); - List> caseCommands = new ArrayList<>(); - List defaultCommands = new ArrayList<>(); - List valueMappings = new ArrayList<>(); - Loop swLoop = new Loop(loops.size(), null, next); - swLoop.phase = 1; - loops.add(swLoop); - boolean first = false; - int pos = 0; - for (GraphPart p : part.nextParts) { - - if (!first) { - caseValues.add(new IntegerValueItem(null, pos++)); - if (vis.contains(p)) { - valueMappings.add(caseCommands.size() - 1); - continue; - } - - valueMappings.add(caseCommands.size()); - } - List stopPart2 = new ArrayList<>(); - if (next != null) { - stopPart2.add(next); - } else if (!stopPart.isEmpty()) { - stopPart2.add(stopPart.get(stopPart.size() - 1)); - } - for (GraphPart p2 : part.nextParts) { - if (p2 == p) { - continue; - } - if (!stopPart2.contains(p2)) { - stopPart2.add(p2); - } - } - if (next != p) { - if (first) { - defaultCommands = printGraph(visited, prepareBranchLocalData(localData), stack, allParts, part, p, stopPart2, loops, null, staticOperation, path, recursionLevel + 1); - } else { - caseCommands.add(printGraph(visited, prepareBranchLocalData(localData), stack, allParts, part, p, stopPart2, loops, null, staticOperation, path, recursionLevel + 1)); - } - vis.add(p); - } - first = false; - } - SwitchItem sw = new SwitchItem(null, swLoop, switchedItem, caseValues, caseCommands, defaultCommands, valueMappings); - currentRet.add(sw); - swLoop.phase = 2; - if (next != null) { - currentRet.addAll(printGraph(visited, localData, stack, allParts, part, next, stopPart, loops, null, staticOperation, path, recursionLevel + 1)); - } - } //else - GraphPart nextOnePart = null; - if (part.nextParts.size() == 2) { - GraphTargetItem expr = stack.pop(); - if (expr instanceof LogicalOpItem) { - expr = ((LogicalOpItem) expr).invert(); - } else { - expr = new NotItem(null, expr); - } - if (staticOperation != SOP_USE_STATIC) { - if (expr.isCompileTime()) { - boolean doJump = EcmaScript.toBoolean(expr.getResult()); - if (doJump) { - nextOnePart = part.nextParts.get(0); - } else { - nextOnePart = part.nextParts.get(1); - } - if (staticOperation == SOP_REMOVE_STATIC) { - //TODO - } - } - } - if (nextOnePart == null) { - - List nps = new ArrayList<>(part.nextParts); - /*for(int i=0;i trueStack = (Stack) stack.clone(); - @SuppressWarnings("unchecked") - Stack falseStack = (Stack) stack.clone(); - int trueStackSizeBefore = trueStack.size(); - int falseStackSizeBefore = falseStack.size(); - List onTrue = new ArrayList<>(); - boolean isEmpty = nps.get(0) == nps.get(1); - - if (isEmpty) { - next = nps.get(0); - } - - List stopPart2 = new ArrayList<>(stopPart); - if (next != null) { - stopPart2.add(next); - } - if (!isEmpty) { - onTrue = printGraph(visited, prepareBranchLocalData(localData), trueStack, allParts, part, nps.get(1), stopPart2, loops, null, staticOperation, path, recursionLevel + 1); - } - List onFalse = new ArrayList<>(); - - if (!isEmpty) { - onFalse = printGraph(visited, prepareBranchLocalData(localData), falseStack, allParts, part, nps.get(0), stopPart2, loops, null, staticOperation, path, recursionLevel + 1); - } - if (isEmpty(onTrue) && isEmpty(onFalse) && (trueStack.size() == trueStackSizeBefore + 1) && (falseStack.size() == falseStackSizeBefore + 1)) { - stack.push(new TernarOpItem(null, expr, trueStack.pop(), falseStack.pop())); - } else { - currentRet.add(new IfItem(null, expr, onTrue, onFalse)); - } - if (next != null) { - if (trueStack.size() != trueStackSizeBefore || falseStack.size() != falseStackSizeBefore) { - // it's a hack, because duplicates all instructions in the next part, but better than EmptyStackException - onTrue = printGraph(visited, localData, trueStack, allParts, part, next, stopPart, loops, null, staticOperation, path, recursionLevel + 1); - onFalse = printGraph(visited, localData, falseStack, allParts, part, next, stopPart, loops, null, staticOperation, path, recursionLevel + 1); - if (isEmpty(onTrue) && isEmpty(onFalse) && (trueStack.size() == trueStackSizeBefore + 1) && (falseStack.size() == falseStackSizeBefore + 1)) { - stack.push(new TernarOpItem(null, expr, trueStack.pop(), falseStack.pop())); - } else { - currentRet.add(new IfItem(null, expr, onTrue, onFalse)); - } - } else { - printGraph(visited, localData, stack, allParts, part, next, stopPart, loops, currentRet, staticOperation, path, recursionLevel + 1); - } - //currentRet.addAll(); - } - } - } //else - if (part.nextParts.size() == 1) { - nextOnePart = part.nextParts.get(0); - } - if (nextOnePart != null) { - printGraph(visited, localData, stack, allParts, part, part.nextParts.get(0), stopPart, loops, currentRet, staticOperation, path, recursionLevel + 1); - } - - } - if (isLoop) { - - LoopItem li = loopItem; - boolean loopTypeFound = false; - - boolean hasContinue = false; - processIfs(loopItem.commands); - checkContinueAtTheEnd(loopItem.commands, currentLoop); - List continues = loopItem.getContinues(); - for (ContinueItem c : continues) { - if (c.loopId == currentLoop.id) { - hasContinue = true; - break; - } - } - if (!hasContinue) { - if (currentLoop.loopPreContinue != null) { - List stopContPart = new ArrayList<>(); - stopContPart.add(currentLoop.loopContinue); - GraphPart precoBackup = currentLoop.loopPreContinue; - currentLoop.loopPreContinue = null; - loopItem.commands.addAll(printGraph(visited, localData, new Stack(), allParts, null, precoBackup, stopContPart, loops, null, staticOperation, path, recursionLevel + 1)); - } - } - - //Loop with condition at the beginning (While) - if (!loopTypeFound && (!loopItem.commands.isEmpty())) { - if (loopItem.commands.get(0) instanceof IfItem) { - IfItem ifi = (IfItem) loopItem.commands.get(0); - - List bodyBranch = null; - boolean inverted = false; - boolean breakpos2 = false; - if ((ifi.onTrue.size() == 1) && (ifi.onTrue.get(0) instanceof BreakItem)) { - BreakItem bi = (BreakItem) ifi.onTrue.get(0); - if (bi.loopId == currentLoop.id) { - bodyBranch = ifi.onFalse; - inverted = true; - } - } else if ((ifi.onFalse.size() == 1) && (ifi.onFalse.get(0) instanceof BreakItem)) { - BreakItem bi = (BreakItem) ifi.onFalse.get(0); - if (bi.loopId == currentLoop.id) { - bodyBranch = ifi.onTrue; - } - } else if (loopItem.commands.size() == 2 && (loopItem.commands.get(1) instanceof BreakItem)) { - BreakItem bi = (BreakItem) loopItem.commands.get(1); - if (bi.loopId == currentLoop.id) { - bodyBranch = ifi.onTrue; - breakpos2 = true; - } - } - if (bodyBranch != null) { - int index = ret.indexOf(loopItem); - ret.remove(index); - List exprList = new ArrayList<>(); - GraphTargetItem expr = ifi.expression; - if (inverted) { - if (expr instanceof LogicalOpItem) { - expr = ((LogicalOpItem) expr).invert(); - } else { - expr = new NotItem(null, expr); - } - } - exprList.add(expr); - List commands = new ArrayList<>(); - commands.addAll(bodyBranch); - loopItem.commands.remove(0); - if (breakpos2) { - loopItem.commands.remove(0); //remove that break too - } - commands.addAll(loopItem.commands); - checkContinueAtTheEnd(commands, currentLoop); - List finalComm = new ArrayList<>(); - if (currentLoop.loopPreContinue != null) { - GraphPart backup = currentLoop.loopPreContinue; - currentLoop.loopPreContinue = null; - List stopPart2 = new ArrayList<>(stopPart); - stopPart2.add(currentLoop.loopContinue); - finalComm = printGraph(visited, localData, new Stack(), allParts, null, backup, stopPart2, loops, null, staticOperation, path, recursionLevel + 1); - currentLoop.loopPreContinue = backup; - checkContinueAtTheEnd(finalComm, currentLoop); - } - if (!finalComm.isEmpty()) { - ret.add(index, li = new ForItem(null, currentLoop, new ArrayList(), exprList.get(exprList.size() - 1), finalComm, commands)); - } else { - ret.add(index, li = new WhileItem(null, currentLoop, exprList, commands)); - } - - loopTypeFound = true; - } - } - } - - //Loop with condition at the end (Do..While) - if (!loopTypeFound && (!loopItem.commands.isEmpty())) { - if (loopItem.commands.get(loopItem.commands.size() - 1) instanceof IfItem) { - IfItem ifi = (IfItem) loopItem.commands.get(loopItem.commands.size() - 1); - List bodyBranch = null; - boolean inverted = false; - if ((ifi.onTrue.size() == 1) && (ifi.onTrue.get(0) instanceof BreakItem)) { - BreakItem bi = (BreakItem) ifi.onTrue.get(0); - if (bi.loopId == currentLoop.id) { - bodyBranch = ifi.onFalse; - inverted = true; - } - } else if ((ifi.onFalse.size() == 1) && (ifi.onFalse.get(0) instanceof BreakItem)) { - BreakItem bi = (BreakItem) ifi.onFalse.get(0); - if (bi.loopId == currentLoop.id) { - bodyBranch = ifi.onTrue; - } - } - if (bodyBranch != null) { - //Condition at the beginning - int index = ret.indexOf(loopItem); - ret.remove(index); - List exprList = new ArrayList<>(); - GraphTargetItem expr = ifi.expression; - if (inverted) { - if (expr instanceof LogicalOpItem) { - expr = ((LogicalOpItem) expr).invert(); - } else { - expr = new NotItem(null, expr); - } - } - - checkContinueAtTheEnd(bodyBranch, currentLoop); - - List commands = new ArrayList<>(); - - if (!bodyBranch.isEmpty()) { - ret.add(index, loopItem); - /* - loopItem.commands.remove(loopItem.commands.size() - 1); - exprList.addAll(loopItem.commands); - commands.addAll(bodyBranch); - exprList.add(expr); - checkContinueAtTheEnd(commands, currentLoop); - ret.add(index, li = new WhileItem(null, currentLoop, exprList, commands));*/ - } else { - loopItem.commands.remove(loopItem.commands.size() - 1); - commands.addAll(loopItem.commands); - commands.addAll(bodyBranch); - exprList.add(expr); - checkContinueAtTheEnd(commands, currentLoop); - ret.add(index, li = new DoWhileItem(null, currentLoop, commands, exprList)); - - } - loopTypeFound = true; - } - } - } - - if (!loopTypeFound) { - if (currentLoop.loopPreContinue != null) { - loopTypeFound = true; - GraphPart backup = currentLoop.loopPreContinue; - currentLoop.loopPreContinue = null; - List stopPart2 = new ArrayList<>(stopPart); - stopPart2.add(currentLoop.loopContinue); - List finalComm = printGraph(visited, localData, new Stack(), allParts, null, backup, stopPart2, loops, null, staticOperation, path, recursionLevel + 1); - currentLoop.loopPreContinue = backup; - checkContinueAtTheEnd(finalComm, currentLoop); - - if (!finalComm.isEmpty()) { - if (finalComm.get(finalComm.size() - 1) instanceof IfItem) { - IfItem ifi = (IfItem) finalComm.get(finalComm.size() - 1); - boolean ok = false; - boolean invert = false; - if (((ifi.onTrue.size() == 1) && (ifi.onTrue.get(0) instanceof BreakItem) && (((BreakItem) ifi.onTrue.get(0)).loopId == currentLoop.id)) - && ((ifi.onTrue.size() == 1) && (ifi.onFalse.get(0) instanceof ContinueItem) && (((ContinueItem) ifi.onFalse.get(0)).loopId == currentLoop.id))) { - ok = true; - invert = true; - } - if (((ifi.onTrue.size() == 1) && (ifi.onTrue.get(0) instanceof ContinueItem) && (((ContinueItem) ifi.onTrue.get(0)).loopId == currentLoop.id)) - && ((ifi.onTrue.size() == 1) && (ifi.onFalse.get(0) instanceof BreakItem) && (((BreakItem) ifi.onFalse.get(0)).loopId == currentLoop.id))) { - ok = true; - } - if (ok) { - finalComm.remove(finalComm.size() - 1); - int index = ret.indexOf(loopItem); - ret.remove(index); - List exprList = new ArrayList<>(finalComm); - GraphTargetItem expr = ifi.expression; - if (invert) { - if (expr instanceof LogicalOpItem) { - expr = ((LogicalOpItem) expr).invert(); - } else { - expr = new NotItem(null, expr); - } - } - exprList.add(expr); - ret.add(index, li = new DoWhileItem(null, currentLoop, loopItem.commands, exprList)); - } - } - } - } - } - - if (!loopTypeFound) { - checkContinueAtTheEnd(loopItem.commands, currentLoop); - } - currentLoop.phase = 2; - - GraphTargetItem replaced = checkLoop(li, localData, loops); - if (replaced != li) { - int index = ret.indexOf(li); - ret.remove(index); - if (replaced != null) { - ret.add(index, replaced); - } - } - - if (currentLoop.loopBreak != null) { - ret.addAll(printGraph(visited, localData, stack, allParts, part, currentLoop.loopBreak, stopPart, loops, null, staticOperation, path, recursionLevel + 1)); - } - } - - return ret; - - } - - protected void checkGraph(List allBlocks) { - } - - private List makeGraph(GraphSource code, List allBlocks, List alternateEntries) throws InterruptedException { - HashMap> refs = code.visitCode(alternateEntries); - List ret = new ArrayList<>(); - boolean[] visited = new boolean[code.size()]; - ret.add(makeGraph(null, new GraphPath(), code, 0, 0, allBlocks, refs, visited)); - for (int pos : alternateEntries) { - GraphPart e1 = new GraphPart(-1, -1); - e1.path = new GraphPath("e"); - ret.add(makeGraph(e1, new GraphPath("e"), code, pos, pos, allBlocks, refs, visited)); - } - checkGraph(allBlocks); - return ret; - } - - protected int checkIp(int ip) { - return ip; - } - - private GraphPart makeGraph(GraphPart parent, GraphPath path, GraphSource code, int startip, int lastIp, List allBlocks, HashMap> refs, boolean[] visited2) throws InterruptedException { - if (Thread.currentThread().isInterrupted()) { - throw new InterruptedException(); - } - - int ip = startip; - for (GraphPart p : allBlocks) { - if (p.start == ip) { - p.refs.add(parent); - return p; - } - } - GraphPart g; - GraphPart ret = new GraphPart(ip, -1); - ret.path = path; - GraphPart part = ret; - while (ip < code.size()) { - if (visited2[ip] || ((ip != startip) && (refs.get(ip).size() > 1))) { - part.end = lastIp; - GraphPart found = null; - for (GraphPart p : allBlocks) { - if (p.start == ip) { - found = p; - break; - } - } - - allBlocks.add(part); - - if (found != null) { - part.nextParts.add(found); - found.refs.add(part); - break; - } else { - GraphPart gp = new GraphPart(ip, -1); - gp.path = path; - part.nextParts.add(gp); - gp.refs.add(part); - part = gp; - } - } - - ip = checkIp(ip); - lastIp = ip; - GraphSourceItem ins = code.get(ip); - if (ins.isIgnored()) { - ip++; - continue; - } - if (ins instanceof GraphSourceItemContainer) { - GraphSourceItemContainer cnt = (GraphSourceItemContainer) ins; - if (ins instanceof Action) { //TODO: Remove dependency of AVM1 - long endAddr = ((Action) ins).getAddress() + cnt.getHeaderSize(); - for (long size : cnt.getContainerSizes()) { - endAddr += size; - } - ip = code.adr2pos(endAddr); - } - continue; - } else if (ins.isExit()) { - part.end = ip; - allBlocks.add(part); - break; - } else if (ins.isJump()) { - part.end = ip; - allBlocks.add(part); - ip = ins.getBranches(code).get(0); - part.nextParts.add(g = makeGraph(part, path, code, ip, lastIp, allBlocks, refs, visited2)); - g.refs.add(part); - break; - } else if (ins.isBranch()) { - part.end = ip; - - allBlocks.add(part); - List branches = ins.getBranches(code); - for (int i = 0; i < branches.size(); i++) { - part.nextParts.add(g = makeGraph(part, path.sub(i, ip), code, branches.get(i), ip, allBlocks, refs, visited2)); - g.refs.add(part); - } - break; - } - ip++; - } - if ((part.end == -1) && (ip >= code.size())) { - if (part.start == code.size()) { - part.end = code.size(); - allBlocks.add(part); - } else { - part.end = ip - 1; - for (GraphPart p : allBlocks) { - if (p.start == ip) { - p.refs.add(part); - part.nextParts.add(p); - allBlocks.add(part); - return ret; - } - } - GraphPart gp = new GraphPart(ip, ip); - allBlocks.add(gp); - gp.refs.add(part); - part.nextParts.add(gp); - allBlocks.add(part); - } - } - return ret; - } - /** - * String used to indent line when converting to string - */ - public static final String INDENTOPEN = "INDENTOPEN"; - /** - * String used to unindent line when converting to string - */ - public static final String INDENTCLOSE = "INDENTCLOSE"; - - /** - * Converts list of TreeItems to string - * - * @param tree List of TreeItem - * @param writer - * @param localData - * @return String - * @throws java.lang.InterruptedException - */ - public static GraphTextWriter graphToString(List tree, GraphTextWriter writer, LocalData localData) throws InterruptedException { - for (GraphTargetItem ti : tree) { - if (!ti.isEmpty()) { - ti.toStringSemicoloned(writer, localData).newLine(); - } - } - return writer; - } - - public BaseLocalData prepareBranchLocalData(BaseLocalData localData) { - return localData; - } - - protected List checkPrecoNextParts(GraphPart part) { - return null; - } - - protected GraphPart makeMultiPart(GraphPart part) { - List parts = new ArrayList<>(); - do { - parts.add(part); - if (part.nextParts.size() == 1 && part.nextParts.get(0).refs.size() == 1) { - part = part.nextParts.get(0); - } else { - part = null; - } - } while (part != null); - if (parts.size() > 1) { - GraphPartMulti ret = new GraphPartMulti(parts); - ret.refs.addAll(parts.get(0).refs); - ret.nextParts.addAll(parts.get(parts.size() - 1).nextParts); - return ret; - } else { - return parts.get(0); - } - } - - protected List getPartItems(GraphPart part) { - List ret = new ArrayList<>(); - do { - for (int i = 0; i < part.getHeight(); i++) { - if (part.getPosAt(i) < code.size()) { - if (part.getPosAt(i) < 0) { - continue; - } - GraphSourceItem s = code.get(part.getPosAt(i)); - if (!s.isJump()) { - ret.add(s); - } - } - } - if (part.nextParts.size() == 1 && part.nextParts.get(0).refs.size() == 1) { - part = part.nextParts.get(0); - } else { - part = null; - } - } while (part != null); - return ret; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.graph; + +import com.jpexs.decompiler.flash.BaseLocalData; +import com.jpexs.decompiler.flash.FinalProcessLocalData; +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.ecma.EcmaScript; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.graph.model.AndItem; +import com.jpexs.decompiler.graph.model.BreakItem; +import com.jpexs.decompiler.graph.model.ContinueItem; +import com.jpexs.decompiler.graph.model.DoWhileItem; +import com.jpexs.decompiler.graph.model.ExitItem; +import com.jpexs.decompiler.graph.model.ForItem; +import com.jpexs.decompiler.graph.model.IfItem; +import com.jpexs.decompiler.graph.model.IntegerValueItem; +import com.jpexs.decompiler.graph.model.LocalData; +import com.jpexs.decompiler.graph.model.LogicalOpItem; +import com.jpexs.decompiler.graph.model.LoopItem; +import com.jpexs.decompiler.graph.model.NotItem; +import com.jpexs.decompiler.graph.model.OrItem; +import com.jpexs.decompiler.graph.model.ScriptEndItem; +import com.jpexs.decompiler.graph.model.SwitchItem; +import com.jpexs.decompiler.graph.model.TernarOpItem; +import com.jpexs.decompiler.graph.model.UniversalLoopItem; +import com.jpexs.decompiler.graph.model.WhileItem; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author JPEXS + */ +public class Graph { + + public List heads; + protected GraphSource code; + private final List alternateEntries; + public static final int SOP_USE_STATIC = 0; + public static final int SOP_SKIP_STATIC = 1; + public static final int SOP_REMOVE_STATIC = 2; + + public Graph(GraphSource code, List alternateEntries) { + this.code = code; + this.alternateEntries = alternateEntries; + + } + + public void init(BaseLocalData localData) throws InterruptedException { + if (heads != null) { + return; + } + heads = makeGraph(code, new ArrayList(), alternateEntries); + int time = 1; + List ordered = new ArrayList<>(); + List visited = new ArrayList<>(); + for (GraphPart head : heads) { + time = head.setTime(time, ordered, visited); + } + } + + protected static void populateParts(GraphPart part, List allParts) { + if (allParts.contains(part)) { + return; + } + allParts.add(part); + for (GraphPart p : part.nextParts) { + populateParts(p, allParts); + } + } + + public GraphPart deepCopy(GraphPart part, List visited, List copies) { + if (visited == null) { + visited = new ArrayList<>(); + } + if (copies == null) { + copies = new ArrayList<>(); + } + if (visited.contains(part)) { + return copies.get(visited.indexOf(part)); + } + visited.add(part); + GraphPart copy = new GraphPart(part.start, part.end); + copy.path = part.path; + copies.add(copy); + copy.nextParts = new ArrayList<>(); + for (int i = 0; i < part.nextParts.size(); i++) { + copy.nextParts.add(deepCopy(part.nextParts.get(i), visited, copies)); + } + for (int i = 0; i < part.refs.size(); i++) { + copy.refs.add(deepCopy(part.refs.get(i), visited, copies)); + } + return copy; + } + + public void resetGraph(GraphPart part, List visited) { + if (visited.contains(part)) { + return; + } + visited.add(part); + int pos = 0; + for (GraphPart p : part.nextParts) { + if (!visited.contains(p)) { + p.path = part.path.sub(pos, p.end); + } + resetGraph(p, visited); + pos++; + } + } + + private void getReachableParts(GraphPart part, List ret, List loops) { + getReachableParts(part, ret, loops, true); + } + + private void getReachableParts(GraphPart part, List ret, List loops, boolean first) { + + if (first) { + for (Loop l : loops) { + l.reachableMark = 0; + } + } + Loop currentLoop = null; + + for (Loop l : loops) { + if ((l.phase == 1) || (l.reachableMark == 1)) { + if (l.loopContinue == part) { + return; + } + if (l.loopBreak == part) { + return; + } + if (l.loopPreContinue == part) { + return; + } + } + if (l.reachableMark == 0) { + if (l.loopContinue == part) { + l.reachableMark = 1; + currentLoop = l; + } + } + } + + List newparts = new ArrayList<>(); + loopnext: + for (GraphPart next : part.nextParts) { + for (Loop l : loops) { + if ((l.phase == 1) || (l.reachableMark == 1)) { + if (l.loopContinue == next) { + continue loopnext; + } + if (l.loopBreak == next) { + continue loopnext; + } + if (l.loopPreContinue == next) { + continue loopnext; + } + } + + } + if (!ret.contains(next)) { + newparts.add(next); + } + } + + ret.addAll(newparts); + for (GraphPart next : newparts) { + getReachableParts(next, ret, loops); + } + + if (currentLoop != null) { + if (currentLoop.loopBreak != null) { + if (!ret.contains(currentLoop.loopBreak)) { + ret.add(currentLoop.loopBreak); + currentLoop.reachableMark = 2; + getReachableParts(currentLoop.loopBreak, ret, loops); + } + } + } + } + + /* public GraphPart getNextCommonPart(GraphPart part, List loops) { + return getNextCommonPart(part, new ArrayList(),loops); + }*/ + public GraphPart getNextCommonPart(BaseLocalData localData, GraphPart part, List loops) throws InterruptedException { + return getCommonPart(localData, part.nextParts, loops); + } + + public GraphPart getCommonPart(BaseLocalData localData, List parts, List loops) throws InterruptedException { + if (parts.isEmpty()) { + return null; + } + + List loopContinues = new ArrayList<>();//getLoopsContinues(loops); + for (Loop l : loops) { + if (l.phase == 1) { + loopContinues.add(l.loopContinue); + } + } + + for (GraphPart p : parts) { + if (loopContinues.contains(p)) { + break; + } + boolean common = true; + for (GraphPart q : parts) { + if (q == p) { + continue; + } + if (!q.leadsTo(localData, this, code, p, loops)) { + common = false; + break; + } + } + if (common) { + return p; + } + } + List> reachable = new ArrayList<>(); + for (GraphPart p : parts) { + List r1 = new ArrayList<>(); + getReachableParts(p, r1, loops); + r1.add(p); + reachable.add(r1); + } + List first = reachable.get(0); + for (GraphPart p : first) { + /*if (ignored.contains(p)) { + continue; + }*/ + p = checkPart(null, localData, p, null); + if (p == null) { + continue; + } + boolean common = true; + for (List r : reachable) { + if (!r.contains(p)) { + common = false; + break; + } + } + if (common) { + return p; + } + } + return null; + } + + public GraphPart getMostCommonPart(BaseLocalData localData, List parts, List loops) throws InterruptedException { + if (parts.isEmpty()) { + return null; + } + + Set s = new HashSet<>(parts); //unique + parts = new ArrayList<>(s); //make local copy + + List loopContinues = new ArrayList<>();//getLoopsContinues(loops); + for (Loop l : loops) { + if (l.phase == 1) { + loopContinues.add(l.loopContinue); + loopContinues.add(l.loopPreContinue); + } + } + + for (GraphPart p : parts) { + if (loopContinues.contains(p)) { + break; + } + boolean common = true; + for (GraphPart q : parts) { + if (q == p) { + continue; + } + if (!q.leadsTo(localData, this, code, p, loops)) { + common = false; + break; + } + } + if (common) { + return p; + } + } + + loopi: + for (int i = 0; i < parts.size(); i++) { + for (int j = 0; j < parts.size(); j++) { + if (j == i) { + continue; + } + if (parts.get(i).leadsTo(localData, this, code, parts.get(j), loops)) { + parts.remove(i); + i--; + continue loopi; + } + } + } + List> reachable = new ArrayList<>(); + for (GraphPart p : parts) { + List r1 = new ArrayList<>(); + getReachableParts(p, r1, loops); + r1.add(0, p); + reachable.add(r1); + } + ///List first = reachable.get(0); + int commonLevel; + Map levelMap = new HashMap<>(); + for (List first : reachable) { + int maxclevel = 0; + Set visited = new HashSet<>(); + for (GraphPart p : first) { + if (loopContinues.contains(p)) { + break; + } + if (visited.contains(p)) { + continue; + } + visited.add(p); + boolean common = true; + commonLevel = 1; + for (List r : reachable) { + if (r == first) { + continue; + } + if (r.contains(p)) { + commonLevel++; + } + } + if (commonLevel <= maxclevel) { + continue; + } + maxclevel = commonLevel; + if (levelMap.containsKey(p)) { + if (levelMap.get(p) > commonLevel) { + commonLevel = levelMap.get(p); + } + } + levelMap.put(p, commonLevel); + if (common) { + //return p; + } + } + } + for (int i = reachable.size() - 1; i >= 2; i--) { + for (GraphPart p : levelMap.keySet()) { + if (levelMap.get(p) == i) { + return p; + } + } + } + for (GraphPart p : levelMap.keySet()) { + if (levelMap.get(p) == parts.size()) { + return p; + } + } + return null; + } + + public GraphPart getNextNoJump(GraphPart part, BaseLocalData localData) { + while (code.get(part.start).isJump()) { + part = part.getSubParts().get(0).nextParts.get(0); + } + /*localData = prepareBranchLocalData(localData); + Stack st = new Stack<>(); + List output=new ArrayList<>(); + GraphPart startPart = part; + for (int i = part.start; i <= part.end; i++) { + GraphSourceItem src = code.get(i); + if (src.isJump()) { + part = part.nextParts.get(0); + if(st.isEmpty()){ + startPart = part; + } + i = part.start - 1; + continue; + } + try{ + src.translate(localData, st, output, SOP_USE_STATIC, ""); + }catch(Exception ex){ + return startPart; + } + if(!output.isEmpty()){ + return startPart; + } + }*/ + return part; + } + + public static List translateViaGraph(BaseLocalData localData, String path, GraphSource code, List alternateEntries, int staticOperation) throws InterruptedException { + Graph g = new Graph(code, alternateEntries); + g.init(localData); + return g.translate(localData, staticOperation, path); + } + + public List translate(BaseLocalData localData, int staticOperation, String path) throws InterruptedException { + List allParts = new ArrayList<>(); + for (GraphPart head : heads) { + populateParts(head, allParts); + } + TranslateStack stack = new TranslateStack(); + List loops = new ArrayList<>(); + getLoops(localData, heads.get(0), loops, null); + /*System.out.println(""); + for (Loop el : loops) { + System.out.println(el); + } + System.out.println("");*/ + getPrecontinues(path, localData, null, heads.get(0), allParts, loops, null); + /*System.err.println(""); + for (Loop el : loops) { + System.err.println(el); + } + System.err.println("");//*/ + + List ret = printGraph(localData, stack, allParts, null, heads.get(0), null, loops, staticOperation, path); + processIfs(ret); + finalProcessStack(stack, ret); + finalProcessAll(ret, 0, new FinalProcessLocalData()); + return ret; + + } + + public void finalProcessStack(TranslateStack stack, List output) { + } + + private void finalProcessAll(List list, int level, FinalProcessLocalData localData) { + finalProcess(list, level, localData); + for (GraphTargetItem item : list) { + if (item instanceof Block) { + List> subs = ((Block) item).getSubs(); + for (List sub : subs) { + finalProcessAll(sub, level + 1, localData); + } + } + } + } + + protected void finalProcess(List list, int level, FinalProcessLocalData localData) { + } + + private void processIfs(List list) { + //if(true) return; + for (int i = 0; i < list.size(); i++) { + GraphTargetItem item = list.get(i); + if (item instanceof Block) { + List> subs = ((Block) item).getSubs(); + for (List sub : subs) { + processIfs(sub); + } + } + if ((item instanceof LoopItem) && (item instanceof Block)) { + List> subs = ((Block) item).getSubs(); + for (List sub : subs) { + processIfs(sub); + checkContinueAtTheEnd(sub, ((LoopItem) item).loop); + } + } + if (item instanceof IfItem) { + IfItem ifi = (IfItem) item; + List onTrue = ifi.onTrue; + List onFalse = ifi.onFalse; + if ((!onTrue.isEmpty()) && (!onFalse.isEmpty())) { + if (onTrue.get(onTrue.size() - 1) instanceof ContinueItem) { + if (onFalse.get(onFalse.size() - 1) instanceof ContinueItem) { + if (((ContinueItem) onTrue.get(onTrue.size() - 1)).loopId == ((ContinueItem) onFalse.get(onFalse.size() - 1)).loopId) { + onTrue.remove(onTrue.size() - 1); + list.add(i + 1, onFalse.remove(onFalse.size() - 1)); + } + } + } + } + + if ((!onTrue.isEmpty()) && (!onFalse.isEmpty())) { + GraphTargetItem last = onTrue.get(onTrue.size() - 1); + if ((last instanceof ExitItem) || (last instanceof ContinueItem) || (last instanceof BreakItem)) { + list.addAll(i + 1, onFalse); + onFalse.clear(); + } + } + + if ((!onTrue.isEmpty()) && (!onFalse.isEmpty())) { + if (onFalse.get(onFalse.size() - 1) instanceof ExitItem) { + if (onTrue.get(onTrue.size() - 1) instanceof ContinueItem) { + list.add(i + 1, onTrue.remove(onTrue.size() - 1)); + } + } + } + } + } + + //Same continues in onTrue and onFalse gets continue on parent level + } + + protected List getLoopsContinuesPreAndBreaks(List loops) { + List ret = new ArrayList<>(); + for (Loop l : loops) { + if (l.loopContinue != null) { + ret.add(l.loopContinue); + } + if (l.loopPreContinue != null) { + ret.add(l.loopPreContinue); + } + if (l.loopBreak != null) { + ret.add(l.loopBreak); + } + } + return ret; + } + + protected List getLoopsContinuesAndPre(List loops) { + List ret = new ArrayList<>(); + for (Loop l : loops) { + if (l.loopContinue != null) { + ret.add(l.loopContinue); + } + if (l.loopPreContinue != null) { + ret.add(l.loopPreContinue); + } + } + return ret; + } + + protected List getLoopsContinues(List loops) { + List ret = new ArrayList<>(); + for (Loop l : loops) { + if (l.loopContinue != null) { + ret.add(l.loopContinue); + } + /*if (l.loopPreContinue != null) { + ret.add(l.loopPreContinue); + }*/ + } + return ret; + } + + protected GraphTargetItem checkLoop(GraphPart part, List stopPart, List loops) { + if (stopPart.contains(part)) { + return null; + } + for (Loop l : loops) { + if (l.loopContinue == part) { + return (new ContinueItem(null, l.id)); + } + if (l.loopBreak == part) { + return (new BreakItem(null, l.id)); + } + } + return null; + } + + private void checkContinueAtTheEnd(List commands, Loop loop) { + if (!commands.isEmpty()) { + int i = commands.size() - 1; + for (; i >= 0; i--) { + if (commands.get(i) instanceof ContinueItem) { + continue; + } + if (commands.get(i) instanceof BreakItem) { + continue; + } + break; + } + if (i < commands.size() - 1) { + for (int k = i + 2; k < commands.size(); k++) { + commands.remove(k); + } + } + if (commands.get(commands.size() - 1) instanceof ContinueItem) { + if (((ContinueItem) commands.get(commands.size() - 1)).loopId == loop.id) { + commands.remove(commands.size() - 1); + } + } + } + } + + protected boolean isEmpty(List output) { + if (output.isEmpty()) { + return true; + } + if (output.size() == 1) { + if (output.get(0) instanceof MarkItem) { + return true; + } + } + return false; + } + + protected List check(GraphSource code, BaseLocalData localData, List allParts, TranslateStack stack, GraphPart parent, GraphPart part, List stopPart, List loops, List output, Loop currentLoop, int staticOperation, String path) throws InterruptedException { + return null; + } + + protected GraphPart checkPart(TranslateStack stack, BaseLocalData localData, GraphPart part, List allParts) { + return part; + } + + //@SuppressWarnings("unchecked") + protected GraphTargetItem translatePartGetStack(BaseLocalData localData, GraphPart part, TranslateStack stack, int staticOperation) throws InterruptedException { + stack = (TranslateStack) stack.clone(); + translatePart(localData, part, stack, staticOperation, null); + return stack.pop(); + } + + protected List translatePart(BaseLocalData localData, GraphPart part, TranslateStack stack, int staticOperation, String path) throws InterruptedException { + List sub = part.getSubParts(); + List ret = new ArrayList<>(); + int end; + for (GraphPart p : sub) { + if (p.end == -1) { + p.end = code.size() - 1; + } + if (p.start == code.size()) { + continue; + } else if (p.end == code.size()) { + p.end--; + } + end = p.end; + int start = p.start; + ret.addAll(code.translatePart(part, localData, stack, start, end, staticOperation, path)); + } + return ret; + } + + private void markBranchEnd(List items) { + if (!items.isEmpty()) { + if (items.get(items.size() - 1) instanceof BreakItem) { + return; + } + if (items.get(items.size() - 1) instanceof ContinueItem) { + return; + } + if (items.get(items.size() - 1) instanceof ExitItem) { + return; + } + } + items.add(new MarkItem("finish")); + } + + private static GraphTargetItem getLastNoEnd(List list) { + if (list.isEmpty()) { + return null; + } + if (list.get(list.size() - 1) instanceof ScriptEndItem) { + if (list.size() >= 2) { + return list.get(list.size() - 2); + } + return list.get(list.size() - 1); + } + return list.get(list.size() - 1); + } + + private static void removeLastNoEnd(List list) { + if (list.isEmpty()) { + return; + } + if (list.get(list.size() - 1) instanceof ScriptEndItem) { + if (list.size() >= 2) { + list.remove(list.size() - 2); + } + return; + } + list.remove(list.size() - 1); + } + + protected List printGraph(BaseLocalData localData, TranslateStack stack, List allParts, GraphPart parent, GraphPart part, List stopPart, List loops, int staticOperation, String path) throws InterruptedException { + List visited = new ArrayList<>(); + return printGraph(visited, localData, stack, allParts, parent, part, stopPart, loops, null, staticOperation, path, 0); + } + + protected GraphTargetItem checkLoop(LoopItem loopItem, BaseLocalData localData, List loops) { + return loopItem; + } + + private void getPrecontinues(String path, BaseLocalData localData, GraphPart parent, GraphPart part, List allParts, List loops, List stopPart) throws InterruptedException { + markLevels(path, localData, part, allParts, loops); + //Note: this also marks part as precontinue when there is if + /* + while(k<10){ + if(k==7){ + trace(a); + }else{ + trace(b); + } + //precontinue + k++; + } + + */ + looploops: + for (Loop l : loops) { + if (l.loopContinue != null) { + Set uniqueRefs = new HashSet<>(); + uniqueRefs.addAll(l.loopContinue.refs); + if (uniqueRefs.size() == 2) { //only one path - from precontinue + List uniqueRefsList = new ArrayList<>(uniqueRefs); + if (uniqueRefsList.get(0).discoveredTime > uniqueRefsList.get(1).discoveredTime) { //latch node is discovered later + part = uniqueRefsList.get(0); + } else { + part = uniqueRefsList.get(1); + } + if (part == l.loopContinue) { + continue looploops; + } + + while (part.refs.size() == 1) { + if (part.refs.get(0).nextParts.size() != 1) { + continue looploops; + } + + part = part.refs.get(0); + if (part == l.loopContinue) { + break; + } + } + if (part.level == 0 && part != l.loopContinue) { + l.loopPreContinue = part; + } + } + } + } + /*clearLoops(loops); + getPrecontinues(parent, part, loops, stopPart, 0, new ArrayList()); + clearLoops(loops);*/ + } + + private void markLevels(String path, BaseLocalData localData, GraphPart part, List allParts, List loops) throws InterruptedException { + clearLoops(loops); + markLevels(path, localData, part, allParts, loops, new ArrayList(), 1, new ArrayList(), 0); + clearLoops(loops); + } + + private void markLevels(String path, BaseLocalData localData, GraphPart part, List allParts, List loops, List stopPart, int level, List visited, int recursionLevel) throws InterruptedException { + boolean debugMode = false; + if (stopPart == null) { + stopPart = new ArrayList<>(); + } + if (recursionLevel > allParts.size() + 1) { + Logger.getLogger(Graph.class.getName()).log(Level.WARNING, "{0} : markLevels max recursion level reached", path); + return; + } + + if (debugMode) { + System.err.println("markLevels " + part); + } + if (stopPart.contains(part)) { + return; + } + for (Loop el : loops) { + if ((el.phase == 2) && (el.loopContinue == part)) { + return; + } + if (el.phase != 1) { + if (debugMode) { + //System.err.println("ignoring "+el); + } + continue; + } + if (el.loopContinue == part) { + return; + } + if (el.loopPreContinue == part) { + return; + } + if (el.loopBreak == part) { + return; + } + } + + if (visited.contains(part)) { + part.level = 0; + } else { + visited.add(part); + part.level = level; + } + + boolean isLoop = false; + Loop currentLoop = null; + for (Loop el : loops) { + if ((el.phase == 0) && (el.loopContinue == part)) { + isLoop = true; + currentLoop = el; + el.phase = 1; + break; + } + } + + List nextParts = checkPrecoNextParts(part); + if (nextParts == null) { + nextParts = part.nextParts; + } + + if (nextParts.size() == 2) { + GraphPart next = getCommonPart(localData, nextParts, loops);//part.getNextPartPath(new ArrayList()); + List stopParts2 = new ArrayList<>(); //stopPart); + if (next != null) { + stopParts2.add(next); + } else if (!stopPart.isEmpty()) { + stopParts2.add(stopPart.get(stopPart.size() - 1)); + } + if (next != nextParts.get(0)) { + markLevels(path, localData, nextParts.get(0), allParts, loops, next == null ? stopPart : stopParts2, level + 1, visited, recursionLevel + 1); + } + if (next != nextParts.get(1)) { + markLevels(path, localData, nextParts.get(1), allParts, loops, next == null ? stopPart : stopParts2, level + 1, visited, recursionLevel + 1); + } + if (next != null) { + markLevels(path, localData, next, allParts, loops, stopPart, level, visited, recursionLevel + 1); + } + } + + if (nextParts.size() > 2) { + GraphPart next = getMostCommonPart(localData, nextParts, loops); + List vis = new ArrayList<>(); + for (GraphPart p : nextParts) { + if (vis.contains(p)) { + continue; + } + List stopPart2 = new ArrayList<>(); //(stopPart); + if (next != null) { + stopPart2.add(next); + } else if (!stopPart.isEmpty()) { + stopPart2.add(stopPart.get(stopPart.size() - 1)); + } + for (GraphPart p2 : nextParts) { + if (p2 == p) { + continue; + } + if (!stopPart2.contains(p2)) { + stopPart2.add(p2); + } + } + if (next != p) { + markLevels(path, localData, p, allParts, loops, stopPart2, level + 1, visited, recursionLevel + 1); + vis.add(p); + } + } + if (next != null) { + markLevels(path, localData, next, allParts, loops, stopPart, level, visited, recursionLevel + 1); + } + } + + if (nextParts.size() == 1) { + markLevels(path, localData, nextParts.get(0), allParts, loops, stopPart, level, visited, recursionLevel + 1); + } + + for (GraphPart t : part.throwParts) { + if (!visited.contains(t)) { + List stopPart2 = new ArrayList<>(); + List cmn = new ArrayList<>(); + cmn.add(part); + cmn.add(t); + GraphPart next = getCommonPart(localData, cmn, loops); + if (next != null) { + stopPart2.add(next); + } else { + stopPart2 = stopPart; + } + + markLevels(path, localData, t, allParts, loops, stopPart2, level, visited, recursionLevel + 1); + } + } + + if (isLoop) { + if (currentLoop.loopBreak != null) { + currentLoop.phase = 2; + markLevels(path, localData, currentLoop.loopBreak, allParts, loops, stopPart, level, visited, recursionLevel + 1); + } + } + } + + private void clearLoops(List loops) { + for (Loop l : loops) { + l.phase = 0; + } + } + + private void getLoops(BaseLocalData localData, GraphPart part, List loops, List stopPart) throws InterruptedException { + clearLoops(loops); + getLoops(localData, part, loops, stopPart, true, 1, new ArrayList()); + clearLoops(loops); + } + + 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; + } + + part = checkPart(null, localData, part, null); + if (part == null) { + return; + } + if (!visited.contains(part)) { + visited.add(part); + } + + if (debugMode) { + System.err.println("getloops: " + part); + } + List loopContinues = getLoopsContinues(loops); + Loop lastP1 = null; + for (Loop el : loops) { + if ((el.phase == 1) && el.loopBreak == null) { //break not found yet + if (el.loopContinue != part) { + lastP1 = el; + + } else { + lastP1 = null; + } + + } + } + if (lastP1 != null) { + if (lastP1.breakCandidates.contains(part)) { + lastP1.breakCandidates.add(part); + lastP1.breakCandidatesLevels.add(level); + return; + } else { + List loopContinues2 = new ArrayList<>(loopContinues); + loopContinues2.remove(lastP1.loopContinue); + List loops2 = new ArrayList<>(loops); + loops2.remove(lastP1); + if (!part.leadsTo(localData, this, code, lastP1.loopContinue, loops2)) { + if (lastP1.breakCandidatesLocked == 0) { + if (debugMode) { + System.err.println("added breakCandidate " + part + " to " + lastP1); + } + + lastP1.breakCandidates.add(part); + lastP1.breakCandidatesLevels.add(level); + return; + } + } + } + } + + for (Loop el : loops) { + if (el.loopContinue == part) { + return; + } + } + + if (stopPart.contains(part)) { + return; + } + part.level = level; + + boolean isLoop = part.leadsTo(localData, this, code, part, loops); + Loop currentLoop = null; + if (isLoop) { + currentLoop = new Loop(loops.size(), part, null); + currentLoop.phase = 1; + loops.add(currentLoop); + loopContinues.add(part); + } + + if (part.nextParts.size() == 2) { + + List nps = new ArrayList<>(part.nextParts); + /*for(int i=0;i stopPart2 = new ArrayList<>(stopPart); + if (next != null) { + stopPart2.add(next); + } + if (next != nps.get(0)) { + getLoops(localData, nps.get(0), loops, stopPart2, false, level + 1, visited); + } + if (next != nps.get(1)) { + getLoops(localData, nps.get(1), loops, stopPart2, false, level + 1, visited); + } + if (next != null) { + getLoops(localData, next, loops, stopPart, false, level, visited); + } + } + if (part.nextParts.size() > 2) { + GraphPart next = getNextCommonPart(localData, part, loops); + + for (GraphPart p : part.nextParts) { + List stopPart2 = new ArrayList<>(stopPart); + if (next != null) { + stopPart2.add(next); + } + for (GraphPart p2 : part.nextParts) { + if (p2 == p) { + continue; + } + if (!stopPart2.contains(p2)) { + stopPart2.add(p2); + } + } + if (next != p) { + getLoops(localData, p, loops, stopPart2, false, level + 1, visited); + } + } + if (next != null) { + getLoops(localData, next, loops, stopPart, false, level, visited); + } + } + if (part.nextParts.size() == 1) { + getLoops(localData, part.nextParts.get(0), loops, stopPart, false, level, visited); + } + + List loops2 = new ArrayList<>(loops); + for (Loop l : loops2) { + l.breakCandidatesLocked++; + } + for (GraphPart t : part.throwParts) { + if (!visited.contains(t)) { + getLoops(localData, t, loops, stopPart, false, level, visited); + } + } + for (Loop l : loops2) { + l.breakCandidatesLocked--; + } + + if (isLoop) { + GraphPart found; + Map removed = new HashMap<>(); + do { + found = null; + for (int i = 0; i < currentLoop.breakCandidates.size(); i++) { + GraphPart ch = checkPart(null, localData, currentLoop.breakCandidates.get(i), null); + if (ch == null) { + currentLoop.breakCandidates.remove(i); + i--; + } + } + loopcand: + for (GraphPart cand : currentLoop.breakCandidates) { + for (GraphPart cand2 : currentLoop.breakCandidates) { + if (cand == cand2) { + continue; + } + if (cand.leadsTo(localData, this, code, cand2, loops)) { + int lev1 = Integer.MAX_VALUE; + int lev2 = Integer.MAX_VALUE; + for (int i = 0; i < currentLoop.breakCandidates.size(); i++) { + if (currentLoop.breakCandidates.get(i) == cand) { + if (currentLoop.breakCandidatesLevels.get(i) < lev1) { + lev1 = currentLoop.breakCandidatesLevels.get(i); + } + } + if (currentLoop.breakCandidates.get(i) == cand2) { + if (currentLoop.breakCandidatesLevels.get(i) < lev2) { + lev2 = currentLoop.breakCandidatesLevels.get(i); + } + } + } + if (lev1 <= lev2) { + found = cand2; + } else { + found = cand; + } + break loopcand; + } + } + } + if (found != null) { + int maxlevel = 0; + while (currentLoop.breakCandidates.contains(found)) { + int ind = currentLoop.breakCandidates.indexOf(found); + currentLoop.breakCandidates.remove(ind); + int lev = currentLoop.breakCandidatesLevels.remove(ind); + if (lev > maxlevel) { + maxlevel = lev; + } + } + if (removed.containsKey(found)) { + if (removed.get(found) > maxlevel) { + maxlevel = removed.get(found); + } + } + removed.put(found, maxlevel); + } + } while ((found != null) && (currentLoop.breakCandidates.size() > 1)); + + Map count = new HashMap<>(); + GraphPart winner = null; + int winnerCount = 0; + for (GraphPart cand : currentLoop.breakCandidates) { + + if (!count.containsKey(cand)) { + count.put(cand, 0); + } + count.put(cand, count.get(cand) + 1); + boolean otherBreakCandidate = false; + for (Loop el : loops) { + if (el == currentLoop) { + continue; + } + if (el.breakCandidates.contains(cand)) { + otherBreakCandidate = true; + break; + } + } + if (otherBreakCandidate) { + } else if (count.get(cand) > winnerCount) { + winnerCount = count.get(cand); + winner = cand; + } else if (count.get(cand) == winnerCount) { + if (cand.path.length() < winner.path.length()) { + winner = cand; + } + } + } + for (int i = 0; i < currentLoop.breakCandidates.size(); i++) { + GraphPart cand = currentLoop.breakCandidates.get(i); + if (cand != winner) { + int lev = currentLoop.breakCandidatesLevels.get(i); + if (removed.containsKey(cand)) { + if (removed.get(cand) > lev) { + lev = removed.get(cand); + } + } + removed.put(cand, lev); + } + } + currentLoop.loopBreak = winner; + currentLoop.phase = 2; + boolean start = false; + for (int l = 0; l < loops.size(); l++) { + Loop el = loops.get(l); + if (start) { + el.phase = 1; + } + if (el == currentLoop) { + start = true; + } + } + List removedVisited = new ArrayList<>(); + for (GraphPart r : removed.keySet()) { + if (removedVisited.contains(r)) { + continue; + } + getLoops(localData, r, loops, stopPart, false, removed.get(r), visited); + removedVisited.add(r); + } + start = false; + for (int l = 0; l < loops.size(); l++) { + Loop el = loops.get(l); + if (el == currentLoop) { + start = true; + } + if (start) { + el.phase = 2; + } + } + getLoops(localData, currentLoop.loopBreak, loops, stopPart, false, level, visited); + } + } + + protected List printGraph(List visited, BaseLocalData localData, TranslateStack stack, List allParts, GraphPart parent, GraphPart part, List stopPart, List loops, List ret, int staticOperation, String path, int recursionLevel) throws InterruptedException { + if (Thread.currentThread().isInterrupted()) { + throw new InterruptedException(); + } + if (stopPart == null) { + stopPart = new ArrayList<>(); + } + if (recursionLevel > allParts.size() + 1) { + throw new TranslateException("printGraph max recursion level reached."); + } + if (visited.contains(part)) { + //return new ArrayList(); + } else { + visited.add(part); + } + if (ret == null) { + ret = new ArrayList<>(); + } + //try { + boolean debugMode = false; + + if (debugMode) { + System.err.println("PART " + part + " nextsize:" + part.nextParts.size()); + } + + /*while (((part != null) && (part.getHeight() == 1)) && (code.size() > part.start) && (code.get(part.start).isJump())) { //Parts with only jump in it gets ignored + + if (part == stopPart) { + return ret; + } + GraphTargetItem lop = checkLoop(part.nextParts.get(0), stopPart, loops); + if (lop == null) { + part = part.nextParts.get(0); + } else { + break; + } + }*/ + if (part == null) { + return ret; + } + part = checkPart(stack, localData, part, allParts); + if (part == null) { + return ret; + } + + if (part.ignored) { + return ret; + } + + List loopContinues = getLoopsContinues(loops); + boolean isLoop = false; + Loop currentLoop = null; + for (Loop el : loops) { + if ((el.loopContinue == part) && (el.phase == 0)) { + currentLoop = el; + currentLoop.phase = 1; + isLoop = true; + break; + } + } + + if (debugMode) { + System.err.println("loopsize:" + loops.size()); + } + for (int l = loops.size() - 1; l >= 0; l--) { + Loop el = loops.get(l); + if (el == currentLoop) { + if (debugMode) { + System.err.println("ignoring current loop " + el); + } + continue; + } + if (el.phase != 1) { + if (debugMode) { + //System.err.println("ignoring loop "+el); + } + continue; + } + if (el.loopBreak == part) { + if (currentLoop != null) { + currentLoop.phase = 0; + } + if (debugMode) { + System.err.println("Adding break"); + } + ret.add(new BreakItem(null, el.id)); + return ret; + } + if (el.loopPreContinue == part) { + if (currentLoop != null) { + currentLoop.phase = 0; + } + if (debugMode) { + System.err.println("Adding precontinue"); + } + ret.add(new ContinueItem(null, el.id)); + return ret; + } + if (el.loopContinue == part) { + if (currentLoop != null) { + currentLoop.phase = 0; + } + if (debugMode) { + System.err.println("Adding continue"); + } + ret.add(new ContinueItem(null, el.id)); + return ret; + } + } + + if (stopPart.contains(part)) { + if (currentLoop != null) { + currentLoop.phase = 0; + } + return ret; + } + + if ((part != null) && (code.size() <= part.start)) { + ret.add(new ScriptEndItem()); + return ret; + } + List currentRet = ret; + UniversalLoopItem loopItem = null; + if (isLoop) { + loopItem = new UniversalLoopItem(null, currentLoop); + //loopItem.commands=printGraph(visited, localData, stack, allParts, parent, part, stopPart, loops); + currentRet.add(loopItem); + loopItem.commands = new ArrayList<>(); + currentRet = loopItem.commands; + //return ret; + } + + boolean parseNext = true; + + //****************************DECOMPILING PART************* + List output = new ArrayList<>(); + + List parts = new ArrayList<>(); + if (part instanceof GraphPartMulti) { + parts = ((GraphPartMulti) part).parts; + } else { + parts.add(part); + } + for (GraphPart p : parts) { + int end = p.end; + int start = p.start; + + output.addAll(code.translatePart(p, localData, stack, start, end, staticOperation, path)); + if ((end >= code.size() - 1) && p.nextParts.isEmpty()) { + output.add(new ScriptEndItem()); + } + } + + //Assuming part with two nextparts is an IF + + /* //If with both branches empty + if (part.nextParts.size() == 2) { + if (part.nextParts.get(0) == part.nextParts.get(1)) { + if (!stack.isEmpty()) { + GraphTargetItem expr = stack.pop(); + if (expr instanceof LogicalOpItem) { + expr = ((LogicalOpItem) expr).invert(); + } else { + expr = new NotItem(null, expr); + } + output.add(new IfItem(null, expr, new ArrayList(), new ArrayList())); + } + part.nextParts.remove(0); + } + }*/ + if (parseNext) { + List retCheck = check(code, localData, allParts, stack, parent, part, stopPart, loops, output, currentLoop, staticOperation, path); + if (retCheck != null) { + if (!retCheck.isEmpty()) { + currentRet.addAll(retCheck); + } + parseNext = false; + //return ret; + } else { + currentRet.addAll(output); + } + } + + /** + * AND / OR detection + */ + if (parseNext && part.nextParts.size() == 2) { + if ((stack.size() >= 2) && (stack.get(stack.size() - 1) instanceof NotItem) && (((NotItem) (stack.get(stack.size() - 1))).getOriginal().getNotCoerced() == stack.get(stack.size() - 2).getNotCoerced())) { + GraphPart sp0 = getNextNoJump(part.nextParts.get(0), localData); + GraphPart sp1 = getNextNoJump(part.nextParts.get(1), localData); + boolean reversed = false; + loopContinues = getLoopsContinues(loops); + loopContinues.add(part);//??? + if (sp1.leadsTo(localData, this, code, sp0, loops)) { + } else if (sp0.leadsTo(localData, this, code, sp1, loops)) { + reversed = true; + } + GraphPart next = reversed ? sp0 : sp1; + GraphTargetItem ti; + if ((ti = checkLoop(next, stopPart, loops)) != null) { + currentRet.add(ti); + } else { + List stopPart2 = new ArrayList<>(stopPart); + stopPart2.add(reversed ? sp1 : sp0); + printGraph(visited, localData, stack, allParts, parent, next, stopPart2, loops, null, staticOperation, path, recursionLevel + 1); + GraphTargetItem second = stack.pop(); + GraphTargetItem first = stack.pop(); + + if (!reversed) { + AndItem a = new AndItem(null, first, second); + stack.push(a); + a.firstPart = part; + if (second instanceof AndItem) { + a.firstPart = ((AndItem) second).firstPart; + } + if (second instanceof OrItem) { + a.firstPart = ((OrItem) second).firstPart; + } + } else { + OrItem o = new OrItem(null, first, second); + stack.push(o); + o.firstPart = part; + if (second instanceof AndItem) { + o.firstPart = ((AndItem) second).firstPart; + } + if (second instanceof OrItem) { + o.firstPart = ((OrItem) second).firstPart; + } + } + next = reversed ? sp1 : sp0; + if ((ti = checkLoop(next, stopPart, loops)) != null) { + currentRet.add(ti); + } else { + currentRet.addAll(printGraph(visited, localData, stack, allParts, parent, next, stopPart, loops, null, staticOperation, path, recursionLevel + 1)); + } + } + parseNext = false; + //return ret; + } else if ((stack.size() >= 2) && (stack.get(stack.size() - 1).getNotCoerced() == stack.get(stack.size() - 2).getNotCoerced())) { + GraphPart sp0 = getNextNoJump(part.nextParts.get(0), localData); + GraphPart sp1 = getNextNoJump(part.nextParts.get(1), localData); + boolean reversed = false; + loopContinues = getLoopsContinues(loops); + loopContinues.add(part);//??? + if (sp1.leadsTo(localData, this, code, sp0, loops)) { + } else if (sp0.leadsTo(localData, this, code, sp1, loops)) { + reversed = true; + } + GraphPart next = reversed ? sp0 : sp1; + GraphTargetItem ti; + if ((ti = checkLoop(next, stopPart, loops)) != null) { + currentRet.add(ti); + } else { + List stopPart2 = new ArrayList<>(stopPart); + stopPart2.add(reversed ? sp1 : sp0); + printGraph(visited, localData, stack, allParts, parent, next, stopPart2, loops, null, staticOperation, path, recursionLevel + 1); + GraphTargetItem second = stack.pop(); + GraphTargetItem first = stack.pop(); + + if (reversed) { + AndItem a = new AndItem(null, first, second); + stack.push(a); + a.firstPart = part; + if (second instanceof AndItem) { + a.firstPart = ((AndItem) second).firstPart; + } + if (second instanceof OrItem) { + a.firstPart = ((AndItem) second).firstPart; + } + } else { + OrItem o = new OrItem(null, first, second); + stack.push(o); + o.firstPart = part; + if (second instanceof OrItem) { + o.firstPart = ((OrItem) second).firstPart; + } + if (second instanceof OrItem) { + o.firstPart = ((OrItem) second).firstPart; + } + } + + next = reversed ? sp1 : sp0; + if ((ti = checkLoop(next, stopPart, loops)) != null) { + currentRet.add(ti); + } else { + currentRet.addAll(printGraph(visited, localData, stack, allParts, parent, next, stopPart, loops, null, staticOperation, path, recursionLevel + 1)); + } + } + parseNext = false; + //return ret; + } + } +//********************************END PART DECOMPILING + + if (parseNext) { + + if (false && part.nextParts.size() > 2) {//alchemy direct switch + GraphPart next = getMostCommonPart(localData, part.nextParts, loops); + List vis = new ArrayList<>(); + GraphTargetItem switchedItem = stack.pop(); + List caseValues = new ArrayList<>(); + List> caseCommands = new ArrayList<>(); + List defaultCommands = new ArrayList<>(); + List valueMappings = new ArrayList<>(); + Loop swLoop = new Loop(loops.size(), null, next); + swLoop.phase = 1; + loops.add(swLoop); + boolean first = false; + int pos = 0; + for (GraphPart p : part.nextParts) { + + if (!first) { + caseValues.add(new IntegerValueItem(null, pos++)); + if (vis.contains(p)) { + valueMappings.add(caseCommands.size() - 1); + continue; + } + + valueMappings.add(caseCommands.size()); + } + List stopPart2 = new ArrayList<>(); + if (next != null) { + stopPart2.add(next); + } else if (!stopPart.isEmpty()) { + stopPart2.add(stopPart.get(stopPart.size() - 1)); + } + for (GraphPart p2 : part.nextParts) { + if (p2 == p) { + continue; + } + if (!stopPart2.contains(p2)) { + stopPart2.add(p2); + } + } + if (next != p) { + if (first) { + defaultCommands = printGraph(visited, prepareBranchLocalData(localData), stack, allParts, part, p, stopPart2, loops, null, staticOperation, path, recursionLevel + 1); + } else { + caseCommands.add(printGraph(visited, prepareBranchLocalData(localData), stack, allParts, part, p, stopPart2, loops, null, staticOperation, path, recursionLevel + 1)); + } + vis.add(p); + } + first = false; + } + SwitchItem sw = new SwitchItem(null, swLoop, switchedItem, caseValues, caseCommands, defaultCommands, valueMappings); + currentRet.add(sw); + swLoop.phase = 2; + if (next != null) { + currentRet.addAll(printGraph(visited, localData, stack, allParts, part, next, stopPart, loops, null, staticOperation, path, recursionLevel + 1)); + } + } //else + GraphPart nextOnePart = null; + if (part.nextParts.size() == 2) { + GraphTargetItem expr = stack.pop(); + if (expr instanceof LogicalOpItem) { + expr = ((LogicalOpItem) expr).invert(); + } else { + expr = new NotItem(null, expr); + } + if (staticOperation != SOP_USE_STATIC) { + if (expr.isCompileTime()) { + boolean doJump = EcmaScript.toBoolean(expr.getResult()); + if (doJump) { + nextOnePart = part.nextParts.get(0); + } else { + nextOnePart = part.nextParts.get(1); + } + if (staticOperation == SOP_REMOVE_STATIC) { + //TODO + } + } + } + if (nextOnePart == null) { + + List nps; + /*nps = new ArrayList<>(part.nextParts); + for(int i=0;i onTrue = new ArrayList<>(); + boolean isEmpty = nps.get(0) == nps.get(1); + + if (isEmpty) { + next = nps.get(0); + } + + List stopPart2 = new ArrayList<>(stopPart); + if (next != null) { + stopPart2.add(next); + } + if (!isEmpty) { + onTrue = printGraph(visited, prepareBranchLocalData(localData), trueStack, allParts, part, nps.get(1), stopPart2, loops, null, staticOperation, path, recursionLevel + 1); + } + List onFalse = new ArrayList<>(); + + if (!isEmpty) { + onFalse = printGraph(visited, prepareBranchLocalData(localData), falseStack, allParts, part, nps.get(0), stopPart2, loops, null, staticOperation, path, recursionLevel + 1); + } + if (isEmpty(onTrue) && isEmpty(onFalse) && (trueStack.size() == trueStackSizeBefore + 1) && (falseStack.size() == falseStackSizeBefore + 1)) { + stack.push(new TernarOpItem(null, expr, trueStack.pop(), falseStack.pop())); + } else { + currentRet.add(new IfItem(null, expr, onTrue, onFalse)); + } + if (next != null) { + if (trueStack.size() != trueStackSizeBefore || falseStack.size() != falseStackSizeBefore) { + // it's a hack, because duplicates all instructions in the next part, but better than EmptyStackException + onTrue = printGraph(visited, localData, trueStack, allParts, part, next, stopPart, loops, null, staticOperation, path, recursionLevel + 1); + onFalse = printGraph(visited, localData, falseStack, allParts, part, next, stopPart, loops, null, staticOperation, path, recursionLevel + 1); + if (isEmpty(onTrue) && isEmpty(onFalse) && (trueStack.size() == trueStackSizeBefore + 1) && (falseStack.size() == falseStackSizeBefore + 1)) { + stack.push(new TernarOpItem(null, expr, trueStack.pop(), falseStack.pop())); + } else { + currentRet.add(new IfItem(null, expr, onTrue, onFalse)); + } + } else { + printGraph(visited, localData, stack, allParts, part, next, stopPart, loops, currentRet, staticOperation, path, recursionLevel + 1); + } + //currentRet.addAll(); + } + } + } //else + if (part.nextParts.size() == 1) { + nextOnePart = part.nextParts.get(0); + } + if (nextOnePart != null) { + printGraph(visited, localData, stack, allParts, part, part.nextParts.get(0), stopPart, loops, currentRet, staticOperation, path, recursionLevel + 1); + } + + } + if (isLoop) { + + LoopItem li = loopItem; + boolean loopTypeFound = false; + + boolean hasContinue = false; + processIfs(loopItem.commands); + checkContinueAtTheEnd(loopItem.commands, currentLoop); + List continues = loopItem.getContinues(); + for (ContinueItem c : continues) { + if (c.loopId == currentLoop.id) { + hasContinue = true; + break; + } + } + if (!hasContinue) { + if (currentLoop.loopPreContinue != null) { + List stopContPart = new ArrayList<>(); + stopContPart.add(currentLoop.loopContinue); + GraphPart precoBackup = currentLoop.loopPreContinue; + currentLoop.loopPreContinue = null; + loopItem.commands.addAll(printGraph(visited, localData, new TranslateStack(), allParts, null, precoBackup, stopContPart, loops, null, staticOperation, path, recursionLevel + 1)); + } + } + + //Loop with condition at the beginning (While) + if (!loopTypeFound && (!loopItem.commands.isEmpty())) { + if (loopItem.commands.get(0) instanceof IfItem) { + IfItem ifi = (IfItem) loopItem.commands.get(0); + + List bodyBranch = null; + boolean inverted = false; + boolean breakpos2 = false; + if ((ifi.onTrue.size() == 1) && (ifi.onTrue.get(0) instanceof BreakItem)) { + BreakItem bi = (BreakItem) ifi.onTrue.get(0); + if (bi.loopId == currentLoop.id) { + bodyBranch = ifi.onFalse; + inverted = true; + } + } else if ((ifi.onFalse.size() == 1) && (ifi.onFalse.get(0) instanceof BreakItem)) { + BreakItem bi = (BreakItem) ifi.onFalse.get(0); + if (bi.loopId == currentLoop.id) { + bodyBranch = ifi.onTrue; + } + } else if (loopItem.commands.size() == 2 && (loopItem.commands.get(1) instanceof BreakItem)) { + BreakItem bi = (BreakItem) loopItem.commands.get(1); + if (bi.loopId == currentLoop.id) { + bodyBranch = ifi.onTrue; + breakpos2 = true; + } + } + if (bodyBranch != null) { + int index = ret.indexOf(loopItem); + ret.remove(index); + List exprList = new ArrayList<>(); + GraphTargetItem expr = ifi.expression; + if (inverted) { + if (expr instanceof LogicalOpItem) { + expr = ((LogicalOpItem) expr).invert(); + } else { + expr = new NotItem(null, expr); + } + } + exprList.add(expr); + List commands = new ArrayList<>(); + commands.addAll(bodyBranch); + loopItem.commands.remove(0); + if (breakpos2) { + loopItem.commands.remove(0); //remove that break too + } + commands.addAll(loopItem.commands); + checkContinueAtTheEnd(commands, currentLoop); + List finalComm = new ArrayList<>(); + if (currentLoop.loopPreContinue != null) { + GraphPart backup = currentLoop.loopPreContinue; + currentLoop.loopPreContinue = null; + List stopPart2 = new ArrayList<>(stopPart); + stopPart2.add(currentLoop.loopContinue); + finalComm = printGraph(visited, localData, new TranslateStack(), allParts, null, backup, stopPart2, loops, null, staticOperation, path, recursionLevel + 1); + currentLoop.loopPreContinue = backup; + checkContinueAtTheEnd(finalComm, currentLoop); + } + if (!finalComm.isEmpty()) { + ret.add(index, li = new ForItem(null, currentLoop, new ArrayList(), exprList.get(exprList.size() - 1), finalComm, commands)); + } else { + ret.add(index, li = new WhileItem(null, currentLoop, exprList, commands)); + } + + loopTypeFound = true; + } + } + } + + //Loop with condition at the end (Do..While) + if (!loopTypeFound && (!loopItem.commands.isEmpty())) { + if (loopItem.commands.get(loopItem.commands.size() - 1) instanceof IfItem) { + IfItem ifi = (IfItem) loopItem.commands.get(loopItem.commands.size() - 1); + List bodyBranch = null; + boolean inverted = false; + if ((ifi.onTrue.size() == 1) && (ifi.onTrue.get(0) instanceof BreakItem)) { + BreakItem bi = (BreakItem) ifi.onTrue.get(0); + if (bi.loopId == currentLoop.id) { + bodyBranch = ifi.onFalse; + inverted = true; + } + } else if ((ifi.onFalse.size() == 1) && (ifi.onFalse.get(0) instanceof BreakItem)) { + BreakItem bi = (BreakItem) ifi.onFalse.get(0); + if (bi.loopId == currentLoop.id) { + bodyBranch = ifi.onTrue; + } + } + if (bodyBranch != null) { + //Condition at the beginning + int index = ret.indexOf(loopItem); + ret.remove(index); + List exprList = new ArrayList<>(); + GraphTargetItem expr = ifi.expression; + if (inverted) { + if (expr instanceof LogicalOpItem) { + expr = ((LogicalOpItem) expr).invert(); + } else { + expr = new NotItem(null, expr); + } + } + + checkContinueAtTheEnd(bodyBranch, currentLoop); + + List commands = new ArrayList<>(); + + if (!bodyBranch.isEmpty()) { + ret.add(index, loopItem); + /* + loopItem.commands.remove(loopItem.commands.size() - 1); + exprList.addAll(loopItem.commands); + commands.addAll(bodyBranch); + exprList.add(expr); + checkContinueAtTheEnd(commands, currentLoop); + ret.add(index, li = new WhileItem(null, currentLoop, exprList, commands));*/ + } else { + loopItem.commands.remove(loopItem.commands.size() - 1); + commands.addAll(loopItem.commands); + commands.addAll(bodyBranch); + exprList.add(expr); + checkContinueAtTheEnd(commands, currentLoop); + ret.add(index, li = new DoWhileItem(null, currentLoop, commands, exprList)); + + } + loopTypeFound = true; + } + } + } + + if (!loopTypeFound) { + if (currentLoop.loopPreContinue != null) { + loopTypeFound = true; + GraphPart backup = currentLoop.loopPreContinue; + currentLoop.loopPreContinue = null; + List stopPart2 = new ArrayList<>(stopPart); + stopPart2.add(currentLoop.loopContinue); + List finalComm = printGraph(visited, localData, new TranslateStack(), allParts, null, backup, stopPart2, loops, null, staticOperation, path, recursionLevel + 1); + currentLoop.loopPreContinue = backup; + checkContinueAtTheEnd(finalComm, currentLoop); + + if (!finalComm.isEmpty()) { + if (finalComm.get(finalComm.size() - 1) instanceof IfItem) { + IfItem ifi = (IfItem) finalComm.get(finalComm.size() - 1); + boolean ok = false; + boolean invert = false; + if (((ifi.onTrue.size() == 1) && (ifi.onTrue.get(0) instanceof BreakItem) && (((BreakItem) ifi.onTrue.get(0)).loopId == currentLoop.id)) + && ((ifi.onTrue.size() == 1) && (ifi.onFalse.get(0) instanceof ContinueItem) && (((ContinueItem) ifi.onFalse.get(0)).loopId == currentLoop.id))) { + ok = true; + invert = true; + } + if (((ifi.onTrue.size() == 1) && (ifi.onTrue.get(0) instanceof ContinueItem) && (((ContinueItem) ifi.onTrue.get(0)).loopId == currentLoop.id)) + && ((ifi.onTrue.size() == 1) && (ifi.onFalse.get(0) instanceof BreakItem) && (((BreakItem) ifi.onFalse.get(0)).loopId == currentLoop.id))) { + ok = true; + } + if (ok) { + finalComm.remove(finalComm.size() - 1); + int index = ret.indexOf(loopItem); + ret.remove(index); + List exprList = new ArrayList<>(finalComm); + GraphTargetItem expr = ifi.expression; + if (invert) { + if (expr instanceof LogicalOpItem) { + expr = ((LogicalOpItem) expr).invert(); + } else { + expr = new NotItem(null, expr); + } + } + exprList.add(expr); + ret.add(index, li = new DoWhileItem(null, currentLoop, loopItem.commands, exprList)); + } + } + } + } + } + + if (!loopTypeFound) { + checkContinueAtTheEnd(loopItem.commands, currentLoop); + } + currentLoop.phase = 2; + + GraphTargetItem replaced = checkLoop(li, localData, loops); + if (replaced != li) { + int index = ret.indexOf(li); + ret.remove(index); + if (replaced != null) { + ret.add(index, replaced); + } + } + + if (currentLoop.loopBreak != null) { + ret.addAll(printGraph(visited, localData, stack, allParts, part, currentLoop.loopBreak, stopPart, loops, null, staticOperation, path, recursionLevel + 1)); + } + } + + return ret; + + } + + protected void checkGraph(List allBlocks) { + } + + private List makeGraph(GraphSource code, List allBlocks, List alternateEntries) throws InterruptedException { + HashMap> refs = code.visitCode(alternateEntries); + List ret = new ArrayList<>(); + boolean[] visited = new boolean[code.size()]; + ret.add(makeGraph(null, new GraphPath(), code, 0, 0, allBlocks, refs, visited)); + for (int pos : alternateEntries) { + GraphPart e1 = new GraphPart(-1, -1); + e1.path = new GraphPath("e"); + ret.add(makeGraph(e1, new GraphPath("e"), code, pos, pos, allBlocks, refs, visited)); + } + checkGraph(allBlocks); + return ret; + } + + protected int checkIp(int ip) { + return ip; + } + + private GraphPart makeGraph(GraphPart parent, GraphPath path, GraphSource code, int startip, int lastIp, List allBlocks, HashMap> refs, boolean[] visited2) throws InterruptedException { + if (Thread.currentThread().isInterrupted()) { + throw new InterruptedException(); + } + + int ip = startip; + for (GraphPart p : allBlocks) { + if (p.start == ip) { + p.refs.add(parent); + return p; + } + } + GraphPart g; + GraphPart ret = new GraphPart(ip, -1); + ret.path = path; + GraphPart part = ret; + while (ip < code.size()) { + if (visited2[ip] || ((ip != startip) && (refs.get(ip).size() > 1))) { + part.end = lastIp; + GraphPart found = null; + for (GraphPart p : allBlocks) { + if (p.start == ip) { + found = p; + break; + } + } + + allBlocks.add(part); + + if (found != null) { + part.nextParts.add(found); + found.refs.add(part); + break; + } else { + GraphPart gp = new GraphPart(ip, -1); + gp.path = path; + part.nextParts.add(gp); + gp.refs.add(part); + part = gp; + } + } + + ip = checkIp(ip); + lastIp = ip; + GraphSourceItem ins = code.get(ip); + if (ins.isIgnored()) { + ip++; + continue; + } + if (ins instanceof GraphSourceItemContainer) { + GraphSourceItemContainer cnt = (GraphSourceItemContainer) ins; + if (ins instanceof Action) { //TODO: Remove dependency of AVM1 + long endAddr = ((Action) ins).getAddress() + cnt.getHeaderSize(); + for (long size : cnt.getContainerSizes()) { + endAddr += size; + } + ip = code.adr2pos(endAddr); + } + continue; + } else if (ins.isExit()) { + part.end = ip; + allBlocks.add(part); + break; + } else if (ins.isJump()) { + part.end = ip; + allBlocks.add(part); + ip = ins.getBranches(code).get(0); + part.nextParts.add(g = makeGraph(part, path, code, ip, lastIp, allBlocks, refs, visited2)); + g.refs.add(part); + break; + } else if (ins.isBranch()) { + part.end = ip; + + allBlocks.add(part); + List branches = ins.getBranches(code); + for (int i = 0; i < branches.size(); i++) { + part.nextParts.add(g = makeGraph(part, path.sub(i, ip), code, branches.get(i), ip, allBlocks, refs, visited2)); + g.refs.add(part); + } + break; + } + ip++; + } + if ((part.end == -1) && (ip >= code.size())) { + if (part.start == code.size()) { + part.end = code.size(); + allBlocks.add(part); + } else { + part.end = ip - 1; + for (GraphPart p : allBlocks) { + if (p.start == ip) { + p.refs.add(part); + part.nextParts.add(p); + allBlocks.add(part); + return ret; + } + } + GraphPart gp = new GraphPart(ip, ip); + allBlocks.add(gp); + gp.refs.add(part); + part.nextParts.add(gp); + allBlocks.add(part); + } + } + return ret; + } + /** + * String used to indent line when converting to string + */ + public static final String INDENTOPEN = "INDENTOPEN"; + /** + * String used to unindent line when converting to string + */ + public static final String INDENTCLOSE = "INDENTCLOSE"; + + /** + * Converts list of TreeItems to string + * + * @param tree List of TreeItem + * @param writer + * @param localData + * @return String + * @throws java.lang.InterruptedException + */ + public static GraphTextWriter graphToString(List tree, GraphTextWriter writer, LocalData localData) throws InterruptedException { + for (GraphTargetItem ti : tree) { + if (!ti.isEmpty()) { + ti.toStringSemicoloned(writer, localData).newLine(); + } + } + return writer; + } + + public BaseLocalData prepareBranchLocalData(BaseLocalData localData) { + return localData; + } + + protected List checkPrecoNextParts(GraphPart part) { + return null; + } + + protected GraphPart makeMultiPart(GraphPart part) { + List parts = new ArrayList<>(); + do { + parts.add(part); + if (part.nextParts.size() == 1 && part.nextParts.get(0).refs.size() == 1) { + part = part.nextParts.get(0); + } else { + part = null; + } + } while (part != null); + if (parts.size() > 1) { + GraphPartMulti ret = new GraphPartMulti(parts); + ret.refs.addAll(parts.get(0).refs); + ret.nextParts.addAll(parts.get(parts.size() - 1).nextParts); + return ret; + } else { + return parts.get(0); + } + } + + protected List getPartItems(GraphPart part) { + List ret = new ArrayList<>(); + do { + for (int i = 0; i < part.getHeight(); i++) { + if (part.getPosAt(i) < code.size()) { + if (part.getPosAt(i) < 0) { + continue; + } + GraphSourceItem s = code.get(part.getPosAt(i)); + if (!s.isJump()) { + ret.add(s); + } + } + } + if (part.nextParts.size() == 1 && part.nextParts.get(0).refs.size() == 1) { + part = part.nextParts.get(0); + } else { + part = null; + } + } while (part != null); + return ret; + } +} diff --git a/src/com/jpexs/decompiler/graph/GraphSource.java b/src/com/jpexs/decompiler/graph/GraphSource.java index 430cae0b8..88a015692 100644 --- a/src/com/jpexs/decompiler/graph/GraphSource.java +++ b/src/com/jpexs/decompiler/graph/GraphSource.java @@ -1,112 +1,111 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.graph; - -import com.jpexs.decompiler.flash.BaseLocalData; -import com.jpexs.decompiler.flash.action.Action; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -/** - * - * @author JPEXS - */ -public abstract class GraphSource implements Serializable { - - public abstract int size(); - - public abstract GraphSourceItem get(int pos); - - public abstract boolean isEmpty(); - - public abstract List translatePart(GraphPart part, BaseLocalData localData, Stack stack, int start, int end, int staticOperation, String path) throws InterruptedException; - - private void visitCode(int ip, int lastIp, HashMap> refs, int endIp) throws InterruptedException { - if (Thread.currentThread().isInterrupted()) { - throw new InterruptedException(); - } - boolean debugMode = false; - while (((endIp == -1) || (ip < endIp)) && (ip < size())) { - refs.get(ip).add(lastIp); - lastIp = ip; - if (refs.get(ip).size() > 1) { - break; - } - GraphSourceItem ins = get(ip); - - if (ins.isIgnored()) { - ip++; - continue; - } - if (debugMode) { - System.err.println("visit ip " + ip + " action:" + ins); - } - if (ins.isExit()) { - break; - } - - if (ins instanceof GraphSourceItemContainer) { - GraphSourceItemContainer cnt = (GraphSourceItemContainer) ins; - if (ins instanceof Action) { //TODO: Remove dependency of AVM1 - long endAddr = ((Action) ins).getAddress() + cnt.getHeaderSize(); - for (long size : cnt.getContainerSizes()) { - if (size != 0) { - visitCode(adr2pos(endAddr), ip, refs, adr2pos(endAddr + size)); - } - endAddr += size; - } - ip = adr2pos(endAddr); - continue; - } - - } - - if (ins.isBranch() || ins.isJump()) { - List branches = ins.getBranches(this); - for (int b : branches) { - if (b >= 0) { - visitCode(b, ip, refs, endIp); - } - } - break; - } - ip++; - }; - } - - public HashMap> visitCode(List alternateEntries) throws InterruptedException { - HashMap> refs = new HashMap<>(); - int siz = size(); - for (int i = 0; i < siz; i++) { - refs.put(i, new ArrayList()); - } - visitCode(0, 0, refs, -1); - int pos = 0; - for (int e : alternateEntries) { - pos++; - visitCode(e, -pos, refs, -1); - } - return refs; - } - - public abstract int adr2pos(long adr); - - public abstract long pos2adr(int pos); -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.graph; + +import com.jpexs.decompiler.flash.BaseLocalData; +import com.jpexs.decompiler.flash.action.Action; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +/** + * + * @author JPEXS + */ +public abstract class GraphSource implements Serializable { + + public abstract int size(); + + public abstract GraphSourceItem get(int pos); + + public abstract boolean isEmpty(); + + public abstract List translatePart(GraphPart part, BaseLocalData localData, TranslateStack stack, int start, int end, int staticOperation, String path) throws InterruptedException; + + private void visitCode(int ip, int lastIp, HashMap> refs, int endIp) throws InterruptedException { + if (Thread.currentThread().isInterrupted()) { + throw new InterruptedException(); + } + boolean debugMode = false; + while (((endIp == -1) || (ip < endIp)) && (ip < size())) { + refs.get(ip).add(lastIp); + lastIp = ip; + if (refs.get(ip).size() > 1) { + break; + } + GraphSourceItem ins = get(ip); + + if (ins.isIgnored()) { + ip++; + continue; + } + if (debugMode) { + System.err.println("visit ip " + ip + " action:" + ins); + } + if (ins.isExit()) { + break; + } + + if (ins instanceof GraphSourceItemContainer) { + GraphSourceItemContainer cnt = (GraphSourceItemContainer) ins; + if (ins instanceof Action) { //TODO: Remove dependency of AVM1 + long endAddr = ((Action) ins).getAddress() + cnt.getHeaderSize(); + for (long size : cnt.getContainerSizes()) { + if (size != 0) { + visitCode(adr2pos(endAddr), ip, refs, adr2pos(endAddr + size)); + } + endAddr += size; + } + ip = adr2pos(endAddr); + continue; + } + + } + + if (ins.isBranch() || ins.isJump()) { + List branches = ins.getBranches(this); + for (int b : branches) { + if (b >= 0) { + visitCode(b, ip, refs, endIp); + } + } + break; + } + ip++; + }; + } + + public HashMap> visitCode(List alternateEntries) throws InterruptedException { + HashMap> refs = new HashMap<>(); + int siz = size(); + for (int i = 0; i < siz; i++) { + refs.put(i, new ArrayList()); + } + visitCode(0, 0, refs, -1); + int pos = 0; + for (int e : alternateEntries) { + pos++; + visitCode(e, -pos, refs, -1); + } + return refs; + } + + public abstract int adr2pos(long adr); + + public abstract long pos2adr(int pos); +} diff --git a/src/com/jpexs/decompiler/graph/GraphSourceItem.java b/src/com/jpexs/decompiler/graph/GraphSourceItem.java index 89015dc96..baf4d9722 100644 --- a/src/com/jpexs/decompiler/graph/GraphSourceItem.java +++ b/src/com/jpexs/decompiler/graph/GraphSourceItem.java @@ -1,49 +1,48 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.graph; - -import com.jpexs.decompiler.flash.BaseLocalData; -import java.io.Serializable; -import java.util.List; -import java.util.Stack; - -/** - * - * @author JPEXS - */ -public interface GraphSourceItem extends Serializable { - - public void translate(BaseLocalData localData, Stack stack, List output, int staticOperation, String path) throws InterruptedException; - - public boolean isJump(); - - public boolean isBranch(); - - public boolean isExit(); - - public long getOffset(); - - public boolean ignoredLoops(); - - public List getBranches(GraphSource code); - - public boolean isIgnored(); - - public void setIgnored(boolean ignored, int pos); - - public boolean isDeobfuscatePop(); -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.graph; + +import com.jpexs.decompiler.flash.BaseLocalData; +import java.io.Serializable; +import java.util.List; + +/** + * + * @author JPEXS + */ +public interface GraphSourceItem extends Serializable { + + public void translate(BaseLocalData localData, TranslateStack stack, List output, int staticOperation, String path) throws InterruptedException; + + public boolean isJump(); + + public boolean isBranch(); + + public boolean isExit(); + + public long getOffset(); + + public boolean ignoredLoops(); + + public List getBranches(GraphSource code); + + public boolean isIgnored(); + + public void setIgnored(boolean ignored, int pos); + + public boolean isDeobfuscatePop(); +} diff --git a/src/com/jpexs/decompiler/graph/GraphSourceItemContainer.java b/src/com/jpexs/decompiler/graph/GraphSourceItemContainer.java index 01429b28d..c1eaaa45c 100644 --- a/src/com/jpexs/decompiler/graph/GraphSourceItemContainer.java +++ b/src/com/jpexs/decompiler/graph/GraphSourceItemContainer.java @@ -1,45 +1,44 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.graph; - -import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -/** - * - * @author JPEXS - */ -public interface GraphSourceItemContainer { - - public long getHeaderSize(); - - public List getContainerSizes(); - - public void setContainerSize(int index, long size); - - public String getASMSourceBetween(int pos); - - public boolean parseDivision(long size, FlasmLexer lexer); - - public HashMap getRegNames(); - - public void translateContainer(List> contents, Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions); - - public String getName(); -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.graph; + +import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; +import java.util.HashMap; +import java.util.List; + +/** + * + * @author JPEXS + */ +public interface GraphSourceItemContainer { + + public long getHeaderSize(); + + public List getContainerSizes(); + + public void setContainerSize(int index, long size); + + public String getASMSourceBetween(int pos); + + public boolean parseDivision(long size, FlasmLexer lexer); + + public HashMap getRegNames(); + + public void translateContainer(List> contents, TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions); + + public String getName(); +} diff --git a/src/com/jpexs/decompiler/graph/ScopeStack.java b/src/com/jpexs/decompiler/graph/ScopeStack.java new file mode 100644 index 000000000..0323bd599 --- /dev/null +++ b/src/com/jpexs/decompiler/graph/ScopeStack.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.graph; + +import java.util.Stack; + +/** + * + * @author JPEXS + */ +public class ScopeStack extends Stack { + +} diff --git a/src/com/jpexs/decompiler/graph/TranslateStack.java b/src/com/jpexs/decompiler/graph/TranslateStack.java new file mode 100644 index 000000000..8669c6d27 --- /dev/null +++ b/src/com/jpexs/decompiler/graph/TranslateStack.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.graph; + +import java.util.Stack; + +/** + * + * @author JPEXS + */ +public class TranslateStack extends Stack { + +} diff --git a/src/com/jpexs/helpers/Helper.java b/src/com/jpexs/helpers/Helper.java index 8e48abae4..3bf91a610 100644 --- a/src/com/jpexs/helpers/Helper.java +++ b/src/com/jpexs/helpers/Helper.java @@ -21,7 +21,7 @@ import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.helpers.Freed; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; -import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateStack; import com.jpexs.decompiler.graph.model.LocalData; import com.jpexs.helpers.utf8.Utf8Helper; import java.awt.Component; @@ -47,7 +47,6 @@ import java.util.BitSet; import java.util.Collection; import java.util.List; import java.util.Scanner; -import java.util.Stack; import java.util.logging.Level; import java.util.logging.Logger; import java.util.regex.Matcher; @@ -490,7 +489,7 @@ public class Helper { } } - public static String stackToString(Stack stack, LocalData localData) throws InterruptedException { + public static String stackToString(TranslateStack stack, LocalData localData) throws InterruptedException { String ret = "["; for (int i = stack.size() - 1; i >= 0; i--) { if (i < stack.size() - 1) { diff --git a/test/com/jpexs/decompiler/flash/ActionScript3Test.java b/test/com/jpexs/decompiler/flash/ActionScript3Test.java index 708307aea..9c5f96799 100644 --- a/test/com/jpexs/decompiler/flash/ActionScript3Test.java +++ b/test/com/jpexs/decompiler/flash/ActionScript3Test.java @@ -25,12 +25,11 @@ import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; import com.jpexs.decompiler.flash.helpers.NulWriter; import com.jpexs.decompiler.flash.tags.DoABCDefineTag; import com.jpexs.decompiler.flash.tags.Tag; -import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; import java.io.BufferedInputStream; import java.io.FileInputStream; import java.io.IOException; import java.util.ArrayList; -import java.util.Stack; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; @@ -73,9 +72,9 @@ public class ActionScript3Test extends ActionScriptTestBase { assertTrue(bodyIndex > -1); HilightedTextWriter writer = null; try { - abc.bodies.get(bodyIndex).convert(methodName, ScriptExportMode.AS, isStatic, -1/*FIX?*/, clsIndex, abc, null, abc.constants, abc.method_info, new Stack(), false, new NulWriter(), new ArrayList(), abc.instance_info.get(clsIndex).instance_traits, true); + abc.bodies.get(bodyIndex).convert(methodName, ScriptExportMode.AS, isStatic, -1/*FIX?*/, clsIndex, abc, null, abc.constants, abc.method_info, new ScopeStack(), false, new NulWriter(), new ArrayList(), abc.instance_info.get(clsIndex).instance_traits, true); writer = new HilightedTextWriter(new CodeFormatting(), false); - abc.bodies.get(bodyIndex).toString(methodName, ScriptExportMode.AS, isStatic, -1/*FIX?*/, clsIndex, abc, null, abc.constants, abc.method_info, new Stack(), false, writer, new ArrayList(), abc.instance_info.get(clsIndex).instance_traits); + abc.bodies.get(bodyIndex).toString(methodName, ScriptExportMode.AS, abc, null, abc.constants, abc.method_info, writer, new ArrayList()); } catch (InterruptedException ex) { fail(); } diff --git a/test/com/jpexs/decompiler/flash/generators/AS3Generator.java b/test/com/jpexs/decompiler/flash/generators/AS3Generator.java index 1c3423682..d775afec3 100644 --- a/test/com/jpexs/decompiler/flash/generators/AS3Generator.java +++ b/test/com/jpexs/decompiler/flash/generators/AS3Generator.java @@ -1,92 +1,91 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.generators; - -import com.jpexs.decompiler.flash.SWF; -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.traits.Trait; -import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter; -import com.jpexs.decompiler.flash.configuration.Configuration; -import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; -import com.jpexs.decompiler.flash.helpers.CodeFormatting; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; -import com.jpexs.decompiler.flash.helpers.NulWriter; -import com.jpexs.decompiler.flash.tags.DoABCDefineTag; -import com.jpexs.decompiler.flash.tags.Tag; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.io.BufferedInputStream; -import java.io.FileInputStream; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.Stack; - -/** - * - * Generates stub for ActionScript3Test - * - * @author JPEXS - */ -public class AS3Generator { - - public static void main(String[] args) throws Exception { - Configuration.autoDeobfuscate.set(false); - SWF swf = new SWF(new BufferedInputStream(new FileInputStream("testdata/as3/as3.swf")), false); - DoABCDefineTag tag = null; - for (Tag t : swf.tags) { - if (t instanceof DoABCDefineTag) { - tag = (DoABCDefineTag) t; - break; - } - } - ABC abc = tag.getABC(); - int classId = abc.findClassByName("classes.Test"); - StringBuilder s = new StringBuilder(); - for (Trait t : abc.instance_info.get(classId).instance_traits.traits) { - if (t instanceof TraitMethodGetterSetter) { - String name = t.getName(abc).getName(abc.constants, new ArrayList()); - if (name.startsWith("test")) { - s.append("@Test\r\npublic void "); - s.append(name); - s.append("(){\r\ndecompileMethod(\""); - s.append(name); - s.append("\", "); - HilightedTextWriter src = new HilightedTextWriter(new CodeFormatting(), false); - MethodBody b = abc.findBody(((TraitMethodGetterSetter) t).method_info); - b.convert("", ScriptExportMode.AS, false, -1/*FIX?*/, classId, abc, null, abc.constants, abc.method_info, new Stack(), false, new NulWriter(), new ArrayList(), abc.instance_info.get(classId).instance_traits, true); - b.toString("", ScriptExportMode.AS, false, -1/*FIX?*/, classId, abc, null, abc.constants, abc.method_info, new Stack(), false, src, new ArrayList(), abc.instance_info.get(classId).instance_traits); - String[] srcs = src.toString().split("[\r\n]+"); - for (int i = 0; i < srcs.length; i++) { - String ss = srcs[i]; - s.append("\""); - s.append(ss.trim().replace("\\", "\\\\").replace("\"", "\\\"")); - s.append("\\r\\n\""); - if (i < srcs.length - 1) { - s.append("+"); - } - s.append("\r\n"); - } - s.append(", false);"); - s.append("}"); - } - } - try (PrintWriter pw = new PrintWriter("as3_teststub.java")) { - pw.println(s.toString()); - } - } - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.generators; + +import com.jpexs.decompiler.flash.SWF; +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.traits.Trait; +import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter; +import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; +import com.jpexs.decompiler.flash.helpers.CodeFormatting; +import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.NulWriter; +import com.jpexs.decompiler.flash.tags.DoABCDefineTag; +import com.jpexs.decompiler.flash.tags.Tag; +import com.jpexs.decompiler.graph.ScopeStack; +import java.io.BufferedInputStream; +import java.io.FileInputStream; +import java.io.PrintWriter; +import java.util.ArrayList; + +/** + * + * Generates stub for ActionScript3Test + * + * @author JPEXS + */ +public class AS3Generator { + + public static void main(String[] args) throws Exception { + Configuration.autoDeobfuscate.set(false); + SWF swf = new SWF(new BufferedInputStream(new FileInputStream("testdata/as3/as3.swf")), false); + DoABCDefineTag tag = null; + for (Tag t : swf.tags) { + if (t instanceof DoABCDefineTag) { + tag = (DoABCDefineTag) t; + break; + } + } + ABC abc = tag.getABC(); + int classId = abc.findClassByName("classes.Test"); + StringBuilder s = new StringBuilder(); + for (Trait t : abc.instance_info.get(classId).instance_traits.traits) { + if (t instanceof TraitMethodGetterSetter) { + String name = t.getName(abc).getName(abc.constants, new ArrayList()); + if (name.startsWith("test")) { + s.append("@Test\r\npublic void "); + s.append(name); + s.append("(){\r\ndecompileMethod(\""); + s.append(name); + s.append("\", "); + HilightedTextWriter src = new HilightedTextWriter(new CodeFormatting(), false); + MethodBody b = abc.findBody(((TraitMethodGetterSetter) t).method_info); + b.convert("", ScriptExportMode.AS, false, -1/*FIX?*/, classId, abc, null, abc.constants, abc.method_info, new ScopeStack(), false, new NulWriter(), new ArrayList(), abc.instance_info.get(classId).instance_traits, true); + b.toString("", ScriptExportMode.AS, abc, null, abc.constants, abc.method_info, src, new ArrayList()); + String[] srcs = src.toString().split("[\r\n]+"); + for (int i = 0; i < srcs.length; i++) { + String ss = srcs[i]; + s.append("\""); + s.append(ss.trim().replace("\\", "\\\\").replace("\"", "\\\"")); + s.append("\\r\\n\""); + if (i < srcs.length - 1) { + s.append("+"); + } + s.append("\r\n"); + } + s.append(", false);"); + s.append("}"); + } + } + try (PrintWriter pw = new PrintWriter("as3_teststub.java")) { + pw.println(s.toString()); + } + } + } +}