From a5fa22d9eb8eb534a8db10f911b3797a6b5be6e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=F8=EDk?= Date: Sun, 20 Apr 2014 17:22:45 +0200 Subject: [PATCH] AS3 direct editation - for(each) in fix, calling types fix --- .../avm2/parser/script/AVM2SourceGenerator.java | 4 ++++ .../avm2/parser/script/ActionScriptParser.java | 4 ++-- .../abc/avm2/parser/script/CallAVM2Item.java | 17 +++++++++++++---- .../script/ConstructSomethingAVM2Item.java | 4 ++-- .../abc/avm2/parser/script/NameAVM2Item.java | 6 +----- 5 files changed, 22 insertions(+), 13 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 600e410c9..9c00fa713 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 @@ -430,6 +430,10 @@ public class AVM2SourceGenerator implements SourceGenerator { final Reference counterReg = new Reference<>(0); final Reference collectionReg = new Reference<>(0); + if(assignable instanceof UnresolvedAVM2Item){ + assignable = (AssignableAVM2Item)((UnresolvedAVM2Item)assignable).resolved; + } + ret.addAll(GraphTargetItem.toSourceMerge(localData, this, ins(new PushByteIns(), 0), AssignableAVM2Item.setTemp(localData, this, counterReg), diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptParser.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptParser.java index be98993e5..eb9cb0dc6 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptParser.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptParser.java @@ -173,7 +173,7 @@ public class ActionScriptParser { ret = member(needsActivation, importedClasses, openedNamespaces, ret, registerVars, inFunction, inMethod, variables); break; case PARENT_OPEN: - ret = new CallAVM2Item(ret, call(needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, variables)); + ret = new CallAVM2Item(lexer.yyline(),ret, call(needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, variables)); break; } s = lex(); @@ -2007,7 +2007,7 @@ public class ActionScriptParser { case NEW: GraphTargetItem newvar = name(needsActivation, true, openedNamespaces, registerVars, inFunction, inMethod, variables, importedClasses); expectedType(SymbolType.PARENT_OPEN); - ret = new ConstructSomethingAVM2Item(openedNamespaces, newvar, call(needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, variables)); + ret = new ConstructSomethingAVM2Item(lexer.yyline(),openedNamespaces, newvar, call(needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, variables)); existsRemainder = true; break; case IDENTIFIER: diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/CallAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/CallAVM2Item.java index ddad04c06..dccce26b4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/CallAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/CallAVM2Item.java @@ -34,6 +34,7 @@ import com.jpexs.decompiler.graph.TypeFunctionItem; import com.jpexs.decompiler.graph.TypeItem; import com.jpexs.decompiler.graph.model.LocalData; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; /** @@ -44,11 +45,13 @@ public class CallAVM2Item extends AVM2Item { public GraphTargetItem name; public List arguments; + public int line; - public CallAVM2Item(GraphTargetItem name, List arguments) { + public CallAVM2Item(int line, GraphTargetItem name, List arguments) { super(null, NOPRECEDENCE); this.name = name; this.arguments = arguments; + this.line = line; } @Override @@ -93,7 +96,12 @@ public class CallAVM2Item extends AVM2Item { p.setAssignedValue(n.getAssignedValue()); callable = p; } - + + if(callable instanceof TypeItem){ + TypeItem t=(TypeItem)callable; + callable = new PropertyAVM2Item(null, t.fullTypeName, g.abc, g.allABCs, new ArrayList(), new ArrayList()); + } + if (callable instanceof PropertyAVM2Item) { PropertyAVM2Item prop = (PropertyAVM2Item) callable; Object obj = prop.object; @@ -115,7 +123,7 @@ public class CallAVM2Item extends AVM2Item { Reference outPropNsKind = new Reference<>(1); Reference outPropType = new Reference<>(""); Reference outPropValue = new Reference<>(null); - if (AVM2SourceGenerator.searchPrototypeChain(true, allAbcs, pkgName, cname, prop.propertyName, outName, outNs, outPropNs, outPropNsKind, outPropType, outPropValue)) { + if (AVM2SourceGenerator.searchPrototypeChain(true, allAbcs, pkgName, cname, prop.propertyName, outName, outNs, outPropNs, outPropNsKind, outPropType, outPropValue) && (localData.currentClass.equals("".equals(outNs.getVal())?outName.getVal():outNs.getVal()+"."+outName.getVal()))) { NameAVM2Item nobj = new NameAVM2Item(new TypeItem(localData.currentClass), 0, "this", null, false, new ArrayList()); nobj.setRegNumber(0); obj = nobj; @@ -127,7 +135,8 @@ public class CallAVM2Item extends AVM2Item { new AVM2Instruction(0, new CallPropertyIns(), new int[]{prop.resolveProperty(localData), arguments.size()}, new byte[0]) ); } - return new ArrayList<>(); + throw new CompilationException("Cannot call a type", line); + //return new ArrayList<>(); } @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ConstructSomethingAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ConstructSomethingAVM2Item.java index bd0cf93e8..942997425 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ConstructSomethingAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ConstructSomethingAVM2Item.java @@ -43,8 +43,8 @@ public class ConstructSomethingAVM2Item extends CallAVM2Item { public List openedNamespaces; - public ConstructSomethingAVM2Item(List openedNamespaces, GraphTargetItem name, List arguments) { - super(name, arguments); + public ConstructSomethingAVM2Item(int line,List openedNamespaces, GraphTargetItem name, List arguments) { + super(line,name, arguments); this.openedNamespaces = openedNamespaces; } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NameAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NameAVM2Item.java index d0fa15968..bb3a0efed 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NameAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NameAVM2Item.java @@ -143,11 +143,7 @@ public class NameAVM2Item extends AssignableAVM2Item { public int getNsKind() { return nsKind; } - - @Override - public void setAssignedValue(GraphTargetItem storeValue) { - this.assignedValue = storeValue; - } + public String getVariableName() { return variableName;