From 66e9a650b8281b528abb5d5f4bb47a182c2ecd13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=F8=EDk?= Date: Sun, 13 Apr 2014 15:02:29 +0200 Subject: [PATCH] AS3 parser: inner function names --- .../parser/script/AVM2SourceGenerator.java | 18 +++++++++++++++++- .../flash/abc/avm2/parser/script/todo.txt | 1 - 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java index 8ee0f8f86..1d3825027 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java @@ -27,6 +27,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.NewActivati import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.NewCatchIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.NewClassIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.NewFunctionIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.NewObjectIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfFalseIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfStrictNeIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfTrueIns; @@ -44,6 +45,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.other.NextNameIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.other.NextValueIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ReturnValueIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ReturnVoidIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.other.SetPropertyIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.other.SetSlotIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ThrowIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.DupIns; @@ -589,8 +591,22 @@ public class AVM2SourceGenerator implements SourceGenerator { public List generate(SourceGeneratorLocalData localData, FunctionAVM2Item item) throws CompilationException { List ret = new ArrayList<>(); + int scope = 0; + if(!item.functionName.equals("")){ + ret.add(ins(new NewObjectIns(),0)); + ret.add(ins(new PushWithIns())); + scope=localData.scopeStack.size(); + localData.scopeStack.add(new PropertyAVM2Item(null, item.functionName, null, abc, allABCs, new ArrayList(), localData.callStack)); + } ret.add(ins(new NewFunctionIns(), method(localData.callStack, localData.pkg, item.needsActivation, item.subvariables, 0 /*Set later*/, item.hasRest, item.line, null, null, false, localData, item.paramTypes, item.paramNames, item.paramValues, item.body, item.retType))); - + if(!item.functionName.equals("")){ + ret.add(ins(new DupIns())); + ret.add(ins(new GetScopeObjectIns(),scope)); + ret.add(ins(new SwapIns())); + ret.add(ins(new SetPropertyIns(),abc.constants.getMultinameId(new Multiname(Multiname.QNAME, abc.constants.getStringId(item.functionName, true), abc.constants.getNamespaceId(new Namespace(Namespace.KIND_PACKAGE, abc.constants.getStringId(localData.pkg, true)), 0, true), 0, 0, new ArrayList()), true))); + ret.add(ins(new PopScopeIns())); + localData.scopeStack.remove(localData.scopeStack.size()-1); + } return ret; } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/todo.txt b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/todo.txt index 717246fe8..4ce10ca19 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/todo.txt +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/todo.txt @@ -2,6 +2,5 @@ TODO List for AS3 parser/compiler: ------------------------------ - E4X (XML) - typenames (Vectors) -- inner function names - default xml namespace - custom namespace modifiers \ No newline at end of file