AS2:Fixed Ifs, Added For..in, better Functions

This commit is contained in:
Jindra Pet��k
2010-09-06 15:32:07 +02:00
parent fafbbc4add
commit d0b5bf3559
102 changed files with 270 additions and 136 deletions
+81 -33
View File
@@ -6,6 +6,7 @@ import com.jpexs.asdec.action.parser.ParseException;
import com.jpexs.asdec.action.parser.ParsedSymbol; import com.jpexs.asdec.action.parser.ParsedSymbol;
import com.jpexs.asdec.action.swf4.*; import com.jpexs.asdec.action.swf4.*;
import com.jpexs.asdec.action.swf5.*; import com.jpexs.asdec.action.swf5.*;
import com.jpexs.asdec.action.swf6.ActionEnumerate2;
import com.jpexs.asdec.action.swf6.ActionStrictEquals; import com.jpexs.asdec.action.swf6.ActionStrictEquals;
import com.jpexs.asdec.action.swf7.ActionDefineFunction2; import com.jpexs.asdec.action.swf7.ActionDefineFunction2;
import com.jpexs.asdec.action.swf7.ActionTry; import com.jpexs.asdec.action.swf7.ActionTry;
@@ -21,6 +22,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.EmptyStackException; import java.util.EmptyStackException;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Stack; import java.util.Stack;
@@ -379,8 +381,9 @@ public class Action {
* @param stack Stack * @param stack Stack
* @param constants Constant pool * @param constants Constant pool
* @param output Output * @param output Output
* @param regNames Register names
*/ */
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
} }
@@ -541,24 +544,25 @@ public class Action {
* @return String with Source code * @return String with Source code
*/ */
public static String actionsToSource(List<Action> actions, int version) { public static String actionsToSource(List<Action> actions, int version) {
List<TreeItem> tree = actionsToTree(actions, version); List<TreeItem> tree = actionsToTree(new HashMap<Integer,String>(),actions, version);
return treeToString(tree); return treeToString(tree);
} }
/** /**
* Converts list of actions to List of treeItems * Converts list of actions to List of treeItems
* *
* @param regNames Register names
* @param actions List of actions * @param actions List of actions
* @param version SWF version * @param version SWF version
* @return List of treeItems * @return List of treeItems
*/ */
public static List<TreeItem> actionsToTree(List<Action> actions, int version) { public static List<TreeItem> actionsToTree(HashMap<Integer,String> regNames,List<Action> actions, int version) {
return actionsToTree(new ArrayList<Long>(), new ArrayList<Loop>(), getActionsAllIfsOrJumps(actions), new Stack<TreeItem>(), new ConstantPool(), actions, 0, actions.size() - 1, version); return actionsToTree(regNames,new ArrayList<Long>(), new ArrayList<Loop>(), getActionsAllIfsOrJumps(actions), new Stack<TreeItem>(), new ConstantPool(), actions, 0, actions.size() - 1, version);
} }
private static Stack<TreeItem> actionsToStackTree(List<Action> jumpsOrIfs, List<Action> actions, ConstantPool constants, int start, int end, int version) { private static Stack<TreeItem> actionsToStackTree(HashMap<Integer,String> regNames,List<Action> jumpsOrIfs, List<Action> actions, ConstantPool constants, int start, int end, int version) {
Stack<TreeItem> ret = new Stack<TreeItem>(); Stack<TreeItem> ret = new Stack<TreeItem>();
actionsToTree(new ArrayList<Long>(), new ArrayList<Loop>(), jumpsOrIfs, ret, constants, actions, start, end, version); actionsToTree(regNames,new ArrayList<Long>(), new ArrayList<Loop>(), jumpsOrIfs, ret, constants, actions, start, end, version);
return ret; return ret;
} }
@@ -576,10 +580,12 @@ public class Action {
} }
} }
private static List<TreeItem> actionsToTree(List<Long> unknownJumps, List<Loop> loopList, List<Action> jumpsOrIfs, Stack<TreeItem> stack, ConstantPool constants, List<Action> actions, int start, int end, int version) { private static List<TreeItem> actionsToTree(HashMap<Integer,String> registerNames,List<Long> unknownJumps, List<Loop> loopList, List<Action> jumpsOrIfs, Stack<TreeItem> stack, ConstantPool constants, List<Action> actions, int start, int end, int version) {
List<TreeItem> output = new ArrayList<TreeItem>(); List<TreeItem> output = new ArrayList<TreeItem>();
int ip = start; int ip = start;
boolean isWhile = false; boolean isWhile = false;
boolean isForIn = false;
TreeItem inItem=null;
int loopStart = 0; int loopStart = 0;
loopip: loopip:
while (ip <= end + 1) { while (ip <= end + 1) {
@@ -624,7 +630,7 @@ public class Action {
if (((ActionIf) jif).getRef(version) == addr) { if (((ActionIf) jif).getRef(version) == addr) {
if (jif.getAddress() > addr) { if (jif.getAddress() > addr) {
jumpsOrIfs.remove(j); jumpsOrIfs.remove(j);
List<TreeItem> doBody = actionsToTree(unknownJumps, loopList, jumpsOrIfs, stack, constants, actions, ip, adr2ip(actions, jif.getAddress(), version) - 1, version); List<TreeItem> doBody = actionsToTree(registerNames,unknownJumps, loopList, jumpsOrIfs, stack, constants, actions, ip, adr2ip(actions, jif.getAddress(), version) - 1, version);
Loop currentLoop = new Loop(ip, adr2ip(actions, jif.getAddress(), version) + 1); Loop currentLoop = new Loop(ip, adr2ip(actions, jif.getAddress(), version) + 1);
loopList.add(currentLoop); loopList.add(currentLoop);
output.add(new DoWhileTreeItem(action, adr2ip(actions, jif.getAddress(), version) + 1, ip, doBody, stack.pop())); output.add(new DoWhileTreeItem(action, adr2ip(actions, jif.getAddress(), version) + 1, ip, doBody, stack.pop()));
@@ -678,11 +684,14 @@ public class Action {
output.add(new UnsupportedTreeItem(action, "ActionIf to jump back")); output.add(new UnsupportedTreeItem(action, "ActionIf to jump back"));
break; break;
} }
TreeItem expression = stack.pop(); TreeItem expression = null;
if (expression instanceof NotTreeItem) { if(!isForIn){
expression = ((NotTreeItem) expression).value; expression=stack.pop();
} else { if (expression instanceof NotTreeItem) {
expression = new NotTreeItem(action, expression); expression = ((NotTreeItem) expression).value;
} else {
expression = new NotTreeItem(action, expression);
}
} }
List<TreeItem> onTrue = new ArrayList<TreeItem>(); List<TreeItem> onTrue = new ArrayList<TreeItem>();
List<TreeItem> onFalse = new ArrayList<TreeItem>(); List<TreeItem> onFalse = new ArrayList<TreeItem>();
@@ -697,21 +706,36 @@ public class Action {
if ((refIp > jumpIp) && (refIp <= end + 1)) { if ((refIp > jumpIp) && (refIp <= end + 1)) {
hasElse = true; hasElse = true;
jumpElseIp = adr2ip(actions, ((ActionJump) actions.get(jumpIp - 1)).getRef(version), version); jumpElseIp = adr2ip(actions, ((ActionJump) actions.get(jumpIp - 1)).getRef(version), version);
onFalse = actionsToTree(unknownJumps, loopList, jumpsOrIfs, falseStack, constants, actions, jumpIp, jumpElseIp - 1, version); onFalse = actionsToTree(registerNames,unknownJumps, loopList, jumpsOrIfs, falseStack, constants, actions, jumpIp, jumpElseIp - 1, version);
} }
} }
//} //}
Loop currentLoop = null; Loop currentLoop = null;
if (isWhile) { if (isWhile||isForIn) {
currentLoop = new Loop(loopStart, jumpIp); currentLoop = new Loop(loopStart, jumpIp);
loopList.add(currentLoop); loopList.add(currentLoop);
} }
boolean isFor = false; boolean isFor = false;
boolean isTernar = false; boolean isTernar = false;
List<TreeItem> finalExpression = null; List<TreeItem> finalExpression = null;
TreeItem variableName=null;
if(isForIn){
for(int t=ip+1;t<=end;t++){
Action actionSV=actions.get(t);
actionSV.translate(stack, constants, output, registerNames);
if(actionSV instanceof ActionSetVariable){
SetVariableTreeItem svt=(SetVariableTreeItem)output.remove(output.size()-1);
variableName=svt.name;
ip=t;
break;
}
}
}
try { try {
onTrue = actionsToTree(unknownJumps, loopList, jumpsOrIfs, trueStack, constants, actions, ip + 1, jumpIp - 1 - (hasElse || isWhile ? 1 : 0), version); onTrue = actionsToTree(registerNames,unknownJumps, loopList, jumpsOrIfs, trueStack, constants, actions, ip + 1, jumpIp - 1 - (hasElse || isWhile || isForIn ? 1 : 0), version);
if (onTrue.size() == 0 && trueStack.size() > 0) { if (onTrue.size() == 0 && trueStack.size() > 0) {
isTernar = true; isTernar = true;
} }
@@ -740,13 +764,15 @@ public class Action {
} }
} }
} }
finalExpression = actionsToTree(unknownJumps, loopList, jumpsOrIfs, stack, constants, actions, adr2ip(actions, uje.addr, version), jumpIp - 2, version); finalExpression = actionsToTree(registerNames,unknownJumps, loopList, jumpsOrIfs, stack, constants, actions, adr2ip(actions, uje.addr, version), jumpIp - 2, version);
isFor = true; isFor = true;
} else { } else {
//throw new ConvertException("Unknown pattern: jump to nowhere", ip); //throw new ConvertException("Unknown pattern: jump to nowhere", ip);
} }
} }
if (isFor) { if(isForIn){
output.add(new ForInTreeItem(action,jumpIp, loopStart,variableName,inItem,onTrue));
}else if (isFor) {
output.add(new ForTreeItem(action, currentLoop.loopBreak, currentLoop.loopContinue, new ArrayList<TreeItem>(), expression, finalExpression, onTrue)); output.add(new ForTreeItem(action, currentLoop.loopBreak, currentLoop.loopContinue, new ArrayList<TreeItem>(), expression, finalExpression, onTrue));
} else if (isTernar) { } else if (isTernar) {
stack.push(new TernarOpTreeItem(action, expression, trueStack.pop(), falseStack.pop())); stack.push(new TernarOpTreeItem(action, expression, trueStack.pop(), falseStack.pop()));
@@ -758,10 +784,17 @@ public class Action {
ip = (hasElse ? jumpElseIp : jumpIp); ip = (hasElse ? jumpElseIp : jumpIp);
isWhile = false; isWhile = false;
isFor = false; isFor = false;
isForIn = false;
continue; continue;
} else if (action instanceof ActionTry) { } else if(action instanceof ActionEnumerate2){
loopStart=ip+1;
isForIn=true;
inItem=stack.pop();
ip+=4;
continue;
}else if (action instanceof ActionTry) {
ActionTry atry = (ActionTry) action; ActionTry atry = (ActionTry) action;
List<TreeItem> tryCommands = actionsToTree(unknownJumps, loopList, jumpsOrIfs, new Stack<TreeItem>(), constants, atry.tryBody, 0, atry.tryBody.size() - 1, version); List<TreeItem> tryCommands = actionsToTree(registerNames,unknownJumps, loopList, jumpsOrIfs, new Stack<TreeItem>(), constants, atry.tryBody, 0, atry.tryBody.size() - 1, version);
TreeItem catchName; TreeItem catchName;
if (atry.catchInRegisterFlag) { if (atry.catchInRegisterFlag) {
catchName = new DirectValueTreeItem(atry, new RegisterNumber(atry.catchRegister), constants); catchName = new DirectValueTreeItem(atry, new RegisterNumber(atry.catchRegister), constants);
@@ -771,25 +804,39 @@ public class Action {
List<TreeItem> catchExceptions = new ArrayList<TreeItem>(); List<TreeItem> catchExceptions = new ArrayList<TreeItem>();
catchExceptions.add(catchName); catchExceptions.add(catchName);
List<List<TreeItem>> catchCommands = new ArrayList<List<TreeItem>>(); List<List<TreeItem>> catchCommands = new ArrayList<List<TreeItem>>();
catchCommands.add(actionsToTree(unknownJumps, loopList, jumpsOrIfs, new Stack<TreeItem>(), constants, atry.catchBody, 0, atry.catchBody.size() - 1, version)); catchCommands.add(actionsToTree(registerNames,unknownJumps, loopList, jumpsOrIfs, new Stack<TreeItem>(), constants, atry.catchBody, 0, atry.catchBody.size() - 1, version));
List<TreeItem> finallyCommands = actionsToTree(unknownJumps, loopList, jumpsOrIfs, new Stack<TreeItem>(), constants, atry.finallyBody, 0, atry.finallyBody.size() - 1, version); List<TreeItem> finallyCommands = actionsToTree(registerNames,unknownJumps, loopList, jumpsOrIfs, new Stack<TreeItem>(), constants, atry.finallyBody, 0, atry.finallyBody.size() - 1, version);
output.add(new TryTreeItem(tryCommands, catchExceptions, catchCommands, finallyCommands)); output.add(new TryTreeItem(tryCommands, catchExceptions, catchCommands, finallyCommands));
} else if (action instanceof ActionWith) { } else if (action instanceof ActionWith) {
ActionWith awith = (ActionWith) action; ActionWith awith = (ActionWith) action;
List<TreeItem> withCommands = actionsToTree(unknownJumps, loopList, jumpsOrIfs, new Stack<TreeItem>(), constants, awith.actions, 0, awith.actions.size() - 1, version); List<TreeItem> withCommands = actionsToTree(registerNames,unknownJumps, loopList, jumpsOrIfs, new Stack<TreeItem>(), constants, awith.actions, 0, awith.actions.size() - 1, version);
output.add(new WithTreeItem(action, stack.pop(), withCommands)); output.add(new WithTreeItem(action, stack.pop(), withCommands));
} else if (action instanceof ActionDefineFunction) { } else if (action instanceof ActionDefineFunction) {
FunctionTreeItem fti = new FunctionTreeItem(action, actionsToTree(unknownJumps, loopList, jumpsOrIfs, new Stack<TreeItem>(), constants, ((ActionDefineFunction) action).code, 0, ((ActionDefineFunction) action).code.size() - 1, version), constants); FunctionTreeItem fti = new FunctionTreeItem(action,((ActionDefineFunction)action).functionName,((ActionDefineFunction)action).paramNames, actionsToTree(registerNames,unknownJumps, loopList, jumpsOrIfs, new Stack<TreeItem>(), constants, ((ActionDefineFunction) action).code, 0, ((ActionDefineFunction) action).code.size() - 1, version), constants);
stack.push(fti); stack.push(fti);
} else if (action instanceof ActionDefineFunction2) { } else if (action instanceof ActionDefineFunction2) {
FunctionTreeItem fti = new FunctionTreeItem(action, actionsToTree(unknownJumps, loopList, jumpsOrIfs, new Stack<TreeItem>(), constants, ((ActionDefineFunction2) action).code, 0, ((ActionDefineFunction2) action).code.size() - 1, version), constants); HashMap<Integer,String> funcRegNames=(HashMap<Integer,String>)registerNames.clone();
for(int f=0;f<((ActionDefineFunction2)action).paramNames.size();f++){
int reg=((ActionDefineFunction2)action).paramRegisters.get(f);
if(reg!=0)
funcRegNames.put(reg, ((ActionDefineFunction2)action).paramNames.get(f));
}
int pos=1;
if(((ActionDefineFunction2)action).preloadThisFlag) {funcRegNames.put(pos, "this");pos++;}
if(((ActionDefineFunction2)action).preloadArgumentsFlag) {funcRegNames.put(pos, "arguments");pos++;}
if(((ActionDefineFunction2)action).preloadSuperFlag) {funcRegNames.put(pos, "super");pos++;}
if(((ActionDefineFunction2)action).preloadRootFlag) {funcRegNames.put(pos, "_root");pos++;}
if(((ActionDefineFunction2)action).preloadParentFlag) {funcRegNames.put(pos, "_parent");pos++;}
if(((ActionDefineFunction2)action).preloadGlobalFlag) {funcRegNames.put(pos, "_global");pos++;}
FunctionTreeItem fti = new FunctionTreeItem(action,((ActionDefineFunction2)action).functionName,((ActionDefineFunction2)action).paramNames, actionsToTree(funcRegNames,unknownJumps, loopList, jumpsOrIfs, new Stack<TreeItem>(), constants, ((ActionDefineFunction2) action).code, 0, ((ActionDefineFunction2) action).code.size() - 1, version), constants);
stack.push(fti); stack.push(fti);
} else if (action instanceof ActionPushDuplicate) { } else if (action instanceof ActionPushDuplicate) {
do { do {
if (actions.get(ip + 1) instanceof ActionNot) { if (actions.get(ip + 1) instanceof ActionNot) {
if (actions.get(ip + 2) instanceof ActionIf) { if (actions.get(ip + 2) instanceof ActionIf) {
int nextPos = adr2ip(actions, ((ActionIf) actions.get(ip + 2)).getRef(version), version); int nextPos = adr2ip(actions, ((ActionIf) actions.get(ip + 2)).getRef(version), version);
stack.push(new AndTreeItem(action, stack.pop(), actionsToStackTree(jumpsOrIfs, actions, constants, ip + 4 /*je tam pop*/, nextPos - 1, version).pop())); stack.push(new AndTreeItem(action, stack.pop(), actionsToStackTree(registerNames,jumpsOrIfs, actions, constants, ip + 4 /*je tam pop*/, nextPos - 1, version).pop()));
ip = nextPos; ip = nextPos;
} else { } else {
output.add(new UnsupportedTreeItem(action, "ActionPushDuplicate with Not")); output.add(new UnsupportedTreeItem(action, "ActionPushDuplicate with Not"));
@@ -797,7 +844,7 @@ public class Action {
} }
} else if (actions.get(ip + 1) instanceof ActionIf) { } else if (actions.get(ip + 1) instanceof ActionIf) {
int nextPos = adr2ip(actions, ((ActionIf) actions.get(ip + 1)).getRef(version), version); int nextPos = adr2ip(actions, ((ActionIf) actions.get(ip + 1)).getRef(version), version);
stack.push(new OrTreeItem(action, stack.pop(), actionsToStackTree(jumpsOrIfs, actions, constants, ip + 3, nextPos - 1, version).pop())); stack.push(new OrTreeItem(action, stack.pop(), actionsToStackTree(registerNames,jumpsOrIfs, actions, constants, ip + 3, nextPos - 1, version).pop()));
ip = nextPos; ip = nextPos;
} else { } else {
output.add(new UnsupportedTreeItem(action, "ActionPushDuplicate with no If")); output.add(new UnsupportedTreeItem(action, "ActionPushDuplicate with no If"));
@@ -806,13 +853,14 @@ public class Action {
action = actions.get(ip); action = actions.get(ip);
} }
while (action instanceof ActionPushDuplicate); while (action instanceof ActionPushDuplicate);
continue;
} else if (action instanceof ActionStoreRegister) { } else if (action instanceof ActionStoreRegister) {
if ((ip + 1 <= end) && (actions.get(ip + 1) instanceof ActionPop)) { if ((ip + 1 <= end) && (actions.get(ip + 1) instanceof ActionPop)) {
action.translate(stack, constants, output); action.translate(stack, constants, output, registerNames);
stack.pop(); stack.pop();
ip++; ip++;
} else { } else {
action.translate(stack, constants, output); action.translate(stack, constants, output, registerNames);
} }
} else if (action instanceof ActionStrictEquals) { } else if (action instanceof ActionStrictEquals) {
if ((ip + 1 < actions.size()) && (actions.get(ip + 1) instanceof ActionIf)) { if ((ip + 1 < actions.size()) && (actions.get(ip + 1) instanceof ActionIf)) {
@@ -833,7 +881,7 @@ public class Action {
do { do {
ip++; ip++;
if ((actions.get(ip - 1) instanceof ActionStrictEquals) && (actions.get(ip) instanceof ActionIf)) { if ((actions.get(ip - 1) instanceof ActionStrictEquals) && (actions.get(ip) instanceof ActionIf)) {
caseValues.add(actionsToStackTree(jumpsOrIfs, actions, constants, caseStart, ip - 2, version).pop()); caseValues.add(actionsToStackTree(registerNames,jumpsOrIfs, actions, constants, caseStart, ip - 2, version).pop());
caseStart = ip + 1; caseStart = ip + 1;
caseBodyIps.add(adr2ip(actions, ((ActionIf) actions.get(ip)).getRef(version), version)); caseBodyIps.add(adr2ip(actions, ((ActionIf) actions.get(ip)).getRef(version), version));
if (actions.get(ip + 1) instanceof ActionJump) { if (actions.get(ip + 1) instanceof ActionJump) {
@@ -848,16 +896,16 @@ public class Action {
if (i < caseBodyIps.size() - 1) { if (i < caseBodyIps.size() - 1) {
caseEnd = caseBodyIps.get(i + 1) - 1; caseEnd = caseBodyIps.get(i + 1) - 1;
} }
caseCommands.add(actionsToTree(unknownJumps, loopList, jumpsOrIfs, stack, constants, actions, caseBodyIps.get(i), caseEnd, version)); caseCommands.add(actionsToTree(registerNames,unknownJumps, loopList, jumpsOrIfs, stack, constants, actions, caseBodyIps.get(i), caseEnd, version));
} }
output.add(new SwitchTreeItem(action, defaultAddr, switchedObject, caseValues, caseCommands, null)); output.add(new SwitchTreeItem(action, defaultAddr, switchedObject, caseValues, caseCommands, null));
continue; continue;
} else { } else {
action.translate(stack, constants, output); action.translate(stack, constants, output, registerNames);
} }
} else { } else {
try { try {
action.translate(stack, constants, output); action.translate(stack, constants, output, registerNames);
} catch (EmptyStackException ese) { } catch (EmptyStackException ese) {
output.add(new UnsupportedTreeItem(action, "Empty stack")); output.add(new UnsupportedTreeItem(action, "Empty stack"));
} }
@@ -103,7 +103,7 @@ public class MainFrame extends JFrame implements TreeSelectionListener, ActionLi
miSaveAs.addActionListener(this); miSaveAs.addActionListener(this);
JMenuItem miExport = new JMenuItem("Export..."); JMenuItem miExport = new JMenuItem("Export...");
miExport.setActionCommand("EXPORT"); miExport.setActionCommand("EXPORT");
miExport.addActionListener(this); //miExport.addActionListener(this);
menuFile.add(miOpen); menuFile.add(miOpen);
menuFile.add(miSave); menuFile.add(miSave);
menuFile.add(miSaveAs); menuFile.add(miSaveAs);
@@ -50,7 +50,7 @@ public class ActionGetURL extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
output.add(new GetURLTreeItem(this, urlString, targetString)); output.add(new GetURLTreeItem(this, urlString, targetString));
} }
} }
@@ -46,7 +46,7 @@ public class ActionGoToLabel extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
output.add(new GotoLabelTreeItem(this, label)); output.add(new GotoLabelTreeItem(this, label));
} }
} }
@@ -45,7 +45,7 @@ public class ActionGotoFrame extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
output.add(new GotoFrameTreeItem(this, frame)); output.add(new GotoFrameTreeItem(this, frame));
} }
} }
@@ -20,7 +20,7 @@ public class ActionNextFrame extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
output.add(new SimpleActionTreeItem(this, "nextFrame();")); output.add(new SimpleActionTreeItem(this, "nextFrame();"));
} }
} }
@@ -19,7 +19,7 @@ public class ActionPlay extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
output.add(new SimpleActionTreeItem(this, "Play();")); output.add(new SimpleActionTreeItem(this, "Play();"));
} }
} }
@@ -20,7 +20,7 @@ public class ActionPrevFrame extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
output.add(new SimpleActionTreeItem(this, "prevFrame();")); output.add(new SimpleActionTreeItem(this, "prevFrame();"));
} }
} }
@@ -46,7 +46,7 @@ public class ActionSetTarget extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
output.add(new SetTargetTreeItem(this, targetName)); output.add(new SetTargetTreeItem(this, targetName));
} }
} }
@@ -20,7 +20,7 @@ public class ActionStop extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
output.add(new SimpleActionTreeItem(this, "stop();")); output.add(new SimpleActionTreeItem(this, "stop();"));
} }
} }
@@ -19,7 +19,7 @@ public class ActionStopSounds extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
output.add(new SimpleActionTreeItem(this, "stopAllSounds();")); output.add(new SimpleActionTreeItem(this, "stopAllSounds();"));
} }
} }
@@ -20,7 +20,7 @@ public class ActionToggleQuality extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
output.add(new SimpleActionTreeItem(this, "toggleHighQuality();")); output.add(new SimpleActionTreeItem(this, "toggleHighQuality();"));
} }
} }
@@ -49,7 +49,7 @@ public class ActionWaitForFrame extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
output.add(new WaitForFrameTreeItem(this, frame, skipCount)); output.add(new WaitForFrameTreeItem(this, frame, skipCount));
} }
} }
@@ -20,7 +20,7 @@ public class ActionAdd extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem a = stack.pop(); TreeItem a = stack.pop();
TreeItem b = stack.pop(); TreeItem b = stack.pop();
stack.push(new AddTreeItem(this, b, a)); stack.push(new AddTreeItem(this, b, a));
@@ -20,7 +20,7 @@ public class ActionAnd extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem a = stack.pop(); TreeItem a = stack.pop();
TreeItem b = stack.pop(); TreeItem b = stack.pop();
stack.push(new AndTreeItem(this, b, a)); stack.push(new AndTreeItem(this, b, a));
@@ -20,7 +20,7 @@ public class ActionAsciiToChar extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem a = stack.pop(); TreeItem a = stack.pop();
stack.push(new AsciiToCharTreeItem(this, a)); stack.push(new AsciiToCharTreeItem(this, a));
} }
@@ -20,7 +20,7 @@ public class ActionCall extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
output.add(new CallTreeItem(this, stack.pop())); output.add(new CallTreeItem(this, stack.pop()));
} }
} }
@@ -20,7 +20,7 @@ public class ActionCharToAscii extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem a = stack.pop(); TreeItem a = stack.pop();
stack.push(new CharToAsciiTreeItem(this, a)); stack.push(new CharToAsciiTreeItem(this, a));
} }
@@ -20,7 +20,7 @@ public class ActionCloneSprite extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem depth = stack.pop(); TreeItem depth = stack.pop();
TreeItem target = stack.pop(); TreeItem target = stack.pop();
TreeItem source = stack.pop(); TreeItem source = stack.pop();
@@ -21,7 +21,7 @@ public class ActionDivide extends Action {
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem a = stack.pop(); TreeItem a = stack.pop();
TreeItem b = stack.pop(); TreeItem b = stack.pop();
stack.push(new DivideTreeItem(this, b, a)); stack.push(new DivideTreeItem(this, b, a));
@@ -20,7 +20,7 @@ public class ActionEndDrag extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
output.add(new SimpleActionTreeItem(this, "stopDrag();")); output.add(new SimpleActionTreeItem(this, "stopDrag();"));
} }
} }
@@ -20,7 +20,7 @@ public class ActionEquals extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem a = stack.pop(); TreeItem a = stack.pop();
TreeItem b = stack.pop(); TreeItem b = stack.pop();
stack.push(new EqTreeItem(this, b, a)); stack.push(new EqTreeItem(this, b, a));
@@ -21,7 +21,7 @@ public class ActionGetProperty extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem index = stack.pop(); TreeItem index = stack.pop();
TreeItem target = stack.pop(); TreeItem target = stack.pop();
int indexInt = 0; int indexInt = 0;
@@ -20,7 +20,7 @@ public class ActionGetTime extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
stack.push(new SimpleActionTreeItem(this, "getTimer()")); stack.push(new SimpleActionTreeItem(this, "getTimer()"));
} }
} }
@@ -57,7 +57,7 @@ public class ActionGetURL2 extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem targetString = stack.pop(); TreeItem targetString = stack.pop();
TreeItem urlString = stack.pop(); TreeItem urlString = stack.pop();
output.add(new GetURL2TreeItem(this, urlString, targetString, sendVarsMethod, loadTargetFlag, loadTargetFlag)); output.add(new GetURL2TreeItem(this, urlString, targetString, sendVarsMethod, loadTargetFlag, loadTargetFlag));
@@ -20,7 +20,7 @@ public class ActionGetVariable extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem value=stack.pop(); TreeItem value=stack.pop();
stack.push(new GetVariableTreeItem(this,value)); stack.push(new GetVariableTreeItem(this,value));
} }
@@ -62,7 +62,7 @@ public class ActionGotoFrame2 extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem frame = stack.pop(); TreeItem frame = stack.pop();
output.add(new GotoFrame2TreeItem(this, frame, sceneBiasFlag, playFlag, sceneBias)); output.add(new GotoFrame2TreeItem(this, frame, sceneBiasFlag, playFlag, sceneBias));
} }
@@ -20,7 +20,7 @@ public class ActionLess extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem a = stack.pop(); TreeItem a = stack.pop();
TreeItem b = stack.pop(); TreeItem b = stack.pop();
stack.push(new LtTreeItem(this, b, a)); stack.push(new LtTreeItem(this, b, a));
@@ -20,7 +20,7 @@ public class ActionMBAsciiToChar extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem a = stack.pop(); TreeItem a = stack.pop();
stack.push(new MBAsciiToCharTreeItem(this, a)); stack.push(new MBAsciiToCharTreeItem(this, a));
} }
@@ -19,7 +19,7 @@ public class ActionMBCharToAscii extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem a = stack.pop(); TreeItem a = stack.pop();
stack.push(new MBCharToAsciiTreeItem(this, a)); stack.push(new MBCharToAsciiTreeItem(this, a));
} }
@@ -20,7 +20,7 @@ public class ActionMBStringExtract extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem count = stack.pop(); TreeItem count = stack.pop();
TreeItem index = stack.pop(); TreeItem index = stack.pop();
TreeItem value = stack.pop(); TreeItem value = stack.pop();
@@ -19,7 +19,7 @@ public class ActionMBStringLength extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem a = stack.pop(); TreeItem a = stack.pop();
stack.push(new MBStringLengthTreeItem(this, a)); stack.push(new MBStringLengthTreeItem(this, a));
} }
@@ -20,7 +20,7 @@ public class ActionMultiply extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem a = stack.pop(); TreeItem a = stack.pop();
TreeItem b = stack.pop(); TreeItem b = stack.pop();
stack.push(new MultiplyTreeItem(this, b, a)); stack.push(new MultiplyTreeItem(this, b, a));
@@ -20,7 +20,7 @@ public class ActionNot extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem a = stack.pop(); TreeItem a = stack.pop();
stack.push(new NotTreeItem(this, a)); stack.push(new NotTreeItem(this, a));
} }
@@ -20,7 +20,7 @@ public class ActionOr extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem a = stack.pop(); TreeItem a = stack.pop();
TreeItem b = stack.pop(); TreeItem b = stack.pop();
stack.push(new OrTreeItem(this, b, a)); stack.push(new OrTreeItem(this, b, a));
@@ -21,7 +21,7 @@ public class ActionPop extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem val = stack.pop(); TreeItem val = stack.pop();
if (!(val instanceof DirectValueTreeItem)) if (!(val instanceof DirectValueTreeItem))
output.add(new VoidTreeItem(this, val)); output.add(new VoidTreeItem(this, val));
@@ -182,11 +182,16 @@ public class ActionPush extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
for (Object o : values) { for (Object o : values) {
if (o instanceof ConstantIndex) { if (o instanceof ConstantIndex) {
o = constants.constants.get(((ConstantIndex) o).index); o = constants.constants.get(((ConstantIndex) o).index);
} }
if (o instanceof RegisterNumber) {
if(regNames.containsKey(((RegisterNumber)o).number)){
((RegisterNumber)o).name=regNames.get(((RegisterNumber)o).number);
}
}
stack.push(new DirectValueTreeItem(this, o, constants)); stack.push(new DirectValueTreeItem(this, o, constants));
} }
} }
@@ -20,7 +20,7 @@ public class ActionRandomNumber extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem maximum = stack.pop(); TreeItem maximum = stack.pop();
stack.push(new RandomNumberTreeItem(this, maximum)); stack.push(new RandomNumberTreeItem(this, maximum));
} }
@@ -20,7 +20,7 @@ public class ActionRemoveSprite extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem target = stack.pop(); TreeItem target = stack.pop();
output.add(new RemoveSpriteTreeItem(this, target)); output.add(new RemoveSpriteTreeItem(this, target));
} }
@@ -21,7 +21,7 @@ public class ActionSetProperty extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem value = stack.pop(); TreeItem value = stack.pop();
TreeItem index = stack.pop(); TreeItem index = stack.pop();
TreeItem target = stack.pop(); TreeItem target = stack.pop();
@@ -20,7 +20,7 @@ public class ActionSetTarget2 extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem target = stack.pop(); TreeItem target = stack.pop();
output.add(new SetTarget2TreeItem(this, target)); output.add(new SetTarget2TreeItem(this, target));
} }
@@ -20,7 +20,7 @@ public class ActionSetVariable extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem value = stack.pop(); TreeItem value = stack.pop();
TreeItem name = stack.pop(); TreeItem name = stack.pop();
output.add(new SetVariableTreeItem(this, name, value)); output.add(new SetVariableTreeItem(this, name, value));
@@ -21,7 +21,7 @@ public class ActionStartDrag extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem target = stack.pop(); TreeItem target = stack.pop();
TreeItem lockCenter = stack.pop(); TreeItem lockCenter = stack.pop();
TreeItem constrain = stack.pop(); TreeItem constrain = stack.pop();
@@ -20,7 +20,7 @@ public class ActionStringAdd extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem a = stack.pop(); TreeItem a = stack.pop();
TreeItem b = stack.pop(); TreeItem b = stack.pop();
stack.push(new StringAddTreeItem(this, b, a)); stack.push(new StringAddTreeItem(this, b, a));
@@ -20,7 +20,7 @@ public class ActionStringEquals extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem a = stack.pop(); TreeItem a = stack.pop();
TreeItem b = stack.pop(); TreeItem b = stack.pop();
stack.push(new StringEqTreeItem(this, b, a)); stack.push(new StringEqTreeItem(this, b, a));
@@ -20,7 +20,7 @@ public class ActionStringExtract extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem count = stack.pop(); TreeItem count = stack.pop();
TreeItem index = stack.pop(); TreeItem index = stack.pop();
TreeItem value = stack.pop(); TreeItem value = stack.pop();
@@ -20,7 +20,7 @@ public class ActionStringLength extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem a = stack.pop(); TreeItem a = stack.pop();
stack.push(new StringLengthTreeItem(this, a)); stack.push(new StringLengthTreeItem(this, a));
} }
@@ -20,7 +20,7 @@ public class ActionStringLess extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem a = stack.pop(); TreeItem a = stack.pop();
TreeItem b = stack.pop(); TreeItem b = stack.pop();
stack.push(new StringLtTreeItem(this, b, a)); stack.push(new StringLtTreeItem(this, b, a));
@@ -20,7 +20,7 @@ public class ActionSubtract extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem a = stack.pop(); TreeItem a = stack.pop();
TreeItem b = stack.pop(); TreeItem b = stack.pop();
stack.push(new SubtractTreeItem(this, b, a)); stack.push(new SubtractTreeItem(this, b, a));
@@ -20,7 +20,7 @@ public class ActionToInteger extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem a = stack.pop(); TreeItem a = stack.pop();
stack.push(new ToIntegerTreeItem(this, a)); stack.push(new ToIntegerTreeItem(this, a));
} }
@@ -20,7 +20,7 @@ public class ActionTrace extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem value = stack.pop(); TreeItem value = stack.pop();
output.add(new TraceTreeItem(this, value)); output.add(new TraceTreeItem(this, value));
} }
@@ -45,7 +45,7 @@ public class ActionWaitForFrame2 extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem frame = stack.pop(); TreeItem frame = stack.pop();
output.add(new WaitForFrame2TreeItem(this, frame, skipCount)); output.add(new WaitForFrame2TreeItem(this, frame, skipCount));
} }
@@ -2,6 +2,7 @@ package com.jpexs.asdec.action.swf4;
public class RegisterNumber { public class RegisterNumber {
public int number; public int number;
public String name=null;
public RegisterNumber(int number) { public RegisterNumber(int number) {
this.number = number; this.number = number;
@@ -9,6 +10,7 @@ public class RegisterNumber {
@Override @Override
public String toString() { public String toString() {
return "register" + number; if(name==null) return "register" + number;
return name;
} }
} }
@@ -19,7 +19,7 @@ public class ActionAdd2 extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem a = stack.pop(); TreeItem a = stack.pop();
TreeItem b = stack.pop(); TreeItem b = stack.pop();
stack.push(new AddTreeItem(this, b, a)); stack.push(new AddTreeItem(this, b, a));
@@ -20,7 +20,7 @@ public class ActionBitAnd extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem a = stack.pop(); TreeItem a = stack.pop();
TreeItem b = stack.pop(); TreeItem b = stack.pop();
stack.push(new BitAndTreeItem(this, b, a)); stack.push(new BitAndTreeItem(this, b, a));
@@ -19,7 +19,7 @@ public class ActionBitLShift extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem a = stack.pop(); TreeItem a = stack.pop();
TreeItem b = stack.pop(); TreeItem b = stack.pop();
stack.push(new LShiftTreeItem(this, b, a)); stack.push(new LShiftTreeItem(this, b, a));
@@ -20,7 +20,7 @@ public class ActionBitOr extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem a = stack.pop(); TreeItem a = stack.pop();
TreeItem b = stack.pop(); TreeItem b = stack.pop();
stack.push(new BitOrTreeItem(this, b, a)); stack.push(new BitOrTreeItem(this, b, a));
@@ -20,7 +20,7 @@ public class ActionBitRShift extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem a = stack.pop(); TreeItem a = stack.pop();
TreeItem b = stack.pop(); TreeItem b = stack.pop();
stack.push(new RShiftTreeItem(this, b, a)); stack.push(new RShiftTreeItem(this, b, a));
@@ -19,7 +19,7 @@ public class ActionBitURShift extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem a = stack.pop(); TreeItem a = stack.pop();
TreeItem b = stack.pop(); TreeItem b = stack.pop();
stack.push(new URShiftTreeItem(this, b, a)); stack.push(new URShiftTreeItem(this, b, a));
@@ -20,7 +20,7 @@ public class ActionBitXor extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem a = stack.pop(); TreeItem a = stack.pop();
TreeItem b = stack.pop(); TreeItem b = stack.pop();
stack.push(new BitXorTreeItem(this, b, a)); stack.push(new BitXorTreeItem(this, b, a));
@@ -21,7 +21,7 @@ public class ActionCallFunction extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem functionName = stack.pop(); TreeItem functionName = stack.pop();
long numArgs = popLong(stack); long numArgs = popLong(stack);
List<TreeItem> args = new ArrayList<TreeItem>(); List<TreeItem> args = new ArrayList<TreeItem>();
@@ -21,7 +21,7 @@ public class ActionCallMethod extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem methodName = stack.pop(); TreeItem methodName = stack.pop();
TreeItem scriptObject = stack.pop(); TreeItem scriptObject = stack.pop();
long numArgs = popLong(stack); long numArgs = popLong(stack);
@@ -66,7 +66,7 @@ public class ActionConstantPool extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
constants.constants = constantPool; constants.constants = constantPool;
} }
} }
@@ -20,7 +20,7 @@ public class ActionDecrement extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem a = stack.pop(); TreeItem a = stack.pop();
stack.push(new DecrementTreeItem(this, a)); stack.push(new DecrementTreeItem(this, a));
} }
@@ -20,7 +20,7 @@ public class ActionDefineLocal extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem value = stack.pop(); TreeItem value = stack.pop();
TreeItem name = stack.pop(); TreeItem name = stack.pop();
output.add(new DefineLocalTreeItem(this, name, value)); output.add(new DefineLocalTreeItem(this, name, value));
@@ -21,7 +21,7 @@ public class ActionDefineLocal2 extends Action {
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem name = stack.pop(); TreeItem name = stack.pop();
output.add(new DefineLocalTreeItem(this, name, null)); output.add(new DefineLocalTreeItem(this, name, null));
} }
@@ -22,7 +22,7 @@ public class ActionDelete extends Action {
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem propertyName = stack.pop(); TreeItem propertyName = stack.pop();
TreeItem object = stack.pop(); TreeItem object = stack.pop();
@@ -21,7 +21,7 @@ public class ActionDelete2 extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem propertyName = stack.pop(); TreeItem propertyName = stack.pop();
output.add(new DeleteTreeItem(this, null, propertyName)); output.add(new DeleteTreeItem(this, null, propertyName));
@@ -20,7 +20,7 @@ public class ActionEnumerate extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem object = stack.pop(); TreeItem object = stack.pop();
stack.push(new EnumerateTreeItem(this, object)); stack.push(new EnumerateTreeItem(this, object));
} }
@@ -20,7 +20,7 @@ public class ActionEquals2 extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem a = stack.pop(); TreeItem a = stack.pop();
TreeItem b = stack.pop(); TreeItem b = stack.pop();
stack.push(new EqTreeItem(this, b, a)); stack.push(new EqTreeItem(this, b, a));
@@ -20,7 +20,7 @@ public class ActionGetMember extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem functionName = stack.pop(); TreeItem functionName = stack.pop();
TreeItem object = stack.pop(); TreeItem object = stack.pop();
stack.push(new GetMemberTreeItem(this, object, functionName)); stack.push(new GetMemberTreeItem(this, object, functionName));
@@ -20,7 +20,7 @@ public class ActionIncrement extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem a = stack.pop(); TreeItem a = stack.pop();
stack.push(new IncrementTreeItem(this, a)); stack.push(new IncrementTreeItem(this, a));
} }
@@ -16,7 +16,7 @@ public class ActionInitArray extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
long numArgs = popLong(stack); long numArgs = popLong(stack);
List<TreeItem> args = new ArrayList<TreeItem>(); List<TreeItem> args = new ArrayList<TreeItem>();
for (int l = 0; l < numArgs; l++) { for (int l = 0; l < numArgs; l++) {
@@ -21,7 +21,7 @@ public class ActionInitObject extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
long numArgs = popLong(stack); long numArgs = popLong(stack);
List<TreeItem> values = new ArrayList<TreeItem>(); List<TreeItem> values = new ArrayList<TreeItem>();
List<TreeItem> names = new ArrayList<TreeItem>(); List<TreeItem> names = new ArrayList<TreeItem>();
@@ -20,7 +20,7 @@ public class ActionLess2 extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem a = stack.pop(); TreeItem a = stack.pop();
TreeItem b = stack.pop(); TreeItem b = stack.pop();
stack.push(new LtTreeItem(this, b, a)); stack.push(new LtTreeItem(this, b, a));
@@ -20,7 +20,7 @@ public class ActionModulo extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem a = stack.pop(); TreeItem a = stack.pop();
TreeItem b = stack.pop(); TreeItem b = stack.pop();
stack.push(new ModuloTreeItem(this, b, a)); stack.push(new ModuloTreeItem(this, b, a));
@@ -21,7 +21,7 @@ public class ActionNewMethod extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem methodName = stack.pop(); TreeItem methodName = stack.pop();
TreeItem scriptObject = stack.pop(); TreeItem scriptObject = stack.pop();
long numArgs = popLong(stack); long numArgs = popLong(stack);
@@ -21,7 +21,7 @@ public class ActionNewObject extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem objectName = stack.pop(); TreeItem objectName = stack.pop();
long numArgs = popLong(stack); long numArgs = popLong(stack);
List<TreeItem> args = new ArrayList<TreeItem>(); List<TreeItem> args = new ArrayList<TreeItem>();
@@ -19,7 +19,7 @@ public class ActionPushDuplicate extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem value = stack.pop(); TreeItem value = stack.pop();
stack.push(value); stack.push(value);
stack.push(value); stack.push(value);
@@ -20,7 +20,7 @@ public class ActionReturn extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem value = stack.pop(); TreeItem value = stack.pop();
output.add(new ReturnTreeItem(this, value)); output.add(new ReturnTreeItem(this, value));
} }
@@ -20,7 +20,7 @@ public class ActionSetMember extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem value = stack.pop(); TreeItem value = stack.pop();
TreeItem objectName = stack.pop(); TreeItem objectName = stack.pop();
TreeItem object = stack.pop(); TreeItem object = stack.pop();
@@ -19,7 +19,7 @@ public class ActionStackSwap extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem a = stack.pop(); TreeItem a = stack.pop();
TreeItem b = stack.pop(); TreeItem b = stack.pop();
stack.push(a); stack.push(a);
@@ -5,6 +5,7 @@ import com.jpexs.asdec.SWFOutputStream;
import com.jpexs.asdec.action.Action; import com.jpexs.asdec.action.Action;
import com.jpexs.asdec.action.parser.FlasmLexer; import com.jpexs.asdec.action.parser.FlasmLexer;
import com.jpexs.asdec.action.parser.ParseException; import com.jpexs.asdec.action.parser.ParseException;
import com.jpexs.asdec.action.swf4.RegisterNumber;
import com.jpexs.asdec.action.treemodel.ConstantPool; import com.jpexs.asdec.action.treemodel.ConstantPool;
import com.jpexs.asdec.action.treemodel.StoreRegisterTreeItem; import com.jpexs.asdec.action.treemodel.StoreRegisterTreeItem;
import com.jpexs.asdec.action.treemodel.TreeItem; import com.jpexs.asdec.action.treemodel.TreeItem;
@@ -45,8 +46,12 @@ public class ActionStoreRegister extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem item = stack.peek(); TreeItem item = stack.peek();
output.add(new StoreRegisterTreeItem(this, registerNumber, item)); RegisterNumber rn=new RegisterNumber(registerNumber);
if(regNames.containsKey(registerNumber)){
rn.name=regNames.get(registerNumber);
}
output.add(new StoreRegisterTreeItem(this, rn, item));
} }
} }
@@ -20,7 +20,7 @@ public class ActionTargetPath extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem object = stack.pop(); TreeItem object = stack.pop();
stack.push(new TargetPathTreeItem(this, object)); stack.push(new TargetPathTreeItem(this, object));
} }
@@ -20,7 +20,7 @@ public class ActionToNumber extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem object = stack.pop(); TreeItem object = stack.pop();
stack.push(new ToNumberTreeItem(this, object)); stack.push(new ToNumberTreeItem(this, object));
} }
@@ -20,7 +20,7 @@ public class ActionToString extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem object = stack.pop(); TreeItem object = stack.pop();
stack.push(new ToStringTreeItem(this, object)); stack.push(new ToStringTreeItem(this, object));
} }
@@ -20,7 +20,7 @@ public class ActionTypeOf extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem object = stack.pop(); TreeItem object = stack.pop();
stack.push(new TypeOfTreeItem(this, object)); stack.push(new TypeOfTreeItem(this, object));
} }
@@ -19,7 +19,7 @@ public class ActionEnumerate2 extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem object = stack.pop(); TreeItem object = stack.pop();
stack.push(new EnumerateTreeItem(this, object)); stack.push(new EnumerateTreeItem(this, object));
} }
@@ -20,7 +20,7 @@ public class ActionGreater extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem a = stack.pop(); TreeItem a = stack.pop();
TreeItem b = stack.pop(); TreeItem b = stack.pop();
stack.push(new GtTreeItem(this, b, a)); stack.push(new GtTreeItem(this, b, a));
@@ -19,7 +19,7 @@ public class ActionInstanceOf extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem a = stack.pop(); TreeItem a = stack.pop();
TreeItem b = stack.pop(); TreeItem b = stack.pop();
stack.push(new InstanceOfTreeItem(this, b, a)); stack.push(new InstanceOfTreeItem(this, b, a));
@@ -20,7 +20,7 @@ public class ActionStrictEquals extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem a = stack.pop(); TreeItem a = stack.pop();
TreeItem b = stack.pop(); TreeItem b = stack.pop();
stack.push(new StrictEqTreeItem(this, b, a)); stack.push(new StrictEqTreeItem(this, b, a));
@@ -20,7 +20,7 @@ public class ActionStringGreater extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem a = stack.pop(); TreeItem a = stack.pop();
TreeItem b = stack.pop(); TreeItem b = stack.pop();
stack.push(new GtTreeItem(this, b, a)); stack.push(new GtTreeItem(this, b, a));
@@ -20,7 +20,7 @@ public class ActionCastOp extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem object = stack.pop(); TreeItem object = stack.pop();
TreeItem constructor = stack.pop(); TreeItem constructor = stack.pop();
stack.push(new CastOpTreeItem(this, constructor, object)); stack.push(new CastOpTreeItem(this, constructor, object));
@@ -80,6 +80,7 @@ public class ActionDefineFunction2 extends Action {
code = ASMParser.parse(labels, address + getPreLen(version), lexer, constantPool, version); code = ASMParser.parse(labels, address + getPreLen(version), lexer, constantPool, version);
} }
@Override
public byte[] getBytes(int version) { public byte[] getBytes(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version); SWFOutputStream sos = new SWFOutputStream(baos, version);
@@ -21,7 +21,7 @@ public class ActionExtends extends Action {
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem superclass = stack.pop(); TreeItem superclass = stack.pop();
TreeItem subclass = stack.pop(); TreeItem subclass = stack.pop();
output.add(new ExtendsTreeItem(this, subclass, superclass)); output.add(new ExtendsTreeItem(this, subclass, superclass));
@@ -21,7 +21,7 @@ public class ActionImplementsOp extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem subclass = stack.pop(); TreeItem subclass = stack.pop();
long inCount = popLong(stack); long inCount = popLong(stack);
List<TreeItem> superclasses = new ArrayList<TreeItem>(); List<TreeItem> superclasses = new ArrayList<TreeItem>();
@@ -20,7 +20,7 @@ public class ActionThrow extends Action {
} }
@Override @Override
public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output) { public void translate(Stack<TreeItem> stack, ConstantPool constants, List<TreeItem> output, java.util.HashMap<Integer,String> regNames) {
TreeItem object = stack.pop(); TreeItem object = stack.pop();
output.add(new ThrowTreeItem(this, object)); output.add(new ThrowTreeItem(this, object));
} }
@@ -7,15 +7,28 @@ import java.util.List;
public class FunctionTreeItem extends TreeItem { public class FunctionTreeItem extends TreeItem {
public List<TreeItem> actions; public List<TreeItem> actions;
public List<String> constants; public List<String> constants;
public String functionName;
public List<String> paramNames;
public FunctionTreeItem(Action instruction, List<TreeItem> actions,ConstantPool constants) { public FunctionTreeItem(Action instruction, String functionName,List<String> paramNames,List<TreeItem> actions,ConstantPool constants) {
super(instruction,PRECEDENCE_PRIMARY); super(instruction,PRECEDENCE_PRIMARY);
this.actions=actions; this.actions=actions;
this.constants=constants.constants; this.constants=constants.constants;
this.functionName=functionName;
this.paramNames=paramNames;
} }
@Override @Override
public String toString(ConstantPool constants) { public String toString(ConstantPool constants) {
return "function()\r\n{\r\n"+Action.treeToString(actions)+"}"; String ret="function";
if(!functionName.equals(""))
ret+=" "+functionName;
ret+="(";
for(int p=0;p<paramNames.size();p++){
if(p>0) ret+=", ";
ret+=paramNames.get(p);
}
ret+=")\r\n{\r\n"+Action.treeToString(actions)+"}";
return ret;
} }
} }
@@ -14,6 +14,10 @@ public class GetMemberTreeItem extends TreeItem {
@Override @Override
public String toString(ConstantPool constants) { public String toString(ConstantPool constants) {
if(!((functionName instanceof DirectValueTreeItem)&&(((DirectValueTreeItem)functionName).value instanceof String))){
//if(!(functionName instanceof GetVariableTreeItem))
return object.toString(constants) + "[" + stripQuotes(functionName)+"]";
}
return object.toString(constants) + "." + stripQuotes(functionName); return object.toString(constants) + "." + stripQuotes(functionName);
} }
} }
@@ -1,19 +1,20 @@
package com.jpexs.asdec.action.treemodel; package com.jpexs.asdec.action.treemodel;
import com.jpexs.asdec.action.Action; import com.jpexs.asdec.action.Action;
import com.jpexs.asdec.action.swf4.RegisterNumber;
public class StoreRegisterTreeItem extends TreeItem { public class StoreRegisterTreeItem extends TreeItem {
public int registerIndex; public RegisterNumber register;
public TreeItem value; public TreeItem value;
public StoreRegisterTreeItem(Action instruction, int registerIndex, TreeItem value) { public StoreRegisterTreeItem(Action instruction, RegisterNumber register, TreeItem value) {
super(instruction, PRECEDENCE_PRIMARY); super(instruction, PRECEDENCE_PRIMARY);
this.value = value; this.value = value;
this.registerIndex = registerIndex; this.register = register;
} }
@Override @Override
public String toString(ConstantPool constants) { public String toString(ConstantPool constants) {
return "register" + registerIndex + "=" + value.toString(constants) + ";"; return register.toString() + "=" + value.toString(constants) + ";";
} }
} }

Some files were not shown because too many files have changed in this diff Show More