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

This commit is contained in:
Jindra Petk
2010-09-06 15:32:07 +02:00
parent fafbbc4add
commit d0b5bf3559
102 changed files with 270 additions and 136 deletions

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.swf4.*;
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.swf7.ActionDefineFunction2;
import com.jpexs.asdec.action.swf7.ActionTry;
@@ -21,6 +22,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.EmptyStackException;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
@@ -379,8 +381,9 @@ public class Action {
* @param stack Stack
* @param constants Constant pool
* @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
*/
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);
}
/**
* Converts list of actions to List of treeItems
*
* @param regNames Register names
* @param actions List of actions
* @param version SWF version
* @return List of treeItems
*/
public static List<TreeItem> actionsToTree(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);
public static List<TreeItem> actionsToTree(HashMap<Integer,String> regNames,List<Action> actions, int 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>();
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;
}
@@ -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>();
int ip = start;
boolean isWhile = false;
boolean isForIn = false;
TreeItem inItem=null;
int loopStart = 0;
loopip:
while (ip <= end + 1) {
@@ -624,7 +630,7 @@ public class Action {
if (((ActionIf) jif).getRef(version) == addr) {
if (jif.getAddress() > addr) {
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);
loopList.add(currentLoop);
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"));
break;
}
TreeItem expression = stack.pop();
if (expression instanceof NotTreeItem) {
expression = ((NotTreeItem) expression).value;
} else {
expression = new NotTreeItem(action, expression);
TreeItem expression = null;
if(!isForIn){
expression=stack.pop();
if (expression instanceof NotTreeItem) {
expression = ((NotTreeItem) expression).value;
} else {
expression = new NotTreeItem(action, expression);
}
}
List<TreeItem> onTrue = new ArrayList<TreeItem>();
List<TreeItem> onFalse = new ArrayList<TreeItem>();
@@ -697,21 +706,36 @@ public class Action {
if ((refIp > jumpIp) && (refIp <= end + 1)) {
hasElse = true;
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;
if (isWhile) {
if (isWhile||isForIn) {
currentLoop = new Loop(loopStart, jumpIp);
loopList.add(currentLoop);
}
boolean isFor = false;
boolean isTernar = false;
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 {
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) {
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;
} else {
//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));
} else if (isTernar) {
stack.push(new TernarOpTreeItem(action, expression, trueStack.pop(), falseStack.pop()));
@@ -758,10 +784,17 @@ public class Action {
ip = (hasElse ? jumpElseIp : jumpIp);
isWhile = false;
isFor = false;
isForIn = false;
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;
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;
if (atry.catchInRegisterFlag) {
catchName = new DirectValueTreeItem(atry, new RegisterNumber(atry.catchRegister), constants);
@@ -771,25 +804,39 @@ public class Action {
List<TreeItem> catchExceptions = new ArrayList<TreeItem>();
catchExceptions.add(catchName);
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));
List<TreeItem> finallyCommands = actionsToTree(unknownJumps, loopList, jumpsOrIfs, new Stack<TreeItem>(), constants, atry.finallyBody, 0, atry.finallyBody.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(registerNames,unknownJumps, loopList, jumpsOrIfs, new Stack<TreeItem>(), constants, atry.finallyBody, 0, atry.finallyBody.size() - 1, version);
output.add(new TryTreeItem(tryCommands, catchExceptions, catchCommands, finallyCommands));
} else if (action instanceof ActionWith) {
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));
} 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);
} 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);
} else if (action instanceof ActionPushDuplicate) {
do {
if (actions.get(ip + 1) instanceof ActionNot) {
if (actions.get(ip + 2) instanceof ActionIf) {
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;
} else {
output.add(new UnsupportedTreeItem(action, "ActionPushDuplicate with Not"));
@@ -797,7 +844,7 @@ public class Action {
}
} else if (actions.get(ip + 1) instanceof ActionIf) {
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;
} else {
output.add(new UnsupportedTreeItem(action, "ActionPushDuplicate with no If"));
@@ -806,13 +853,14 @@ public class Action {
action = actions.get(ip);
}
while (action instanceof ActionPushDuplicate);
continue;
} else if (action instanceof ActionStoreRegister) {
if ((ip + 1 <= end) && (actions.get(ip + 1) instanceof ActionPop)) {
action.translate(stack, constants, output);
action.translate(stack, constants, output, registerNames);
stack.pop();
ip++;
} else {
action.translate(stack, constants, output);
action.translate(stack, constants, output, registerNames);
}
} else if (action instanceof ActionStrictEquals) {
if ((ip + 1 < actions.size()) && (actions.get(ip + 1) instanceof ActionIf)) {
@@ -833,7 +881,7 @@ public class Action {
do {
ip++;
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;
caseBodyIps.add(adr2ip(actions, ((ActionIf) actions.get(ip)).getRef(version), version));
if (actions.get(ip + 1) instanceof ActionJump) {
@@ -848,16 +896,16 @@ public class Action {
if (i < caseBodyIps.size() - 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));
continue;
} else {
action.translate(stack, constants, output);
action.translate(stack, constants, output, registerNames);
}
} else {
try {
action.translate(stack, constants, output);
action.translate(stack, constants, output, registerNames);
} catch (EmptyStackException ese) {
output.add(new UnsupportedTreeItem(action, "Empty stack"));
}

View File

@@ -103,7 +103,7 @@ public class MainFrame extends JFrame implements TreeSelectionListener, ActionLi
miSaveAs.addActionListener(this);
JMenuItem miExport = new JMenuItem("Export...");
miExport.setActionCommand("EXPORT");
miExport.addActionListener(this);
//miExport.addActionListener(this);
menuFile.add(miOpen);
menuFile.add(miSave);
menuFile.add(miSaveAs);

View File

@@ -50,7 +50,7 @@ public class ActionGetURL extends Action {
}
@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));
}
}

View File

@@ -46,7 +46,7 @@ public class ActionGoToLabel extends Action {
}
@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));
}
}

View File

@@ -45,7 +45,7 @@ public class ActionGotoFrame extends Action {
}
@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));
}
}

