From 2da1d61f59b02d0d05897fb876e2f771accb7375 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=F8=EDk?= Date: Sun, 7 Apr 2013 14:36:03 +0200 Subject: [PATCH] AS1/2 Fixed DefineFunction2 register names (this, super,...) --- .../src/com/jpexs/decompiler/flash/action/Action.java | 2 +- .../flash/action/swf5/ActionDefineFunction.java | 7 +++++++ .../jpexs/decompiler/flash/action/swf5/ActionWith.java | 5 +++++ .../flash/action/swf7/ActionDefineFunction2.java | 10 +++++++--- .../jpexs/decompiler/flash/action/swf7/ActionTry.java | 5 +++++ .../flash/graph/GraphSourceItemContainer.java | 2 ++ 6 files changed, 27 insertions(+), 4 deletions(-) diff --git a/trunk/src/com/jpexs/decompiler/flash/action/Action.java b/trunk/src/com/jpexs/decompiler/flash/action/Action.java index 917f640b6..3080ffedb 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/Action.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/Action.java @@ -756,7 +756,7 @@ public class Action implements GraphSourceItem { outs.add(new ArrayList()); continue; } - List out = ActionGraph.translateViaGraph(registerNames, variables, functions, src.subList(adr2ip(actions, endAddr, version), adr2ip(actions, endAddr + size, version)), version); + List out = ActionGraph.translateViaGraph(cnt.getRegNames(), variables, functions, src.subList(adr2ip(actions, endAddr, version), adr2ip(actions, endAddr + size, version)), version); outs.add(out); endAddr += size; } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineFunction.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineFunction.java index 5e60f513b..cb4814dbb 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineFunction.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineFunction.java @@ -189,6 +189,13 @@ public class ActionDefineFunction extends Action implements GraphSourceItemConta public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions) { } + @Override + public HashMap getRegNames() { + return new HashMap(); + } + + + @Override public void translateContainer(List> content, Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions) { FunctionTreeItem fti = new FunctionTreeItem(this, functionName, paramNames, content.get(0), constantPool, 1); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionWith.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionWith.java index 0c21a2676..b2570b6be 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionWith.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionWith.java @@ -121,4 +121,9 @@ public class ActionWith extends Action implements GraphSourceItemContainer { public long getHeaderSize() { return surroundWithAction(new byte[]{0, 0}, version).length; } + + @Override + public HashMap getRegNames() { + return new HashMap(); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionDefineFunction2.java b/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionDefineFunction2.java index 21b4c69f8..8e3178133 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionDefineFunction2.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionDefineFunction2.java @@ -284,8 +284,8 @@ public class ActionDefineFunction2 extends Action implements GraphSourceItemCont } @Override - public void translateContainer(List> content, Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions) { - HashMap funcRegNames = (HashMap) regNames.clone(); + public HashMap getRegNames(){ + HashMap funcRegNames = new HashMap(); for (int f = 0; f < paramNames.size(); f++) { int reg = paramRegisters.get(f); if (reg != 0) { @@ -317,7 +317,11 @@ public class ActionDefineFunction2 extends Action implements GraphSourceItemCont funcRegNames.put(pos, "_global"); pos++; } - + return funcRegNames; + } + + @Override + public void translateContainer(List> content, Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions) { FunctionTreeItem fti = new FunctionTreeItem(this, functionName, paramNames, content.get(0), constantPool, getFirstRegister()); functions.put(functionName, fti); stack.push(fti); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionTry.java b/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionTry.java index 18ebfcf6c..48abe2607 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionTry.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionTry.java @@ -271,4 +271,9 @@ public class ActionTry extends Action implements GraphSourceItemContainer { public String toString() { return "Try"; } + + @Override + public HashMap getRegNames(){ + return new HashMap(); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/graph/GraphSourceItemContainer.java b/trunk/src/com/jpexs/decompiler/flash/graph/GraphSourceItemContainer.java index 046dd93ac..eb7ee2c0d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/graph/GraphSourceItemContainer.java +++ b/trunk/src/com/jpexs/decompiler/flash/graph/GraphSourceItemContainer.java @@ -19,5 +19,7 @@ public interface GraphSourceItemContainer { public boolean parseDivision(int pos, long addr, FlasmLexer lexer); + public HashMap getRegNames(); + public void translateContainer(List> contents, Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions); }