diff --git a/trunk/src/com/jpexs/decompiler/flash/SourceGeneratorLocalData.java b/trunk/src/com/jpexs/decompiler/flash/SourceGeneratorLocalData.java index ab2ffd567..fe0b700b5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SourceGeneratorLocalData.java +++ b/trunk/src/com/jpexs/decompiler/flash/SourceGeneratorLocalData.java @@ -32,10 +32,10 @@ public class SourceGeneratorLocalData implements Serializable { public Integer inFunction; public Boolean inMethod; public Integer forInLevel; - public List openedNamespaces = new ArrayList<>(); - public List openedNamespacesKinds = new ArrayList<>(); + //public List openedNamespaces = new ArrayList<>(); + //public List openedNamespacesKinds = new ArrayList<>(); public List exceptions = new ArrayList<>(); - +/* public void addNamespace(int kind, String ns) { addNamespace(kind, ns, openedNamespaces.size() - 1); } @@ -43,7 +43,7 @@ public class SourceGeneratorLocalData implements Serializable { public void addNamespace(int kind, String ns, int index) { openedNamespaces.add(index, ns); openedNamespacesKinds.add(index, kind); - } + }*/ public SourceGeneratorLocalData(HashMap registerVars, Integer inFunction, Boolean inMethod, Integer forInLevel) { this.registerVars = registerVars; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/BooleanAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/BooleanAVM2Item.java index b3663f81f..c3bd4427b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/BooleanAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/BooleanAVM2Item.java @@ -16,10 +16,17 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ReturnValueIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushFalseIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushTrueIns; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.LocalData; +import java.util.List; import java.util.Set; public class BooleanAVM2Item extends AVM2Item { @@ -45,4 +52,11 @@ public class BooleanAVM2Item extends AVM2Item { public boolean isCompileTime(Set dependencies) { return true; } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, + new AVM2Instruction(0, value?new PushTrueIns():new PushFalseIns(), new int[]{}, new byte[0]) + ); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CallPropertyAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CallPropertyAVM2Item.java index f5ec24a3d..50705e911 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CallPropertyAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CallPropertyAVM2Item.java @@ -16,9 +16,15 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.executing.CallPropertyIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetPropertyIns; +import com.jpexs.decompiler.flash.abc.avm2.parser.script.AVM2SourceGenerator; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.LocalData; import java.util.List; @@ -49,4 +55,12 @@ public class CallPropertyAVM2Item extends AVM2Item { } return writer.append(")"); } + + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, receiver, arguments, + new AVM2Instruction(0, new CallPropertyIns(), new int[]{((AVM2SourceGenerator)generator).propertyName(propertyName),arguments.size()}, new byte[0]) + ); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CallSuperAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CallSuperAVM2Item.java index 0bbe38a86..2e76d830f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CallSuperAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CallSuperAVM2Item.java @@ -25,11 +25,11 @@ import java.util.List; public class CallSuperAVM2Item extends AVM2Item { public GraphTargetItem receiver; - public FullMultinameAVM2Item multiname; + public GraphTargetItem multiname; public List arguments; public boolean isVoid; - public CallSuperAVM2Item(AVM2Instruction instruction, boolean isVoid, GraphTargetItem receiver, FullMultinameAVM2Item multiname, List arguments) { + public CallSuperAVM2Item(AVM2Instruction instruction, boolean isVoid, GraphTargetItem receiver, GraphTargetItem multiname, List arguments) { super(instruction, PRECEDENCE_PRIMARY); this.receiver = receiver; this.multiname = multiname; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/FloatValueAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/FloatValueAVM2Item.java index 7c8cab3e6..dbbda09a5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/FloatValueAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/FloatValueAVM2Item.java @@ -16,10 +16,16 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushDoubleIns; +import com.jpexs.decompiler.flash.abc.avm2.parser.script.AVM2SourceGenerator; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.LocalData; +import java.util.List; import java.util.Set; public class FloatValueAVM2Item extends NumberValueAVM2Item { @@ -45,4 +51,11 @@ public class FloatValueAVM2Item extends NumberValueAVM2Item { public boolean isCompileTime(Set dependencies) { return true; } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, + new AVM2Instruction(0, new PushDoubleIns(), new int[]{((AVM2SourceGenerator)generator).abc.constants.getDoubleId(value, true)}, new byte[0]) + ); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/GetPropertyAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/GetPropertyAVM2Item.java index 60d42e722..0a197b11d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/GetPropertyAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/GetPropertyAVM2Item.java @@ -16,10 +16,17 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetPropertyIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushDoubleIns; +import com.jpexs.decompiler.flash.abc.avm2.parser.script.AVM2SourceGenerator; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.LocalData; +import java.util.List; public class GetPropertyAVM2Item extends AVM2Item { @@ -36,4 +43,11 @@ public class GetPropertyAVM2Item extends AVM2Item { public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException { return formatProperty(writer, object, propertyName, localData); } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, object, + new AVM2Instruction(0, new GetPropertyIns(), new int[]{((AVM2SourceGenerator)generator).propertyName(propertyName)}, new byte[0]) + ); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/IntegerValueAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/IntegerValueAVM2Item.java index e61bf92a3..025d235c8 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/IntegerValueAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/IntegerValueAVM2Item.java @@ -16,10 +16,19 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushByteIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushIntIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushShortIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.types.TypeOfIns; +import com.jpexs.decompiler.flash.abc.avm2.parser.script.AVM2SourceGenerator; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.LocalData; +import java.util.List; import java.util.Set; public class IntegerValueAVM2Item extends NumberValueAVM2Item { @@ -45,4 +54,18 @@ public class IntegerValueAVM2Item extends NumberValueAVM2Item { public boolean isCompileTime(Set dependencies) { return true; } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + AVM2Instruction ins = null; + if (value >= 0 && value <= 255) { + ins = new AVM2Instruction(0, new PushByteIns(), new int[]{(int) (long) value}, new byte[0]); + } else if (value >= 0 && value <= 65535) { + ins = new AVM2Instruction(0, new PushShortIns(), new int[]{(int) (long) value}, new byte[0]); + } else { + ins = new AVM2Instruction(0, new PushIntIns(), new int[]{((AVM2SourceGenerator)generator).abc.constants.getIntId(value, true)}, new byte[0]); + } + + return toSourceMerge(localData, generator, ins); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/LocalRegAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/LocalRegAVM2Item.java index 8db2a056d..d22dbdbb6 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/LocalRegAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/LocalRegAVM2Item.java @@ -16,12 +16,26 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.GetLocal0Ins; +import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.GetLocal1Ins; +import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.GetLocal2Ins; +import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.GetLocal3Ins; +import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.GetLocalIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.SetLocal0Ins; +import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.SetLocal1Ins; +import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.SetLocal2Ins; +import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.SetLocal3Ins; +import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.SetLocalIns; import com.jpexs.decompiler.flash.abc.avm2.model.clauses.FilterAVM2Item; import com.jpexs.decompiler.flash.ecma.Undefined; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.LocalData; +import java.util.List; import java.util.Set; public class LocalRegAVM2Item extends AVM2Item { @@ -76,4 +90,27 @@ public class LocalRegAVM2Item extends AVM2Item { public boolean isCompileTime(Set dependencies) { return isCT; } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + AVM2Instruction ins; + switch(regIndex){ + case 0: + ins = new AVM2Instruction(0, new GetLocal0Ins(), new int[]{},new byte[0]); + break; + case 1: + ins = new AVM2Instruction(0, new GetLocal1Ins(), new int[]{},new byte[0]); + break; + case 2: + ins = new AVM2Instruction(0, new GetLocal2Ins(), new int[]{},new byte[0]); + break; + case 3: + ins = new AVM2Instruction(0, new GetLocal3Ins(), new int[]{},new byte[0]); + break; + default: + ins = new AVM2Instruction(0, new GetLocalIns(), new int[]{regIndex},new byte[0]); + break; + } + return toSourceMerge(localData, generator, ins); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NanAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NanAVM2Item.java index af9a4d56c..8e5e1c102 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NanAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NanAVM2Item.java @@ -16,9 +16,16 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushFalseIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushNanIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushTrueIns; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.graph.GraphSourceItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.LocalData; +import java.util.List; public class NanAVM2Item extends AVM2Item { @@ -30,4 +37,11 @@ public class NanAVM2Item extends AVM2Item { public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { return writer.append("NaN"); } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, + new AVM2Instruction(0, new PushNanIns(), new int[]{}, new byte[0]) + ); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NullAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NullAVM2Item.java index b7bc2d2dc..955863e20 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NullAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NullAVM2Item.java @@ -16,11 +16,17 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushNanIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushNullIns; import com.jpexs.decompiler.flash.ecma.Null; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.LocalData; +import java.util.List; import java.util.Set; public class NullAVM2Item extends AVM2Item { @@ -43,4 +49,11 @@ public class NullAVM2Item extends AVM2Item { public Object getResult() { return new Null(); } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, + new AVM2Instruction(0, new PushNullIns(), new int[]{}, new byte[0]) + ); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ReturnValueAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ReturnValueAVM2Item.java index b37ed5f65..79de0494b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ReturnValueAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ReturnValueAVM2Item.java @@ -16,11 +16,17 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ReturnValueIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.types.TypeOfIns; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.ExitItem; import com.jpexs.decompiler.graph.model.LocalData; +import java.util.List; public class ReturnValueAVM2Item extends AVM2Item implements ExitItem { @@ -35,4 +41,11 @@ public class ReturnValueAVM2Item extends AVM2Item implements ExitItem { writer.append("return "); return value.toString(writer, localData); } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, value, + new AVM2Instruction(0, new ReturnValueIns(), new int[]{}, new byte[0]) + ); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ReturnVoidAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ReturnVoidAVM2Item.java index 8c22330bd..1dd7309db 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ReturnVoidAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ReturnVoidAVM2Item.java @@ -16,10 +16,16 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ReturnVoidIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.types.TypeOfIns; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.graph.GraphSourceItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.ExitItem; import com.jpexs.decompiler.graph.model.LocalData; +import java.util.List; public class ReturnVoidAVM2Item extends AVM2Item implements ExitItem { @@ -31,4 +37,10 @@ public class ReturnVoidAVM2Item extends AVM2Item implements ExitItem { public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { return writer.append("return"); } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, new AVM2Instruction(0, new ReturnVoidIns(), new int[]{}, new byte[0]) + ); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/SetLocalAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/SetLocalAVM2Item.java index e8053b1e6..8649b7b77 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/SetLocalAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/SetLocalAVM2Item.java @@ -16,11 +16,22 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.SetLocal0Ins; +import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.SetLocal1Ins; +import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.SetLocal2Ins; +import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.SetLocal3Ins; +import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.SetLocalIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetPropertyIns; import com.jpexs.decompiler.flash.abc.avm2.model.clauses.AssignmentAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.parser.script.AVM2SourceGenerator; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.LocalData; +import java.util.List; public class SetLocalAVM2Item extends AVM2Item implements SetTypeAVM2Item, AssignmentAVM2Item { @@ -53,4 +64,27 @@ public class SetLocalAVM2Item extends AVM2Item implements SetTypeAVM2Item, Assig public boolean hasSideEffect() { return true; } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + AVM2Instruction ins; + switch(regIndex){ + case 0: + ins = new AVM2Instruction(0, new SetLocal0Ins(), new int[]{},new byte[0]); + break; + case 1: + ins = new AVM2Instruction(0, new SetLocal1Ins(), new int[]{},new byte[0]); + break; + case 2: + ins = new AVM2Instruction(0, new SetLocal2Ins(), new int[]{},new byte[0]); + break; + case 3: + ins = new AVM2Instruction(0, new SetLocal3Ins(), new int[]{},new byte[0]); + break; + default: + ins = new AVM2Instruction(0, new SetLocalIns(), new int[]{regIndex},new byte[0]); + break; + } + return toSourceMerge(localData, generator, value, ins); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/SetPropertyAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/SetPropertyAVM2Item.java index 036bdc7be..c4dcec113 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/SetPropertyAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/SetPropertyAVM2Item.java @@ -16,12 +16,19 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetPropertyIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.other.SetPropertyIns; import com.jpexs.decompiler.flash.abc.avm2.model.clauses.AssignmentAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.parser.script.AVM2SourceGenerator; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.GraphPart; +import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.LocalData; +import java.util.List; public class SetPropertyAVM2Item extends AVM2Item implements SetTypeAVM2Item, AssignmentAVM2Item { @@ -62,4 +69,11 @@ public class SetPropertyAVM2Item extends AVM2Item implements SetTypeAVM2Item, As public boolean hasSideEffect() { return true; } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, object, value, + new AVM2Instruction(0, new SetPropertyIns(), new int[]{((AVM2SourceGenerator)generator).propertyName(propertyName)}, new byte[0]) + ); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/StringAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/StringAVM2Item.java index d22cb5919..3e4555013 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/StringAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/StringAVM2Item.java @@ -16,11 +16,18 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushNanIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushStringIns; +import com.jpexs.decompiler.flash.abc.avm2.parser.script.AVM2SourceGenerator; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.LocalData; import com.jpexs.helpers.Helper; +import java.util.List; import java.util.Set; public class StringAVM2Item extends AVM2Item { @@ -46,4 +53,11 @@ public class StringAVM2Item extends AVM2Item { public Object getResult() { return value; } + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, + new AVM2Instruction(0, new PushStringIns(), new int[]{((AVM2SourceGenerator)generator).str(value)}, new byte[0]) + ); + } + } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ThisAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ThisAVM2Item.java index 479bcf0ec..1e8f60d81 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ThisAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ThisAVM2Item.java @@ -16,9 +16,16 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.GetLocal0Ins; +import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ReturnVoidIns; import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.graph.GraphSourceItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.LocalData; +import java.util.List; public class ThisAVM2Item extends AVM2Item { @@ -38,4 +45,10 @@ public class ThisAVM2Item extends AVM2Item { public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { return writer.append("this"); } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, new AVM2Instruction(0, new GetLocal0Ins(), new int[]{}, new byte[0]) + ); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/AddAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/AddAVM2Item.java index 10d2a9b8f..17fc3cfdf 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/AddAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/AddAVM2Item.java @@ -16,13 +16,18 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.AddIns; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.flash.ecma.EcmaType; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.BinaryOpItem; import com.jpexs.decompiler.graph.model.LocalData; +import java.util.List; public class AddAVM2Item extends BinaryOpItem { @@ -59,4 +64,13 @@ public class AddAVM2Item extends BinaryOpItem { } return EcmaScript.toNumber(leftSide.getResult()) + EcmaScript.toNumber(rightSide.getResult()); } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, leftSide, rightSide, + new AVM2Instruction(0, new AddIns(), new int[]{}, new byte[0]) + ); + } + + } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/AndAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/AndAVM2Item.java deleted file mode 100644 index 5393f663f..000000000 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/AndAVM2Item.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2010-2014 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.decompiler.flash.abc.avm2.model.operations; - -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.graph.GraphPart; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.decompiler.graph.model.BinaryOpItem; - -public class AndAVM2Item extends BinaryOpItem { - - public GraphPart firstPart; - - public AndAVM2Item(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { - super(instruction, PRECEDENCE_LOGICALAND, leftSide, rightSide, "&&"); - } -} diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/AsTypeAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/AsTypeAVM2Item.java index 93f4fa3f1..2de324bba 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/AsTypeAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/AsTypeAVM2Item.java @@ -16,13 +16,26 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise.BitOrIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.types.AsTypeIns; +import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.BinaryOpItem; +import java.util.List; public class AsTypeAVM2Item extends BinaryOpItem { public AsTypeAVM2Item(AVM2Instruction instruction, GraphTargetItem value, GraphTargetItem type) { super(instruction, PRECEDENCE_RELATIONAL, value, type, "as"); } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, leftSide, rightSide, + new AVM2Instruction(0, new AsTypeIns(), new int[]{}, new byte[0]) + ); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitAndAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitAndAVM2Item.java index eea9368e0..d4a549f3b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitAndAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitAndAVM2Item.java @@ -16,10 +16,16 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.AddIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise.BitAndIns; import com.jpexs.decompiler.flash.ecma.EcmaScript; +import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.BinaryOpItem; +import java.util.List; public class BitAndAVM2Item extends BinaryOpItem { @@ -31,4 +37,11 @@ public class BitAndAVM2Item extends BinaryOpItem { public Object getResult() { return ((long) (double) EcmaScript.toNumber(leftSide.getResult())) & ((long) (double) EcmaScript.toNumber(rightSide.getResult())); } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, leftSide, rightSide, + new AVM2Instruction(0, new BitAndIns(), new int[]{}, new byte[0]) + ); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitNotAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitNotAVM2Item.java index f7f9bb3ca..a5f24745e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitNotAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitNotAVM2Item.java @@ -16,10 +16,15 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise.BitNotIns; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.UnaryOpItem; +import java.util.List; public class BitNotAVM2Item extends UnaryOpItem { @@ -31,4 +36,11 @@ public class BitNotAVM2Item extends UnaryOpItem { public Object getResult() { return ~((long) (double) EcmaScript.toNumber(value.getResult())); } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, value, + new AVM2Instruction(0, new BitNotIns(), new int[]{}, new byte[0]) + ); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitOrAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitOrAVM2Item.java index 2e15b2945..e88d5dc9e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitOrAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitOrAVM2Item.java @@ -16,10 +16,16 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.AddIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise.BitOrIns; import com.jpexs.decompiler.flash.ecma.EcmaScript; +import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.BinaryOpItem; +import java.util.List; public class BitOrAVM2Item extends BinaryOpItem { @@ -31,4 +37,11 @@ public class BitOrAVM2Item extends BinaryOpItem { public Object getResult() { return ((long) (double) EcmaScript.toNumber(leftSide.getResult())) | ((long) (double) EcmaScript.toNumber(rightSide.getResult())); } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, leftSide, rightSide, + new AVM2Instruction(0, new BitOrIns(), new int[]{}, new byte[0]) + ); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitXorAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitXorAVM2Item.java index 9153945c7..42fa66b07 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitXorAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitXorAVM2Item.java @@ -16,10 +16,16 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.AddIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise.BitXorIns; import com.jpexs.decompiler.flash.ecma.EcmaScript; +import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.BinaryOpItem; +import java.util.List; public class BitXorAVM2Item extends BinaryOpItem { @@ -31,4 +37,11 @@ public class BitXorAVM2Item extends BinaryOpItem { public Object getResult() { return ((long) (double) EcmaScript.toNumber(leftSide.getResult())) ^ ((long) (double) EcmaScript.toNumber(rightSide.getResult())); } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, leftSide, rightSide, + new AVM2Instruction(0, new BitXorIns(), new int[]{}, new byte[0]) + ); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/DeletePropertyAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/DeletePropertyAVM2Item.java index 1ca37131b..ca7ef552d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/DeletePropertyAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/DeletePropertyAVM2Item.java @@ -16,11 +16,18 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.other.DeletePropertyIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.types.TypeOfIns; import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.parser.script.AVM2SourceGenerator; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.LocalData; +import java.util.List; public class DeletePropertyAVM2Item extends AVM2Item { @@ -41,4 +48,11 @@ public class DeletePropertyAVM2Item extends AVM2Item { propertyName.toString(writer, localData); return writer.append("]"); } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, object, + new AVM2Instruction(0, new DeletePropertyIns(), new int[]{((AVM2SourceGenerator)generator).propertyName(propertyName)}, new byte[0]) + ); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/DivideAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/DivideAVM2Item.java index 6f6b4aa7b..12cd0c856 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/DivideAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/DivideAVM2Item.java @@ -16,12 +16,18 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.AddIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.DivideIns; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.BinaryOpItem; import com.jpexs.decompiler.graph.model.LocalData; +import java.util.List; public class DivideAVM2Item extends BinaryOpItem { @@ -58,4 +64,11 @@ public class DivideAVM2Item extends BinaryOpItem { return super.appendTo(writer, localData); } } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, leftSide, rightSide, + new AVM2Instruction(0, new DivideIns(), new int[]{}, new byte[0]) + ); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/EqAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/EqAVM2Item.java index d8967b805..77e30f0c2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/EqAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/EqAVM2Item.java @@ -16,11 +16,18 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.AddIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.comparison.EqualsIns; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.BinaryOpItem; +import com.jpexs.decompiler.graph.model.ExitItem; import com.jpexs.decompiler.graph.model.LogicalOpItem; +import java.util.List; public class EqAVM2Item extends BinaryOpItem implements LogicalOpItem { @@ -37,4 +44,11 @@ public class EqAVM2Item extends BinaryOpItem implements LogicalOpItem { public GraphTargetItem invert() { return new NeqAVM2Item(src, leftSide, rightSide); } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, leftSide, rightSide, + new AVM2Instruction(0, new EqualsIns(), new int[]{}, new byte[0]) + ); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/GeAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/GeAVM2Item.java index 4914e37d1..265ff80d0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/GeAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/GeAVM2Item.java @@ -16,11 +16,17 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.AddIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.comparison.GreaterEqualsIns; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.BinaryOpItem; import com.jpexs.decompiler.graph.model.LogicalOpItem; +import java.util.List; public class GeAVM2Item extends BinaryOpItem implements LogicalOpItem { @@ -44,4 +50,11 @@ public class GeAVM2Item extends BinaryOpItem implements LogicalOpItem { } return ret;//undefined } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, leftSide, rightSide, + new AVM2Instruction(0, new GreaterEqualsIns(), new int[]{}, new byte[0]) + ); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/GtAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/GtAVM2Item.java index 8973be828..a00784398 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/GtAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/GtAVM2Item.java @@ -16,11 +16,17 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.AddIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.comparison.GreaterThanIns; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.BinaryOpItem; import com.jpexs.decompiler.graph.model.LogicalOpItem; +import java.util.List; public class GtAVM2Item extends BinaryOpItem implements LogicalOpItem { @@ -37,4 +43,11 @@ public class GtAVM2Item extends BinaryOpItem implements LogicalOpItem { public Object getResult() { return EcmaScript.compare(rightSide.getResult(), leftSide.getResult()); } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, leftSide, rightSide, + new AVM2Instruction(0, new GreaterThanIns(), new int[]{}, new byte[0]) + ); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/InAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/InAVM2Item.java index fe355233c..8eb0ca608 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/InAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/InAVM2Item.java @@ -16,13 +16,26 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.other.InIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.types.InstanceOfIns; +import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.BinaryOpItem; +import java.util.List; public class InAVM2Item extends BinaryOpItem { public InAVM2Item(AVM2Instruction instruction, GraphTargetItem name, GraphTargetItem object) { super(instruction, PRECEDENCE_RELATIONAL, name, object, "in"); } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, leftSide, rightSide, + new AVM2Instruction(0, new InIns(), new int[]{}, new byte[0]) + ); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/InstanceOfAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/InstanceOfAVM2Item.java index e8110c91a..5aa059dd4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/InstanceOfAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/InstanceOfAVM2Item.java @@ -16,13 +16,26 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.AddIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.types.InstanceOfIns; +import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.BinaryOpItem; +import java.util.List; public class InstanceOfAVM2Item extends BinaryOpItem { public InstanceOfAVM2Item(AVM2Instruction instruction, GraphTargetItem value, GraphTargetItem type) { super(instruction, PRECEDENCE_RELATIONAL, value, type, "instanceof"); } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, leftSide, rightSide, + new AVM2Instruction(0, new InstanceOfIns(), new int[]{}, new byte[0]) + ); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/IsTypeAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/IsTypeAVM2Item.java index 4ef593641..a9341d14c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/IsTypeAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/IsTypeAVM2Item.java @@ -16,13 +16,26 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.AddIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.types.IsTypeIns; +import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.BinaryOpItem; +import java.util.List; public class IsTypeAVM2Item extends BinaryOpItem { public IsTypeAVM2Item(AVM2Instruction instruction, GraphTargetItem value, GraphTargetItem type) { super(instruction, PRECEDENCE_RELATIONAL, value, type, "is"); } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, leftSide, rightSide, + new AVM2Instruction(0, new IsTypeIns(), new int[]{}, new byte[0]) + ); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/LShiftAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/LShiftAVM2Item.java index 2d34b7356..999431d9d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/LShiftAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/LShiftAVM2Item.java @@ -16,10 +16,16 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.AddIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise.LShiftIns; import com.jpexs.decompiler.flash.ecma.EcmaScript; +import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.BinaryOpItem; +import java.util.List; public class LShiftAVM2Item extends BinaryOpItem { @@ -31,4 +37,11 @@ public class LShiftAVM2Item extends BinaryOpItem { public Object getResult() { return ((int) (double) EcmaScript.toNumber(leftSide.getResult())) << ((int) (double) EcmaScript.toNumber(rightSide.getResult())); } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, leftSide, rightSide, + new AVM2Instruction(0, new LShiftIns(), new int[]{}, new byte[0]) + ); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/LeAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/LeAVM2Item.java index 69cf7eab8..7e58627e0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/LeAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/LeAVM2Item.java @@ -16,11 +16,17 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.AddIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.comparison.LessEqualsIns; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.BinaryOpItem; import com.jpexs.decompiler.graph.model.LogicalOpItem; +import java.util.List; public class LeAVM2Item extends BinaryOpItem implements LogicalOpItem { @@ -44,4 +50,11 @@ public class LeAVM2Item extends BinaryOpItem implements LogicalOpItem { } return ret;//undefined } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, leftSide, rightSide, + new AVM2Instruction(0, new LessEqualsIns(), new int[]{}, new byte[0]) + ); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/LtAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/LtAVM2Item.java index baa39790d..41801d5be 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/LtAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/LtAVM2Item.java @@ -16,11 +16,17 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.AddIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.comparison.LessThanIns; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.BinaryOpItem; import com.jpexs.decompiler.graph.model.LogicalOpItem; +import java.util.List; public class LtAVM2Item extends BinaryOpItem implements LogicalOpItem { @@ -37,4 +43,11 @@ public class LtAVM2Item extends BinaryOpItem implements LogicalOpItem { public Object getResult() { return EcmaScript.compare(leftSide.getResult(), rightSide.getResult()); } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, leftSide, rightSide, + new AVM2Instruction(0, new LessThanIns(), new int[]{}, new byte[0]) + ); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/ModuloAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/ModuloAVM2Item.java index 6377b7454..76a45535b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/ModuloAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/ModuloAVM2Item.java @@ -16,12 +16,18 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.AddIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.ModuloIns; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.BinaryOpItem; import com.jpexs.decompiler.graph.model.LocalData; +import java.util.List; public class ModuloAVM2Item extends BinaryOpItem { @@ -58,4 +64,11 @@ public class ModuloAVM2Item extends BinaryOpItem { return super.appendTo(writer, localData); } } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, leftSide, rightSide, + new AVM2Instruction(0, new ModuloIns(), new int[]{}, new byte[0]) + ); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/MultiplyAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/MultiplyAVM2Item.java index c6420af26..5dc9c8361 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/MultiplyAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/MultiplyAVM2Item.java @@ -16,12 +16,19 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.AddIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.MultiplyIIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.MultiplyIns; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.BinaryOpItem; import com.jpexs.decompiler.graph.model.LocalData; +import java.util.List; public class MultiplyAVM2Item extends BinaryOpItem { @@ -55,4 +62,11 @@ public class MultiplyAVM2Item extends BinaryOpItem { return super.appendTo(writer, localData); } } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, leftSide, rightSide, + new AVM2Instruction(0, new MultiplyIns(), new int[]{}, new byte[0]) + ); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/NegAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/NegAVM2Item.java index 2a5e478f8..bca5a11ac 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/NegAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/NegAVM2Item.java @@ -16,10 +16,16 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.NegateIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.types.TypeOfIns; import com.jpexs.decompiler.flash.ecma.EcmaScript; +import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.UnaryOpItem; +import java.util.List; public class NegAVM2Item extends UnaryOpItem { @@ -31,4 +37,11 @@ public class NegAVM2Item extends UnaryOpItem { public Object getResult() { return -EcmaScript.toNumber(value.getResult()); } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, value, + new AVM2Instruction(0, new NegateIns(), new int[]{}, new byte[0]) + ); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/NeqAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/NeqAVM2Item.java index 45b9697e9..f4ffdd8a1 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/NeqAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/NeqAVM2Item.java @@ -16,11 +16,18 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.AddIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.NotIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.comparison.EqualsIns; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.BinaryOpItem; import com.jpexs.decompiler.graph.model.LogicalOpItem; +import java.util.List; public class NeqAVM2Item extends BinaryOpItem implements LogicalOpItem { @@ -37,4 +44,12 @@ public class NeqAVM2Item extends BinaryOpItem implements LogicalOpItem { public GraphTargetItem invert() { return new EqAVM2Item(src, leftSide, rightSide); } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, leftSide, rightSide, + new AVM2Instruction(0, new EqualsIns(), new int[]{}, new byte[0]), + new AVM2Instruction(0, new NotIns(), new int[]{}, new byte[0]) + ); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/OrAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/OrAVM2Item.java deleted file mode 100644 index 8a45e792d..000000000 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/OrAVM2Item.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2010-2014 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.decompiler.flash.abc.avm2.model.operations; - -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.ecma.EcmaScript; -import com.jpexs.decompiler.graph.GraphPart; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.decompiler.graph.model.BinaryOpItem; - -public class OrAVM2Item extends BinaryOpItem { - - public GraphPart firstPart; - - public OrAVM2Item(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { - super(instruction, PRECEDENCE_LOGICALOR, leftSide, rightSide, "||"); - } - - @Override - public Object getResult() { - return EcmaScript.toBoolean(leftSide.getResult()) || EcmaScript.toBoolean(rightSide.getResult()); - } -} diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/PreDecrementAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/PreDecrementAVM2Item.java index 3bbf9ccc7..e04c692e1 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/PreDecrementAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/PreDecrementAVM2Item.java @@ -16,10 +16,14 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.model.clauses.AssignmentAVM2Item; +import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.UnaryOpItem; +import java.util.List; public class PreDecrementAVM2Item extends UnaryOpItem implements AssignmentAVM2Item { @@ -31,4 +35,10 @@ public class PreDecrementAVM2Item extends UnaryOpItem implements AssignmentAVM2I public boolean hasSideEffect() { return true; } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return super.toSource(localData, generator); //TODO + } + } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/PreIncrementAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/PreIncrementAVM2Item.java index e4bd06279..bb7833170 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/PreIncrementAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/PreIncrementAVM2Item.java @@ -16,9 +16,13 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.UnaryOpItem; +import java.util.List; public class PreIncrementAVM2Item extends UnaryOpItem { @@ -30,4 +34,9 @@ public class PreIncrementAVM2Item extends UnaryOpItem { public boolean hasSideEffect() { return true; } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return super.toSource(localData, generator); //TODO + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/RShiftAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/RShiftAVM2Item.java index 7acf80ca5..7c1e52177 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/RShiftAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/RShiftAVM2Item.java @@ -16,10 +16,16 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.ModuloIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise.RShiftIns; import com.jpexs.decompiler.flash.ecma.EcmaScript; +import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.BinaryOpItem; +import java.util.List; public class RShiftAVM2Item extends BinaryOpItem { @@ -31,4 +37,11 @@ public class RShiftAVM2Item extends BinaryOpItem { public Object getResult() { return ((long) (double) EcmaScript.toNumber(leftSide.getResult())) >> ((long) (double) EcmaScript.toNumber(rightSide.getResult())); } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, leftSide, rightSide, + new AVM2Instruction(0, new RShiftIns(), new int[]{}, new byte[0]) + ); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/StrictEqAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/StrictEqAVM2Item.java index a4140cc29..127a60815 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/StrictEqAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/StrictEqAVM2Item.java @@ -16,11 +16,17 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.ModuloIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.comparison.StrictEqualsIns; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.BinaryOpItem; import com.jpexs.decompiler.graph.model.LogicalOpItem; +import java.util.List; public class StrictEqAVM2Item extends BinaryOpItem implements LogicalOpItem { @@ -40,4 +46,11 @@ public class StrictEqAVM2Item extends BinaryOpItem implements LogicalOpItem { public GraphTargetItem invert() { return new StrictNeqAVM2Item(src, leftSide, rightSide); } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, leftSide, rightSide, + new AVM2Instruction(0, new StrictEqualsIns(), new int[]{}, new byte[0]) + ); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/StrictNeqAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/StrictNeqAVM2Item.java index 497f54b53..bc5f936e8 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/StrictNeqAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/StrictNeqAVM2Item.java @@ -16,11 +16,18 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.ModuloIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.NotIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.comparison.StrictEqualsIns; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.BinaryOpItem; import com.jpexs.decompiler.graph.model.LogicalOpItem; +import java.util.List; public class StrictNeqAVM2Item extends BinaryOpItem implements LogicalOpItem { @@ -40,4 +47,12 @@ public class StrictNeqAVM2Item extends BinaryOpItem implements LogicalOpItem { return EcmaScript.type(x) != EcmaScript.type(y) || (!EcmaScript.equals(x, y)); } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, leftSide, rightSide, + new AVM2Instruction(0, new StrictEqualsIns(), new int[]{}, new byte[0]), + new AVM2Instruction(0, new NotIns(), new int[]{}, new byte[0]) + ); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/SubtractAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/SubtractAVM2Item.java index 749d35be7..629ebfe8c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/SubtractAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/SubtractAVM2Item.java @@ -16,12 +16,18 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.SubtractIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise.RShiftIns; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.BinaryOpItem; import com.jpexs.decompiler.graph.model.LocalData; +import java.util.List; public class SubtractAVM2Item extends BinaryOpItem { @@ -55,4 +61,11 @@ public class SubtractAVM2Item extends BinaryOpItem { return super.appendTo(writer, localData); } } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, leftSide, rightSide, + new AVM2Instruction(0, new SubtractIns(), new int[]{}, new byte[0]) + ); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/TypeOfAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/TypeOfAVM2Item.java index 44e37771a..343ba068c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/TypeOfAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/TypeOfAVM2Item.java @@ -16,11 +16,16 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.types.TypeOfIns; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.flash.ecma.EcmaType; +import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.UnaryOpItem; +import java.util.List; import java.util.Set; public class TypeOfAVM2Item extends UnaryOpItem { @@ -60,4 +65,11 @@ public class TypeOfAVM2Item extends UnaryOpItem { //TODO: function,xml return "object"; } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, value, + new AVM2Instruction(0, new TypeOfIns(), new int[]{}, new byte[0]) + ); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/URShiftAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/URShiftAVM2Item.java index a109ad133..aa1479ef4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/URShiftAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/URShiftAVM2Item.java @@ -16,10 +16,16 @@ */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise.RShiftIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise.URShiftIns; import com.jpexs.decompiler.flash.ecma.EcmaScript; +import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.BinaryOpItem; +import java.util.List; public class URShiftAVM2Item extends BinaryOpItem { @@ -31,4 +37,11 @@ public class URShiftAVM2Item extends BinaryOpItem { public Object getResult() { return ((long) (double) EcmaScript.toNumber(leftSide.getResult())) >>> ((long) (double) EcmaScript.toNumber(rightSide.getResult())); } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return toSourceMerge(localData, generator, leftSide, rightSide, + new AVM2Instruction(0, new URShiftIns(), new int[]{}, new byte[0]) + ); + } } 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 3d9b35ab6..b9a987336 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 @@ -93,8 +93,8 @@ import java.util.logging.Logger; */ public class AVM2SourceGenerator implements SourceGenerator { - private final ABC abc; - private List allABCs; + public final ABC abc; + public List allABCs; private AVM2Instruction ins(InstructionDefinition def, int... operands) { return new AVM2Instruction(0, def, operands, new byte[0]); @@ -470,7 +470,7 @@ public class AVM2SourceGenerator implements SourceGenerator { for (ExceptionSAVM2item e : item.catchExceptions2) { ABCException aex = new ABCException(); aex.name_index = ident(e.name); - aex.type_index = typeName(e.type); + aex.type_index = typeName(localData,e.type); localData.exceptions.add(aex); //TODO } @@ -547,32 +547,6 @@ public class AVM2SourceGenerator implements SourceGenerator { return tmpReg; } - private String getName(GraphTargetItem item) { - if (item instanceof VariableAVM2Item) { - return ((VariableAVM2Item) item).getVariableName(); - } - if (item instanceof GetPropertyAVM2Item) { - GetPropertyAVM2Item mem = (GetPropertyAVM2Item) item; - return getName(mem.propertyName); - } - return null; - } - - private List getVarParts(GraphTargetItem item) { - List ret = new ArrayList<>(); - do { - if (item instanceof GetPropertyAVM2Item) { - GetPropertyAVM2Item mem = (GetPropertyAVM2Item) item; - ret.add(0, getName(mem)); - item = mem.object; - } - } while (item instanceof GetPropertyAVM2Item); - String f = getName(item); - if (f != null) { - ret.add(0, f); - } - return ret; - } public AVM2SourceGenerator(ABC abc, List allABCs) { this.abc = abc; @@ -583,16 +557,6 @@ public class AVM2SourceGenerator implements SourceGenerator { return abc; } - /*private int generateName(GraphTargetItem name){ - - }*/ - private void generateMethod(GraphTargetItem method) { - if (method instanceof MethodAVM2Item) { - MethodAVM2Item m = (MethodAVM2Item) method; - //MethodInfo mi=new MethodInfo(param_types, ret_type, name_index, flags, optional, paramNames) - } - } - public void generateClass(ClassInfo classInfo, InstanceInfo instanceInfo, SourceGeneratorLocalData localData, boolean isInterface, GraphTargetItem name, GraphTargetItem extendsVal, List implementsStr, GraphTargetItem constructor, List traitItems) { List ret = new ArrayList<>(); @@ -609,7 +573,7 @@ public class AVM2SourceGenerator implements SourceGenerator { generateTraits(true, localData, traitItems, classInfo.static_traits); if (extendsVal != null) { - instanceInfo.super_index = typeName(extendsVal); + instanceInfo.super_index = typeName(localData,extendsVal); } else if (!isInterface) { instanceInfo.super_index = abc.constants.getMultinameId(new Multiname(Multiname.QNAME, str("Object"), namespace(Namespace.KIND_PACKAGE, ""), 0, 0, new ArrayList()), true); } @@ -663,19 +627,60 @@ public class AVM2SourceGenerator implements SourceGenerator { } public int traitName(int nsKind, String var) { - return -1; //TODO + return abc.constants.getMultinameId(new Multiname(Multiname.QNAME, str(var), namespace(nsKind, ""), 0, 0, new ArrayList()), true); } - public int typeName(GraphTargetItem type) { + public int typeName(SourceGeneratorLocalData localData, GraphTargetItem type) { if (type instanceof UnboundedAVM2Item) { return 0; } - return -1; //TODO + + String pkg=""; + String name = type.toString(); + NameAVM2Item nameItem=(NameAVM2Item)type; + if(name.contains(".")){ + pkg = name.substring(0,name.lastIndexOf(".")); + name = name.substring(name.lastIndexOf(".")+1); + } + + int nsKind = Namespace.KIND_PACKAGE; + if(pkg.equals("")){ + for(int i=0;i abcs=new ArrayList<>(); + abcs.add(abc); + abcs.addAll(allABCs); + loopabc:for(ABC a:abcs){ + for(InstanceInfo ii:a.instance_info){ + Multiname n=a.constants.constant_multiname.get(ii.name_index); + if(n.getNamespace(a.constants).getName(a.constants).equals(nspkg) && n.getName(a.constants, new ArrayList()).equals(name)){ + pkg = nspkg; + nsKind = n.getNamespace(a.constants).kind; + break loopabc; + } + } + } + } else if(name.equals(nsclass)){ + pkg = nspkg; + nsKind = nameItem.openedNamespacesKind.get(i); + break; + } + } + } + + return abc.constants.getMultinameId(new Multiname(Multiname.QNAME, str(name), namespace(nsKind, pkg), 0, 0, new ArrayList()), true); } public int ident(GraphTargetItem name) { - if (name instanceof VariableAVM2Item) { - return str(((VariableAVM2Item) name).getVariableName()); + if (name instanceof NameAVM2Item) { + return str(((NameAVM2Item) name).getVariableName()); } throw new RuntimeException("no ident"); //FIXME } @@ -688,12 +693,20 @@ public class AVM2SourceGenerator implements SourceGenerator { return abc.constants.getStringId(name, true); } + public int propertyName(GraphTargetItem name) { + if (name instanceof NameAVM2Item) { + NameAVM2Item va = (NameAVM2Item) name; + return abc.constants.getMultinameId(new Multiname(Multiname.QNAME, str(va.getVariableName()), namespace(Namespace.KIND_PACKAGE, ""), 0, 0, new ArrayList()), true); + } + throw new RuntimeException("no prop"); //FIXME + } + public int method(SourceGeneratorLocalData localData, List paramTypes, List paramNames, List paramValues, List body, GraphTargetItem retType) { int param_types[] = new int[paramTypes.size()]; ValueKind optional[] = new ValueKind[paramValues.size()]; int param_names[] = new int[paramNames.size()]; for (int i = 0; i < paramTypes.size(); i++) { - param_types[i] = typeName(paramTypes.get(i)); + param_types[i] = typeName(localData,paramTypes.get(i)); param_names[i] = str(paramNames.get(i)); } @@ -701,7 +714,7 @@ public class AVM2SourceGenerator implements SourceGenerator { optional[i] = getValueKind(paramTypes.get(paramTypes.size() - paramValues.size() + i), paramTypes.get(i)); } - MethodInfo mi = new MethodInfo(param_types, typeName(retType), 0/*name_index*/, 0/*TODO*/, optional, param_names); + MethodInfo mi = new MethodInfo(param_types, typeName(localData,retType), 0/*name_index*/, 0/*TODO*/, optional, param_names); MethodBody mbody = new MethodBody(); mbody.method_info = abc.addMethodInfo(mi); List src = generate(localData, body); @@ -725,8 +738,8 @@ public class AVM2SourceGenerator implements SourceGenerator { } boolean isNs = false; - if (type instanceof VariableAVM2Item) { - if (((VariableAVM2Item) type).getVariableName().equals("namespace")) { + if (type instanceof NameAVM2Item) { + if (((NameAVM2Item) type).getVariableName().equals("namespace")) { isNs = true; } } @@ -754,19 +767,23 @@ public class AVM2SourceGenerator implements SourceGenerator { } public void generateTraits(boolean generateStatic, SourceGeneratorLocalData localData, List items, Traits ts) { - for (GraphTargetItem item : items) { + Trait[] traits=new Trait[items.size()]; + for (int k=0;k commands(Stack loops, Map loopLabels, HashMap registerVars, boolean inFunction, boolean inMethod, int forinlevel, List variables) throws IOException, ParseException { + private List commands(List openedNamespaces, List openedNamespacesKinds, Stack loops, Map loopLabels, HashMap registerVars, boolean inFunction, boolean inMethod, int forinlevel, List variables) throws IOException, ParseException { List ret = new ArrayList<>(); if (debugMode) { System.out.println("commands:"); } GraphTargetItem cmd = null; - while ((cmd = command(loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables)) != null) { + while ((cmd = command(openedNamespaces, openedNamespacesKinds, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables)) != null) { ret.add(cmd); } if (debugMode) { @@ -129,18 +132,21 @@ public class ActionScriptParser { return ret; } - private GraphTargetItem type(List variables) throws IOException, ParseException { + private GraphTargetItem type(List openedNamespaces, List openedNamespacesKinds, List variables) throws IOException, ParseException { GraphTargetItem ret = null; ParsedSymbol s = lex(); + if (s.type == SymbolType.MULTIPLY) { + return new UnboundedAVM2Item(); + } expected(s, lexer.yyline(), SymbolType.IDENTIFIER, SymbolType.STRING_OP); - ret = new VariableAVM2Item(s.value.toString(), null, false); - variables.add((VariableAVM2Item) ret); + ret = new NameAVM2Item(lexer.yyline(),s.value.toString(), null, false, openedNamespaces, openedNamespacesKinds); + variables.add((NameAVM2Item) ret); s = lex(); while (s.type == SymbolType.DOT) { s = lex(); expected(s, lexer.yyline(), SymbolType.IDENTIFIER, SymbolType.STRING_OP); - VariableAVM2Item var = new VariableAVM2Item(s.value.toString(), null, false); + NameAVM2Item var = new NameAVM2Item(lexer.yyline(),s.value.toString(), null, false, openedNamespaces, openedNamespacesKinds); ret = new GetPropertyAVM2Item(null, ret, var); s = lex(); } @@ -148,7 +154,7 @@ public class ActionScriptParser { return ret; } - private GraphTargetItem memberOrCall(GraphTargetItem newcmds, HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, ParseException { + private GraphTargetItem memberOrCall(List openedNamespaces, List openedNamespacesKinds, GraphTargetItem newcmds, HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, ParseException { ParsedSymbol s = lex(); GraphTargetItem ret = newcmds; while (s.isType(SymbolType.DOT, SymbolType.BRACKET_OPEN, SymbolType.PARENT_OPEN)) { @@ -156,20 +162,10 @@ public class ActionScriptParser { case DOT: case BRACKET_OPEN: lexer.pushback(s); - ret = member(ret, registerVars, inFunction, inMethod, variables); + ret = member(openedNamespaces, openedNamespacesKinds, ret, registerVars, inFunction, inMethod, variables); break; case PARENT_OPEN: - if (ret instanceof GetPropertyAVM2Item) { - GetPropertyAVM2Item mem = (GetPropertyAVM2Item) ret; - ret = new CallPropertyAVM2Item(null, false, mem.object, mem.propertyName, call(registerVars, inFunction, inMethod, variables)); - } else if (ret instanceof VariableAVM2Item) { - VariableAVM2Item var = (VariableAVM2Item) ret; - ret = new CallPropertyAVM2Item(null, false, new FindPropertyAVM2Item(null, var), var, call(registerVars, inFunction, inMethod, variables)); - //ret = new CallFunctionAVM2Item(null, pushConst(var.getVariableName()), call(registerVars, inFunction, inMethod, variables)); - } else { - //ret = new CallPropertyAVM2Item(null,false, ret, call(registerVars, inFunction, inMethod, variables)); - //FIXME? - } + ret = new CallAVM2Item(ret, call(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, variables)); break; } s = lex(); @@ -178,11 +174,11 @@ public class ActionScriptParser { return ret; } - private GraphTargetItem member(GraphTargetItem obj, HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, ParseException { + private GraphTargetItem member(List openedNamespaces, List openedNamespacesKinds, GraphTargetItem obj, HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, ParseException { GraphTargetItem ret = obj; ParsedSymbol s = lex(); while (s.isType(SymbolType.DOT)) { - VariableAVM2Item var = name(registerVars, inFunction, inMethod, variables); + NameAVM2Item var = name(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, variables); ret = new GetPropertyAVM2Item(null, ret, var); s = lex(); } @@ -190,26 +186,31 @@ public class ActionScriptParser { return ret; } - private VariableAVM2Item qname(List variables) throws IOException, ParseException { + private NameAVM2Item qname(List openedNamespaces, List openedNamespacesKinds, List variables) throws IOException, ParseException { ParsedSymbol s = lex(); expected(s, lexer.yyline(), SymbolType.IDENTIFIER, SymbolType.THIS, SymbolType.SUPER, SymbolType.STRING_OP); - VariableAVM2Item ret = new VariableAVM2Item(s.value.toString(), null, false); - variables.add((VariableAVM2Item) ret); + NameAVM2Item ret = new NameAVM2Item(lexer.yyline(),s.value.toString(), null, false, openedNamespaces, openedNamespacesKinds); + variables.add((NameAVM2Item) ret); return ret; } - private VariableAVM2Item name(HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, ParseException { + private NameAVM2Item name(List openedNamespaces, List openedNamespacesKinds, HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, ParseException { ParsedSymbol s = lex(); expected(s, lexer.yyline(), SymbolType.IDENTIFIER, SymbolType.THIS, SymbolType.SUPER, SymbolType.STRING_OP); - VariableAVM2Item ret = new VariableAVM2Item(s.value.toString(), null, false); + NameAVM2Item ret = new NameAVM2Item(lexer.yyline(),s.value.toString(), null, false, openedNamespaces, openedNamespacesKinds); s = lex(); + while (s.type == SymbolType.DOT) { + s = lex(); + expected(s, lexer.yyline(), SymbolType.IDENTIFIER); + ret.appendName(s.value.toString()); + } if (s.type == SymbolType.BRACKET_OPEN) { - ret.setIndex(expression(registerVars, inFunction, inMethod, true, variables)); + ret.setIndex(expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, true, variables)); expectedType(SymbolType.BRACKET_CLOSE); } else { lexer.pushback(s); } - variables.add((VariableAVM2Item) ret); + variables.add((NameAVM2Item) ret); return ret; } @@ -251,7 +252,7 @@ public class ActionScriptParser { return ret; } - private List call(HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, ParseException { + private List call(List openedNamespaces, List openedNamespacesKinds, HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, ParseException { List ret = new ArrayList<>(); //expected(SymbolType.PARENT_OPEN); //MUST BE HANDLED BY CALLER ParsedSymbol s = lex(); @@ -259,19 +260,19 @@ public class ActionScriptParser { if (s.type != SymbolType.COMMA) { lexer.pushback(s); } - ret.add(expression(registerVars, inFunction, inMethod, true, variables)); + ret.add(expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, true, variables)); s = lex(); expected(s, lexer.yyline(), SymbolType.COMMA, SymbolType.PARENT_CLOSE); } return ret; } - private MethodAVM2Item method(boolean isStatic, int namespaceKind, boolean withBody, String functionName, boolean isMethod, List variables) throws IOException, ParseException { - FunctionAVM2Item f = function(withBody, functionName, isMethod, variables); + private MethodAVM2Item method(List openedNamespaces, List openedNamespacesKinds, boolean isStatic, int namespaceKind, boolean withBody, String functionName, boolean isMethod, List variables) throws IOException, ParseException { + FunctionAVM2Item f = function(openedNamespaces, openedNamespacesKinds, withBody, functionName, isMethod, variables); return new MethodAVM2Item(isStatic, namespaceKind, functionName, f.paramTypes, f.paramNames, f.paramValues, f.body, variables, f.retType); } - private FunctionAVM2Item function(boolean withBody, String functionName, boolean isMethod, List variables) throws IOException, ParseException { + private FunctionAVM2Item function(List openedNamespaces, List openedNamespacesKinds, boolean withBody, String functionName, boolean isMethod, List variables) throws IOException, ParseException { ParsedSymbol s; expectedType(SymbolType.PARENT_OPEN); s = lex(); @@ -288,13 +289,13 @@ public class ActionScriptParser { paramNames.add(s.value.toString()); s = lex(); if (s.type == SymbolType.COLON) { - paramTypes.add(type(variables)); + paramTypes.add(type(openedNamespaces, openedNamespacesKinds, variables)); s = lex(); } else { paramTypes.add(new UnboundedAVM2Item()); } if (s.type == SymbolType.ASSIGN) { - paramValues.add(expression(null, isMethod, isMethod, isMethod, variables)); + paramValues.add(expression(openedNamespaces, openedNamespacesKinds, null, isMethod, isMethod, isMethod, variables)); } else { if (!paramValues.isEmpty()) { throw new ParseException("Some of parameters do not have default values", lexer.yyline()); @@ -308,17 +309,17 @@ public class ActionScriptParser { s = lex(); GraphTargetItem retType; if (s.type == SymbolType.COLON) { - retType = type(variables); + retType = type(openedNamespaces, openedNamespacesKinds, variables); } else { retType = new UnboundedAVM2Item(); lexer.pushback(s); } List body = null; - List subvariables = new ArrayList<>(); + List subvariables = new ArrayList<>(); if (withBody) { expectedType(SymbolType.CURLY_OPEN); - body = commands(new Stack(), new HashMap(), new HashMap(), true, isMethod, 0, subvariables); + body = commands(openedNamespaces, openedNamespacesKinds, new Stack(), new HashMap(), new HashMap(), true, isMethod, 0, subvariables); expectedType(SymbolType.CURLY_CLOSE); } @@ -326,10 +327,10 @@ public class ActionScriptParser { return new FunctionAVM2Item(functionName, paramTypes, paramNames, paramValues, body, subvariables, retType); } - private GraphTargetItem traits(String classNameStr, boolean isInterface, List traits) throws ParseException, IOException { + private GraphTargetItem traits(List openedNamespaces, List openedNamespacesKinds, String packageName, String classNameStr, boolean isInterface, List traits) throws ParseException, IOException { ParsedSymbol s; GraphTargetItem constr = null; - List variables = new ArrayList<>(); + List variables = new ArrayList<>(); looptrait: while (true) { s = lex(); @@ -396,42 +397,42 @@ public class ActionScriptParser { if (classNameStr != null) { throw new ParseException("Nested classes not supported", lexer.yyline()); } - GraphTargetItem classTypeStr = type(variables); + GraphTargetItem classTypeStr = type(openedNamespaces, openedNamespacesKinds, variables); s = lex(); GraphTargetItem extendsTypeStr = null; if (s.type == SymbolType.EXTENDS) { - extendsTypeStr = type(variables); + extendsTypeStr = type(openedNamespaces, openedNamespacesKinds, variables); s = lex(); } List implementsTypeStrs = new ArrayList<>(); if (s.type == SymbolType.IMPLEMENTS) { do { - GraphTargetItem implementsTypeStr = type(variables); + GraphTargetItem implementsTypeStr = type(openedNamespaces, openedNamespacesKinds, variables); implementsTypeStrs.add(implementsTypeStr); s = lex(); } while (s.type == SymbolType.COMMA); } expected(s, lexer.yyline(), SymbolType.CURLY_OPEN); - traits.add((classTraits(nsKind, false, classTypeStr, extendsTypeStr, implementsTypeStrs, variables))); + traits.add((classTraits(openedNamespaces, openedNamespacesKinds, packageName, nsKind, false, classTypeStr, extendsTypeStr, implementsTypeStrs, variables))); expectedType(SymbolType.CURLY_CLOSE); break; case INTERFACE: if (classNameStr != null) { throw new ParseException("Nested interfaces not supported", lexer.yyline()); } - GraphTargetItem interfaceTypeStr = type(variables); + GraphTargetItem interfaceTypeStr = type(openedNamespaces, openedNamespacesKinds, variables); s = lex(); List intExtendsTypeStrs = new ArrayList<>(); if (s.type == SymbolType.EXTENDS) { do { - GraphTargetItem intExtendsTypeStr = type(variables); + GraphTargetItem intExtendsTypeStr = type(openedNamespaces, openedNamespacesKinds, variables); intExtendsTypeStrs.add(intExtendsTypeStr); s = lex(); } while (s.type == SymbolType.COMMA); } expected(s, lexer.yyline(), SymbolType.CURLY_OPEN); - traits.add((classTraits(nsKind, true, interfaceTypeStr, null, intExtendsTypeStrs, variables))); + traits.add((classTraits(openedNamespaces, openedNamespacesKinds, packageName, nsKind, true, interfaceTypeStr, null, intExtendsTypeStrs, variables))); expectedType(SymbolType.CURLY_CLOSE); break; @@ -443,17 +444,17 @@ public class ActionScriptParser { if (isStatic) { throw new ParseException("Constructor cannot be static", lexer.yyline()); } - constr = (method(false, nsKind, !isInterface, "", true, variables)); + constr = (method(openedNamespaces, openedNamespacesKinds, false, nsKind, !isInterface, "", true, variables)); } else { if (isStatic) { GraphTargetItem t; - MethodAVM2Item ft = method(isStatic, nsKind, !isInterface, fname, true, variables); + MethodAVM2Item ft = method(openedNamespaces, openedNamespacesKinds, isStatic, nsKind, !isInterface, fname, true, variables); traits.add(ft); if (isGetter || isSetter) { throw new ParseException("Getter or Setter cannot be static", lexer.yyline()); } } else { - MethodAVM2Item ft = method(isStatic, nsKind, !isInterface, fname, true, variables); + MethodAVM2Item ft = method(openedNamespaces, openedNamespacesKinds, isStatic, nsKind, !isInterface, fname, true, variables); GraphTargetItem t; if (isGetter) { GetterAVM2Item g = new GetterAVM2Item(isStatic, ft.namespaceKind, ft.functionName, ft.paramTypes, ft.paramNames, ft.paramValues, ft.body, ft.subvariables, ft.retType); @@ -479,15 +480,15 @@ public class ActionScriptParser { s = lex(); GraphTargetItem type = null; if (s.type == SymbolType.COLON) { - type = type(variables); + type = type(openedNamespaces, openedNamespacesKinds, variables); s = lex(); } if (s.type == SymbolType.ASSIGN) { GraphTargetItem tar; if (isConst) { - tar = new ConstAVM2Item(isStatic, nsKind, vcname, type, expression(new HashMap(), false, false, true, variables)); + tar = new ConstAVM2Item(isStatic, nsKind, vcname, type, expression(openedNamespaces, openedNamespacesKinds, new HashMap(), false, false, true, variables)); } else { - tar = new SlotAVM2Item(isStatic, nsKind, vcname, type, expression(new HashMap(), false, false, true, variables)); + tar = new SlotAVM2Item(isStatic, nsKind, vcname, type, expression(openedNamespaces, openedNamespacesKinds, new HashMap(), false, false, true, variables)); } traits.add(tar); s = lex(); @@ -505,7 +506,7 @@ public class ActionScriptParser { return constr; } - private GraphTargetItem classTraits(int namespaceKind, boolean isInterface, GraphTargetItem nameStr, GraphTargetItem extendsStr, List implementsStr, List variables) throws IOException, ParseException { + private GraphTargetItem classTraits(List openedNamespaces, List openedNamespacesKinds, String packageName, int namespaceKind, boolean isInterface, GraphTargetItem nameStr, GraphTargetItem extendsStr, List implementsStr, List variables) throws IOException, ParseException { GraphTargetItem ret = null; @@ -513,18 +514,29 @@ public class ActionScriptParser { MethodAVM2Item constr = null; List traits = new ArrayList<>(); - String classNameStr = ""; - if (nameStr instanceof GetPropertyAVM2Item) { - GetPropertyAVM2Item mem = (GetPropertyAVM2Item) nameStr; - if (mem.propertyName instanceof VariableAVM2Item) { - classNameStr = ((VariableAVM2Item) mem.propertyName).getVariableName(); - } - } else if (nameStr instanceof VariableAVM2Item) { - VariableAVM2Item var = (VariableAVM2Item) nameStr; - classNameStr = var.getVariableName(); - } + String classNameStr = nameStr.toString(); - traits(classNameStr, isInterface, traits); + openedNamespaces = new ArrayList<>(openedNamespaces); + openedNamespacesKinds = new ArrayList<>(openedNamespacesKinds); + + openedNamespacesKinds.add(Namespace.KIND_PRIVATE); + openedNamespaces.add(packageName + ":" + classNameStr); + openedNamespacesKinds.add(Namespace.KIND_PACKAGE); + openedNamespaces.add(""); + openedNamespacesKinds.add(Namespace.KIND_PRIVATE); + openedNamespaces.add(classNameStr + ".as$"); + openedNamespacesKinds.add(Namespace.KIND_PACKAGE); + openedNamespaces.add(packageName); + openedNamespacesKinds.add(Namespace.KIND_PACKAGE_INTERNAL); + openedNamespaces.add(packageName); + openedNamespacesKinds.add(Namespace.KIND_NAMESPACE); + openedNamespaces.add(AS3_NAMESPACE); + openedNamespacesKinds.add(Namespace.KIND_PROTECTED); + openedNamespaces.add(packageName + ":" + classNameStr); + openedNamespacesKinds.add(Namespace.KIND_STATIC_PROTECTED); + openedNamespaces.add(packageName + ":" + classNameStr); + + traits(openedNamespaces, openedNamespacesKinds, packageName, classNameStr, isInterface, traits); if (isInterface) { return new InterfaceAVM2Item(namespaceKind, classNameStr, implementsStr, traits); @@ -533,12 +545,12 @@ public class ActionScriptParser { } } - private GraphTargetItem expressionCommands(ParsedSymbol s, HashMap registerVars, boolean inFunction, boolean inMethod, int forinlevel, List variables) throws IOException, ParseException { + private GraphTargetItem expressionCommands(ParsedSymbol s, HashMap registerVars, boolean inFunction, boolean inMethod, int forinlevel, List variables) throws IOException, ParseException { GraphTargetItem ret = null; switch (s.type) { /*case INT: expectedType(SymbolType.PARENT_OPEN); - ret = new ToIntegerAVM2Item(null, expression(registerVars, inFunction, inMethod, true, variables)); + ret = new ToIntegerAVM2Item(null, expression(openedNamespaces,openedNamespacesKinds,registerVars, inFunction, inMethod, true, variables)); expectedType(SymbolType.PARENT_CLOSE); break; case NUMBER_OP: @@ -549,7 +561,7 @@ public class ActionScriptParser { ret = memberOrCall(vi, registerVars, inFunction, inMethod, variables); } else { expected(s, lexer.yyline(), SymbolType.PARENT_OPEN); - ret = new ToNumberAVM2Item(null, expression(registerVars, inFunction, inMethod, true, variables)); + ret = new ToNumberAVM2Item(null, expression(openedNamespaces,openedNamespacesKinds,registerVars, inFunction, inMethod, true, variables)); expectedType(SymbolType.PARENT_CLOSE); } break; @@ -563,7 +575,7 @@ public class ActionScriptParser { ret = memberOrCall(vi2, registerVars, inFunction, inMethod, variables); } else { expected(s, lexer.yyline(), SymbolType.PARENT_OPEN); - ret = new ToStringAVM2Item(null, expression(registerVars, inFunction, inMethod, true, variables)); + ret = new ToStringAVM2Item(null, expression(openedNamespaces,openedNamespacesKinds,registerVars, inFunction, inMethod, true, variables)); expectedType(SymbolType.PARENT_CLOSE); ret = memberOrCall(ret, registerVars, inFunction, inMethod, variables); } @@ -574,7 +586,7 @@ public class ActionScriptParser { //return ret; } - private GraphTargetItem command(Stack loops, Map loopLabels, HashMap registerVars, boolean inFunction, boolean inMethod, int forinlevel, boolean mustBeCommand, List variables) throws IOException, ParseException { + private GraphTargetItem command(List openedNamespaces, List openedNamespacesKinds, Stack loops, Map loopLabels, HashMap registerVars, boolean inFunction, boolean inMethod, int forinlevel, boolean mustBeCommand, List variables) throws IOException, ParseException { LexBufferer buf = new LexBufferer(); lexer.addListener(buf); GraphTargetItem ret = null; @@ -600,21 +612,21 @@ public class ActionScriptParser { switch (s.type) { case WITH: expectedType(SymbolType.PARENT_OPEN); - GraphTargetItem wvar = (name(registerVars, inFunction, inMethod, variables)); + GraphTargetItem wvar = (name(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, variables)); expectedType(SymbolType.PARENT_CLOSE); expectedType(SymbolType.CURLY_OPEN); - List wcmd = commands(loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, variables); + List wcmd = commands(openedNamespaces, openedNamespacesKinds, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, variables); expectedType(SymbolType.CURLY_CLOSE); ret = new WithAVM2Item(null, wvar, wcmd); break; case DELETE: - GraphTargetItem varDel = name(registerVars, inFunction, inMethod, variables); + GraphTargetItem varDel = name(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, variables); if (varDel instanceof GetPropertyAVM2Item) { GetPropertyAVM2Item gm = (GetPropertyAVM2Item) varDel; ret = new DeletePropertyAVM2Item(null, gm.object, gm.propertyName); - } else if (varDel instanceof VariableAVM2Item) { + } else if (varDel instanceof NameAVM2Item) { variables.remove(varDel); - ret = new DeletePropertyAVM2Item(null, null, (VariableAVM2Item) varDel); + ret = new DeletePropertyAVM2Item(null, null, (NameAVM2Item) varDel); } else { throw new ParseException("Not a property", lexer.yyline()); } @@ -622,7 +634,7 @@ public class ActionScriptParser { case FUNCTION: s = lexer.lex(); expected(s, lexer.yyline(), SymbolType.IDENTIFIER); - ret = (function(true, s.value.toString(), false, variables)); + ret = (function(openedNamespaces, openedNamespacesKinds, true, s.value.toString(), false, variables)); break; case VAR: s = lex(); @@ -630,28 +642,28 @@ public class ActionScriptParser { String varIdentifier = s.value.toString(); s = lex(); if (s.type == SymbolType.COLON) { - type(variables); + type(openedNamespaces, openedNamespacesKinds, variables); s = lex(); //TODO: handle value type } if (s.type == SymbolType.ASSIGN) { - GraphTargetItem varval = (expression(registerVars, inFunction, inMethod, true, variables)); - ret = new VariableAVM2Item(varIdentifier, varval, true); - variables.add((VariableAVM2Item) ret); + GraphTargetItem varval = (expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, true, variables)); + ret = new NameAVM2Item(lexer.yyline(),varIdentifier, varval, true, openedNamespaces, openedNamespacesKinds); + variables.add((NameAVM2Item) ret); } else { - ret = new VariableAVM2Item(varIdentifier, null, true); - variables.add((VariableAVM2Item) ret); + ret = new NameAVM2Item(lexer.yyline(),varIdentifier, null, true, openedNamespaces, openedNamespacesKinds); + variables.add((NameAVM2Item) ret); lexer.pushback(s); } break; case CURLY_OPEN: - ret = new BlockItem(null, commands(loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, variables)); + ret = new BlockItem(null, commands(openedNamespaces, openedNamespacesKinds, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, variables)); expectedType(SymbolType.CURLY_CLOSE); break; case INCREMENT: //preincrement case DECREMENT: //predecrement - GraphTargetItem varincdec = name(registerVars, inFunction, inMethod, variables); + GraphTargetItem varincdec = name(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, variables); if (s.type == SymbolType.INCREMENT) { ret = new PreIncrementAVM2Item(null, varincdec); } else if (s.type == SymbolType.DECREMENT) { @@ -661,8 +673,8 @@ public class ActionScriptParser { case SUPER: //constructor call ParsedSymbol ss2 = lex(); if (ss2.type == SymbolType.PARENT_OPEN) { - List args = call(registerVars, inFunction, inMethod, variables); - ret = new ConstructAVM2Item(null, new VariableAVM2Item(s.value.toString(), null, false), args); + List args = call(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, variables); + ret = new ConstructSuperAVM2Item(null, new LocalRegAVM2Item(null, 0, null), args); } else {//no costructor call, but it could be calling parent methods... => handle in expression lexer.pushback(ss2); lexer.pushback(s); @@ -670,16 +682,16 @@ public class ActionScriptParser { break; case IF: expectedType(SymbolType.PARENT_OPEN); - GraphTargetItem ifExpr = (expression(registerVars, inFunction, inMethod, true, variables)); + GraphTargetItem ifExpr = (expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, true, variables)); expectedType(SymbolType.PARENT_CLOSE); - GraphTargetItem onTrue = command(loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables); + GraphTargetItem onTrue = command(openedNamespaces, openedNamespacesKinds, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables); List onTrueList = new ArrayList<>(); onTrueList.add(onTrue); s = lex(); List onFalseList = null; if (s.type == SymbolType.ELSE) { onFalseList = new ArrayList<>(); - onFalseList.add(command(loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables)); + onFalseList.add(command(openedNamespaces, openedNamespacesKinds, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables)); } else { lexer.pushback(s); } @@ -688,7 +700,7 @@ public class ActionScriptParser { case WHILE: expectedType(SymbolType.PARENT_OPEN); List whileExpr = new ArrayList<>(); - whileExpr.add(commaExpression(loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, variables)); + whileExpr.add(commaExpression(openedNamespaces, openedNamespacesKinds, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, variables)); expectedType(SymbolType.PARENT_CLOSE); List whileBody = new ArrayList<>(); Loop wloop = new Loop(uniqId(), null, null); @@ -696,7 +708,7 @@ public class ActionScriptParser { loopLabels.put(wloop, loopLabel); } loops.push(wloop); - whileBody.add(command(loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables)); + whileBody.add(command(openedNamespaces, openedNamespacesKinds, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables)); ret = new WhileItem(null, wloop, whileExpr, whileBody); break; case DO: @@ -706,11 +718,11 @@ public class ActionScriptParser { if (loopLabel != null) { loopLabels.put(dloop, loopLabel); } - doBody.add(command(loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables)); + doBody.add(command(openedNamespaces, openedNamespacesKinds, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables)); expectedType(SymbolType.WHILE); expectedType(SymbolType.PARENT_OPEN); List doExpr = new ArrayList<>(); - doExpr.add(commaExpression(loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, variables)); + doExpr.add(commaExpression(openedNamespaces, openedNamespacesKinds, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, variables)); expectedType(SymbolType.PARENT_CLOSE); ret = new DoWhileItem(null, dloop, doBody, doExpr); break; @@ -752,7 +764,7 @@ public class ActionScriptParser { } } } - collection = expression(registerVars, inFunction, inMethod, true, variables); + collection = expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, true, variables); forin = true; } else { lexer.pushback(s3); @@ -779,20 +791,20 @@ public class ActionScriptParser { GraphTargetItem forExpr = null; List forFirstCommands = new ArrayList<>(); if (!forin) { - GraphTargetItem fc = command(loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables); + GraphTargetItem fc = command(openedNamespaces, openedNamespacesKinds, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables); if (fc != null) { //can be empty command forFirstCommands.add(fc); } - forExpr = (expression(registerVars, inFunction, inMethod, true, variables)); + forExpr = (expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, true, variables)); expectedType(SymbolType.SEMICOLON); - forFinalCommands.add(command(loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables)); + forFinalCommands.add(command(openedNamespaces, openedNamespacesKinds, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables)); } expectedType(SymbolType.PARENT_CLOSE); List forBody = new ArrayList<>(); - forBody.add(command(loops, loopLabels, registerVars, inFunction, inMethod, forin ? forinlevel + 1 : forinlevel, true, variables)); + forBody.add(command(openedNamespaces, openedNamespacesKinds, loops, loopLabels, registerVars, inFunction, inMethod, forin ? forinlevel + 1 : forinlevel, true, variables)); if (forin) { - VariableAVM2Item obj = new VariableAVM2Item(objIdent, null, false); + NameAVM2Item obj = new NameAVM2Item(lexer.yyline(),objIdent, null, false, openedNamespaces, openedNamespacesKinds); variables.add(obj); if (each) { ret = new ForEachInAVM2Item(null, floop, new InAVM2Item(null, obj, collection), forBody); @@ -811,7 +823,7 @@ public class ActionScriptParser { loopLabels.put(sloop, loopLabel); } expectedType(SymbolType.PARENT_OPEN); - GraphTargetItem switchExpr = expression(registerVars, inFunction, inMethod, true, variables); + GraphTargetItem switchExpr = expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, true, variables); expectedType(SymbolType.PARENT_CLOSE); expectedType(SymbolType.CURLY_OPEN); s = lex(); @@ -832,7 +844,7 @@ public class ActionScriptParser { while (s.type == SymbolType.CASE) { List caseExprs = new ArrayList<>(); while (s.type == SymbolType.CASE) { - GraphTargetItem curCaseExpr = expression(registerVars, inFunction, inMethod, true, variables); + GraphTargetItem curCaseExpr = expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, true, variables); caseExprs.add(curCaseExpr); expectedType(SymbolType.COLON); s = lex(); @@ -841,14 +853,14 @@ public class ActionScriptParser { } pos++; lexer.pushback(s); - List caseCmd = commands(loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, variables); + List caseCmd = commands(openedNamespaces, openedNamespacesKinds, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, variables); caseCmds.add(caseCmd); s = lex(); } List defCmd = new ArrayList<>(); if (s.type == SymbolType.DEFAULT) { expectedType(SymbolType.COLON); - defCmd = commands(loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, variables); + defCmd = commands(openedNamespaces, openedNamespacesKinds, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, variables); s = lexer.lex(); } expected(s, lexer.yyline(), SymbolType.CURLY_CLOSE); @@ -913,7 +925,7 @@ public class ActionScriptParser { ret = new ContinueItem(null, cloopId); break; case RETURN: - GraphTargetItem retexpr = expression(true, registerVars, inFunction, inMethod, true, variables); + GraphTargetItem retexpr = expression(openedNamespaces, openedNamespacesKinds, true, registerVars, inFunction, inMethod, true, variables); if (retexpr == null) { ret = new ReturnVoidAVM2Item(null); } else { @@ -922,22 +934,22 @@ public class ActionScriptParser { break; case TRY: List tryCommands = new ArrayList<>(); - tryCommands.add(command(loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables)); + tryCommands.add(command(openedNamespaces, openedNamespacesKinds, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables)); s = lex(); boolean found = false; List> catchCommands = null; List catchExceptions = new ArrayList<>(); if (s.type == SymbolType.CATCH) { expectedType(SymbolType.PARENT_OPEN); - VariableAVM2Item ename = qname(variables); + NameAVM2Item ename = qname(openedNamespaces, openedNamespacesKinds, variables); expectedType(SymbolType.COLON); - VariableAVM2Item etype = name(registerVars, inFunction, inMethod, variables); + NameAVM2Item etype = name(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, variables); ABCException e = new ABCException(); catchExceptions.add(new ExceptionSAVM2item(etype, ename)); expectedType(SymbolType.PARENT_CLOSE); catchCommands = new ArrayList<>(); List cc = new ArrayList<>(); - cc.add(command(loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables)); + cc.add(command(openedNamespaces, openedNamespacesKinds, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables)); catchCommands.add(cc); s = lex(); found = true; @@ -945,7 +957,7 @@ public class ActionScriptParser { List finallyCommands = null; if (s.type == SymbolType.FINALLY) { finallyCommands = new ArrayList<>(); - finallyCommands.add(command(loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables)); + finallyCommands.add(command(openedNamespaces, openedNamespacesKinds, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables)); found = true; s = lex(); } @@ -958,7 +970,7 @@ public class ActionScriptParser { ret = tai; break; case THROW: - ret = new ThrowAVM2Item(null, expression(registerVars, inFunction, inMethod, true, variables)); + ret = new ThrowAVM2Item(null, expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, true, variables)); break; default: GraphTargetItem valcmd = expressionCommands(s, registerVars, inFunction, inMethod, forinlevel, variables); @@ -970,7 +982,7 @@ public class ActionScriptParser { return null; } lexer.pushback(s); - ret = expression(registerVars, inFunction, inMethod, true, variables); + ret = expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, true, variables); if (debugMode) { System.out.println("/command"); } @@ -981,7 +993,7 @@ public class ActionScriptParser { lexer.removeListener(buf); if (ret == null) { //can be popped expression buf.pushAllBack(lexer); - ret = expression(registerVars, inFunction, inMethod, true, variables); + ret = expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, true, variables); } s = lex(); if ((s != null) && (s.type != SymbolType.SEMICOLON)) { @@ -992,8 +1004,8 @@ public class ActionScriptParser { } - private GraphTargetItem expression(HashMap registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List variables) throws IOException, ParseException { - return expression(false, registerVars, inFunction, inMethod, allowRemainder, variables); + private GraphTargetItem expression(List openedNamespaces, List openedNamespacesKinds, HashMap registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List variables) throws IOException, ParseException { + return expression(openedNamespaces, openedNamespacesKinds, false, registerVars, inFunction, inMethod, allowRemainder, variables); } private GraphTargetItem fixPrecedence(GraphTargetItem expr) { @@ -1014,84 +1026,84 @@ public class ActionScriptParser { return ret; } - private GraphTargetItem expressionRemainder(GraphTargetItem expr, HashMap registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List variables) throws IOException, ParseException { + private GraphTargetItem expressionRemainder(List openedNamespaces, List openedNamespacesKinds, GraphTargetItem expr, HashMap registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List variables) throws IOException, ParseException { GraphTargetItem ret = null; ParsedSymbol s = lex(); switch (s.type) { case TERNAR: - GraphTargetItem terOnTrue = expression(registerVars, inFunction, inMethod, true, variables); + GraphTargetItem terOnTrue = expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, true, variables); expectedType(SymbolType.COLON); - GraphTargetItem terOnFalse = expression(registerVars, inFunction, inMethod, true, variables); + GraphTargetItem terOnFalse = expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, true, variables); ret = new TernarOpItem(null, expr, terOnTrue, terOnFalse); break; case SHIFT_LEFT: - ret = new LShiftAVM2Item(null, expr, expression(registerVars, inFunction, inMethod, false, variables)); + ret = new LShiftAVM2Item(null, expr, expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, false, variables)); break; case SHIFT_RIGHT: - ret = new RShiftAVM2Item(null, expr, expression(registerVars, inFunction, inMethod, false, variables)); + ret = new RShiftAVM2Item(null, expr, expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, false, variables)); break; case USHIFT_RIGHT: - ret = new URShiftAVM2Item(null, expr, expression(registerVars, inFunction, inMethod, false, variables)); + ret = new URShiftAVM2Item(null, expr, expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, false, variables)); break; case BITAND: - ret = new BitAndAVM2Item(null, expr, expression(registerVars, inFunction, inMethod, false, variables)); + ret = new BitAndAVM2Item(null, expr, expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, false, variables)); break; case BITOR: - ret = new BitOrAVM2Item(null, expr, expression(registerVars, inFunction, inMethod, false, variables)); + ret = new BitOrAVM2Item(null, expr, expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, false, variables)); break; case DIVIDE: - ret = new DivideAVM2Item(null, expr, expression(registerVars, inFunction, inMethod, false, variables)); + ret = new DivideAVM2Item(null, expr, expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, false, variables)); break; case MODULO: - ret = new ModuloAVM2Item(null, expr, expression(registerVars, inFunction, inMethod, false, variables)); + ret = new ModuloAVM2Item(null, expr, expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, false, variables)); break; case EQUALS: - ret = new EqAVM2Item(null, expr, expression(registerVars, inFunction, inMethod, false, variables)); + ret = new EqAVM2Item(null, expr, expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, false, variables)); break; case STRICT_EQUALS: - ret = new StrictEqAVM2Item(null, expr, expression(registerVars, inFunction, inMethod, false, variables)); + ret = new StrictEqAVM2Item(null, expr, expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, false, variables)); break; case NOT_EQUAL: - ret = new NeqAVM2Item(null, expr, expression(registerVars, inFunction, inMethod, false, variables)); + ret = new NeqAVM2Item(null, expr, expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, false, variables)); break; case STRICT_NOT_EQUAL: - ret = new StrictNeqAVM2Item(null, expr, expression(registerVars, inFunction, inMethod, false, variables)); + ret = new StrictNeqAVM2Item(null, expr, expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, false, variables)); break; case LOWER_THAN: - ret = new LtAVM2Item(null, expr, expression(registerVars, inFunction, inMethod, false, variables)); + ret = new LtAVM2Item(null, expr, expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, false, variables)); break; case LOWER_EQUAL: - ret = new LeAVM2Item(null, expr, expression(registerVars, inFunction, inMethod, false, variables)); + ret = new LeAVM2Item(null, expr, expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, false, variables)); break; case GREATER_THAN: - ret = new GtAVM2Item(null, expr, expression(registerVars, inFunction, inMethod, false, variables)); + ret = new GtAVM2Item(null, expr, expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, false, variables)); break; case GREATER_EQUAL: - ret = new GeAVM2Item(null, expr, expression(registerVars, inFunction, inMethod, false, variables)); + ret = new GeAVM2Item(null, expr, expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, false, variables)); break; case AND: - ret = new AndItem(null, expr, expression(registerVars, inFunction, inMethod, false, variables)); + ret = new AndItem(null, expr, expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, false, variables)); break; case OR: - ret = new OrItem(null, expr, expression(registerVars, inFunction, inMethod, false, variables)); + ret = new OrItem(null, expr, expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, false, variables)); break; case MINUS: - ret = new SubtractAVM2Item(null, expr, expression(registerVars, inFunction, inMethod, false, variables)); + ret = new SubtractAVM2Item(null, expr, expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, false, variables)); break; case MULTIPLY: - ret = new MultiplyAVM2Item(null, expr, expression(registerVars, inFunction, inMethod, false, variables)); + ret = new MultiplyAVM2Item(null, expr, expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, false, variables)); break; case PLUS: - ret = new AddAVM2Item(null, expr, expression(registerVars, inFunction, inMethod, false, variables)); + ret = new AddAVM2Item(null, expr, expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, false, variables)); break; case XOR: - ret = new BitXorAVM2Item(null, expr, expression(registerVars, inFunction, inMethod, false, variables)); + ret = new BitXorAVM2Item(null, expr, expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, false, variables)); break; case AS: //TODO break; case INSTANCEOF: - ret = new InstanceOfAVM2Item(null, expr, expression(registerVars, inFunction, inMethod, false, variables)); + ret = new InstanceOfAVM2Item(null, expr, expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, false, variables)); break; case IS: @@ -1109,7 +1121,7 @@ public class ActionScriptParser { case ASSIGN_SHIFT_RIGHT: case ASSIGN_USHIFT_RIGHT: case ASSIGN_XOR: - GraphTargetItem assigned = expression(registerVars, inFunction, inMethod, true, variables); + GraphTargetItem assigned = expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, true, variables); switch (s.type) { case ASSIGN: //assigned = assigned; @@ -1148,9 +1160,9 @@ public class ActionScriptParser { assigned = new BitXorAVM2Item(null, expr, assigned); break; } - if (expr instanceof VariableAVM2Item) { - ((VariableAVM2Item) expr).setStoreValue(assigned); - ((VariableAVM2Item) expr).setDefinition(false); + if (expr instanceof NameAVM2Item) { + ((NameAVM2Item) expr).setStoreValue(assigned); + ((NameAVM2Item) expr).setDefinition(false); ret = expr; } else if (expr instanceof GetPropertyAVM2Item) { ret = new SetPropertyAVM2Item(null, ((GetPropertyAVM2Item) expr).object, ((GetPropertyAVM2Item) expr).propertyName, assigned); @@ -1159,13 +1171,13 @@ public class ActionScriptParser { } break; case INCREMENT: //postincrement - if (!(expr instanceof VariableAVM2Item) && !(expr instanceof GetPropertyAVM2Item)) { + if (!(expr instanceof NameAVM2Item) && !(expr instanceof GetPropertyAVM2Item)) { throw new ParseException("Invalid assignment", lexer.yyline()); } ret = new PostIncrementAVM2Item(null, expr); break; case DECREMENT: //postdecrement - if (!(expr instanceof VariableAVM2Item) && !(expr instanceof GetPropertyAVM2Item)) { + if (!(expr instanceof NameAVM2Item) && !(expr instanceof GetPropertyAVM2Item)) { throw new ParseException("Invalid assignment", lexer.yyline()); } ret = new PostDecrementAVM2Item(null, expr); @@ -1174,14 +1186,14 @@ public class ActionScriptParser { case BRACKET_OPEN: //member case PARENT_OPEN: //function call lexer.pushback(s); - ret = memberOrCall(expr, registerVars, inFunction, inMethod, variables); + ret = memberOrCall(openedNamespaces, openedNamespacesKinds, expr, registerVars, inFunction, inMethod, variables); break; default: lexer.pushback(s); if (expr instanceof ParenthesisItem) { if (isType(((ParenthesisItem) expr).value)) { - GraphTargetItem expr2 = expression(false, registerVars, inFunction, inMethod, true, variables); + GraphTargetItem expr2 = expression(openedNamespaces, openedNamespacesKinds, false, registerVars, inFunction, inMethod, true, variables); if (expr2 != null) { ret = new CoerceAVM2Item(null, ((ParenthesisItem) expr).value, expr2); } @@ -1200,13 +1212,13 @@ public class ActionScriptParser { while (item instanceof GetPropertyAVM2Item) { item = ((GetPropertyAVM2Item) item).object; } - if (item instanceof VariableAVM2Item) { + if (item instanceof NameAVM2Item) { return true; } return false; } - private int brackets(List ret, HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, ParseException { + private int brackets(List openedNamespaces, List openedNamespacesKinds, List ret, HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, ParseException { ParsedSymbol s = lex(); int arrCnt = 0; if (s.type == SymbolType.BRACKET_OPEN) { @@ -1217,7 +1229,7 @@ public class ActionScriptParser { lexer.pushback(s); } arrCnt++; - ret.add(expression(registerVars, inFunction, inMethod, true, variables)); + ret.add(expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, true, variables)); s = lex(); if (!s.isType(SymbolType.COMMA, SymbolType.BRACKET_CLOSE)) { expected(s, lexer.yyline(), SymbolType.COMMA, SymbolType.BRACKET_CLOSE); @@ -1230,12 +1242,12 @@ public class ActionScriptParser { return arrCnt; } - private GraphTargetItem commaExpression(Stack loops, Map loopLabels, HashMap registerVars, boolean inFunction, boolean inMethod, int forInLevel, List variables) throws IOException, ParseException { + private GraphTargetItem commaExpression(List openedNamespaces, List openedNamespacesKinds, Stack loops, Map loopLabels, HashMap registerVars, boolean inFunction, boolean inMethod, int forInLevel, List variables) throws IOException, ParseException { GraphTargetItem cmd = null; List expr = new ArrayList<>(); ParsedSymbol s; do { - cmd = command(loops, loopLabels, registerVars, inFunction, inMethod, forInLevel, false, variables); + cmd = command(openedNamespaces, openedNamespacesKinds, loops, loopLabels, registerVars, inFunction, inMethod, forInLevel, false, variables); if (cmd != null) { expr.add(cmd); } @@ -1243,7 +1255,7 @@ public class ActionScriptParser { } while (s.type == SymbolType.COMMA && cmd != null); lexer.pushback(s); if (cmd == null) { - expr.add(expression(registerVars, inFunction, inMethod, true, variables)); + expr.add(expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, true, variables)); } else { if (!cmd.hasReturnValue()) { throw new ParseException("Expression expected", lexer.yyline()); @@ -1252,7 +1264,7 @@ public class ActionScriptParser { return new CommaExpressionItem(null, expr); } - private GraphTargetItem expression(boolean allowEmpty, HashMap registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List variables) throws IOException, ParseException { + private GraphTargetItem expression(List openedNamespaces, List openedNamespacesKinds, boolean allowEmpty, HashMap registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List variables) throws IOException, ParseException { if (debugMode) { System.out.println("expression:"); } @@ -1271,7 +1283,7 @@ public class ActionScriptParser { existsRemainder = true; } else { lexer.pushback(s); - GraphTargetItem num = expression(registerVars, inFunction, inMethod, true, variables); + GraphTargetItem num = expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, true, variables); if (num instanceof IntegerValueAVM2Item) { ((IntegerValueAVM2Item) num).value = -(Long) ((IntegerValueAVM2Item) num).value; ret = num; @@ -1290,7 +1302,7 @@ public class ActionScriptParser { break; case TYPEOF: expectedType(SymbolType.PARENT_OPEN); - ret = new TypeOfAVM2Item(null, expression(registerVars, inFunction, inMethod, true, variables)); + ret = new TypeOfAVM2Item(null, expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, true, variables)); expectedType(SymbolType.PARENT_CLOSE); existsRemainder = true; break; @@ -1318,9 +1330,9 @@ public class ActionScriptParser { lexer.pushback(s); } - GraphTargetItem n = expression(registerVars, inFunction, inMethod, allowRemainder, variables); + GraphTargetItem n = expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, allowRemainder, variables); expectedType(SymbolType.COLON); - GraphTargetItem v = expression(registerVars, inFunction, inMethod, allowRemainder, variables); + GraphTargetItem v = expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, allowRemainder, variables); NameValuePair nv = new NameValuePair(n, v); nvs.add(nv); @@ -1334,7 +1346,7 @@ public class ActionScriptParser { case BRACKET_OPEN: //Array literal or just brackets lexer.pushback(s); List inBrackets = new ArrayList<>(); - int arrCnt = brackets(inBrackets, registerVars, inFunction, inMethod, variables); + int arrCnt = brackets(openedNamespaces, openedNamespacesKinds, inBrackets, registerVars, inFunction, inMethod, variables); ret = new NewArrayAVM2Item(null, inBrackets); break; case FUNCTION: @@ -1345,7 +1357,7 @@ public class ActionScriptParser { } else { lexer.pushback(s); } - ret = function(true, fname, false, variables); + ret = function(openedNamespaces, openedNamespacesKinds, true, fname, false, variables); break; case NAN: ret = new NanAVM2Item(null); @@ -1364,7 +1376,7 @@ public class ActionScriptParser { existsRemainder = true; break; case DELETE: - GraphTargetItem varDel = name(registerVars, inFunction, inMethod, variables); + GraphTargetItem varDel = name(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, variables); if (varDel instanceof GetPropertyAVM2Item) { GetPropertyAVM2Item gm = (GetPropertyAVM2Item) varDel; ret = new DeletePropertyAVM2Item(null, gm.object, gm.propertyName); @@ -1374,7 +1386,7 @@ public class ActionScriptParser { break; case INCREMENT: case DECREMENT: //preincrement - GraphTargetItem prevar = name(registerVars, inFunction, inMethod, variables); + GraphTargetItem prevar = name(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, variables); if (s.type == SymbolType.INCREMENT) { ret = new PreIncrementAVM2Item(null, prevar); } @@ -1384,23 +1396,23 @@ public class ActionScriptParser { existsRemainder = true; break; case NOT: - ret = new NotItem(null, expression(registerVars, inFunction, inMethod, true, variables)); + ret = new NotItem(null, expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, true, variables)); existsRemainder = true; break; case PARENT_OPEN: - ret = new ParenthesisItem(null, expression(registerVars, inFunction, inMethod, true, variables)); + ret = new ParenthesisItem(null, expression(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, true, variables)); expectedType(SymbolType.PARENT_CLOSE); - ret = memberOrCall(ret, registerVars, inFunction, inMethod, variables); + ret = memberOrCall(openedNamespaces, openedNamespacesKinds, ret, registerVars, inFunction, inMethod, variables); existsRemainder = true; break; case NEW: - GraphTargetItem newvar = name(registerVars, inFunction, inMethod, variables); + GraphTargetItem newvar = name(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, variables); expectedType(SymbolType.PARENT_OPEN); if (newvar instanceof GetPropertyAVM2Item) { GetPropertyAVM2Item mem = (GetPropertyAVM2Item) newvar; - ret = new ConstructPropAVM2Item(null, mem.object, mem.propertyName, call(registerVars, inFunction, inMethod, variables)); - } else if (newvar instanceof VariableAVM2Item) { - ret = new ConstructAVM2Item(null, newvar, call(registerVars, inFunction, inMethod, variables)); + ret = new ConstructPropAVM2Item(null, mem.object, mem.propertyName, call(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, variables)); + } else if (newvar instanceof NameAVM2Item) { + ret = new ConstructAVM2Item(null, newvar, call(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, variables)); } else { throw new ParseException("Invalid new item", lexer.yyline()); } @@ -1409,6 +1421,12 @@ public class ActionScriptParser { case IDENTIFIER: case THIS: case SUPER: + lexer.pushback(s); + GraphTargetItem var = name(openedNamespaces, openedNamespacesKinds, registerVars, inFunction, inMethod, variables); + var = memberOrCall(openedNamespaces, openedNamespacesKinds, var, registerVars, inFunction, inMethod, variables); + ret = var; + existsRemainder = true; + break; default: GraphTargetItem excmd = expressionCommands(s, registerVars, inFunction, inMethod, -1, variables); if (excmd != null) { @@ -1421,7 +1439,7 @@ public class ActionScriptParser { if (allowRemainder && existsRemainder) { GraphTargetItem rem = ret; do { - rem = expressionRemainder(rem, registerVars, inFunction, inMethod, assocRight, variables); + rem = expressionRemainder(openedNamespaces, openedNamespacesKinds, rem, registerVars, inFunction, inMethod, assocRight, variables); if (rem != null) { ret = rem; } @@ -1452,30 +1470,52 @@ public class ActionScriptParser { name += "." + s.value.toString(); } List items = new ArrayList<>(); - traits(null, false, items); + List openedNamespacesKinds = new ArrayList<>(); + List openedNamespaces = new ArrayList<>(); + s = lex(); + while(s.type == SymbolType.IMPORT){ + String impPackage = ""; + String impName = null; + boolean all = false; + s = lex(); + expected(s, lexer.yyline(), SymbolType.IDENTIFIER); + impName = s.value.toString(); + s = lex(); + while(s.type == SymbolType.DOT){ + if(!"".equals(impPackage)){ + impPackage += "."; + } + impPackage += impName; + + s = lex(); + if(s.type == SymbolType.MULTIPLY){ + impName = null; + break; + } + expected(s, lexer.yyline(), SymbolType.IDENTIFIER); + + impName = s.value.toString(); + s = lex(); + } + + String fullImp = impName==null?impPackage:impPackage+":"+impName; + openedNamespaces.add(fullImp); + openedNamespacesKinds.add(Namespace.KIND_PACKAGE); + + expectedType(SymbolType.SEMICOLON); + } + lexer.pushback(s); + + traits(openedNamespaces, openedNamespacesKinds, name, null, false, items); expectedType(SymbolType.CURLY_CLOSE); return new PackageAVM2Item(name, items); } - public PackageAVM2Item packageFromString(String str, List constantPool) throws ParseException, IOException { + public PackageAVM2Item packageFromString(String str) throws ParseException, IOException { this.constantPool = constantPool; lexer = new ActionScriptLexer(new StringReader(str)); - List vars = new ArrayList<>(); PackageAVM2Item ret = parsePackage(); - /*for (VariableAVM2Item v : vars) { - String varName = v.getVariableName(); - GraphTargetItem stored = v.getStoreValue(); - if (v.isDefinition()) { - //v.setBoxedValue(new DefineLocalAVM2Item(null, pushConst(varName), stored)); //FIXME!!! - } else { - if (stored != null) { - //v.setBoxedValue(new SetVariableAVM2Item(null, pushConst(varName), stored)); //FIXME!!! - } else { - //v.setBoxedValue(new GetVariableAVM2Item(null, pushConst(varName))); //FIXME!!! - } - } - }*/ if (lexer.lex().type != SymbolType.EOF) { throw new ParseException("Parsing finisned before end of the file", lexer.yyline()); } @@ -1490,23 +1530,14 @@ public class ActionScriptParser { String className = ""; for (GraphTargetItem it : pkg.items) { if (it instanceof ClassAVM2Item) { - className = ((ClassAVM2Item) it).className.toString(); + className = ((ClassAVM2Item) it).className; } } - localData.addNamespace(Namespace.KIND_PRIVATE, pkg.packageName + ":" + className); - localData.addNamespace(Namespace.KIND_PACKAGE, ""); - localData.addNamespace(Namespace.KIND_PRIVATE, className + ".as"); - localData.addNamespace(Namespace.KIND_PACKAGE, pkg.packageName); - localData.addNamespace(Namespace.KIND_PACKAGE_INTERNAL, pkg.packageName); - localData.addNamespace(Namespace.KIND_NAMESPACE, AS3_NAMESPACE); - localData.addNamespace(Namespace.KIND_PROTECTED, pkg.packageName + ":" + className); - localData.addNamespace(Namespace.KIND_STATIC_PROTECTED, pkg.packageName + ":" + className); return gen.generateScriptInfo(localData, pkg.items); } public ScriptInfo scriptFromString(String s, ABC abc, List otherABCs) throws ParseException, IOException { - List constantPool = new ArrayList<>(); - PackageAVM2Item pkg = packageFromString(s, constantPool); + PackageAVM2Item pkg = packageFromString(s); return scriptFromTree(pkg, abc, otherABCs); } } 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 new file mode 100644 index 000000000..2b4702e15 --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/CallAVM2Item.java @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2014 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.decompiler.flash.abc.avm2.parser.script; + +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; +import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.graph.GraphSourceItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; +import com.jpexs.decompiler.graph.model.LocalData; +import java.util.List; + +/** + * + * @author JPEXS + */ +public class CallAVM2Item extends AVM2Item { + + public GraphTargetItem name; + public List arguments; + + public CallAVM2Item(GraphTargetItem name,List arguments) { + super(null,NOPRECEDENCE); + this.name = name; + this.arguments = arguments; + } + + @Override + public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException { + return writer; + } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + return super.toSource(localData, generator); //To change body of generated methods, choose Tools | Templates. + } + +} diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/FunctionAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/FunctionAVM2Item.java index 282a8f32f..324d39ce7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/FunctionAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/FunctionAVM2Item.java @@ -32,12 +32,12 @@ public class FunctionAVM2Item extends AVM2Item { public String functionName; public List paramNames; public List body; - public List subvariables; + public List subvariables; public List paramTypes; public List paramValues; public GraphTargetItem retType; - public FunctionAVM2Item(String functionName, List paramTypes, List paramNames, List paramValues, List body, List subvariables, GraphTargetItem retType) { + public FunctionAVM2Item(String functionName, List paramTypes, List paramNames, List paramValues, List body, List subvariables, GraphTargetItem retType) { super(null, NOPRECEDENCE); this.paramNames = paramNames; this.body = body; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/GetterAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/GetterAVM2Item.java index 1bc1939ce..a5013e2bf 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/GetterAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/GetterAVM2Item.java @@ -25,7 +25,7 @@ import java.util.List; */ public class GetterAVM2Item extends MethodAVM2Item { - public GetterAVM2Item(boolean isStatic, int namespaceKind, String methodName, List paramTypes, List paramNames, List paramValues, List body, List subvariables, GraphTargetItem retType) { + public GetterAVM2Item(boolean isStatic, int namespaceKind, String methodName, List paramTypes, List paramNames, List paramValues, List body, List subvariables, GraphTargetItem retType) { super(isStatic, namespaceKind, methodName, paramTypes, paramNames, paramValues, body, subvariables, retType); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/MethodAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/MethodAVM2Item.java index 9746bfa21..d4c21ade3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/MethodAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/MethodAVM2Item.java @@ -30,7 +30,7 @@ public class MethodAVM2Item extends FunctionAVM2Item { public int namespaceKind; private boolean isStatic; - public MethodAVM2Item(boolean isStatic, int namespaceKind, String methodName, List paramTypes, List paramNames, List paramValues, List body, List subvariables, GraphTargetItem retType) { + public MethodAVM2Item(boolean isStatic, int namespaceKind, String methodName, List paramTypes, List paramNames, List paramValues, List body, List subvariables, GraphTargetItem retType) { super(methodName, paramTypes, paramNames, paramValues, body, subvariables, retType); this.namespaceKind = namespaceKind; this.isStatic = isStatic; 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 new file mode 100644 index 000000000..18c4e5242 --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NameAVM2Item.java @@ -0,0 +1,243 @@ +/* + * Copyright (C) 2014 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.decompiler.flash.abc.avm2.parser.script; + +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.GetPropertyAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.parser.ParseException; +import com.jpexs.decompiler.flash.abc.types.InstanceInfo; +import com.jpexs.decompiler.flash.abc.types.Multiname; +import com.jpexs.decompiler.flash.abc.types.Namespace; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.graph.GraphSourceItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; +import com.jpexs.decompiler.graph.model.LocalData; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * + * @author JPEXS + */ +public class NameAVM2Item extends AVM2Item { + + private AVM2Item it; + + private String variableName; + private GraphTargetItem storeValue; + private boolean definition; + private GraphTargetItem index; + private int nsKind = -1; + public List openedNamespaces; + public List openedNamespacesKind; + public int line; + + public void appendName(String name) { + this.variableName += "." + name; + } + + public void setDefinition(boolean definition) { + this.definition = definition; + } + + public void setIndex(GraphTargetItem index) { + this.index = index; + } + + public GraphTargetItem getIndex() { + return index; + } + + public void setNsKind(int nsKind) { + this.nsKind = nsKind; + } + + public int getNsKind() { + return nsKind; + } + + public void setStoreValue(GraphTargetItem storeValue) { + this.storeValue = storeValue; + } + + public String getVariableName() { + return variableName; + } + + public NameAVM2Item(int line,String variableName, GraphTargetItem storeValue, boolean definition, List openedNamespaces, List openedNamespacesKind) { + super(null, PRECEDENCE_PRIMARY); + this.variableName = variableName; + this.storeValue = storeValue; + this.definition = definition; + this.line = line; + } + + public boolean isDefinition() { + return definition; + } + + public void setBoxedValue(AVM2Item it) { + this.it = it; + if (it != null) { + this.precedence = it.getPrecedence(); + } + } + + public AVM2Item getBoxedValue() { + return it; + } + + public GraphTargetItem getStoreValue() { + return storeValue; + } + + @Override + public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException { + if (it == null) { + return writer; + } + return it.appendTo(writer, localData); + } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { + if (it == null) { + return new ArrayList<>(); + } + return it.toSource(localData, generator); + } + + @Override + public List toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) { + if (it == null) { + return new ArrayList<>(); + } + return it.toSourceIgnoreReturnValue(localData, generator); + } + + @Override + public boolean hasReturnValue() { + if (definition) { + return false; + } + return true; + } + + @Override + public boolean needsSemicolon() { + if (definition) { + return true; + } + return false; + } + + @Override + public String toString() { + return variableName; + } + + public GraphTargetItem resolve(boolean typeOnly,List variables,AVM2SourceGenerator generator) throws ParseException { + String name = toString(); + String parts[] = new String[]{name}; + if (name.contains(".")) { + parts = name.split("."); + } + + String pkg = ""; + int k; + loopk:for (k = parts.length - 1; k >= 0; k--) { + pkg = ""; + for (int j = 0; j <= k - 1; j++) { + if (!"".equals(pkg)) { + pkg += "."; + } + pkg += parts[j]; + } + name = parts[k]; + + int nsKind = Namespace.KIND_PACKAGE; + //if (pkg.equals("")) { + for (int i = 0; i < openedNamespaces.size(); i++) { + String ns = openedNamespaces.get(i); + String nspkg = ns; + String nsclass = null; + if (nspkg.contains(":")) { + nsclass = nspkg.substring(nspkg.indexOf(":") + 1); + nspkg = nspkg.substring(0, nspkg.indexOf(":")); + } + if (nspkg.equals(pkg)) { + if (nsclass == null) { + List abcs = new ArrayList<>(); + abcs.add(generator.abc); + abcs.addAll(generator.allABCs); + loopabc: + for (ABC a : abcs) { + for (InstanceInfo ii : a.instance_info) { + Multiname n = a.constants.constant_multiname.get(ii.name_index); + if (n.getNamespace(a.constants).getName(a.constants).equals(nspkg) && n.getName(a.constants, new ArrayList()).equals(name)) { + + nsKind = n.getNamespace(a.constants).kind; + break loopk; + } + } + } + } else if (name.equals(nsclass)) { + nsKind = openedNamespacesKind.get(i); + break loopk; + } + } + } + //} + } + + GraphTargetItem ret; + if(k<0){ //Class not found, its variable + if(typeOnly){ + throw new ParseException("Undefined type", line); + } + this.variableName = null; + for(NameAVM2Item n:variables){ + if(n.definition && n.getVariableName().equals(parts[0])){ + this.variableName = parts[0]; + } + } + + if(this.variableName == null){ + throw new ParseException("Undefined variable", line); + } + ret=this; + for(int i=1;i()), true)); + /*for(int i=k+1;i paramTypes, List paramNames, List paramValues, List body, List subvariables, GraphTargetItem retType) { + public SetterAVM2Item(boolean isStatic, int namespaceKind, String methodName, List paramTypes, List paramNames, List paramValues, List body, List subvariables, GraphTargetItem retType) { super(isStatic, namespaceKind, methodName, paramTypes, paramNames, paramValues, body, subvariables, retType); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/VariableAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/VariableAVM2Item.java deleted file mode 100644 index c73c442a5..000000000 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/VariableAVM2Item.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (C) 2014 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.decompiler.flash.abc.avm2.parser.script; - -import com.jpexs.decompiler.flash.SourceGeneratorLocalData; -import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item; -import com.jpexs.decompiler.flash.helpers.GraphTextWriter; -import com.jpexs.decompiler.graph.GraphSourceItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.decompiler.graph.SourceGenerator; -import com.jpexs.decompiler.graph.model.LocalData; -import java.util.ArrayList; -import java.util.List; - -/** - * - * @author JPEXS - */ -public class VariableAVM2Item extends AVM2Item { - - private AVM2Item it; - - private final String variableName; - private GraphTargetItem storeValue; - private boolean definition; - private GraphTargetItem index; - private int nsKind = -1; - - public void setDefinition(boolean definition) { - this.definition = definition; - } - - public void setIndex(GraphTargetItem index) { - this.index = index; - } - - public GraphTargetItem getIndex() { - return index; - } - - public void setNsKind(int nsKind) { - this.nsKind = nsKind; - } - - public int getNsKind() { - return nsKind; - } - - public void setStoreValue(GraphTargetItem storeValue) { - this.storeValue = storeValue; - } - - public String getVariableName() { - return variableName; - } - - public VariableAVM2Item(String variableName, GraphTargetItem storeValue, boolean definition) { - super(null, PRECEDENCE_PRIMARY); - this.variableName = variableName; - this.storeValue = storeValue; - this.definition = definition; - } - - public boolean isDefinition() { - return definition; - } - - public void setBoxedValue(AVM2Item it) { - this.it = it; - if (it != null) { - this.precedence = it.getPrecedence(); - } - } - - public AVM2Item getBoxedValue() { - return it; - } - - public GraphTargetItem getStoreValue() { - return storeValue; - } - - @Override - public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException { - if (it == null) { - return writer; - } - return it.appendTo(writer, localData); - } - - @Override - public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) { - if (it == null) { - return new ArrayList<>(); - } - return it.toSource(localData, generator); - } - - @Override - public List toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) { - if (it == null) { - return new ArrayList<>(); - } - return it.toSourceIgnoreReturnValue(localData, generator); - } - - @Override - public boolean hasReturnValue() { - if (definition) { - return false; - } - return true; - } - - @Override - public boolean needsSemicolon() { - if (definition) { - return true; - } - return false; - } - - @Override - public String toString() { - return variableName; - } - -}