View File

@@ -20,7 +20,7 @@ public class ActionNextFrame extends Action {
}
@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();"));
}
}

View File

@@ -19,7 +19,7 @@ public class ActionPlay extends Action {
}
@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();"));
}
}

View File

@@ -20,7 +20,7 @@ public class ActionPrevFrame extends Action {
}
@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();"));
}
}

View File

@@ -46,7 +46,7 @@ public class ActionSetTarget extends Action {
}
@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));
}
}

View File

@@ -20,7 +20,7 @@ public class ActionStop extends Action {
}
@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();"));
}
}

View File

@@ -19,7 +19,7 @@ public class ActionStopSounds extends Action {
}
@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();"));
}
}

View File

@@ -20,7 +20,7 @@ public class ActionToggleQuality extends Action {
}
@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();"));
}
}

View File

@@ -49,7 +49,7 @@ public class ActionWaitForFrame extends Action {
}
@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));
}
}

View File

@@ -20,7 +20,7 @@ public class ActionAdd extends Action {
}
@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 b = stack.pop();
stack.push(new AddTreeItem(this, b, a));

View File

@@ -20,7 +20,7 @@ public class ActionAnd extends Action {
}
@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 b = stack.pop();
stack.push(new AndTreeItem(this, b, a));

View File

@@ -20,7 +20,7 @@ public class ActionAsciiToChar extends Action {
}
@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();
stack.push(new AsciiToCharTreeItem(this, a));
}

View File

@@ -20,7 +20,7 @@ public class ActionCall extends Action {
}
@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()));
}
}

View File

@@ -20,7 +20,7 @@ public class ActionCharToAscii extends Action {
}
@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();
stack.push(new CharToAsciiTreeItem(this, a));
}

View File

@@ -20,7 +20,7 @@ public class ActionCloneSprite extends Action {
}
@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 target = stack.pop();
TreeItem source = stack.pop();

View File

@@ -21,7 +21,7 @@ public class ActionDivide extends Action {
@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 b = stack.pop();
stack.push(new DivideTreeItem(this, b, a));

View File

@@ -20,7 +20,7 @@ public class ActionEndDrag extends Action {
}
@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();"));
}
}

View File

@@ -20,7 +20,7 @@ public class ActionEquals extends Action {
}
@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 b = stack.pop();
stack.push(new EqTreeItem(this, b, a));

View File

@@ -21,7 +21,7 @@ public class ActionGetProperty extends Action {
}
@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 target = stack.pop();
int indexInt = 0;

View File

@@ -20,7 +20,7 @@ public class ActionGetTime extends Action {
}
@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()"));
}
}

View File

@@ -57,7 +57,7 @@ public class ActionGetURL2 extends Action {
}
@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 urlString = stack.pop();
output.add(new GetURL2TreeItem(this, urlString, targetString, sendVarsMethod, loadTargetFlag, loadTargetFlag));

View File

@@ -20,7 +20,7 @@ public class ActionGetVariable extends Action {
}
@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();
stack.push(new GetVariableTreeItem(this,value));
}

View File

