From 45ff89c36f61a4d651499a5f45a14cb8bb92cda6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=F8=EDk?= Date: Tue, 1 Jan 2013 13:19:51 +0100 Subject: [PATCH] AS3:Fixed with statements --- .../avm2/instructions/stack/PopScopeIns.java | 4 ++ .../avm2/instructions/stack/PushWithIns.java | 4 +- .../avm2/treemodel/WithObjectTreeItem.java | 37 +++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 trunk/src/com/jpexs/asdec/abc/avm2/treemodel/WithObjectTreeItem.java diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PopScopeIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PopScopeIns.java index dbd817dac..0319aa0ee 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PopScopeIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PopScopeIns.java @@ -23,6 +23,7 @@ import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; +import com.jpexs.asdec.abc.avm2.treemodel.WithObjectTreeItem; import com.jpexs.asdec.abc.avm2.treemodel.WithTreeItem; import com.jpexs.asdec.abc.types.MethodBody; import com.jpexs.asdec.abc.types.MethodInfo; @@ -45,6 +46,9 @@ public class PopScopeIns extends InstructionDefinition { @Override public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames) { TreeItem scope = (TreeItem) scopeStack.pop(); + if(scope instanceof WithObjectTreeItem){ + scope = ((WithObjectTreeItem)scope).scope; + } for (int i = output.size() - 1; i >= 0; i--) { if (output.get(i) instanceof WithTreeItem) { WithTreeItem wti = (WithTreeItem) output.get(i); diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushWithIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushWithIns.java index 3a2d8dd2a..26c793edf 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushWithIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushWithIns.java @@ -21,6 +21,7 @@ import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; +import com.jpexs.asdec.abc.avm2.treemodel.WithObjectTreeItem; import com.jpexs.asdec.abc.avm2.treemodel.WithTreeItem; import com.jpexs.asdec.abc.types.MethodBody; import com.jpexs.asdec.abc.types.MethodInfo; @@ -37,7 +38,8 @@ public class PushWithIns extends InstructionDefinition { @Override public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames) { TreeItem w = (TreeItem) stack.pop(); - scopeStack.push(w); + WithObjectTreeItem wot = new WithObjectTreeItem(ins,w); + scopeStack.push(wot); output.add(new WithTreeItem(ins, w)); } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/WithObjectTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/WithObjectTreeItem.java new file mode 100644 index 000000000..fd69b7307 --- /dev/null +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/WithObjectTreeItem.java @@ -0,0 +1,37 @@ +/* + * 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 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 . + */ +package com.jpexs.asdec.abc.avm2.treemodel; + +import com.jpexs.asdec.abc.avm2.ConstantPool; +import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; +import java.util.HashMap; +import java.util.List; + +public class WithObjectTreeItem extends TreeItem { + + public TreeItem scope; + + public WithObjectTreeItem(AVM2Instruction instruction, TreeItem scope) { + super(instruction, PRECEDENCE_PRIMARY); + this.scope = scope; + } + + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return ""; + } +}