AS1/2 direct editing

ifFrameLoaded function
This commit is contained in:
Jindra Petk
2013-04-15 19:07:16 +02:00
parent bb0a1a49bd
commit f85f2cca27
22 changed files with 2246 additions and 1142 deletions

View File

@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.ActionGraphSource;
import com.jpexs.decompiler.flash.action.special.ActionEnd;
import com.jpexs.decompiler.flash.action.special.ActionNop;
import com.jpexs.decompiler.flash.action.special.ActionStore;
import com.jpexs.decompiler.flash.action.swf3.*;
import com.jpexs.decompiler.flash.action.swf4.*;
import com.jpexs.decompiler.flash.action.swf5.*;
@@ -777,7 +778,7 @@ public class SWFInputStream extends InputStream {
//throw new RuntimeException("Wrong length "+a.toString()+" info:"+infoCorrect+" actual:"+b.length+" datalen:"+(infoCorrect-info));
}
int actual = actual = a.getBytes(sis.version).length;
if (!(a instanceof GraphSourceItemContainer)) {
if ((!(a instanceof ActionStore)) && (!(a instanceof GraphSourceItemContainer))) {
int change = info - (rri.getPos() - ip);
if (change > 0) {
a.afterInsert = new ActionJump(change);

View File

@@ -95,7 +95,7 @@ public class Action implements GraphSourceItem {
"_xmouse",
"_ymouse"
};
public static final List<String> propertyNamesList=Arrays.asList(propertyNames);
public static final List<String> propertyNamesList = Arrays.asList(propertyNames);
private static Logger logger = Logger.getLogger(Action.class.getName());
/**

View File

@@ -58,9 +58,13 @@ public class ActionPanel extends JPanel implements ActionListener {
public List<Tag> list;
public JSplitPane splitPane;
public JSplitPane splitPane2;
public JButton saveButton = new JButton("Save");
public JButton editButton = new JButton("Edit");
public JButton cancelButton = new JButton("Cancel");
public JButton saveButton = new JButton("Save", View.getIcon("save16"));
public JButton editButton = new JButton("Edit", View.getIcon("edit16"));
public JButton cancelButton = new JButton("Cancel", View.getIcon("cancel16"));
public JLabel betaLabel = new JLabel("(Beta)");
public JButton editDecompiledButton = new JButton("Edit", View.getIcon("edit16"));
public JButton saveDecompiledButton = new JButton("Save", View.getIcon("save16"));
public JButton cancelDecompiledButton = new JButton("Cancel", View.getIcon("cancel16"));
public JToggleButton hexButton;
public JButton saveHexButton = new JButton("Save hex");
public JButton loadHexButton = new JButton("Load hex");
@@ -71,6 +75,7 @@ public class ActionPanel extends JPanel implements ActionListener {
public String lastDisasm = "";
private boolean ignoreCarret = false;
private boolean editMode = false;
private boolean editDecompiledMode = false;
private List<com.jpexs.decompiler.flash.action.Action> lastCode;
private ASMSource src;
public JPanel topButtonsPan;
@@ -146,6 +151,7 @@ public class ActionPanel extends JPanel implements ActionListener {
}
}
setEditMode(false);
setDecompiledEditMode(false);
Main.stopWork();
}
}).start();
@@ -200,6 +206,21 @@ public class ActionPanel extends JPanel implements ActionListener {
buttonsPan.add(saveButton);
buttonsPan.add(cancelButton);
editButton.setMargin(new Insets(3, 3, 3, 10));
saveButton.setMargin(new Insets(3, 3, 3, 10));
cancelButton.setMargin(new Insets(3, 3, 3, 10));
JPanel decButtonsPan = new JPanel(new FlowLayout());
decButtonsPan.add(editDecompiledButton);
decButtonsPan.add(betaLabel);
decButtonsPan.add(saveDecompiledButton);
decButtonsPan.add(cancelDecompiledButton);
editDecompiledButton.setMargin(new Insets(3, 3, 3, 10));
saveDecompiledButton.setMargin(new Insets(3, 3, 3, 10));
cancelDecompiledButton.setMargin(new Insets(3, 3, 3, 10));
//buttonsPan.add(saveHexButton);
//buttonsPan.add(loadHexButton);
panB.add(buttonsPan, BorderLayout.SOUTH);
@@ -219,10 +240,22 @@ public class ActionPanel extends JPanel implements ActionListener {
cancelButton.setVisible(false);
saveDecompiledButton.addActionListener(this);
saveDecompiledButton.setActionCommand("SAVEDECOMPILED");
editDecompiledButton.addActionListener(this);
editDecompiledButton.setActionCommand("EDITDECOMPILED");
cancelDecompiledButton.addActionListener(this);
cancelDecompiledButton.setActionCommand("CANCELDECOMPILED");
saveDecompiledButton.setVisible(false);
cancelDecompiledButton.setVisible(false);
JPanel panA = new JPanel();
panA.setLayout(new BorderLayout());
panA.add(new JScrollPane(decompiledEditor), BorderLayout.CENTER);
panA.add(decLabel, BorderLayout.NORTH);
panA.add(decButtonsPan, BorderLayout.SOUTH);
decLabel.setHorizontalAlignment(SwingConstants.CENTER);
decLabel.setBorder(new BevelBorder(BevelBorder.RAISED));
@@ -256,6 +289,9 @@ public class ActionPanel extends JPanel implements ActionListener {
if (ignoreCarret) {
return;
}
if (editMode || editDecompiledMode) {
return;
}
editor.getCaret().setVisible(true);
int pos = editor.getCaretPosition();
Highlighting lastH = new Highlighting(0, 0, 0);
@@ -282,7 +318,7 @@ public class ActionPanel extends JPanel implements ActionListener {
if (ignoreCarret) {
return;
}
if (editMode) {
if (editMode || editDecompiledMode) {
return;
}
decompiledEditor.getCaret().setVisible(true);
@@ -336,6 +372,25 @@ public class ActionPanel extends JPanel implements ActionListener {
editMode = val;
}
public void setDecompiledEditMode(boolean val) {
if (val) {
decompiledEditor.setEditable(true);
saveDecompiledButton.setVisible(true);
editDecompiledButton.setVisible(false);
betaLabel.setVisible(false);
cancelDecompiledButton.setVisible(true);
decompiledEditor.getCaret().setVisible(true);
} else {
decompiledEditor.setEditable(false);
saveDecompiledButton.setVisible(false);
editDecompiledButton.setVisible(true);
betaLabel.setVisible(true);
cancelDecompiledButton.setVisible(false);
decompiledEditor.getCaret().setVisible(true);
}
editDecompiledMode = val;
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("GRAPH")) {
@@ -355,13 +410,36 @@ public class ActionPanel extends JPanel implements ActionListener {
src.setActions(ASMParser.parse(0, src.getPos(), true, new ByteArrayInputStream(editor.getText().getBytes()), SWF.DEFAULT_VERSION), SWF.DEFAULT_VERSION);
setSource(this.src);
JOptionPane.showMessageDialog(this, "Code successfully saved");
saveButton.setVisible(false);
cancelButton.setVisible(false);
editButton.setVisible(true);
editor.setEditable(false);
editMode = false;
} catch (IOException ex) {
} catch (ParseException ex) {
JOptionPane.showMessageDialog(this, "" + ex.text + " on line " + ex.line, "Error", JOptionPane.ERROR_MESSAGE);
}
saveButton.setVisible(false);
editButton.setVisible(true);
editor.setEditable(false);
} else if (e.getActionCommand().equals("EDITDECOMPILED")) {
setDecompiledEditMode(true);
} else if (e.getActionCommand().equals("CANCELDECOMPILED")) {
setDecompiledEditMode(false);
} else if (e.getActionCommand().equals("SAVEDECOMPILED")) {
try {
ActionScriptParser par = new ActionScriptParser();
src.setActions(par.parse(decompiledEditor.getText()), SWF.DEFAULT_VERSION);
setSource(this.src);
JOptionPane.showMessageDialog(this, "Code successfully saved");
saveDecompiledButton.setVisible(false);
cancelDecompiledButton.setVisible(false);
editDecompiledButton.setVisible(true);
betaLabel.setVisible(true);
decompiledEditor.setEditable(false);
editDecompiledMode = false;
} catch (IOException ex) {
} catch (ParseException ex) {
JOptionPane.showMessageDialog(this, "" + ex.text + " on line " + ex.line, "Error", JOptionPane.ERROR_MESSAGE);
}
}
}
}

View File

@@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.action.flashlite.ActionFSCommand2;
import com.jpexs.decompiler.flash.action.flashlite.ActionStrictMode;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.special.ActionNop;
import com.jpexs.decompiler.flash.action.special.ActionStore;
import com.jpexs.decompiler.flash.action.swf3.*;
import com.jpexs.decompiler.flash.action.swf4.*;
import com.jpexs.decompiler.flash.action.swf5.*;
@@ -43,6 +44,9 @@ public class ASMParser {
List<Action> list = new ArrayList<Action>();
Stack<GraphSourceItemContainer> containers = new Stack<GraphSourceItemContainer>();
HashMap<GraphSourceItemContainer, Integer> containerPos = new HashMap<GraphSourceItemContainer, Integer>();
Stack<ActionStore> stores = new Stack<ActionStore>();
Stack<Integer> storeLengths = new Stack<Integer>();
int actualLen = 0;
while (true) {
ASMParsedSymbol symb = lexer.yylex();
if (symb.type == ASMParsedSymbol.TYPE_LABEL) {
@@ -298,6 +302,25 @@ public class ASMParser {
}
if (a != null) {
list.add(a);
if (!stores.isEmpty()) {
actualLen++;
if (actualLen == stores.peek().getStoreSize()) {
ActionStore st = stores.pop();
st.setStore(list.subList(list.size() - actualLen, list.size()));
list = list.subList(0, list.size() - actualLen);
if (!stores.isEmpty()) {
actualLen = storeLengths.pop();
}
}
}
if (a instanceof ActionStore) {
if (!stores.isEmpty()) {
storeLengths.push(actualLen);
}
stores.push((ActionStore) a);
actualLen = 0;
}
}
} else if (symb.type == ASMParsedSymbol.TYPE_EOL) {
} else if ((symb.type == ASMParsedSymbol.TYPE_BLOCK_END) || (symb.type == ASMParsedSymbol.TYPE_EOF)) {

View File

@@ -36,6 +36,12 @@ import static com.jpexs.decompiler.flash.action.parser.script.SymbolType.DO;
import static com.jpexs.decompiler.flash.action.parser.script.SymbolType.INCREMENT;
import static com.jpexs.decompiler.flash.action.parser.script.SymbolType.PARENT_OPEN;
import static com.jpexs.decompiler.flash.action.parser.script.SymbolType.SWITCH;
import com.jpexs.decompiler.flash.action.swf3.ActionNextFrame;
import com.jpexs.decompiler.flash.action.swf3.ActionPlay;
import com.jpexs.decompiler.flash.action.swf3.ActionPrevFrame;
import com.jpexs.decompiler.flash.action.swf3.ActionStop;
import com.jpexs.decompiler.flash.action.swf3.ActionStopSounds;
import com.jpexs.decompiler.flash.action.swf3.ActionToggleQuality;
import com.jpexs.decompiler.flash.action.swf4.*;
import com.jpexs.decompiler.flash.action.swf5.*;
import com.jpexs.decompiler.flash.action.swf6.ActionEnumerate2;
@@ -66,14 +72,17 @@ import java.util.logging.Logger;
*/
public class ActionScriptParser {
public static final int REGISTER_PARENT = 5;
public static final int REGISTER_ROOT = 4;
public static final int REGISTER_SUPER = 3;
public static final int REGISTER_ARGUMENTS = 2;
public static final int REGISTER_THIS = 1;
public static final int REGISTER_ARGUMENTS = 2;
public static final int REGISTER_SUPER = 3;
public static final int REGISTER_ROOT = 4;
public static final int REGISTER_PARENT = 5;
public static final int REGISTER_GLOBAL = 6;
private long uniqLast = 0;
private boolean debugMode = false;
/*
* TODO: WITH
*/
private String uniqId() {
uniqLast++;
@@ -193,7 +202,7 @@ public class ActionScriptParser {
}
} else {
ret.add(s.value.toString().equals("trace") ? new ActionPush(s.value.toString()) : pushConst(s.value.toString()));
ret.add(pushConst(s.value.toString()));
ret.add(new ActionGetVariable());
}
}
@@ -367,28 +376,28 @@ public class ActionScriptParser {
int newpos = 1;
HashMap<Integer, Integer> registerMap = new HashMap<Integer, Integer>();
if (preloadParentFlag) {
registerMap.put(1, newpos);
newpos++;
}
if (preloadRootFlag) {
registerMap.put(2, newpos);
newpos++;
}
if (preloadSuperFlag) {
registerMap.put(3, newpos);
if (preloadThisFlag) {
registerMap.put(REGISTER_THIS, newpos);
newpos++;
}
if (preloadArgumentsFlag) {
registerMap.put(4, newpos);
registerMap.put(REGISTER_ARGUMENTS, newpos);
newpos++;
}
if (preloadThisFlag) {
registerMap.put(5, newpos);
if (preloadSuperFlag) {
registerMap.put(REGISTER_SUPER, newpos);
newpos++;
}
if (preloadRootFlag) {
registerMap.put(REGISTER_ROOT, newpos);
newpos++;
}
if (preloadParentFlag) {
registerMap.put(REGISTER_PARENT, newpos);
newpos++;
}
if (preloadGlobalFlag) {
registerMap.put(6, newpos);
registerMap.put(REGISTER_GLOBAL, newpos);
newpos++;
}
if (newpos < 1) {
@@ -397,10 +406,10 @@ public class ActionScriptParser {
for (int i = 0; i < 256; i++) {
if (usedRegisters.contains(7 + i)) {
registerMap.put(7 + i, newpos);
newpos++;
if (i < paramNames.size()) {
paramRegs.add(0, newpos);
}
newpos++;
} else {
if (i < paramNames.size()) {
paramRegs.add(0, 0);
@@ -549,10 +558,12 @@ public class ActionScriptParser {
constr = (typeToActions(globalClassTypeStr, constr));
} else {
ifbody.add(new ActionPush(new RegisterNumber(isStatic ? 1 : 2)));
ifbody.add(pushConst(fname));
ifbody.addAll(function(!isInterface, "", true));
ifbody.add(new ActionSetMember());
if (!isInterface) {
ifbody.add(new ActionPush(new RegisterNumber(isStatic ? 1 : 2)));
ifbody.add(pushConst(fname));
ifbody.addAll(function(!isInterface, "", true));
ifbody.add(new ActionSetMember());
}
}
break;
case VAR:
@@ -595,8 +606,10 @@ public class ActionScriptParser {
if (constr.isEmpty()) {
List<Action> val = new ArrayList<Action>();
val.add(new ActionDefineFunction(null, new ArrayList<String>(), 0, SWF.DEFAULT_VERSION));
val.add(new ActionStoreRegister(1));
val.add(new ActionDefineFunction("", new ArrayList<String>(), 0, SWF.DEFAULT_VERSION));
if (!isInterface) {
val.add(new ActionStoreRegister(1));
}
constr.addAll(typeToActions(globalClassTypeStr, val));
}
if (!extendsStr.isEmpty()) {
@@ -604,17 +617,22 @@ public class ActionScriptParser {
constr.addAll(typeToActions(extendsStr, null));
constr.add(new ActionExtends());
}
constr.add(new ActionPush(new RegisterNumber(1)));
constr.add(pushConst("prototype"));
constr.add(new ActionGetMember());
constr.add(new ActionStoreRegister(2));
constr.add(new ActionPop());
if (!isInterface) {
constr.add(new ActionPush(new RegisterNumber(1)));
constr.add(pushConst("prototype"));
constr.add(new ActionGetMember());
constr.add(new ActionStoreRegister(2));
constr.add(new ActionPop());
}
for (List<String> imp : implementsStr) {
List<String> globImp = new ArrayList<String>();
globImp.add("_global");
globImp.addAll(imp);
constr.addAll(typeToActions(globImp, null));
if (!implementsStr.isEmpty()) {
for (List<String> imp : implementsStr) {
List<String> globImp = new ArrayList<String>();
globImp.add("_global");
globImp.addAll(imp);
constr.addAll(typeToActions(globImp, null));
}
constr.add(new ActionPush(new Long(implementsStr.size())));
constr.addAll(typeToActions(globalClassTypeStr, null));
constr.add(new ActionImplementsOp());
}
@@ -639,6 +657,325 @@ public class ActionScriptParser {
return null;
}
switch (s.type) {
case TRACE:
expected(SymbolType.PARENT_OPEN);
ret.addAll(expression(registerVars, inFunction, inMethod, inMethod));
ret.add(new ActionTrace());
expected(SymbolType.PARENT_CLOSE);
break;
case GETURL:
expected(SymbolType.PARENT_OPEN);
ret.addAll(expression(registerVars, inFunction, inMethod, inMethod));
s = lex();
expected(s, lexer.yyline(), SymbolType.PARENT_CLOSE, SymbolType.COMMA);
int getuMethod = 1;
if (s.type == SymbolType.COMMA) {
ret.addAll(expression(registerVars, inFunction, inMethod, inMethod));
s = lex();
if (s.type == SymbolType.COMMA) {
s = lex();
expected(s, lexer.yyline(), SymbolType.STRING);
if (s.value.equals("GET")) {
getuMethod = 1;
} else if (s.value.equals("POST")) {
getuMethod = 2;
} else {
throw new ParseException("Invalid method, \"GET\" or \"POST\" expected.", lexer.yyline());
}
} else {
lexer.pushback(s);
}
} else {
lexer.pushback(s);
ret.add(pushConst(""));
}
ret.add(new ActionGetURL2(getuMethod, false, false));
expected(SymbolType.PARENT_CLOSE);
break;
case GOTOANDSTOP:
expected(SymbolType.PARENT_OPEN);
List<Action> gtsFrame = expression(registerVars, inFunction, inMethod, inMethod);
s = lex();
if (s.type == SymbolType.COMMA) {
s = lex();
gtsFrame = expression(registerVars, inFunction, inMethod, inMethod);
} else {
lexer.pushback(s);
}
ret.addAll(gtsFrame);
ret.add(new ActionGotoFrame2(false, false, (int) (long) (Long) s.value));
expected(SymbolType.PARENT_CLOSE);
break;
case NEXTFRAME:
expected(SymbolType.PARENT_OPEN);
expected(SymbolType.PARENT_CLOSE);
ret.add(new ActionNextFrame());
break;
case PLAY:
expected(SymbolType.PARENT_OPEN);
expected(SymbolType.PARENT_CLOSE);
ret.add(new ActionPlay());
break;
case PREVFRAME:
expected(SymbolType.PARENT_OPEN);
expected(SymbolType.PARENT_CLOSE);
ret.add(new ActionPrevFrame());
break;
case TELLTARGET:
expected(SymbolType.PARENT_OPEN);
ret.addAll(expression(registerVars, inFunction, inMethod, inMethod));
expected(SymbolType.PARENT_CLOSE);
ret.add(new ActionSetTarget2());
break;
case STOP:
expected(SymbolType.PARENT_OPEN);
expected(SymbolType.PARENT_CLOSE);
ret.add(new ActionStop());
break;
case STOPALLSOUNDS:
expected(SymbolType.PARENT_OPEN);
expected(SymbolType.PARENT_CLOSE);
ret.add(new ActionStopSounds());
break;
case TOGGLEHIGHQUALITY:
expected(SymbolType.PARENT_OPEN);
expected(SymbolType.PARENT_CLOSE);
ret.add(new ActionToggleQuality());
break;
case ORD:
expected(SymbolType.PARENT_OPEN);
ret.addAll(expression(registerVars, inFunction, inMethod, inMethod));
expected(SymbolType.PARENT_CLOSE);
ret.add(new ActionCharToAscii());
ret.add(new ActionPop());
break;
case CHR:
expected(SymbolType.PARENT_OPEN);
ret.addAll(expression(registerVars, inFunction, inMethod, inMethod));
expected(SymbolType.PARENT_CLOSE);
ret.add(new ActionAsciiToChar());
ret.add(new ActionPop());
break;
case DUPLICATEMOVIECLIP:
expected(SymbolType.PARENT_OPEN);
ret.addAll(expression(registerVars, inFunction, inMethod, inMethod));
expected(SymbolType.COMMA);
ret.addAll(expression(registerVars, inFunction, inMethod, inMethod));
expected(SymbolType.COMMA);
ret.addAll(expression(registerVars, inFunction, inMethod, inMethod));
expected(SymbolType.PARENT_CLOSE);
ret.add(new ActionCloneSprite());
ret.add(new ActionPop());
break;
case STOPDRAG:
expected(SymbolType.PARENT_OPEN);
expected(SymbolType.PARENT_CLOSE);
ret.add(new ActionEndDrag());
break;
case GETTIMER:
expected(SymbolType.PARENT_OPEN);
expected(SymbolType.PARENT_CLOSE);
ret.add(new ActionGetTime());
ret.add(new ActionPop());
break;
case LOADVARIABLES:
expected(SymbolType.PARENT_OPEN);
ret.addAll(expression(registerVars, inFunction, inMethod, inMethod));
expected(SymbolType.COMMA);
ret.addAll(expression(registerVars, inFunction, inMethod, inMethod));
s = lex();
expected(s, lexer.yyline(), SymbolType.PARENT_CLOSE, SymbolType.COMMA);
int lvmethod = 1;
if (s.type == SymbolType.COMMA) {
s = lex();
expected(s, lexer.yyline(), SymbolType.STRING);
if (s.value.equals("POST")) {
lvmethod = 2;
} else if (s.value.equals("GET")) {
lvmethod = 1;
} else {
throw new ParseException("Invalid method, \"GET\" or \"POST\" expected.", lexer.yyline());
}
} else {
lexer.pushback(s);
}
expected(SymbolType.PARENT_CLOSE);
ret.add(new ActionGetURL2(lvmethod, false, true));
break;
case LOADMOVIE:
expected(SymbolType.PARENT_OPEN);
ret.addAll(expression(registerVars, inFunction, inMethod, inMethod));
s = lex();
expected(s, lexer.yyline(), SymbolType.PARENT_CLOSE, SymbolType.COMMA);
int method = 1;
if (s.type == SymbolType.COMMA) {
s = lex();
expected(s, lexer.yyline(), SymbolType.STRING);
if (s.value.equals("POST")) {
method = 2;
} else if (s.value.equals("GET")) {
method = 1;
} else {
throw new ParseException("Invalid method, \"GET\" or \"POST\" expected.", lexer.yyline());
}
} else {
lexer.pushback(s);
}
expected(SymbolType.PARENT_CLOSE);
ret.add(new ActionGetURL2(method, true, false));
break;
case GOTOANDPLAY:
expected(SymbolType.PARENT_OPEN);
List<Action> gtpFrame = expression(registerVars, inFunction, inMethod, inMethod);
s = lex();
if (s.type == SymbolType.COMMA) {
s = lex();
gtpFrame = expression(registerVars, inFunction, inMethod, inMethod);
} else {
lexer.pushback(s);
}
ret.addAll(gtpFrame);
ret.add(new ActionGotoFrame2(true, false, (int) (long) (Long) s.value));
expected(SymbolType.PARENT_CLOSE);
break;
case MBORD:
expected(SymbolType.PARENT_OPEN);
ret.addAll(expression(registerVars, inFunction, inMethod, inMethod));
expected(SymbolType.PARENT_CLOSE);
ret.add(new ActionMBCharToAscii());
ret.add(new ActionPop());
break;
case MBCHR:
expected(SymbolType.PARENT_OPEN);
ret.addAll(expression(registerVars, inFunction, inMethod, inMethod));
expected(SymbolType.PARENT_CLOSE);
ret.add(new ActionMBAsciiToChar());
ret.add(new ActionPop());
break;
case MBLENGTH:
expected(SymbolType.PARENT_OPEN);
ret.addAll(expression(registerVars, inFunction, inMethod, inMethod));
expected(SymbolType.PARENT_CLOSE);
ret.add(new ActionMBStringLength());
ret.add(new ActionPop());
break;
case MBSUBSTRING:
expected(SymbolType.PARENT_OPEN);
ret.addAll(expression(registerVars, inFunction, inMethod, inMethod));
expected(SymbolType.COMMA);
ret.addAll(expression(registerVars, inFunction, inMethod, inMethod));
expected(SymbolType.COMMA);
ret.addAll(expression(registerVars, inFunction, inMethod, inMethod));
expected(SymbolType.PARENT_CLOSE);
ret.add(new ActionMBStringExtract());
ret.add(new ActionPop());
break;
case SUBSTR:
expected(SymbolType.PARENT_OPEN);
ret.addAll(expression(registerVars, inFunction, inMethod, inMethod));
expected(SymbolType.COMMA);
ret.addAll(expression(registerVars, inFunction, inMethod, inMethod));
expected(SymbolType.COMMA);
ret.addAll(expression(registerVars, inFunction, inMethod, inMethod));
expected(SymbolType.PARENT_CLOSE);
ret.add(new ActionStringExtract());
ret.add(new ActionPop());
break;
/*case LENGTH:
break;*/
case RANDOM:
expected(SymbolType.PARENT_OPEN);
ret.addAll(expression(registerVars, inFunction, inMethod, inMethod));
expected(SymbolType.PARENT_CLOSE);
ret.add(new ActionRandomNumber());
ret.add(new ActionPop());
break;
case REMOVEMOVIECLIP:
expected(SymbolType.PARENT_OPEN);
ret.addAll(expression(registerVars, inFunction, inMethod, inMethod));
expected(SymbolType.PARENT_CLOSE);
ret.add(new ActionRemoveSprite());
break;
case STARTDRAG:
expected(SymbolType.PARENT_OPEN);
ret.addAll(expression(registerVars, inFunction, inMethod, inMethod));
s = lex();
if (s.type == SymbolType.COMMA) {
ret.addAll(expression(registerVars, inFunction, inMethod, inMethod));
s = lex();
if (s.type == SymbolType.COMMA) {
ret.add(new ActionPush(Boolean.TRUE));
ret.addAll(expression(registerVars, inFunction, inMethod, inMethod));
s = lex();
if (s.type == SymbolType.COMMA) {
ret.addAll(expression(registerVars, inFunction, inMethod, inMethod));
s = lex();
if (s.type == SymbolType.COMMA) {
ret.addAll(expression(registerVars, inFunction, inMethod, inMethod));
s = lex();
if (s.type == SymbolType.COMMA) {
ret.addAll(expression(registerVars, inFunction, inMethod, inMethod));
} else {
lexer.pushback(s);
ret.add(new ActionPush(new Long(0)));
}
} else {
lexer.pushback(s);
ret.add(new ActionPush(new Long(0)));
ret.add(new ActionPush(new Long(0)));
}
} else {
lexer.pushback(s);
ret.add(new ActionPush(new Long(0)));
ret.add(new ActionPush(new Long(0)));
ret.add(new ActionPush(new Long(0)));
}
} else {
lexer.pushback(s);
ret.add(new ActionPush(Boolean.FALSE));
}
} else {
ret.add(new ActionPush(Boolean.FALSE));
ret.add(new ActionPush(Boolean.FALSE));
lexer.pushback(s);
}
expected(SymbolType.PARENT_CLOSE);
ret.add(new ActionStartDrag());
break;
case INT:
expected(SymbolType.PARENT_OPEN);
ret.addAll(expression(registerVars, inFunction, inMethod, inMethod));
expected(SymbolType.PARENT_CLOSE);
ret.add(new ActionToInteger());
ret.add(new ActionPop());
break;
case TARGETPATH:
break;
case NUMBER_OP:
expected(SymbolType.PARENT_OPEN);
ret.addAll(expression(registerVars, inFunction, inMethod, inMethod));
expected(SymbolType.PARENT_CLOSE);
ret.add(new ActionToNumber());
ret.add(new ActionPop());
break;
case STRING_OP:
expected(SymbolType.PARENT_OPEN);
ret.addAll(expression(registerVars, inFunction, inMethod, inMethod));
expected(SymbolType.PARENT_CLOSE);
ret.add(new ActionToString());
ret.add(new ActionPop());
break;
case IFFRAMELOADED:
expected(SymbolType.PARENT_OPEN);
ret.addAll(expression(registerVars, inFunction, inMethod, inMethod));
expected(SymbolType.PARENT_CLOSE);
expected(SymbolType.CURLY_OPEN);
List<Action> iflComs = commands(registerVars, inFunction, inMethod, forinlevel);
expected(SymbolType.CURLY_CLOSE);
ret.add(new ActionWaitForFrame2(iflComs.size()));
ret.addAll(iflComs);
break;
case CLASS:
List<String> classTypeStr = type();
s = lex();
@@ -809,24 +1146,16 @@ public class ActionScriptParser {
case INCREMENT:
case DECREMENT:
ret.addAll(var);
ret.addAll(var);
Action at = ret.remove(ret.size() - 1);
ret.addAll(var);
List<Action> val = new ArrayList<Action>();
val.addAll(var);
if (s.type == SymbolType.INCREMENT) {
ret.add(new ActionIncrement());
val.add(new ActionIncrement());
}
if (s.type == SymbolType.DECREMENT) {
ret.add(new ActionDecrement());
}
if (at instanceof ActionGetMember) {
ret.add(new ActionSetMember());
}
if (at instanceof ActionGetVariable) {
ret.add(new ActionSetVariable());
}
if (at instanceof ActionGetProperty) {
ret.add(new ActionSetProperty());
val.add(new ActionDecrement());
}
ret = gettoset(ret, val);
break;
case PARENT_OPEN: //function call
List<Action> callcmds = new ArrayList<Action>();
@@ -844,16 +1173,9 @@ public class ActionScriptParser {
} else if (callcmds.get(callcmds.size() - 1) instanceof ActionGetVariable) {
callcmds.remove(callcmds.size() - 1);
ActionPush ap = (ActionPush) callcmds.get(callcmds.size() - 1);
if (ap.values.get(0).equals("trace")) {
callcmds.remove(callcmds.size() - 1);
callcmds.addAll(expression(registerVars, inFunction, inMethod, true));
expected(SymbolType.COMMA, SymbolType.PARENT_CLOSE);
callcmds.add(new ActionTrace());
} else {
callcmds.addAll(0, call(registerVars, inFunction, inMethod));
callcmds.add(new ActionCallFunction());
callcmds.add(new ActionPop());
}
callcmds.addAll(0, call(registerVars, inFunction, inMethod));
callcmds.add(new ActionCallFunction());
callcmds.add(new ActionPop());
}
ret.addAll(callcmds);
break;
@@ -946,19 +1268,24 @@ public class ActionScriptParser {
ParsedSymbol s2 = lex();
if (s2.type == SymbolType.IDENTIFIER) {
objIdent = s2.value.toString();
if (inFunction) {
for (int i = 0; i < 256; i++) {
if (!registerVars.containsValue(i)) {
registerVars.put(objIdent, i);
innerExprReg = i;
break;
}
}
}
ParsedSymbol s3 = lex();
if (s3.type == SymbolType.IN) {
if (inFunction) {
for (int i = 0; i < 256; i++) {
if (!registerVars.containsValue(i)) {
registerVars.put(objIdent, i);
innerExprReg = i;
break;
}
}
}
collection = expression(registerVars, inFunction, inMethod, true);
forin = true;
} else {
lexer.pushback(s3);
lexer.pushback(s2);
lexer.pushback(s);
}
} else {
lexer.pushback(s2);
@@ -971,7 +1298,6 @@ public class ActionScriptParser {
List<Action> forExpr = new ArrayList<Action>();
if (!forin) {
ret.addAll(nonempty(command(registerVars, inFunction, inMethod, forinlevel)));
expected(SymbolType.SEMICOLON);
forExpr = expression(registerVars, inFunction, inMethod, true);
expected(SymbolType.SEMICOLON);
forFinalCommands = command(registerVars, inFunction, inMethod, forinlevel);
@@ -1217,7 +1543,9 @@ public class ActionScriptParser {
ret.add(new ActionThrow());
break;
default:
lexer.pushback(s);
if (s.type != SymbolType.SEMICOLON) {
lexer.pushback(s);
}
if (debugMode) {
System.out.println("/command");
}

View File

@@ -31,5 +31,6 @@ public enum SymbolGroup {
INTEGER,
DOUBLE,
TYPENAME,
EOF
EOF,
GLOBALFUNC
}

View File

@@ -133,5 +133,37 @@ public enum SymbolType {
INTEGER,
DOUBLE,
TYPENAME,
EOF
EOF,
TRACE,
GETURL,
GOTOANDSTOP,
NEXTFRAME,
PLAY,
PREVFRAME,
TELLTARGET,
STOP,
STOPALLSOUNDS,
TOGGLEHIGHQUALITY,
ORD,
CHR,
DUPLICATEMOVIECLIP,
STOPDRAG,
GETTIMER,
LOADVARIABLES,
LOADMOVIE,
GOTOANDPLAY,
MBORD,
MBCHR,
MBLENGTH,
MBSUBSTRING,
RANDOM,
REMOVEMOVIECLIP,
STARTDRAG,
SUBSTR,
LENGTH, //string.length
INT,
TARGETPATH,
NUMBER_OP,
STRING_OP,
IFFRAMELOADED
}

View File

@@ -157,7 +157,38 @@ SingleCharacter = [^\r\n\'\\]
"null" { return new ParsedSymbol(SymbolGroup.KEYWORD,SymbolType.NULL,yytext()); }
"this" { return new ParsedSymbol(SymbolGroup.KEYWORD,SymbolType.THIS,yytext()); }
"true" { return new ParsedSymbol(SymbolGroup.KEYWORD,SymbolType.TRUE,yytext()); }
"getUrl" { return new ParsedSymbol(SymbolGroup.GLOBALFUNC,SymbolType.GETURL,yytext()); }
"trace" { return new ParsedSymbol(SymbolGroup.GLOBALFUNC,SymbolType.TRACE,yytext()); }
"gotoAndStop" { return new ParsedSymbol(SymbolGroup.GLOBALFUNC,SymbolType.GOTOANDSTOP,yytext()); }
"nextFrame" { return new ParsedSymbol(SymbolGroup.GLOBALFUNC,SymbolType.NEXTFRAME,yytext()); }
"play" { return new ParsedSymbol(SymbolGroup.GLOBALFUNC,SymbolType.PLAY,yytext()); }
"prevFrame" { return new ParsedSymbol(SymbolGroup.GLOBALFUNC,SymbolType.PREVFRAME,yytext()); }
"tellTarget" { return new ParsedSymbol(SymbolGroup.GLOBALFUNC,SymbolType.TELLTARGET,yytext()); }
"stop" { return new ParsedSymbol(SymbolGroup.GLOBALFUNC,SymbolType.STOP,yytext()); }
"stopAllSounds" { return new ParsedSymbol(SymbolGroup.GLOBALFUNC,SymbolType.STOPALLSOUNDS,yytext()); }
"toggleHighQuality" { return new ParsedSymbol(SymbolGroup.GLOBALFUNC,SymbolType.TOGGLEHIGHQUALITY,yytext()); }
"ifFrameLoaded" { return new ParsedSymbol(SymbolGroup.GLOBALFUNC,SymbolType.IFFRAMELOADED,yytext()); }
"ord" { return new ParsedSymbol(SymbolGroup.GLOBALFUNC,SymbolType.ORD,yytext()); }
"chr" { return new ParsedSymbol(SymbolGroup.GLOBALFUNC,SymbolType.CHR,yytext()); }
"duplicateMovieClip" { return new ParsedSymbol(SymbolGroup.GLOBALFUNC,SymbolType.DUPLICATEMOVIECLIP,yytext()); }
"stopDrag" { return new ParsedSymbol(SymbolGroup.GLOBALFUNC,SymbolType.STOPDRAG,yytext()); }
"getTimer" { return new ParsedSymbol(SymbolGroup.GLOBALFUNC,SymbolType.GETTIMER,yytext()); }
"loadVariables" { return new ParsedSymbol(SymbolGroup.GLOBALFUNC,SymbolType.LOADVARIABLES,yytext()); }
"loadMovie" { return new ParsedSymbol(SymbolGroup.GLOBALFUNC,SymbolType.LOADMOVIE,yytext()); }
"gotoAndPlay" { return new ParsedSymbol(SymbolGroup.GLOBALFUNC,SymbolType.GOTOANDPLAY,yytext()); }
"mbord" { return new ParsedSymbol(SymbolGroup.GLOBALFUNC,SymbolType.MBORD,yytext()); }
"mbchr" { return new ParsedSymbol(SymbolGroup.GLOBALFUNC,SymbolType.MBCHR,yytext()); }
"mblength" { return new ParsedSymbol(SymbolGroup.GLOBALFUNC,SymbolType.MBLENGTH,yytext()); }
"mbsubstring" { return new ParsedSymbol(SymbolGroup.GLOBALFUNC,SymbolType.MBSUBSTRING,yytext()); }
"random" { return new ParsedSymbol(SymbolGroup.GLOBALFUNC,SymbolType.RANDOM,yytext()); }
"removeMovieClip" { return new ParsedSymbol(SymbolGroup.GLOBALFUNC,SymbolType.REMOVEMOVIECLIP,yytext()); }
"startDrag" { return new ParsedSymbol(SymbolGroup.GLOBALFUNC,SymbolType.STARTDRAG,yytext()); }
"substr" { return new ParsedSymbol(SymbolGroup.GLOBALFUNC,SymbolType.SUBSTR,yytext()); }
"length" { return new ParsedSymbol(SymbolGroup.GLOBALFUNC,SymbolType.LENGTH,yytext()); }
"int" { return new ParsedSymbol(SymbolGroup.GLOBALFUNC,SymbolType.INT,yytext()); }
"targetPath" { return new ParsedSymbol(SymbolGroup.GLOBALFUNC,SymbolType.TARGETPATH,yytext()); }
"Number" { return new ParsedSymbol(SymbolGroup.GLOBALFUNC,SymbolType.NUMBER_OP,yytext()); }
"String" { return new ParsedSymbol(SymbolGroup.GLOBALFUNC,SymbolType.STRING_OP,yytext()); }
/* operators */

View File

@@ -0,0 +1,31 @@
/*
* Copyright (C) 2013 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.action.special;
import com.jpexs.decompiler.flash.action.Action;
import java.util.List;
/**
*
* @author JPEXS
*/
public interface ActionStore {
public int getStoreSize();
public void setStore(List<Action> store);
}

View File

@@ -34,6 +34,11 @@ public class ActionGoToLabel extends Action {
public String label;
public ActionGoToLabel(String label) {
super(0x8C, 0);
this.label = label;
}
public ActionGoToLabel(int actionLength, SWFInputStream sis, int version) throws IOException {
super(0x8C, actionLength);
//byte data[] = sis.readBytes(actionLength);

View File

@@ -33,6 +33,11 @@ public class ActionGotoFrame extends Action {
public int frame;
public ActionGotoFrame(int frame) {
super(0x81, 2);
this.frame = frame;
}
public ActionGotoFrame(SWFInputStream sis) throws IOException {
super(0x81, 2);
frame = sis.readUI16();

View File

@@ -16,33 +16,47 @@
*/
package com.jpexs.decompiler.flash.action.swf3;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.ActionGraph;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.flash.action.treemodel.WaitForFrameTreeItem;
import com.jpexs.decompiler.flash.action.special.ActionStore;
import com.jpexs.decompiler.flash.action.treemodel.DirectValueTreeItem;
import com.jpexs.decompiler.flash.action.treemodel.clauses.IfFrameLoadedTreeItem;
import com.jpexs.decompiler.flash.graph.GraphTargetItem;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
public class ActionWaitForFrame extends Action {
public class ActionWaitForFrame extends Action implements ActionStore {
public int frame;
public int skipCount;
public List<Action> skipped;
public ActionWaitForFrame(SWFInputStream sis) throws IOException {
super(0x8A, 3);
frame = sis.readUI16();
skipCount = sis.readUI8();
skipped = new ArrayList<Action>();
for (int i = 0; i < skipCount; i++) {
skipped.add(sis.readAction());
}
}
@Override
public String toString() {
return "WaitForFrame " + frame + " " + skipCount;
String ret = "WaitForFrame " + frame + " " + skipCount;
for (Action a : skipped) {
ret += "\r\n" + a.toString();
}
return ret;
}
@Override
@@ -52,6 +66,9 @@ public class ActionWaitForFrame extends Action {
try {
sos.writeUI16(frame);
sos.writeUI8(skipCount);
for (Action a : skipped) {
sos.write(a.getBytes(SWF.DEFAULT_VERSION));
}
sos.close();
} catch (IOException e) {
}
@@ -62,10 +79,24 @@ public class ActionWaitForFrame extends Action {
super(0x8A, -1);
frame = (int) lexLong(lexer);
skipCount = (int) lexLong(lexer);
skipped = new ArrayList<Action>();
}
@Override
public void translate(Stack<GraphTargetItem> stack, List<GraphTargetItem> output, java.util.HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions) {
output.add(new WaitForFrameTreeItem(this, frame, skipCount));
GraphTargetItem frameTi = new DirectValueTreeItem(null, 0, new Long(frame), new ArrayList<String>());
List<GraphTargetItem> body = ActionGraph.translateViaGraph(regNames, variables, functions, skipped, SWF.DEFAULT_VERSION);
output.add(new IfFrameLoadedTreeItem(frameTi, body, this));
}
@Override
public int getStoreSize() {
return skipCount;
}
@Override
public void setStore(List<Action> store) {
skipped = store;
skipCount = store.size();
}
}

View File

@@ -37,6 +37,13 @@ public class ActionGetURL2 extends Action {
public boolean loadTargetFlag;
public boolean loadVariablesFlag;
public ActionGetURL2(int sendVarsMethod, boolean loadTargetFlag, boolean loadVariablesFlag) {
super(0x9A, 1);
this.loadTargetFlag = loadTargetFlag;
this.loadVariablesFlag = loadVariablesFlag;
this.sendVarsMethod = sendVarsMethod;
}
public ActionGetURL2(SWFInputStream sis) throws IOException {
super(0x9A, 1);
sendVarsMethod = (int) sis.readUB(2);

View File

@@ -35,6 +35,13 @@ public class ActionGotoFrame2 extends Action {
boolean playFlag;
public int sceneBias;
public ActionGotoFrame2(boolean playFlag, boolean sceneBiasFlag, int sceneBias) {
super(0x9F, 0);
this.sceneBiasFlag = sceneBiasFlag;
this.playFlag = playFlag;
this.sceneBias = sceneBias;
}
public ActionGotoFrame2(int actionLength, SWFInputStream sis) throws IOException {
super(0x9F, actionLength);
sis.readUB(6); //reserved

View File

@@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf4;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.treemodel.ConstantPool;
import com.jpexs.decompiler.flash.action.treemodel.DecrementTreeItem;
import com.jpexs.decompiler.flash.action.treemodel.GetVariableTreeItem;
import com.jpexs.decompiler.flash.action.treemodel.IncrementTreeItem;
import com.jpexs.decompiler.flash.action.treemodel.PostDecrementTreeItem;
import com.jpexs.decompiler.flash.action.treemodel.PostIncrementTreeItem;
@@ -65,6 +66,22 @@ public class ActionSetVariable extends Action {
}
}
}
if (value instanceof IncrementTreeItem) {
if (((IncrementTreeItem) value).object instanceof GetVariableTreeItem) {
if (((GetVariableTreeItem) ((IncrementTreeItem) value).object).name.equals(name)) {
output.add(new PostIncrementTreeItem(this, ((IncrementTreeItem) value).object));
return;
}
}
}
if (value instanceof DecrementTreeItem) {
if (((DecrementTreeItem) value).object instanceof GetVariableTreeItem) {
if (((GetVariableTreeItem) ((DecrementTreeItem) value).object).name.equals(name)) {
output.add(new PostDecrementTreeItem(this, ((DecrementTreeItem) value).object));
return;
}
}
}
SetVariableTreeItem svt = new SetVariableTreeItem(this, name, value);
output.add(svt);
}

View File

@@ -16,26 +16,51 @@
*/
package com.jpexs.decompiler.flash.action.swf4;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.ActionGraph;
import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.flash.action.treemodel.WaitForFrame2TreeItem;
import com.jpexs.decompiler.flash.action.special.ActionStore;
import com.jpexs.decompiler.flash.action.treemodel.clauses.IfFrameLoadedTreeItem;
import com.jpexs.decompiler.flash.graph.GraphTargetItem;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Stack;
public class ActionWaitForFrame2 extends Action {
public class ActionWaitForFrame2 extends Action implements ActionStore {
public int skipCount;
List<Action> skipped;
public ActionWaitForFrame2(int skipCount) {
super(0x8D, 1);
this.skipCount = skipCount;
}
@Override
public int getStoreSize() {
return skipCount;
}
@Override
public void setStore(List<Action> store) {
skipped = store;
skipCount = store.size();
}
public ActionWaitForFrame2(SWFInputStream sis) throws IOException {
super(0x8D, 1);
skipCount = sis.readUI8();
skipped = new ArrayList<Action>();
for (int i = 0; i < skipCount; i++) {
skipped.add(sis.readAction());
}
}
public ActionWaitForFrame2(FlasmLexer lexer) throws IOException, ParseException {
@@ -57,12 +82,17 @@ public class ActionWaitForFrame2 extends Action {
@Override
public String toString() {
return "WaitForFrame2 " + skipCount;
String ret = "WaitForFrame2 " + skipCount;
for (Action a : skipped) {
ret += "\r\n" + a.toString();
}
return ret;
}
@Override
public void translate(Stack<GraphTargetItem> stack, List<GraphTargetItem> output, java.util.HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions) {
GraphTargetItem frame = stack.pop();
output.add(new WaitForFrame2TreeItem(this, frame, skipCount));
List<GraphTargetItem> body = ActionGraph.translateViaGraph(regNames, variables, functions, skipped, SWF.DEFAULT_VERSION);
output.add(new IfFrameLoadedTreeItem(frame, body, this));
}
}

View File

@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.action.swf5;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.treemodel.DecrementTreeItem;
import com.jpexs.decompiler.flash.action.treemodel.GetMemberTreeItem;
import com.jpexs.decompiler.flash.action.treemodel.IncrementTreeItem;
import com.jpexs.decompiler.flash.action.treemodel.PostDecrementTreeItem;
import com.jpexs.decompiler.flash.action.treemodel.PostIncrementTreeItem;
@@ -41,7 +42,7 @@ public class ActionSetMember extends Action {
@Override
public void translate(Stack<GraphTargetItem> stack, List<GraphTargetItem> output, java.util.HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions) {
GraphTargetItem value = stack.pop();
GraphTargetItem objectName = stack.pop();
GraphTargetItem memberName = stack.pop();
GraphTargetItem object = stack.pop();
if (value instanceof IncrementTreeItem) {
GraphTargetItem obj = ((IncrementTreeItem) value).object;
@@ -63,6 +64,27 @@ public class ActionSetMember extends Action {
}
}
}
output.add(new SetMemberTreeItem(this, object, objectName, value));
if (value instanceof IncrementTreeItem) {
if (((IncrementTreeItem) value).object instanceof GetMemberTreeItem) {
if (((GetMemberTreeItem) ((IncrementTreeItem) value).object).object.equals(object)) {
if (((GetMemberTreeItem) ((IncrementTreeItem) value).object).memberName.equals(memberName)) {
output.add(new PostIncrementTreeItem(this, ((IncrementTreeItem) value).object));
return;
}
}
}
}
if (value instanceof DecrementTreeItem) {
if (((DecrementTreeItem) value).object instanceof GetMemberTreeItem) {
if (((GetMemberTreeItem) ((DecrementTreeItem) value).object).object.equals(object)) {
if (((GetMemberTreeItem) ((DecrementTreeItem) value).object).memberName.equals(memberName)) {
output.add(new PostDecrementTreeItem(this, ((DecrementTreeItem) value).object));
return;
}
}
}
}
output.add(new SetMemberTreeItem(this, object, memberName, value));
}
}

View File

@@ -32,7 +32,7 @@ public class ToNumberTreeItem extends TreeItem {
@Override
public String toString(ConstantPool constants) {
return value.toString(Helper.toList(constants)) + hilight(".valueOf()");
return hilight("Number(") + value.toString(Helper.toList(constants)) + hilight(")");
}
@Override

View File

@@ -32,7 +32,7 @@ public class ToStringTreeItem extends TreeItem {
@Override
public String toString(ConstantPool constants) {
return value.toString(Helper.toList(constants)) + hilight(".toString()");
return hilight("String(") + value.toString(Helper.toList(constants)) + hilight(")");
}
@Override

View File

@@ -0,0 +1,65 @@
/*
* Copyright (C) 2013 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.action.treemodel.clauses;
import com.jpexs.decompiler.flash.action.treemodel.ConstantPool;
import com.jpexs.decompiler.flash.action.treemodel.TreeItem;
import com.jpexs.decompiler.flash.graph.Block;
import com.jpexs.decompiler.flash.graph.ContinueItem;
import com.jpexs.decompiler.flash.graph.Graph;
import com.jpexs.decompiler.flash.graph.GraphSourceItem;
import com.jpexs.decompiler.flash.graph.GraphTargetItem;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author JPEXS
*/
public class IfFrameLoadedTreeItem extends TreeItem implements Block {
private List<GraphTargetItem> actions;
private GraphTargetItem frame;
public IfFrameLoadedTreeItem(GraphTargetItem frame, List<GraphTargetItem> actions, GraphSourceItem instruction) {
super(instruction, NOPRECEDENCE);
this.actions = actions;
this.frame = frame;
}
@Override
public String toString(ConstantPool constants) {
return hilight("ifFrameLoaded(") + frame.toString(constants) + hilight(")") + "\r\n" + hilight("{") + "\r\n" + Graph.graphToString(actions, constants) + "}";
}
@Override
public boolean needsSemicolon() {
return false;
}
@Override
public List<ContinueItem> getContinues() {
return new ArrayList<ContinueItem>();
}
@Override
public List<List<GraphTargetItem>> getSubs() {
List<List<GraphTargetItem>> ret = new ArrayList<List<GraphTargetItem>>();
ret.add(actions);
return ret;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 807 B