@@ -62,7 +62,7 @@ public class ActionGotoFrame2 extends Action {
}
@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();
output.add(new GotoFrame2TreeItem(this, frame, sceneBiasFlag, playFlag, sceneBias));
}

View File

@@ -20,7 +20,7 @@ public class ActionLess extends Action {
}
@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 b = stack.pop();
stack.push(new LtTreeItem(this, b, a));

View File

@@ -20,7 +20,7 @@ public class ActionMBAsciiToChar extends Action {
}
@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();
stack.push(new MBAsciiToCharTreeItem(this, a));
}

View File

@@ -19,7 +19,7 @@ public class ActionMBCharToAscii extends Action {
}
@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();
stack.push(new MBCharToAsciiTreeItem(this, a));
}

View File

@@ -20,7 +20,7 @@ public class ActionMBStringExtract extends Action {
}
@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 index = stack.pop();
TreeItem value = stack.pop();

View File

@@ -19,7 +19,7 @@ public class ActionMBStringLength extends Action {
}
@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();
stack.push(new MBStringLengthTreeItem(this, a));
}

View File

@@ -20,7 +20,7 @@ public class ActionMultiply extends Action {
}
@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 b = stack.pop();
stack.push(new MultiplyTreeItem(this, b, a));

View File

@@ -20,7 +20,7 @@ public class ActionNot extends Action {
}
@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();
stack.push(new NotTreeItem(this, a));
}

View File

@@ -20,7 +20,7 @@ public class ActionOr extends Action {
}
@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 b = stack.pop();
stack.push(new OrTreeItem(this, b, a));

View File

@@ -21,7 +21,7 @@ public class ActionPop extends Action {
}
@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();
if (!(val instanceof DirectValueTreeItem))
output.add(new VoidTreeItem(this, val));

View File

@@ -182,11 +182,16 @@ public class ActionPush extends Action {
}
@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) {
if (o instanceof ConstantIndex) {
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));
}
}

View File

@@ -20,7 +20,7 @@ public class ActionRandomNumber extends Action {
}
@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();
stack.push(new RandomNumberTreeItem(this, maximum));
}

View File

@@ -20,7 +20,7 @@ public class ActionRemoveSprite extends Action {
}
@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();
output.add(new RemoveSpriteTreeItem(this, target));
}

View File

@@ -21,7 +21,7 @@ public class ActionSetProperty extends Action {
}
@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 index = stack.pop();
TreeItem target = stack.pop();

View File

@@ -20,7 +20,7 @@ public class ActionSetTarget2 extends Action {
}
@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();
output.add(new SetTarget2TreeItem(this, target));
}

View File

@@ -20,7 +20,7 @@ public class ActionSetVariable extends Action {
}
@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 name = stack.pop();
output.add(new SetVariableTreeItem(this, name, value));

View File

@@ -21,7 +21,7 @@ public class ActionStartDrag extends Action {
}
@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 lockCenter = stack.pop();
TreeItem constrain = stack.pop();

View File

@@ -20,7 +20,7 @@ public class ActionStringAdd extends Action {
}
@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 b = stack.pop();
stack.push(new StringAddTreeItem(this, b, a));

View File

@@ -20,7 +20,7 @@ public class ActionStringEquals extends Action {
}
@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 b = stack.pop();
stack.push(new StringEqTreeItem(this, b, a));

View File

@@ -20,7 +20,7 @@ public class ActionStringExtract extends Action {
}
@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 index = stack.pop();
TreeItem value = stack.pop();

View File

@@ -20,7 +20,7 @@ public class ActionStringLength extends Action {
}
@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();
stack.push(new StringLengthTreeItem(this, a));
}

View File

@@ -20,7 +20,7 @@ public class ActionStringLess extends Action {
}
@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 b = stack.pop();
stack.push(new StringLtTreeItem(this, b, a));

View File

@@ -20,7 +20,7 @@ public class ActionSubtract extends Action {
}
@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 b = stack.pop();
stack.push(new SubtractTreeItem(this, b, a));

View File

@@ -20,7 +20,7 @@ public class ActionToInteger extends Action {
}
@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();
stack.push(new ToIntegerTreeItem(this, a));
}

View File

@@ -20,7 +20,7 @@ public class ActionTrace extends Action {
}
@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();
output.add(new TraceTreeItem(this, value));
}

View File

@@ -45,7 +45,7 @@ public class ActionWaitForFrame2 extends Action {
}
@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();
output.add(new WaitForFrame2TreeItem(this, frame, skipCount));
}

View File

