mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-17 13:48:13 +00:00
AS3: Fixed inline functions
AS3: Fixed hiding assignements bug AS3: Static initializer does not show initialization of static variables/consts AS3: Better imports
This commit is contained in:
@@ -371,7 +371,7 @@ public class ABC {
|
||||
}
|
||||
}
|
||||
|
||||
private void parseImportFromMultiname(List imports, Multiname m) {
|
||||
private void parseImportFromMultiname(List imports, Multiname m, String ignorePackage) {
|
||||
if (m != null) {
|
||||
Namespace ns = m.getNamespace(constants);
|
||||
String name = m.getName(constants);
|
||||
@@ -386,7 +386,10 @@ public class ABC {
|
||||
return;
|
||||
}
|
||||
if (!imports.contains(newimport)) {
|
||||
imports.add(newimport);
|
||||
String pkg = newimport.substring(0,newimport.lastIndexOf("."));
|
||||
if (!pkg.equals(ignorePackage)) {
|
||||
imports.add(newimport);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -400,69 +403,106 @@ public class ABC {
|
||||
|
||||
//parseImportFromMultiname(imports, constants.constant_multiname[instance_info[instanceIndex].name_index]);
|
||||
|
||||
String packageName = instance_info[instanceIndex].getName(constants).getNamespace(constants).getName(constants);
|
||||
|
||||
if (instance_info[instanceIndex].super_index > 0) {
|
||||
parseImportFromMultiname(imports, constants.constant_multiname[instance_info[instanceIndex].super_index]);
|
||||
parseImportFromMultiname(imports, constants.constant_multiname[instance_info[instanceIndex].super_index],packageName);
|
||||
}
|
||||
for (int i : instance_info[instanceIndex].interfaces) {
|
||||
parseImportFromMultiname(imports, constants.constant_multiname[i]);
|
||||
parseImportFromMultiname(imports, constants.constant_multiname[i],packageName);
|
||||
}
|
||||
|
||||
|
||||
MethodBody body;
|
||||
|
||||
|
||||
|
||||
|
||||
//static
|
||||
for (Trait t : class_info[instanceIndex].static_traits.traits) {
|
||||
//parseImportFromMultiname(imports, t.getMultiName(constants));
|
||||
if (t instanceof TraitMethodGetterSetter) {
|
||||
TraitMethodGetterSetter tm = (TraitMethodGetterSetter) t;
|
||||
if (tm.method_info != 0) {
|
||||
MethodBody body = findBody(tm.method_info);
|
||||
body = findBody(tm.method_info);
|
||||
if (body != null) {
|
||||
for (AVM2Instruction ins : body.code.code) {
|
||||
for (int k = 0; k < ins.definition.operands.length; k++) {
|
||||
if (ins.definition.operands[k] == AVM2Code.DAT_MULTINAME_INDEX) {
|
||||
int multinameIndex = ins.operands[k];
|
||||
parseImportFromMultiname(imports, constants.constant_multiname[multinameIndex]);
|
||||
parseImportFromMultiname(imports, constants.constant_multiname[multinameIndex],packageName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int p = 0; p < method_info[tm.method_info].param_types.length; p++) {
|
||||
if (method_info[tm.method_info].param_types[p] != 0) {
|
||||
parseImportFromMultiname(imports, constants.constant_multiname[method_info[tm.method_info].param_types[p]]);
|
||||
parseImportFromMultiname(imports, constants.constant_multiname[method_info[tm.method_info].param_types[p]],packageName);
|
||||
}
|
||||
if (method_info[tm.method_info].ret_type != 0) {
|
||||
parseImportFromMultiname(imports, constants.constant_multiname[method_info[tm.method_info].ret_type]);
|
||||
parseImportFromMultiname(imports, constants.constant_multiname[method_info[tm.method_info].ret_type],packageName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//static initializer
|
||||
body = findBody(class_info[instanceIndex].cinit_index);
|
||||
if (body != null) {
|
||||
for (AVM2Instruction ins : body.code.code) {
|
||||
for (int k = 0; k < ins.definition.operands.length; k++) {
|
||||
if (ins.definition.operands[k] == AVM2Code.DAT_MULTINAME_INDEX) {
|
||||
int multinameIndex = ins.operands[k];
|
||||
parseImportFromMultiname(imports, constants.constant_multiname[multinameIndex],packageName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//instance
|
||||
for (Trait t : instance_info[instanceIndex].instance_traits.traits) {
|
||||
//parseImportFromMultiname(imports, t.getMultiName(constants));
|
||||
if (t instanceof TraitMethodGetterSetter) {
|
||||
TraitMethodGetterSetter tm = (TraitMethodGetterSetter) t;
|
||||
if (tm.method_info != 0) {
|
||||
MethodBody body = findBody(tm.method_info);
|
||||
body = findBody(tm.method_info);
|
||||
if (body != null) {
|
||||
for (AVM2Instruction ins : body.code.code) {
|
||||
for (int k = 0; k < ins.definition.operands.length; k++) {
|
||||
if (ins.definition.operands[k] == AVM2Code.DAT_MULTINAME_INDEX) {
|
||||
int multinameIndex = ins.operands[k];
|
||||
parseImportFromMultiname(imports, constants.constant_multiname[multinameIndex]);
|
||||
parseImportFromMultiname(imports, constants.constant_multiname[multinameIndex],packageName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int p = 0; p < method_info[tm.method_info].param_types.length; p++) {
|
||||
if (method_info[tm.method_info].param_types[p] != 0) {
|
||||
parseImportFromMultiname(imports, constants.constant_multiname[method_info[tm.method_info].param_types[p]]);
|
||||
parseImportFromMultiname(imports, constants.constant_multiname[method_info[tm.method_info].param_types[p]],packageName);
|
||||
}
|
||||
if (method_info[tm.method_info].ret_type != 0) {
|
||||
parseImportFromMultiname(imports, constants.constant_multiname[method_info[tm.method_info].ret_type]);
|
||||
parseImportFromMultiname(imports, constants.constant_multiname[method_info[tm.method_info].ret_type],packageName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//instance initializer
|
||||
body = findBody(instance_info[instanceIndex].iinit_index);
|
||||
if (body != null) {
|
||||
for (AVM2Instruction ins : body.code.code) {
|
||||
for (int k = 0; k < ins.definition.operands.length; k++) {
|
||||
if (ins.definition.operands[k] == AVM2Code.DAT_MULTINAME_INDEX) {
|
||||
int multinameIndex = ins.operands[k];
|
||||
parseImportFromMultiname(imports, constants.constant_multiname[multinameIndex],packageName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return imports;
|
||||
}
|
||||
|
||||
@@ -681,16 +721,18 @@ public class ABC {
|
||||
String bodyStr = "";
|
||||
int bodyIndex = findBodyIndex(class_info[i].cinit_index);
|
||||
if (bodyIndex != -1) {
|
||||
bodyStr = addTabs(bodies[bodyIndex].toString(pcode, true, i, this, constants, method_info, new Stack<TreeItem>(), highlight), 3);
|
||||
bodyStr = bodies[bodyIndex].toString(pcode, true, i, this, constants, method_info, new Stack<TreeItem>(), true, highlight);
|
||||
}
|
||||
if (Highlighting.stripHilights(bodyStr).equals("")) {
|
||||
toPrint = addTabs(bodyStr, 3);
|
||||
} else {
|
||||
toPrint = IDENT_STRING + IDENT_STRING + "{\r\n" + addTabs(bodyStr, 3) + "\r\n" + IDENT_STRING + IDENT_STRING + "}";
|
||||
}
|
||||
// if (!bodyStr.equals("")) {
|
||||
toPrint = IDENT_STRING + IDENT_STRING + "{\r\n" + bodyStr + "\r\n" + IDENT_STRING + IDENT_STRING + "}";
|
||||
if (highlight) {
|
||||
toPrint = Highlighting.hilighTrait(toPrint, class_info[i].static_traits.traits.length + instance_info[i].instance_traits.traits.length + 1);
|
||||
}
|
||||
outTraits.add(toPrint);
|
||||
//}
|
||||
//}
|
||||
|
||||
//constructor
|
||||
//if (instance_info[i].iinit_index != 0) {
|
||||
@@ -710,7 +752,7 @@ public class ABC {
|
||||
bodyStr = "";
|
||||
bodyIndex = findBodyIndex(instance_info[i].iinit_index);
|
||||
if (bodyIndex != -1) {
|
||||
bodyStr = addTabs(bodies[bodyIndex].toString(pcode, false, i, this, constants, method_info, new Stack<TreeItem>(), highlight), 3);
|
||||
bodyStr = addTabs(bodies[bodyIndex].toString(pcode, false, i, this, constants, method_info, new Stack<TreeItem>(), false, highlight), 3);
|
||||
constructorParams = method_info[instance_info[i].iinit_index].getParamStr(constants, bodies[bodyIndex], this);
|
||||
} else {
|
||||
constructorParams = method_info[instance_info[i].iinit_index].getParamStr(constants, null, this);
|
||||
@@ -731,7 +773,7 @@ public class ABC {
|
||||
bodyStr = "";
|
||||
bodyIndex = findBodyIndex(tm.method_info);
|
||||
if (bodyIndex != -1) {
|
||||
bodyStr = addTabs(bodies[bodyIndex].toString(pcode, true, i, this, constants, method_info, new Stack<TreeItem>(), highlight), 3);
|
||||
bodyStr = addTabs(bodies[bodyIndex].toString(pcode, true, i, this, constants, method_info, new Stack<TreeItem>(), false, highlight), 3);
|
||||
}
|
||||
toPrint = IDENT_STRING + IDENT_STRING + tm.convert(method_info, this, true) + " {\r\n" + bodyStr + "\r\n" + IDENT_STRING + IDENT_STRING + "}";
|
||||
}
|
||||
@@ -760,7 +802,7 @@ public class ABC {
|
||||
bodyStr = "";
|
||||
bodyIndex = findBodyIndex(tm.method_info);
|
||||
if (bodyIndex != -1) {
|
||||
bodyStr = addTabs(bodies[bodyIndex].toString(pcode, false, i, this, constants, method_info, new Stack<TreeItem>(), highlight), 3);
|
||||
bodyStr = addTabs(bodies[bodyIndex].toString(pcode, false, i, this, constants, method_info, new Stack<TreeItem>(), false, highlight), 3);
|
||||
}
|
||||
toPrint = IDENT_STRING + IDENT_STRING + tm.convert(method_info, this, false) + " {\r\n" + bodyStr + "\r\n" + IDENT_STRING + IDENT_STRING + "}";
|
||||
}
|
||||
|
||||
@@ -1610,8 +1610,8 @@ public class AVM2Code {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public String toSource(boolean isStatic, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[], MethodBody body, HashMap<Integer, String> localRegNames, Stack<TreeItem> scopeStack) {
|
||||
return toSource(isStatic, classIndex, abc, constants, method_info, body, false, localRegNames, scopeStack);
|
||||
public String toSource(boolean isStatic, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[], MethodBody body, HashMap<Integer, String> localRegNames, Stack<TreeItem> scopeStack,boolean isStaticInitializer) {
|
||||
return toSource(isStatic, classIndex, abc, constants, method_info, body, false, localRegNames, scopeStack,isStaticInitializer);
|
||||
}
|
||||
|
||||
public List<TreeItem> toTree(boolean isStatic, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[], MethodBody body, HashMap<Integer, String> localRegNames) {
|
||||
@@ -1689,7 +1689,7 @@ public class AVM2Code {
|
||||
}
|
||||
}
|
||||
|
||||
public String toSource(boolean isStatic, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[], MethodBody body, boolean hilighted, HashMap<Integer, String> localRegNames, Stack<TreeItem> scopeStack) {
|
||||
public String toSource(boolean isStatic, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[], MethodBody body, boolean hilighted, HashMap<Integer, String> localRegNames, Stack<TreeItem> scopeStack,boolean isStaticInitializer) {
|
||||
toSourceCount = 0;
|
||||
loopList = new ArrayList<Loop>();
|
||||
unknownJumps = new ArrayList<Integer>();
|
||||
@@ -1712,7 +1712,23 @@ public class AVM2Code {
|
||||
|
||||
try {
|
||||
list = toSource(isStatic, classIndex, localRegs, new Stack<TreeItem>(), scopeStack, abc, constants, method_info, body, 0, code.size() - 1, localRegNames).output;
|
||||
|
||||
if(isStaticInitializer){
|
||||
|
||||
List<TreeItem> newList=new ArrayList<TreeItem>();
|
||||
for(TreeItem ti:list){
|
||||
if(!(ti instanceof ReturnVoidTreeItem)){
|
||||
if(!(ti instanceof InitPropertyTreeItem)){
|
||||
if(!(ti instanceof SetPropertyTreeItem)){
|
||||
newList.add(ti);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
list=newList;
|
||||
if(list.isEmpty()){
|
||||
return "";
|
||||
}
|
||||
}
|
||||
//Declarations
|
||||
boolean declaredRegisters[] = new boolean[regCount];
|
||||
for (int b = 0; b < declaredRegisters.length; b++) {
|
||||
|
||||
@@ -43,7 +43,7 @@ public class NewFunctionIns extends InstructionDefinition {
|
||||
String bodyStr = "";
|
||||
String paramStr = "";
|
||||
if (mybody != null) {
|
||||
bodyStr = Highlighting.hilighMethodEnd() + mybody.toString(false, isStatic, classIndex, abc, constants, method_info, scopeStack, true) + Highlighting.hilighMethodBegin(body.method_info);
|
||||
bodyStr = Highlighting.hilighMethodEnd() + mybody.toString(false, isStatic, classIndex, abc, constants, method_info, new Stack<TreeItem>()/*scopeStack*/, false,true) + Highlighting.hilighMethodBegin(body.method_info);
|
||||
paramStr = method_info[methodIndex].getParamStr(constants, mybody, abc);
|
||||
}
|
||||
stack.push(new NewFunctionTreeItem(ins, paramStr, method_info[methodIndex].getReturnTypeStr(constants), bodyStr));
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.ClassTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
import java.util.HashMap;
|
||||
@@ -40,6 +41,10 @@ public class GetGlobalScopeIns extends InstructionDefinition {
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap<Integer, String> localRegNames) {
|
||||
if(scopeStack.isEmpty()){
|
||||
stack.push(new ClassTreeItem(abc.instance_info[classIndex].getName(constants)));
|
||||
return;
|
||||
}
|
||||
stack.push(scopeStack.get(0));
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public class GetScopeObjectIns extends InstructionDefinition {
|
||||
/* System.out.println("Getting scope object"+index+":");
|
||||
for(TreeItem ti:scopeStack){
|
||||
System.out.println(ti.toString(constants));
|
||||
}*/
|
||||
}*/
|
||||
stack.push(scopeStack.get(index));
|
||||
}
|
||||
|
||||
|
||||
@@ -66,12 +66,9 @@ public class SetSlotIns extends InstructionDefinition implements SetTypeIns {
|
||||
|
||||
}
|
||||
|
||||
//if new activation sets params of the function
|
||||
if (obj.getThroughRegister() instanceof NewActivationTreeItem) {
|
||||
if (localRegNames.containsValue(slotname.getName(constants))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (localRegNames.containsValue(slotname.getName(constants))) {
|
||||
return;
|
||||
};
|
||||
|
||||
if (value.getNotCoerced() instanceof IncrementTreeItem) {
|
||||
TreeItem inside = ((IncrementTreeItem) value.getNotCoerced()).object.getThroughRegister().getNotCoerced();
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.jpexs.asdec.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.*;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.clauses.AssignmentTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -52,6 +53,8 @@ public class PopIns extends InstructionDefinition {
|
||||
output.add(top);
|
||||
} else if (top instanceof CallTreeItem) {
|
||||
output.add(top);
|
||||
} else if (top instanceof AssignmentTreeItem) {
|
||||
output.add(top);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,9 +18,10 @@ package com.jpexs.asdec.abc.avm2.treemodel;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.clauses.AssignmentTreeItem;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class InitPropertyTreeItem extends TreeItem implements SetTypeTreeItem {
|
||||
public class InitPropertyTreeItem extends TreeItem implements SetTypeTreeItem,AssignmentTreeItem {
|
||||
|
||||
public TreeItem object;
|
||||
public FullMultinameTreeItem propertyName;
|
||||
|
||||
@@ -18,9 +18,10 @@ package com.jpexs.asdec.abc.avm2.treemodel;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.clauses.AssignmentTreeItem;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class PostDecrementTreeItem extends TreeItem {
|
||||
public class PostDecrementTreeItem extends TreeItem implements AssignmentTreeItem {
|
||||
|
||||
public TreeItem object;
|
||||
|
||||
|
||||
@@ -18,9 +18,10 @@ package com.jpexs.asdec.abc.avm2.treemodel;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.clauses.AssignmentTreeItem;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class PostIncrementTreeItem extends TreeItem {
|
||||
public class PostIncrementTreeItem extends TreeItem implements AssignmentTreeItem {
|
||||
|
||||
public TreeItem object;
|
||||
|
||||
|
||||
@@ -18,9 +18,10 @@ package com.jpexs.asdec.abc.avm2.treemodel;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.clauses.AssignmentTreeItem;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class SetLocalTreeItem extends TreeItem implements SetTypeTreeItem {
|
||||
public class SetLocalTreeItem extends TreeItem implements SetTypeTreeItem,AssignmentTreeItem {
|
||||
|
||||
public int regIndex;
|
||||
public TreeItem value;
|
||||
|
||||
@@ -18,9 +18,10 @@ package com.jpexs.asdec.abc.avm2.treemodel;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.clauses.AssignmentTreeItem;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class SetPropertyTreeItem extends TreeItem implements SetTypeTreeItem {
|
||||
public class SetPropertyTreeItem extends TreeItem implements SetTypeTreeItem,AssignmentTreeItem {
|
||||
|
||||
public TreeItem object;
|
||||
public FullMultinameTreeItem propertyName;
|
||||
|
||||
@@ -18,10 +18,11 @@ package com.jpexs.asdec.abc.avm2.treemodel;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.clauses.AssignmentTreeItem;
|
||||
import com.jpexs.asdec.abc.types.Multiname;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class SetSlotTreeItem extends TreeItem implements SetTypeTreeItem {
|
||||
public class SetSlotTreeItem extends TreeItem implements SetTypeTreeItem,AssignmentTreeItem {
|
||||
|
||||
public Multiname slotName;
|
||||
public TreeItem value;
|
||||
@@ -36,8 +37,14 @@ public class SetSlotTreeItem extends TreeItem implements SetTypeTreeItem {
|
||||
|
||||
@Override
|
||||
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames) {
|
||||
|
||||
return getName(constants,localRegNames)+ hilight("=") + value.toString(constants, localRegNames);
|
||||
}
|
||||
|
||||
public String getName(ConstantPool constants, HashMap<Integer, String> localRegNames){
|
||||
String ret = "";
|
||||
|
||||
/*ret = scope.toString(constants, localRegNames) + ".";
|
||||
if (!(scope instanceof NewActivationTreeItem)) {
|
||||
ret = scope.toString(constants, localRegNames) + ".";
|
||||
}
|
||||
@@ -47,8 +54,8 @@ public class SetSlotTreeItem extends TreeItem implements SetTypeTreeItem {
|
||||
ret = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret + hilight(slotName.getName(constants)) + hilight("=") + value.toString(constants, localRegNames);
|
||||
}*/
|
||||
return ret + hilight(slotName.getName(constants));
|
||||
}
|
||||
|
||||
public TreeItem getObject() {
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2012 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 2
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
package com.jpexs.asdec.abc.avm2.treemodel.clauses;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public interface AssignmentTreeItem {
|
||||
|
||||
}
|
||||
@@ -60,19 +60,8 @@ public class DeclarationTreeItem extends TreeItem {
|
||||
return "var " + hilight(localRegName(localRegNames, lti.regIndex) + ":" + type + " = ") + lti.value.toString(constants, localRegNames);
|
||||
}
|
||||
if (assignment instanceof SetSlotTreeItem) {
|
||||
SetSlotTreeItem ssti = (SetSlotTreeItem) assignment;
|
||||
String ret = "";
|
||||
if (!(ssti.scope instanceof NewActivationTreeItem)) {
|
||||
ret = ssti.scope.toString(constants, localRegNames) + ".";
|
||||
}
|
||||
if (ssti.scope instanceof LocalRegTreeItem) {
|
||||
if (((LocalRegTreeItem) ssti.scope).computedValue != null) {
|
||||
if (((LocalRegTreeItem) ssti.scope).computedValue instanceof NewActivationTreeItem) {
|
||||
ret = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
return "var " + ret + hilight(ssti.slotName.getName(constants)) + ":" + type + hilight(" = ") + ssti.value.toString(constants, localRegNames);
|
||||
SetSlotTreeItem ssti = (SetSlotTreeItem) assignment;
|
||||
return "var " + ssti.getName(constants, localRegNames) + ":" + type + hilight(" = ") + ssti.value.toString(constants, localRegNames);
|
||||
}
|
||||
return "var " + assignment.toString(constants, localRegNames);
|
||||
}
|
||||
|
||||
@@ -30,18 +30,20 @@ public class ForEachInTreeItem extends LoopTreeItem implements Block {
|
||||
|
||||
public ForEachInTreeItem(AVM2Instruction instruction, int loopBreak, int loopContinue, InTreeItem expression, List<TreeItem> commands) {
|
||||
super(instruction, loopBreak, loopContinue);
|
||||
TreeItem firstAssign = commands.get(0);
|
||||
if (firstAssign instanceof SetTypeTreeItem) {
|
||||
if (expression.object instanceof LocalRegTreeItem) {
|
||||
if (((SetTypeTreeItem) firstAssign).getValue().getNotCoerced() instanceof LocalRegTreeItem) {
|
||||
if (((LocalRegTreeItem) ((SetTypeTreeItem) firstAssign).getValue().getNotCoerced()).regIndex == ((LocalRegTreeItem) expression.object).regIndex) {
|
||||
commands.remove(0);
|
||||
expression.object = ((SetTypeTreeItem) firstAssign).getObject();
|
||||
if (!commands.isEmpty()) {
|
||||
TreeItem firstAssign = commands.get(0);
|
||||
if (firstAssign instanceof SetTypeTreeItem) {
|
||||
if (expression.object instanceof LocalRegTreeItem) {
|
||||
if (((SetTypeTreeItem) firstAssign).getValue().getNotCoerced() instanceof LocalRegTreeItem) {
|
||||
if (((LocalRegTreeItem) ((SetTypeTreeItem) firstAssign).getValue().getNotCoerced()).regIndex == ((LocalRegTreeItem) expression.object).regIndex) {
|
||||
commands.remove(0);
|
||||
expression.object = ((SetTypeTreeItem) firstAssign).getObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//locAssign.
|
||||
}
|
||||
//locAssign.
|
||||
}
|
||||
this.expression = expression;
|
||||
this.commands = commands;
|
||||
|
||||
@@ -30,18 +30,20 @@ public class ForInTreeItem extends LoopTreeItem implements Block {
|
||||
|
||||
public ForInTreeItem(AVM2Instruction instruction, int loopBreak, int loopContinue, InTreeItem expression, List<TreeItem> commands) {
|
||||
super(instruction, loopBreak, loopContinue);
|
||||
TreeItem firstAssign = commands.get(0);
|
||||
if (firstAssign instanceof SetTypeTreeItem) {
|
||||
if (expression.object instanceof LocalRegTreeItem) {
|
||||
if (((SetTypeTreeItem) firstAssign).getValue().getNotCoerced() instanceof LocalRegTreeItem) {
|
||||
if (((LocalRegTreeItem) ((SetTypeTreeItem) firstAssign).getValue().getNotCoerced()).regIndex == ((LocalRegTreeItem) expression.object).regIndex) {
|
||||
commands.remove(0);
|
||||
expression.object = ((SetTypeTreeItem) firstAssign).getObject();
|
||||
if (!commands.isEmpty()) {
|
||||
TreeItem firstAssign = commands.get(0);
|
||||
if (firstAssign instanceof SetTypeTreeItem) {
|
||||
if (expression.object instanceof LocalRegTreeItem) {
|
||||
if (((SetTypeTreeItem) firstAssign).getValue().getNotCoerced() instanceof LocalRegTreeItem) {
|
||||
if (((LocalRegTreeItem) ((SetTypeTreeItem) firstAssign).getValue().getNotCoerced()).regIndex == ((LocalRegTreeItem) expression.object).regIndex) {
|
||||
commands.remove(0);
|
||||
expression.object = ((SetTypeTreeItem) firstAssign).getObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//locAssign.
|
||||
}
|
||||
//locAssign.
|
||||
}
|
||||
this.expression = expression;
|
||||
this.commands = commands;
|
||||
|
||||
@@ -18,8 +18,9 @@ package com.jpexs.asdec.abc.avm2.treemodel.operations;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.clauses.AssignmentTreeItem;
|
||||
|
||||
public class PreDecrementTreeItem extends UnaryOpTreeItem {
|
||||
public class PreDecrementTreeItem extends UnaryOpTreeItem implements AssignmentTreeItem {
|
||||
|
||||
public PreDecrementTreeItem(AVM2Instruction instruction, TreeItem object) {
|
||||
super(instruction, PRECEDENCE_UNARY, object, "--");
|
||||
|
||||
@@ -73,11 +73,11 @@ public class MethodBody implements Cloneable {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public String toString(boolean pcode, boolean isStatic, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[], Stack<TreeItem> scopeStack) {
|
||||
return toString(pcode, isStatic, classIndex, abc, constants, method_info, scopeStack, false);
|
||||
}
|
||||
/*public String toString(boolean pcode, boolean isStatic, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[], Stack<TreeItem> scopeStack, boolean isStaticInitializer) {
|
||||
return toString(pcode, isStatic, classIndex, abc, constants, method_info, scopeStack, isStaticInitializer,false);
|
||||
}*/
|
||||
|
||||
public String toString(boolean pcode, boolean isStatic, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[], Stack<TreeItem> scopeStack, boolean hilight) {
|
||||
public String toString(boolean pcode, boolean isStatic, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[], Stack<TreeItem> scopeStack, boolean isStaticInitializer,boolean hilight) {
|
||||
String s = "";
|
||||
|
||||
//s+="method_info="+method_info+" max_stack="+max_stack+" max_regs="+max_regs+" scope_depth="+scope_depth+" max_scope="+max_scope;
|
||||
@@ -86,7 +86,7 @@ public class MethodBody implements Cloneable {
|
||||
s += code.toASMSource(constants, this);
|
||||
} else {
|
||||
try {
|
||||
s += code.toSource(isStatic, classIndex, abc, constants, method_info, this, hilight, getLocalRegNames(abc), scopeStack);
|
||||
s += code.toSource(isStatic, classIndex, abc, constants, method_info, this, hilight, getLocalRegNames(abc), scopeStack,isStaticInitializer);
|
||||
s = s.trim();
|
||||
if (hilight) {
|
||||
s = Highlighting.hilighMethod(s, this.method_info);
|
||||
|
||||
Reference in New Issue
Block a user