diff --git a/trunk/src/com/jpexs/asdec/action/flashlite/ActionFSCommand2.java b/trunk/src/com/jpexs/asdec/action/flashlite/ActionFSCommand2.java new file mode 100644 index 000000000..90719c2f0 --- /dev/null +++ b/trunk/src/com/jpexs/asdec/action/flashlite/ActionFSCommand2.java @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2010-2011 JPEXS + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package com.jpexs.asdec.action.flashlite; + +import com.jpexs.asdec.action.Action; +import com.jpexs.asdec.action.treemodel.ConstantPool; +import com.jpexs.asdec.action.treemodel.FSCommand2TreeItem; +import com.jpexs.asdec.action.treemodel.TreeItem; +import java.util.ArrayList; +import java.util.List; +import java.util.Stack; + +public class ActionFSCommand2 extends Action { + + public ActionFSCommand2() { + super(0x2D, 0); + } + + @Override + public String toString() { + return "FSCommand2"; + } + + @Override + public void translate(Stack stack, ConstantPool constants, List output, java.util.HashMap regNames) { + long numArgs = popLong(stack); + TreeItem command = stack.pop(); + List args = new ArrayList(); + for (long l = 0; l < numArgs; l++) { + args.add(stack.pop()); + } + stack.push(new FSCommand2TreeItem(this, command, args)); + } +} diff --git a/trunk/src/com/jpexs/asdec/action/flashlite/ActionStrictMode.java b/trunk/src/com/jpexs/asdec/action/flashlite/ActionStrictMode.java new file mode 100644 index 000000000..601d47f89 --- /dev/null +++ b/trunk/src/com/jpexs/asdec/action/flashlite/ActionStrictMode.java @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2010-2011 JPEXS + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package com.jpexs.asdec.action.flashlite; + +import com.jpexs.asdec.SWFInputStream; +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.treemodel.ConstantPool; +import com.jpexs.asdec.action.treemodel.StrictModeTreeItem; +import com.jpexs.asdec.action.treemodel.TreeItem; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.List; +import java.util.Stack; + +public class ActionStrictMode extends Action { + public int mode; + + public ActionStrictMode(SWFInputStream sis) throws IOException { + super(0x89, 1); + mode = sis.readUI8(); + } + + public ActionStrictMode(FlasmLexer lexer) throws IOException, ParseException { + super(0x89, 1); + mode = (int) lexLong(lexer); + } + + public byte[] getBytes(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWFOutputStream sos = new SWFOutputStream(baos, version); + try { + sos.writeUI8(mode); + sos.close(); + } catch (IOException e) { + + } + return surroundWithAction(baos.toByteArray(), version); + } + + @Override + public String toString() { + return "StrictMode " + mode; + } + + @Override + public void translate(Stack stack, ConstantPool constants, List output, java.util.HashMap regNames) { + output.add(new StrictModeTreeItem(this, mode)); + } +} diff --git a/trunk/src/com/jpexs/asdec/action/parser/ASMParser.java b/trunk/src/com/jpexs/asdec/action/parser/ASMParser.java index cf949851a..5652b21d0 100644 --- a/trunk/src/com/jpexs/asdec/action/parser/ASMParser.java +++ b/trunk/src/com/jpexs/asdec/action/parser/ASMParser.java @@ -19,6 +19,8 @@ package com.jpexs.asdec.action.parser; import com.jpexs.asdec.action.Action; +import com.jpexs.asdec.action.flashlite.ActionFSCommand2; +import com.jpexs.asdec.action.flashlite.ActionStrictMode; import com.jpexs.asdec.action.swf3.*; import com.jpexs.asdec.action.swf4.*; import com.jpexs.asdec.action.swf5.*; @@ -240,6 +242,10 @@ public class ASMParser { list.add(new ActionThrow()); } else if (instructionName.equals("Try".toLowerCase())) { list.add(new ActionTry(labels, address, lexer, constantPool, version)); + } else if (instructionName.equals("FSCommand2".toLowerCase())) { + list.add(new ActionFSCommand2()); + } else if (instructionName.equals("StrictMode".toLowerCase())) { + list.add(new ActionStrictMode(lexer)); } else { throw new ParseException("Unknown instruction name :" + instructionName, lexer.yyline()); } diff --git a/trunk/src/com/jpexs/asdec/action/treemodel/CallMethodTreeItem.java b/trunk/src/com/jpexs/asdec/action/treemodel/CallMethodTreeItem.java index b55806f21..0a9f6d69a 100644 --- a/trunk/src/com/jpexs/asdec/action/treemodel/CallMethodTreeItem.java +++ b/trunk/src/com/jpexs/asdec/action/treemodel/CallMethodTreeItem.java @@ -20,7 +20,6 @@ package com.jpexs.asdec.action.treemodel; import com.jpexs.asdec.action.Action; import com.jpexs.asdec.action.swf4.Undefined; - import java.util.List; public class CallMethodTreeItem extends TreeItem { diff --git a/trunk/src/com/jpexs/asdec/action/treemodel/FSCommand2TreeItem.java b/trunk/src/com/jpexs/asdec/action/treemodel/FSCommand2TreeItem.java new file mode 100644 index 000000000..26a4878cb --- /dev/null +++ b/trunk/src/com/jpexs/asdec/action/treemodel/FSCommand2TreeItem.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2010-2011 JPEXS + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package com.jpexs.asdec.action.treemodel; + +import com.jpexs.asdec.action.Action; +import java.util.List; + +public class FSCommand2TreeItem extends TreeItem { + public String target; + public List arguments; + public TreeItem command; + + public FSCommand2TreeItem(Action instruction, TreeItem command,List arguments) { + super(instruction, PRECEDENCE_PRIMARY); + this.command = command; + this.arguments=arguments; + } + + @Override + public String toString(ConstantPool constants) { + String paramStr = ""; + for (int t = 0; t < arguments.size(); t++) { + paramStr += ","; + paramStr += arguments.get(t).toString(constants); + } + return "FSCommand2(" + command.toString(constants)+paramStr+");"; + } +} diff --git a/trunk/src/com/jpexs/asdec/action/treemodel/StrictModeTreeItem.java b/trunk/src/com/jpexs/asdec/action/treemodel/StrictModeTreeItem.java new file mode 100644 index 000000000..2cc70f85e --- /dev/null +++ b/trunk/src/com/jpexs/asdec/action/treemodel/StrictModeTreeItem.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2011 JPEXS + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +package com.jpexs.asdec.action.treemodel; + +import com.jpexs.asdec.action.Action; + +public class StrictModeTreeItem extends TreeItem { + public int mode; + public StrictModeTreeItem(Action instruction,int mode){ + super(instruction,PRECEDENCE_PRIMARY); + this.mode=mode; + } + + @Override + public String toString(ConstantPool constants) { + return "StrictMode("+mode+");"; //I still don't know how AS source of Strict Mode instruction looks like, assuming this... + } + +}