@@ -2,6 +2,7 @@ package com.jpexs.asdec.action.swf4;
public class RegisterNumber {
public int number;
public String name=null;
public RegisterNumber(int number) {
this.number = number;
@@ -9,6 +10,7 @@ public class RegisterNumber {
@Override
public String toString() {
return "register" + number;
if(name==null) return "register" + number;
return name;
}
}

View File

@@ -19,7 +19,7 @@ public class ActionAdd2 extends Action {
}
@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 b = stack.pop();
stack.push(new AddTreeItem(this, b, a));

View File

@@ -20,7 +20,7 @@ public class ActionBitAnd extends Action {
}
@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 b = stack.pop();
stack.push(new BitAndTreeItem(this, b, a));

View File

@@ -19,7 +19,7 @@ public class ActionBitLShift extends Action {
}
@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 b = stack.pop();
stack.push(new LShiftTreeItem(this, b, a));

View File

@@ -20,7 +20,7 @@ public class ActionBitOr extends Action {
}
@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 b = stack.pop();
stack.push(new BitOrTreeItem(this, b, a));

View File

@@ -20,7 +20,7 @@ public class ActionBitRShift extends Action {
}
@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 b = stack.pop();
stack.push(new RShiftTreeItem(this, b, a));

View File

@@ -19,7 +19,7 @@ public class ActionBitURShift extends Action {
}
@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 b = stack.pop();
stack.push(new URShiftTreeItem(this, b, a));

View File

@@ -20,7 +20,7 @@ public class ActionBitXor extends Action {
}
@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 b = stack.pop();
stack.push(new BitXorTreeItem(this, b, a));

View File

@@ -21,7 +21,7 @@ public class ActionCallFunction extends Action {
}
@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();
long numArgs = popLong(stack);
List<TreeItem> args = new ArrayList<TreeItem>();

View File

@@ -21,7 +21,7 @@ public class ActionCallMethod extends Action {
}
@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 scriptObject = stack.pop();
long numArgs = popLong(stack);

View File

@@ -66,7 +66,7 @@ public class ActionConstantPool extends Action {
}
@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;
}
}

View File

@@ -20,7 +20,7 @@ public class ActionDecrement extends Action {
}
@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();
stack.push(new DecrementTreeItem(this, a));
}

View File

@@ -20,7 +20,7 @@ public class ActionDefineLocal extends Action {
}
@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 name = stack.pop();
output.add(new DefineLocalTreeItem(this, name, value));

View File

@@ -21,7 +21,7 @@ public class ActionDefineLocal2 extends Action {
@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();
output.add(new DefineLocalTreeItem(this, name, null));
}

View File

@@ -22,7 +22,7 @@ public class ActionDelete extends Action {
@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 object = stack.pop();

View File

@@ -21,7 +21,7 @@ public class ActionDelete2 extends Action {
}
@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();
output.add(new DeleteTreeItem(this, null, propertyName));

View File

@@ -20,7 +20,7 @@ public class ActionEnumerate extends Action {
}
@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();
stack.push(new EnumerateTreeItem(this, object));
}

View File

@@ -20,7 +20,7 @@ public class ActionEquals2 extends Action {
}
@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 b = stack.pop();
stack.push(new EqTreeItem(this, b, a));

View File

@@ -20,7 +20,7 @@ public class ActionGetMember extends Action {
}
@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 object = stack.pop();
stack.push(new GetMemberTreeItem(this, object, functionName));

View File

@@ -20,7 +20,7 @@ public class ActionIncrement extends Action {
}
@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();
stack.push(new IncrementTreeItem(this, a));
}

View File

@@ -16,7 +16,7 @@ public class ActionInitArray extends Action {
}
@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);
List<TreeItem> args = new ArrayList<TreeItem>();
for (int l = 0; l < numArgs; l++) {

View File

@@ -21,7 +21,7 @@ public class ActionInitObject extends Action {
}
@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);
List<TreeItem> values = new ArrayList<TreeItem>();
List<TreeItem> names = new ArrayList<TreeItem>();

View File

@@ -20,7 +20,7 @@ public class ActionLess2 extends Action {
}
@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 b = stack.pop();
stack.push(new LtTreeItem(this, b, a));

View File

@@ -20,7 +20,7 @@ public class ActionModulo extends Action {
}
@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 b = stack.pop();
stack.push(new ModuloTreeItem(this, b, a));

View File

@@ -21,7 +21,7 @@ public class ActionNewMethod extends Action {
}
@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 scriptObject = stack.pop();
long numArgs = popLong(stack);

View File

@@ -21,7 +21,7 @@ public class ActionNewObject extends Action {
}
@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();
long numArgs = popLong(stack);
List<TreeItem> args = new ArrayList<TreeItem>();

View File

@@ -19,7 +19,7 @@ public class ActionPushDuplicate extends Action {
}
@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();
stack.push(value);
stack.push(value);

View File

@@ -20,7 +20,7 @@ public class ActionReturn extends Action {
}
@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();
output.add(new ReturnTreeItem(this, value));
}

View File

@@ -20,7 +20,7 @@ public class ActionSetMember extends Action {
}
@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 objectName = stack.pop();
TreeItem object = stack.pop();

View File

@@ -19,7 +19,7 @@ public class ActionStackSwap extends Action {
}
@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 b = stack.pop();
stack.push(a);

View File

@@ -5,6 +5,7 @@ import com.jpexs.asdec.SWFOutputStream;
import com.jpexs.asdec.action.Action;
import com.jpexs.asdec.action.parser.FlasmLexer;
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.StoreRegisterTreeItem;
import com.jpexs.asdec.action.treemodel.TreeItem;
@@ -45,8 +46,12 @@ public class ActionStoreRegister extends Action {
}
@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();
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));
}
}

View File

@@ -20,7 +20,7 @@ public class ActionTargetPath extends Action {
}
@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();
stack.push(new TargetPathTreeItem(this, object));
}

View File

@@ -20,7 +20,7 @@ public class ActionToNumber extends Action {
}
@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();
stack.push(new ToNumberTreeItem(this, object));
}

View File

@@ -20,7 +20,7 @@ public class ActionToString extends Action {
}
@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();
stack.push(new ToStringTreeItem(this, object));
}

View File

@@ -20,7 +20,7 @@ public class ActionTypeOf extends Action {
}
@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();
stack.push(new TypeOfTreeItem(this, object));
}

View File

@@ -19,7 +19,7 @@ public class ActionEnumerate2 extends Action {
}
@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();
stack.push(new EnumerateTreeItem(this, object));
}

View File

@@ -20,7 +20,7 @@ public class ActionGreater extends Action {
}
@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 b = stack.pop();
stack.push(new GtTreeItem(this, b, a));

View File

@@ -19,7 +19,7 @@ public class ActionInstanceOf extends Action {
}
@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 b = stack.pop();
stack.push(new InstanceOfTreeItem(this, b, a));

View File

@@ -20,7 +20,7 @@ public class ActionStrictEquals extends Action {
}
@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 b = stack.pop();
stack.push(new StrictEqTreeItem(this, b, a));

View File

@@ -20,7 +20,7 @@ public class ActionStringGreater extends Action {
}
@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 b = stack.pop();
stack.push(new GtTreeItem(this, b, a));

View File

@@ -20,7 +20,7 @@ public class ActionCastOp extends Action {
}
@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 constructor = stack.pop();
stack.push(new CastOpTreeItem(this, constructor, object));

View File

@@ -80,6 +80,7 @@ public class ActionDefineFunction2 extends Action {
code = ASMParser.parse(labels, address + getPreLen(version), lexer, constantPool, version);
}
@Override
public byte[] getBytes(int version) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);

View File

@@ -21,7 +21,7 @@ public class ActionExtends extends Action {
@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 subclass = stack.pop();
output.add(new ExtendsTreeItem(this, subclass, superclass));

View File

@@ -21,7 +21,7 @@ public class ActionImplementsOp extends Action {
}
@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();
long inCount = popLong(stack);
List<TreeItem> superclasses = new ArrayList<TreeItem>();

View File

@@ -20,7 +20,7 @@ public class ActionThrow extends Action {
}
@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();
output.add(new ThrowTreeItem(this, object));
}

View File

@@ -7,15 +7,28 @@ import java.util.List;
public class FunctionTreeItem extends TreeItem {
public List<TreeItem> actions;
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);
this.actions=actions;
this.constants=constants.constants;
this.functionName=functionName;
this.paramNames=paramNames;
}
@Override
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;
}
}

View File

@@ -14,6 +14,10 @@ public class GetMemberTreeItem extends TreeItem {
@Override
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);
}
}

View File

@@ -1,19 +1,20 @@
package com.jpexs.asdec.action.treemodel;
import com.jpexs.asdec.action.Action;
import com.jpexs.asdec.action.swf4.RegisterNumber;
public class StoreRegisterTreeItem extends TreeItem {
public int registerIndex;
public RegisterNumber register;
public TreeItem value;
public StoreRegisterTreeItem(Action instruction, int registerIndex, TreeItem value) {
public StoreRegisterTreeItem(Action instruction, RegisterNumber register, TreeItem value) {
super(instruction, PRECEDENCE_PRIMARY);
this.value = value;
this.registerIndex = registerIndex;
this.register = register;
}
@Override
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