From a43163952108c3a500c8f064d68f5be340e98ce4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Mon, 22 Sep 2014 20:41:10 +0200 Subject: [PATCH] Issue #688 AS3 direct editing fixes --- .../parser/script/AVM2SourceGenerator.java | 32 +- .../parser/script/ActionScriptParser.java | 316 +++++++++--------- .../flash/abc/types/MethodBody.java | 2 +- 3 files changed, 181 insertions(+), 169 deletions(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java index 200b005a4..d18118372 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java @@ -701,7 +701,7 @@ public class AVM2SourceGenerator implements SourceGenerator { scope = localData.scopeStack.size(); localData.scopeStack.add(new PropertyAVM2Item(null, item.functionName, abc, allABCs, new ArrayList(), localData.callStack)); } - ret.add(ins(new NewFunctionIns(), method(false, localData.callStack, localData.pkg, item.needsActivation, item.subvariables, 0 /*Set later*/, item.hasRest, item.line, null, null, false, localData, item.paramTypes, item.paramNames, item.paramValues, item.body, item.retType))); + ret.add(ins(new NewFunctionIns(), method(true,false, localData.callStack, localData.pkg, item.needsActivation, item.subvariables, 0 /*Set later*/, item.hasRest, item.line, localData.currentClass, null, false, localData, item.paramTypes, item.paramNames, item.paramValues, item.body, item.retType))); if (!item.functionName.isEmpty()) { ret.add(ins(new DupIns())); ret.add(ins(new GetScopeObjectIns(), scope)); @@ -1188,14 +1188,14 @@ public class AVM2SourceGenerator implements SourceGenerator { generateTraitsPhase3(initScope, isInterface, name, superName, true, localData, traitItems, classInfo.static_traits, st, new HashMap(),class_index); int init = 0; if (constructor == null || isInterface) { - instanceInfo.iinit_index = init = method(isInterface, new ArrayList(), pkg, false, new ArrayList(), initScope + 1, false, 0, isInterface ? null : name, extendsVal != null ? extendsVal.toString() : null, true, localData, new ArrayList(), new ArrayList(), new ArrayList(), new ArrayList(), TypeItem.UNBOUNDED/*?? FIXME*/); + instanceInfo.iinit_index = init = method(false,isInterface, new ArrayList(), pkg, false, new ArrayList(), initScope + 1, false, 0, isInterface ? null : name, extendsVal != null ? extendsVal.toString() : null, true, localData, new ArrayList(), new ArrayList(), new ArrayList(), new ArrayList(), TypeItem.UNBOUNDED/*?? FIXME*/); } else { MethodAVM2Item m = (MethodAVM2Item) constructor; - instanceInfo.iinit_index = init = method(false, new ArrayList(), pkg, m.needsActivation, m.subvariables, initScope + 1, m.hasRest, m.line, name, extendsVal != null ? extendsVal.toString() : null, true, localData, m.paramTypes, m.paramNames, m.paramValues, m.body, TypeItem.UNBOUNDED/*?? FIXME*/); + instanceInfo.iinit_index = init = method(false,false, new ArrayList(), pkg, m.needsActivation, m.subvariables, initScope + 1, m.hasRest, m.line, name, extendsVal != null ? extendsVal.toString() : null, true, localData, m.paramTypes, m.paramNames, m.paramValues, m.body, TypeItem.UNBOUNDED/*?? FIXME*/); } //Class initializer - int staticMi = method(false, new ArrayList(), pkg, staticNeedsActivation, sinitVariables, initScope + (implementsStr.isEmpty() ? 0 : 1), false, 0, isInterface ? null : name, superName, false, localData, new ArrayList(), new ArrayList(), new ArrayList(), staticInit, TypeItem.UNBOUNDED); + int staticMi = method(false,false, new ArrayList(), pkg, staticNeedsActivation, sinitVariables, initScope + (implementsStr.isEmpty() ? 0 : 1), false, 0, isInterface ? null : name, superName, false, localData, new ArrayList(), new ArrayList(), new ArrayList(), staticInit, TypeItem.UNBOUNDED); MethodBody sinitBody = abc.findBody(staticMi); List sinitcode = new ArrayList<>(); @@ -1376,7 +1376,7 @@ public class AVM2SourceGenerator implements SourceGenerator { return false; } - public int method(boolean isInterface, List callStack, String pkg, boolean needsActivation, List subvariables, int initScope, boolean hasRest, int line, String className, String superType, boolean constructor, SourceGeneratorLocalData localData, List paramTypes, List paramNames, List paramValues, List body, GraphTargetItem retType) throws CompilationException { + public int method(boolean subMethod,boolean isInterface, List callStack, String pkg, boolean needsActivation, List subvariables, int initScope, boolean hasRest, int line, String className, String superType, boolean constructor, SourceGeneratorLocalData localData, List paramTypes, List paramNames, List paramValues, List body, GraphTargetItem retType) throws CompilationException { //Reference hasArgs = new Reference<>(Boolean.FALSE); //calcRegisters(localData,needsActivation,paramNames,subvariables,body, hasArgs); SourceGeneratorLocalData newlocalData = new SourceGeneratorLocalData(new HashMap(), 1, true, 0); @@ -1406,6 +1406,18 @@ public class AVM2SourceGenerator implements SourceGenerator { } } } + + for(int t=0;t slotNames = new ArrayList<>(); @@ -1431,9 +1443,9 @@ public class AVM2SourceGenerator implements SourceGenerator { } registerNames.addAll(paramNames); slotNames.addAll(paramNames); - for (GraphTargetItem p : paramTypes) { + /*for (GraphTargetItem p : paramTypes) { slotTypes.add("" + p); - } + }*/ if (hasRest) { slotTypes.add("*"); } @@ -1688,7 +1700,7 @@ public class AVM2SourceGenerator implements SourceGenerator { } } } - if (className != null) {//It's method, not (inner) function + if (className != null && !subMethod) { mbodyCode.add(0, new AVM2Instruction(0, new GetLocal0Ins(), null)); mbodyCode.add(1, new AVM2Instruction(0, new PushScopeIns(), null)); } @@ -1926,10 +1938,10 @@ public class AVM2SourceGenerator implements SourceGenerator { if (mai.isStatic() != generateStatic) { continue; } - ((TraitMethodGetterSetter) traits[k]).method_info = method(isInterface, new ArrayList(), mai.pkg, mai.needsActivation, mai.subvariables, methodInitScope + (mai.isStatic() ? 0 : 1), mai.hasRest, mai.line, className, superName, false, localData, mai.paramTypes, mai.paramNames, mai.paramValues, mai.body, mai.retType); + ((TraitMethodGetterSetter) traits[k]).method_info = method(false,isInterface, new ArrayList(), mai.pkg, mai.needsActivation, mai.subvariables, methodInitScope + (mai.isStatic() ? 0 : 1), mai.hasRest, mai.line, className, superName, false, localData, mai.paramTypes, mai.paramNames, mai.paramValues, mai.body, mai.retType); } else if (item instanceof FunctionAVM2Item) { FunctionAVM2Item fai = (FunctionAVM2Item) item; - ((TraitFunction) traits[k]).method_info = method(isInterface, new ArrayList(), fai.pkg, fai.needsActivation, fai.subvariables, methodInitScope, fai.hasRest, fai.line, className, superName, false, localData, fai.paramTypes, fai.paramNames, fai.paramValues, fai.body, fai.retType); + ((TraitFunction) traits[k]).method_info = method(false,isInterface, new ArrayList(), fai.pkg, fai.needsActivation, fai.subvariables, methodInitScope, fai.hasRest, fai.line, className, superName, false, localData, fai.paramTypes, fai.paramNames, fai.paramValues, fai.body, fai.retType); } } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptParser.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptParser.java index a50ef5a15..f50f234ed 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptParser.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptParser.java @@ -139,13 +139,13 @@ public class ActionScriptParser { return uniqLast; } - private List commands(String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, Stack loops, Map loopLabels, HashMap registerVars, boolean inFunction, boolean inMethod, int forinlevel, List variables) throws IOException, AVM2ParseException { + private List commands(TypeItem thisType,String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, Stack loops, Map loopLabels, HashMap registerVars, boolean inFunction, boolean inMethod, int forinlevel, List variables) throws IOException, AVM2ParseException { List ret = new ArrayList<>(); if (debugMode) { System.out.println("commands:"); } GraphTargetItem cmd = null; - while ((cmd = command(pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables)) != null) { + while ((cmd = command(thisType,pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables)) != null) { ret.add(cmd); } if (debugMode) { @@ -154,7 +154,7 @@ public class ActionScriptParser { return ret; } - private GraphTargetItem type(String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, List variables) throws IOException, AVM2ParseException { + private GraphTargetItem type(TypeItem thisType,String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, List variables) throws IOException, AVM2ParseException { ParsedSymbol s = lex(); if (s.type == SymbolType.MULTIPLY) { return new UnboundedTypeItem(); @@ -164,12 +164,12 @@ public class ActionScriptParser { lexer.pushback(s); } - GraphTargetItem t = name(pkg, needsActivation, true, openedNamespaces, null, false, false, variables, importedClasses); - t = applyType(pkg, needsActivation, importedClasses, openedNamespaces, t, new HashMap(), false, false, variables); + GraphTargetItem t = name(thisType,pkg, needsActivation, true, openedNamespaces, null, false, false, variables, importedClasses); + t = applyType(thisType,pkg, needsActivation, importedClasses, openedNamespaces, t, new HashMap(), false, false, variables); return t; } - private GraphTargetItem memberOrCall(String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, GraphTargetItem newcmds, HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, AVM2ParseException { + private GraphTargetItem memberOrCall(TypeItem thisType,String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, GraphTargetItem newcmds, HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, AVM2ParseException { ParsedSymbol s = lex(); GraphTargetItem ret = newcmds; while (s.isType(SymbolType.DOT, SymbolType.PARENT_OPEN, SymbolType.BRACKET_OPEN, SymbolType.TYPENAME)) { @@ -178,10 +178,10 @@ public class ActionScriptParser { case DOT: case TYPENAME: lexer.pushback(s); - ret = member(pkg, needsActivation, importedClasses, openedNamespaces, ret, registerVars, inFunction, inMethod, variables); + ret = member(thisType,pkg, needsActivation, importedClasses, openedNamespaces, ret, registerVars, inFunction, inMethod, variables); break; case PARENT_OPEN: - ret = new CallAVM2Item(lexer.yyline(), ret, call(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, variables)); + ret = new CallAVM2Item(lexer.yyline(), ret, call(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, variables)); break; } @@ -206,13 +206,13 @@ public class ActionScriptParser { return ret; } - private GraphTargetItem applyType(String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, GraphTargetItem obj, HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, AVM2ParseException { + private GraphTargetItem applyType(TypeItem thisType,String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, GraphTargetItem obj, HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, AVM2ParseException { GraphTargetItem ret = obj; ParsedSymbol s = lex(); if (s.type == SymbolType.TYPENAME) { List params = new ArrayList<>(); do { - params.add(expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); + params.add(expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); s = lex(); } while (s.type == SymbolType.COMMA); if (s.type == SymbolType.USHIFT_RIGHT) { @@ -232,7 +232,7 @@ public class ActionScriptParser { return ret; } - private GraphTargetItem member(String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, GraphTargetItem obj, HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, AVM2ParseException { + private GraphTargetItem member(TypeItem thisType,String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, GraphTargetItem obj, HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, AVM2ParseException { GraphTargetItem ret = obj; ParsedSymbol s = lex(); while (s.isType(SymbolType.DOT, SymbolType.BRACKET_OPEN, SymbolType.TYPENAME)) { @@ -251,10 +251,10 @@ public class ActionScriptParser { } if (s.type == SymbolType.TYPENAME) { lexer.pushback(s); - ret = applyType(pkg, needsActivation, importedClasses, openedNamespaces, ret, registerVars, inFunction, inMethod, variables); + ret = applyType(thisType,pkg, needsActivation, importedClasses, openedNamespaces, ret, registerVars, inFunction, inMethod, variables); s = lex(); } else if (s.type == SymbolType.BRACKET_OPEN) { - GraphTargetItem index = expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); + GraphTargetItem index = expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); expectedType(SymbolType.BRACKET_CLOSE); ret = new IndexAVM2Item(attr, ret, index, null, openedNamespaces); s = lex(); @@ -270,7 +270,7 @@ public class ActionScriptParser { variables.add((UnresolvedAVM2Item) ns); s = lex(); if (s.type == SymbolType.BRACKET_OPEN) { - propItem = expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); + propItem = expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); expectedType(SymbolType.BRACKET_CLOSE); propName = null; } else { @@ -293,7 +293,7 @@ public class ActionScriptParser { return ret; } - private GraphTargetItem name(String pkg, Reference needsActivation, boolean typeOnly, List openedNamespaces, HashMap registerVars, boolean inFunction, boolean inMethod, List variables, List importedClasses) throws IOException, AVM2ParseException { + private GraphTargetItem name(TypeItem thisType,String pkg, Reference needsActivation, boolean typeOnly, List openedNamespaces, HashMap registerVars, boolean inFunction, boolean inMethod, List variables, List importedClasses) throws IOException, AVM2ParseException { ParsedSymbol s = lex(); String name = ""; if (s.type == SymbolType.ATTRIBUTE) { @@ -341,7 +341,7 @@ public class ActionScriptParser { if (s.type == SymbolType.IDENTIFIER) { nsprop = s.value.toString(); } else if (s.type == SymbolType.BRACKET_OPEN) { - nspropItem = expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); + nspropItem = expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); expectedType(SymbolType.BRACKET_CLOSE); } if (name.contains(".")) { @@ -394,7 +394,7 @@ public class ActionScriptParser { lexer.pushback(new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ATTRIBUTE, "@")); lexer.pushback(new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.DOT, ".")); } - ret = member(pkg, needsActivation, importedClasses, openedNamespaces, ret, registerVars, inFunction, inMethod, variables); + ret = member(thisType,pkg, needsActivation, importedClasses, openedNamespaces, ret, registerVars, inFunction, inMethod, variables); } else { lexer.pushback(s); } @@ -439,7 +439,7 @@ public class ActionScriptParser { return ret; } - private List call(String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, AVM2ParseException { + private List call(TypeItem thisType,String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, AVM2ParseException { List ret = new ArrayList<>(); //expected(SymbolType.PARENT_OPEN); //MUST BE HANDLED BY CALLER ParsedSymbol s = lex(); @@ -447,19 +447,19 @@ public class ActionScriptParser { if (s.type != SymbolType.COMMA) { lexer.pushback(s); } - ret.add(expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables)); + ret.add(expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables)); s = lex(); expected(s, lexer.yyline(), SymbolType.COMMA, SymbolType.PARENT_CLOSE); } return ret; } - private MethodAVM2Item method(String pkg, boolean isInterface, String customAccess, Reference needsActivation, List importedClasses, boolean override, boolean isFinal, GraphTargetItem thisType, List openedNamespaces, boolean isStatic, int namespace, String functionName, boolean isMethod, List variables) throws IOException, AVM2ParseException { + private MethodAVM2Item method(String pkg, boolean isInterface, String customAccess, Reference needsActivation, List importedClasses, boolean override, boolean isFinal, TypeItem thisType, List openedNamespaces, boolean isStatic, int namespace, String functionName, boolean isMethod, List variables) throws IOException, AVM2ParseException { FunctionAVM2Item f = function(pkg, isInterface, needsActivation, importedClasses, namespace, thisType, openedNamespaces, functionName, isMethod, variables); return new MethodAVM2Item(f.pkg, f.isInterface, customAccess, f.needsActivation, f.hasRest, f.line, override, isFinal, isStatic, f.namespace, functionName, f.paramTypes, f.paramNames, f.paramValues, f.body, f.subvariables, f.retType); } - private FunctionAVM2Item function(String pkg, boolean isInterface, Reference needsActivation, List importedClasses, int namespace, GraphTargetItem thisType, List openedNamespaces, String functionName, boolean isMethod, List variables) throws IOException, AVM2ParseException { + private FunctionAVM2Item function(String pkg, boolean isInterface, Reference needsActivation, List importedClasses, int namespace, TypeItem thisType, List openedNamespaces, String functionName, boolean isMethod, List variables) throws IOException, AVM2ParseException { openedNamespaces = new ArrayList<>(openedNamespaces); //local copy int line = lexer.yyline(); ParsedSymbol s; @@ -484,13 +484,13 @@ public class ActionScriptParser { s = lex(); if (!hasRest) { if (s.type == SymbolType.COLON) { - paramTypes.add(type(pkg, needsActivation, importedClasses, openedNamespaces, variables)); + paramTypes.add(type(thisType,pkg, needsActivation, importedClasses, openedNamespaces, variables)); s = lex(); } else { paramTypes.add(new UnboundedTypeItem()); } if (s.type == SymbolType.ASSIGN) { - paramValues.add(expression(pkg, new Reference<>(false), importedClasses, openedNamespaces, null, isMethod, isMethod, isMethod, variables)); + paramValues.add(expression(thisType,pkg, new Reference<>(false), importedClasses, openedNamespaces, null, isMethod, isMethod, isMethod, variables)); s = lex(); } else { if (!paramValues.isEmpty()) { @@ -509,7 +509,7 @@ public class ActionScriptParser { s = lex(); GraphTargetItem retType; if (s.type == SymbolType.COLON) { - retType = type(pkg, needsActivation, importedClasses, openedNamespaces, variables); + retType = type(thisType,pkg, needsActivation, importedClasses, openedNamespaces, variables); } else { retType = new UnboundedTypeItem(); lexer.pushback(s); @@ -528,7 +528,7 @@ public class ActionScriptParser { Reference needsActivation2 = new Reference<>(false); if (!isInterface) { expectedType(SymbolType.CURLY_OPEN); - body = commands(pkg, needsActivation2, importedClasses, openedNamespaces, new Stack(), new HashMap(), new HashMap(), true, isMethod, 0, subvariables); + body = commands(thisType,pkg, needsActivation2, importedClasses, openedNamespaces, new Stack(), new HashMap(), new HashMap(), true, isMethod, 0, subvariables); expectedType(SymbolType.CURLY_CLOSE); } else { expectedType(SymbolType.SEMICOLON); @@ -575,7 +575,7 @@ public class ActionScriptParser { } if (inPkg || classNameStr != null) { if (s.type == SymbolType.CURLY_OPEN) { - staticInitializer.addAll(commands(pkg, sinitNeedsActivation, importedClasses, openedNamespaces, new Stack(), new HashMap(), new HashMap(), true, false, 0, sinitVariables)); + staticInitializer.addAll(commands(thisType,pkg, sinitNeedsActivation, importedClasses, openedNamespaces, new Stack(), new HashMap(), new HashMap(), true, false, 0, sinitVariables)); expectedType(SymbolType.CURLY_CLOSE); s = lex(); } @@ -664,20 +664,20 @@ public class ActionScriptParser { throw new AVM2ParseException("Override flag not allowed for classes", lexer.yyline()); } - //GraphTargetItem classTypeStr = type(pkg,needsActivation, importedClasses, openedNamespaces, variables); + //GraphTargetItem classTypeStr = type(thisType,pkg,needsActivation, importedClasses, openedNamespaces, variables); s = lex(); expected(s, lexer.yyline(), SymbolType.IDENTIFIER); String classTypeStr = s.value.toString(); GraphTargetItem extendsTypeStr = null; s = lex(); if (s.type == SymbolType.EXTENDS) { - extendsTypeStr = type(pkg, new Reference<>(false), importedClasses, subNamespaces, new ArrayList()); + extendsTypeStr = type(thisType,pkg, new Reference<>(false), importedClasses, subNamespaces, new ArrayList()); s = lex(); } List implementsTypeStrs = new ArrayList<>(); if (s.type == SymbolType.IMPLEMENTS) { do { - GraphTargetItem implementsTypeStr = type(pkg, new Reference<>(false), importedClasses, subNamespaces, new ArrayList()); + GraphTargetItem implementsTypeStr = type(thisType,pkg, new Reference<>(false), importedClasses, subNamespaces, new ArrayList()); implementsTypeStrs.add(implementsTypeStr); s = lex(); } while (s.type == SymbolType.COMMA); @@ -702,7 +702,7 @@ public class ActionScriptParser { if (isDynamic) { throw new AVM2ParseException("Dynamic flag not allowed for interfaces", lexer.yyline()); } - //GraphTargetItem interfaceTypeStr = type(pkg,needsActivation, importedClasses, openedNamespaces, variables); + //GraphTargetItem interfaceTypeStr = type(thisType,pkg,needsActivation, importedClasses, openedNamespaces, variables); s = lex(); expected(s, lexer.yyline(), SymbolType.IDENTIFIER); String intTypeStr = s.value.toString(); @@ -711,7 +711,7 @@ public class ActionScriptParser { if (s.type == SymbolType.EXTENDS) { do { - GraphTargetItem intExtendsTypeStr = type(pkg, new Reference<>(false), importedClasses, openedNamespaces, new ArrayList()); + GraphTargetItem intExtendsTypeStr = type(thisType,pkg, new Reference<>(false), importedClasses, openedNamespaces, new ArrayList()); intExtendsTypeStrs.add(intExtendsTypeStr); s = lex(); } while (s.type == SymbolType.COMMA); @@ -845,7 +845,7 @@ public class ActionScriptParser { s = lex(); GraphTargetItem type = null; if (s.type == SymbolType.COLON) { - type = type(pkg, new Reference<>(false), importedClasses, openedNamespaces, new ArrayList()); + type = type(thisType,pkg, new Reference<>(false), importedClasses, openedNamespaces, new ArrayList()); s = lex(); } else { type = TypeItem.UNBOUNDED; @@ -854,7 +854,7 @@ public class ActionScriptParser { GraphTargetItem value = null; if (s.type == SymbolType.ASSIGN) { - value = expression(pkg, new Reference<>(false), importedClasses, openedNamespaces, new HashMap(), false, false, true, isStatic || isConst ? sinitVariables : constrVariables); + value = expression(thisType,pkg, new Reference<>(false), importedClasses, openedNamespaces, new HashMap(), false, false, true, isStatic || isConst ? sinitVariables : constrVariables); s = lex(); } GraphTargetItem tar; @@ -950,7 +950,7 @@ public class ActionScriptParser { switch (s.type) { /*case INT: expectedType(SymbolType.PARENT_OPEN); - ret = new ToIntegerAVM2Item(null, expression(pkg,needsActivation, importedClasses, openedNamespaces,openedNamespacesKinds,registerVars, inFunction, inMethod, true, variables)); + ret = new ToIntegerAVM2Item(null, expression(thisType,pkg,needsActivation, importedClasses, openedNamespaces,openedNamespacesKinds,registerVars, inFunction, inMethod, true, variables)); expectedType(SymbolType.PARENT_CLOSE); break; case NUMBER_OP: @@ -958,10 +958,10 @@ public class ActionScriptParser { if (s.type == SymbolType.DOT) { VariableAVM2Item vi = new VariableAVM2Item(s.value.toString(), null, false); variables.add(vi); - ret = memberOrCall(vi, registerVars, inFunction, inMethod, variables); + ret = memberOrCall(thisType,vi, registerVars, inFunction, inMethod, variables); } else { expected(s, lexer.yyline(), SymbolType.PARENT_OPEN); - ret = new ToNumberAVM2Item(null, expression(pkg,needsActivation, importedClasses, openedNamespaces,openedNamespacesKinds,registerVars, inFunction, inMethod, true, variables)); + ret = new ToNumberAVM2Item(null, expression(thisType,pkg,needsActivation, importedClasses, openedNamespaces,openedNamespacesKinds,registerVars, inFunction, inMethod, true, variables)); expectedType(SymbolType.PARENT_CLOSE); } break; @@ -972,12 +972,12 @@ public class ActionScriptParser { lexer.pushback(s); VariableAVM2Item vi2 = new VariableAVM2Item(sop.value.toString(), null, false); variables.add(vi2); - ret = memberOrCall(vi2, registerVars, inFunction, inMethod, variables); + ret = memberOrCall(thisType,vi2, registerVars, inFunction, inMethod, variables); } else { expected(s, lexer.yyline(), SymbolType.PARENT_OPEN); - ret = new ToStringAVM2Item(null, expression(pkg,needsActivation, importedClasses, openedNamespaces,openedNamespacesKinds,registerVars, inFunction, inMethod, true, variables)); + ret = new ToStringAVM2Item(null, expression(thisType,pkg,needsActivation, importedClasses, openedNamespaces,openedNamespacesKinds,registerVars, inFunction, inMethod, true, variables)); expectedType(SymbolType.PARENT_CLOSE); - ret = memberOrCall(ret, registerVars, inFunction, inMethod, variables); + ret = memberOrCall(thisType,ret, registerVars, inFunction, inMethod, variables); } break;*/ default: @@ -1041,7 +1041,7 @@ public class ActionScriptParser { } } - private List xmltag(String pkg, Reference usesVars, List openedTags, Reference closedVarTags, Reference needsActivation, List importedClasses, List openedNamespaces, HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, AVM2ParseException { + private List xmltag(TypeItem thisType,String pkg, Reference usesVars, List openedTags, Reference closedVarTags, Reference needsActivation, List importedClasses, List openedNamespaces, HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, AVM2ParseException { ParsedSymbol s = null; List rets = new ArrayList<>(); //GraphTargetItem ret = null; @@ -1056,7 +1056,7 @@ public class ActionScriptParser { case XML_ATTRNAMEVAR_BEGIN: //add usesVars.setVal(true); addS(rets, sb); - rets.add(expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables)); + rets.add(expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables)); expectedType(SymbolType.CURLY_CLOSE); expectedType(SymbolType.ASSIGN); sb.append("="); @@ -1066,7 +1066,7 @@ public class ActionScriptParser { usesVars.setVal(true); sb.append("\""); addS(rets, sb); - rets.add(new EscapeXAttrAVM2Item(null, expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables))); + rets.add(new EscapeXAttrAVM2Item(null, expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables))); sb.append("\""); expectedType(SymbolType.CURLY_CLOSE); lexer.yybegin(ActionScriptLexer.XMLOPENTAG); @@ -1074,7 +1074,7 @@ public class ActionScriptParser { case XML_INSTRATTRNAMEVAR_BEGIN: //add usesVars.setVal(true); addS(rets, sb); - rets.add(expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables)); + rets.add(expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables)); expectedType(SymbolType.CURLY_CLOSE); expectedType(SymbolType.ASSIGN); sb.append("="); @@ -1084,7 +1084,7 @@ public class ActionScriptParser { usesVars.setVal(true); sb.append("\""); addS(rets, sb); - rets.add(new EscapeXAttrAVM2Item(null, expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables))); + rets.add(new EscapeXAttrAVM2Item(null, expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables))); sb.append("\""); expectedType(SymbolType.CURLY_CLOSE); lexer.yybegin(ActionScriptLexer.XMLOPENTAG); @@ -1092,7 +1092,7 @@ public class ActionScriptParser { case XML_VAR_BEGIN: //esc_xelem usesVars.setVal(true); addS(rets, sb); - rets.add(new EscapeXElemAVM2Item(null, expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables))); + rets.add(new EscapeXElemAVM2Item(null, expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables))); expectedType(SymbolType.CURLY_CLOSE); lexer.yybegin(ActionScriptLexer.XML); break; @@ -1102,7 +1102,7 @@ public class ActionScriptParser { sb.append(""); @@ -1113,14 +1113,14 @@ public class ActionScriptParser { //openedTags.add("*"); //ret = add(ret, ); - GraphTargetItem ex = expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); + GraphTargetItem ex = expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); expectedType(SymbolType.CURLY_CLOSE); lexer.yybegin(ActionScriptLexer.XMLOPENTAG); sub.add("*"); sb.append("<"); addS(rets, sb); rets.add(ex); - rets.addAll(xmltag(pkg, subusesvars, sub, subclose, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, variables)); + rets.addAll(xmltag(thisType,pkg, subusesvars, sub, subclose, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, variables)); closedVarTags.setVal(subclose.getVal() + subclose.getVal()); break; case XML_INSTRVARTAG_BEGIN: //add @@ -1128,13 +1128,13 @@ public class ActionScriptParser { addS(rets, sb); sb.append(" st = xmltag(pkg, subusesvars, sub, closedVarTags, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, variables); + List st = xmltag(thisType,pkg, subusesvars, sub, closedVarTags, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, variables); sb.append(s.value.toString()); addS(rets, sb); rets.addAll(st); @@ -1170,18 +1170,18 @@ public class ActionScriptParser { return rets; } - private GraphTargetItem xml(String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, AVM2ParseException { + private GraphTargetItem xml(TypeItem thisType,String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, AVM2ParseException { List openedTags = new ArrayList<>(); int closedVarTags = 0; - GraphTargetItem ret = add(xmltag(pkg, new Reference<>(false), openedTags, new Reference<>(closedVarTags), needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, variables)); + GraphTargetItem ret = add(xmltag(thisType,pkg, new Reference<>(false), openedTags, new Reference<>(closedVarTags), needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, variables)); ret = new XMLAVM2Item(ret); lexer.yybegin(ActionScriptLexer.YYINITIAL); //TODO: Order of additions as in official compiler return ret; } - private GraphTargetItem command(String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, Stack loops, Map loopLabels, HashMap registerVars, boolean inFunction, boolean inMethod, int forinlevel, boolean mustBeCommand, List variables) throws IOException, AVM2ParseException { + private GraphTargetItem command(TypeItem thisType,String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, Stack loops, Map loopLabels, HashMap registerVars, boolean inFunction, boolean inMethod, int forinlevel, boolean mustBeCommand, List variables) throws IOException, AVM2ParseException { LexBufferer buf = new LexBufferer(); lexer.addListener(buf); GraphTargetItem ret = null; @@ -1214,7 +1214,7 @@ public class ActionScriptParser { } else { expectedType(SymbolType.NAMESPACE); expectedType(SymbolType.ASSIGN); - GraphTargetItem ns = expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); + GraphTargetItem ns = expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); ret = new DefaultXMLNamespace(null, ns); //TODO: use dxns for attribute namespaces instead of dxnslate } @@ -1224,20 +1224,20 @@ public class ActionScriptParser { switch (s.type) { case USE: expectedType(SymbolType.NAMESPACE); - GraphTargetItem ns = type(pkg, needsActivation, importedClasses, openedNamespaces, variables); + GraphTargetItem ns = type(thisType,pkg, needsActivation, importedClasses, openedNamespaces, variables); openedNamespaces.add(abc.constants.getNamespaceId(new Namespace(Namespace.KIND_PACKAGE /*FIXME?*/, abc.constants.getStringId(ns.toString(), true)), 0, true)); break; case WITH: needsActivation.setVal(true); expectedType(SymbolType.PARENT_OPEN); - GraphTargetItem wvar = expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables);//(name(false, openedNamespaces, registerVars, inFunction, inMethod, variables)); + GraphTargetItem wvar = expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables);//(name(thisType,false, openedNamespaces, registerVars, inFunction, inMethod, variables)); if (!isNameOrProp(wvar)) { throw new AVM2ParseException("Not a property or name", lexer.yyline()); } expectedType(SymbolType.PARENT_CLOSE); expectedType(SymbolType.CURLY_OPEN); List withVars = new ArrayList<>(); - List wcmd = commands(pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, withVars); + List wcmd = commands(thisType,pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, withVars); variables.addAll(withVars); for (AssignableAVM2Item a : withVars) { if (a instanceof UnresolvedAVM2Item) { @@ -1250,7 +1250,7 @@ public class ActionScriptParser { ((WithAVM2Item) ret).subvariables = withVars; break; /*case DELETE: - GraphTargetItem varDel = expression(pkg,needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables);//name(false, openedNamespaces, registerVars, inFunction, inMethod, variables); + GraphTargetItem varDel = expression(thisType,pkg,needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables);//name(thisType,false, openedNamespaces, registerVars, inFunction, inMethod, variables); if(!isNameOrProp(varDel)){ throw new ParseException("Not a property or name", lexer.yyline()); } @@ -1268,7 +1268,7 @@ public class ActionScriptParser { s = lexer.lex(); expected(s, lexer.yyline(), SymbolType.IDENTIFIER); needsActivation.setVal(true); - ret = (function(pkg, false, needsActivation, importedClasses, 0/*?*/, TypeItem.UNBOUNDED, openedNamespaces, s.value.toString(), false, variables)); + ret = (function(pkg, false, needsActivation, importedClasses, 0/*?*/, thisType, openedNamespaces, s.value.toString(), false, variables)); break; case VAR: s = lex(); @@ -1277,14 +1277,14 @@ public class ActionScriptParser { s = lex(); GraphTargetItem type; if (s.type == SymbolType.COLON) { - type = type(pkg, needsActivation, importedClasses, openedNamespaces, variables); + type = type(thisType,pkg, needsActivation, importedClasses, openedNamespaces, variables); s = lex(); } else { type = new UnboundedTypeItem(); } if (s.type == SymbolType.ASSIGN) { - GraphTargetItem varval = (expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables)); + GraphTargetItem varval = (expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables)); ret = new NameAVM2Item(type, lexer.yyline(), varIdentifier, varval, true, openedNamespaces); variables.add((NameAVM2Item) ret); } else { @@ -1294,12 +1294,12 @@ public class ActionScriptParser { } break; case CURLY_OPEN: - ret = new BlockItem(null, commands(pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, variables)); + ret = new BlockItem(null, commands(thisType,pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, variables)); expectedType(SymbolType.CURLY_CLOSE); break; /*case INCREMENT: //preincrement case DECREMENT: //predecrement - GraphTargetItem varincdec = expression(pkg,needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables);//name(false, openedNamespaces, registerVars, inFunction, inMethod, variables); + GraphTargetItem varincdec = expression(thisType,pkg,needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables);//name(thisType,false, openedNamespaces, registerVars, inFunction, inMethod, variables); if(!isNameOrProp(varincdec)){ throw new ParseException("Not a property or name", lexer.yyline()); } @@ -1312,7 +1312,7 @@ public class ActionScriptParser { case SUPER: //constructor call ParsedSymbol ss2 = lex(); if (ss2.type == SymbolType.PARENT_OPEN) { - List args = call(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, variables); + List args = call(thisType,pkg, needsActivation, importedClasses, openedNamespaces, 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); @@ -1321,16 +1321,16 @@ public class ActionScriptParser { break; case IF: expectedType(SymbolType.PARENT_OPEN); - GraphTargetItem ifExpr = (expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables)); + GraphTargetItem ifExpr = (expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables)); expectedType(SymbolType.PARENT_CLOSE); - GraphTargetItem onTrue = command(pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables); + GraphTargetItem onTrue = command(thisType,pkg, needsActivation, importedClasses, openedNamespaces, 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(pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables)); + onFalseList.add(command(thisType,pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables)); } else { lexer.pushback(s); } @@ -1339,7 +1339,7 @@ public class ActionScriptParser { case WHILE: expectedType(SymbolType.PARENT_OPEN); List whileExpr = new ArrayList<>(); - whileExpr.add(commaExpression(pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, variables)); + whileExpr.add(commaExpression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, variables)); expectedType(SymbolType.PARENT_CLOSE); List whileBody = new ArrayList<>(); Loop wloop = new Loop(uniqId(), null, null); @@ -1347,7 +1347,7 @@ public class ActionScriptParser { loopLabels.put(wloop, loopLabel); } loops.push(wloop); - whileBody.add(command(pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables)); + whileBody.add(command(thisType,pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables)); ret = new WhileItem(null, wloop, whileExpr, whileBody); break; case DO: @@ -1357,11 +1357,11 @@ public class ActionScriptParser { if (loopLabel != null) { loopLabels.put(dloop, loopLabel); } - doBody.add(command(pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables)); + doBody.add(command(thisType,pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables)); expectedType(SymbolType.WHILE); expectedType(SymbolType.PARENT_OPEN); List doExpr = new ArrayList<>(); - doExpr.add(commaExpression(pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, variables)); + doExpr.add(commaExpression(thisType, pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, variables)); expectedType(SymbolType.PARENT_CLOSE); ret = new DoWhileItem(null, dloop, doBody, doExpr); break; @@ -1376,11 +1376,11 @@ public class ActionScriptParser { s = lex(); } expected(s, lexer.yyline(), SymbolType.PARENT_OPEN); - GraphTargetItem firstCommand = command(pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, false, variables); + GraphTargetItem firstCommand = command(thisType,pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, false, variables); if (firstCommand instanceof NameAVM2Item) { NameAVM2Item nai = (NameAVM2Item) firstCommand; if (nai.isDefinition() && nai.getAssignedValue() == null) { - firstCommand = expressionRemainder(pkg, needsActivation, openedNamespaces, firstCommand, registerVars, inFunction, inMethod, true, variables, importedClasses); + firstCommand = expressionRemainder(thisType,pkg, needsActivation, openedNamespaces, firstCommand, registerVars, inFunction, inMethod, true, variables, importedClasses); } } InAVM2Item inexpr = null; @@ -1402,17 +1402,17 @@ public class ActionScriptParser { GraphTargetItem forExpr = null; List forFirstCommands = new ArrayList<>(); if (!forin) { - //GraphTargetItem firstCommand = command(pkg,needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables); + //GraphTargetItem firstCommand = command(thisType,pkg,needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables); if (firstCommand != null) { //can be empty command forFirstCommands.add(firstCommand); } - forExpr = (expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables)); + forExpr = (expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables)); expectedType(SymbolType.SEMICOLON); - forFinalCommands.add(command(pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables)); + forFinalCommands.add(command(thisType,pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables)); } expectedType(SymbolType.PARENT_CLOSE); List forBody = new ArrayList<>(); - forBody.add(command(pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forin ? forinlevel + 1 : forinlevel, true, variables)); + forBody.add(command(thisType,pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forin ? forinlevel + 1 : forinlevel, true, variables)); if (forin) { if (each) { ret = new ForEachInAVM2Item(null, floop, inexpr, forBody); @@ -1431,7 +1431,7 @@ public class ActionScriptParser { loopLabels.put(sloop, loopLabel); } expectedType(SymbolType.PARENT_OPEN); - GraphTargetItem switchExpr = expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); + GraphTargetItem switchExpr = expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); expectedType(SymbolType.PARENT_CLOSE); expectedType(SymbolType.CURLY_OPEN); s = lex(); @@ -1452,7 +1452,7 @@ public class ActionScriptParser { while (s.type == SymbolType.CASE) { List caseExprs = new ArrayList<>(); while (s.type == SymbolType.CASE) { - GraphTargetItem curCaseExpr = expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); + GraphTargetItem curCaseExpr = expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); caseExprs.add(curCaseExpr); expectedType(SymbolType.COLON); s = lex(); @@ -1461,14 +1461,14 @@ public class ActionScriptParser { } pos++; lexer.pushback(s); - List caseCmd = commands(pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, variables); + List caseCmd = commands(thisType,pkg, needsActivation, importedClasses, openedNamespaces, 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(pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, variables); + defCmd = commands(thisType,pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, variables); s = lexer.lex(); } expected(s, lexer.yyline(), SymbolType.CURLY_CLOSE); @@ -1533,7 +1533,7 @@ public class ActionScriptParser { ret = new ContinueItem(null, cloopId); break; case RETURN: - GraphTargetItem retexpr = expression(pkg, needsActivation, importedClasses, openedNamespaces, true, registerVars, inFunction, inMethod, true, variables); + GraphTargetItem retexpr = expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, true, registerVars, inFunction, inMethod, true, variables); if (retexpr == null) { ret = new ReturnVoidAVM2Item(null); } else { @@ -1543,7 +1543,7 @@ public class ActionScriptParser { case TRY: needsActivation.setVal(true); List tryCommands = new ArrayList<>(); - tryCommands.add(command(pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables)); + tryCommands.add(command(thisType,pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables)); s = lex(); boolean found = false; List> catchCommands = new ArrayList<>(); @@ -1557,7 +1557,7 @@ public class ActionScriptParser { String enamestr = s.value.toString(); expectedType(SymbolType.COLON); - GraphTargetItem etype = type(pkg, needsActivation, importedClasses, openedNamespaces, variables); + GraphTargetItem etype = type(thisType,pkg, needsActivation, importedClasses, openedNamespaces, variables); NameAVM2Item e = new NameAVM2Item(etype, lexer.yyline(), enamestr, new ExceptionAVM2Item(null)/*?*/, true/*?*/, openedNamespaces); variables.add(e); catchExceptions.add(e); @@ -1566,7 +1566,7 @@ public class ActionScriptParser { expectedType(SymbolType.PARENT_CLOSE); List cc = new ArrayList<>(); List catchVars = new ArrayList<>(); - cc.add(command(pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, catchVars)); + cc.add(command(thisType,pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, catchVars)); catchesVars.add(catchVars); variables.addAll(catchVars); @@ -1612,7 +1612,7 @@ public class ActionScriptParser { List finallyCommands = null; if (s.type == SymbolType.FINALLY) { finallyCommands = new ArrayList<>(); - finallyCommands.add(command(pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables)); + finallyCommands.add(command(thisType,pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables)); found = true; s = lex(); } @@ -1626,7 +1626,7 @@ public class ActionScriptParser { ret = tai; break; case THROW: - ret = new ThrowAVM2Item(null, expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables)); + ret = new ThrowAVM2Item(null, expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables)); break; default: GraphTargetItem valcmd = expressionCommands(s, registerVars, inFunction, inMethod, forinlevel, variables); @@ -1638,7 +1638,7 @@ public class ActionScriptParser { return null; } lexer.pushback(s); - ret = expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); + ret = expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); if (debugMode) { System.out.println("/command"); } @@ -1650,7 +1650,7 @@ public class ActionScriptParser { lexer.removeListener(buf); if (ret == null) { //can be popped expression buf.pushAllBack(lexer); - ret = expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); + ret = expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); } s = lex(); if ((s != null) && (s.type != SymbolType.SEMICOLON)) { @@ -1661,8 +1661,8 @@ public class ActionScriptParser { } - private GraphTargetItem expression(String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, HashMap registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List variables) throws IOException, AVM2ParseException { - return expression(pkg, needsActivation, importedClasses, openedNamespaces, false, registerVars, inFunction, inMethod, allowRemainder, variables); + private GraphTargetItem expression(TypeItem thisType,String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, HashMap registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List variables) throws IOException, AVM2ParseException { + return expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, false, registerVars, inFunction, inMethod, allowRemainder, variables); } private GraphTargetItem fixPrecedence(GraphTargetItem expr) { @@ -1683,14 +1683,14 @@ public class ActionScriptParser { return ret; } - private GraphTargetItem expressionRemainder(String pkg, Reference needsActivation, List openedNamespaces, GraphTargetItem expr, HashMap registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List variables, List importedClasses) throws IOException, AVM2ParseException { + private GraphTargetItem expressionRemainder(TypeItem thisType,String pkg, Reference needsActivation, List openedNamespaces, GraphTargetItem expr, HashMap registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List variables, List importedClasses) throws IOException, AVM2ParseException { GraphTargetItem ret = null; ParsedSymbol s = lex(); if (ret == null) { switch (s.type) { case AS: - GraphTargetItem type = type(pkg, needsActivation, importedClasses, openedNamespaces, variables); + GraphTargetItem type = type(thisType,pkg, needsActivation, importedClasses, openedNamespaces, variables); ret = new AsTypeAVM2Item(null, expr, type); allowRemainder = false; break; @@ -1702,14 +1702,14 @@ public class ActionScriptParser { break; case FILTER: needsActivation.setVal(true); - ret = new XMLFilterAVM2Item(expr, expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables), openedNamespaces); + ret = new XMLFilterAVM2Item(expr, expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables), openedNamespaces); expectedType(SymbolType.PARENT_CLOSE); allowRemainder = true; break; /*case NAMESPACE_OP: s = lex(); if (s.type == SymbolType.BRACKET_OPEN) { - GraphTargetItem index = expression(pkg,needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); + GraphTargetItem index = expression(thisType,pkg,needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); NameAVM2Item name = new NameAVM2Item(new UnboundedTypeItem(), lexer.yyline(), null, null, false, openedNamespaces); name.setIndex(index); name.setNs(expr); @@ -1717,7 +1717,7 @@ public class ActionScriptParser { expectedType(SymbolType.BRACKET_CLOSE); } else { lexer.pushback(s); - GraphTargetItem name = name(pkg,needsActivation, false, openedNamespaces, registerVars, inFunction, inMethod, variables, importedClasses); + GraphTargetItem name = name(thisType,pkg,needsActivation, false, openedNamespaces, registerVars, inFunction, inMethod, variables, importedClasses); if (name instanceof UnresolvedAVM2Item) { ((UnresolvedAVM2Item) name).setNs(expr); //((UnresolvedAVM2Item) name).unresolved = false; @@ -1729,52 +1729,52 @@ public class ActionScriptParser { } break;*/ case IN: - ret = new InAVM2Item(null, expr, expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables)); + ret = new InAVM2Item(null, expr, expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables)); break; case TERNAR: - GraphTargetItem terOnTrue = expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); + GraphTargetItem terOnTrue = expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); expectedType(SymbolType.COLON); - GraphTargetItem terOnFalse = expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); + GraphTargetItem terOnFalse = expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); ret = new TernarOpItem(null, expr, terOnTrue, terOnFalse); break; case SHIFT_LEFT: - ret = new LShiftAVM2Item(null, expr, expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); + ret = new LShiftAVM2Item(null, expr, expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); break; case SHIFT_RIGHT: - ret = new RShiftAVM2Item(null, expr, expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); + ret = new RShiftAVM2Item(null, expr, expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); break; case USHIFT_RIGHT: - ret = new URShiftAVM2Item(null, expr, expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); + ret = new URShiftAVM2Item(null, expr, expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); break; case BITAND: - ret = new BitAndAVM2Item(null, expr, expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); + ret = new BitAndAVM2Item(null, expr, expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); break; case BITOR: - ret = new BitOrAVM2Item(null, expr, expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); + ret = new BitOrAVM2Item(null, expr, expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); break; case DIVIDE: - ret = new DivideAVM2Item(null, expr, expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); + ret = new DivideAVM2Item(null, expr, expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); break; case MODULO: - ret = new ModuloAVM2Item(null, expr, expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); + ret = new ModuloAVM2Item(null, expr, expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); break; case EQUALS: - ret = new EqAVM2Item(null, expr, expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); + ret = new EqAVM2Item(null, expr, expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); break; case STRICT_EQUALS: - ret = new StrictEqAVM2Item(null, expr, expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); + ret = new StrictEqAVM2Item(null, expr, expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); break; case NOT_EQUAL: - ret = new NeqAVM2Item(null, expr, expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); + ret = new NeqAVM2Item(null, expr, expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); break; case STRICT_NOT_EQUAL: - ret = new StrictNeqAVM2Item(null, expr, expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); + ret = new StrictNeqAVM2Item(null, expr, expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); break; case LOWER_THAN: - ret = new LtAVM2Item(null, expr, expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); + ret = new LtAVM2Item(null, expr, expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); break; case LOWER_EQUAL: - ret = new LeAVM2Item(null, expr, expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); + ret = new LeAVM2Item(null, expr, expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); break; case GREATER_THAN: case XML_STARTVARTAG_BEGIN: @@ -1782,34 +1782,34 @@ public class ActionScriptParser { if (s.type != SymbolType.GREATER_THAN) { lexer.yypushbackstr(s.value.toString().substring(1)); //parse again as GREATER_THAN } - ret = new GtAVM2Item(null, expr, expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); + ret = new GtAVM2Item(null, expr, expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); break; case GREATER_EQUAL: - ret = new GeAVM2Item(null, expr, expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); + ret = new GeAVM2Item(null, expr, expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); break; case AND: - ret = new AndItem(null, expr, expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); + ret = new AndItem(null, expr, expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); break; case OR: - ret = new OrItem(null, expr, expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); + ret = new OrItem(null, expr, expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); break; case MINUS: - ret = new SubtractAVM2Item(null, expr, expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); + ret = new SubtractAVM2Item(null, expr, expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); break; case MULTIPLY: - ret = new MultiplyAVM2Item(null, expr, expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); + ret = new MultiplyAVM2Item(null, expr, expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); break; case PLUS: - ret = new AddAVM2Item(null, expr, expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); + ret = new AddAVM2Item(null, expr, expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); break; case XOR: - ret = new BitXorAVM2Item(null, expr, expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); + ret = new BitXorAVM2Item(null, expr, expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); break; case INSTANCEOF: - ret = new InstanceOfAVM2Item(null, expr, expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); + ret = new InstanceOfAVM2Item(null, expr, expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); break; case IS: - GraphTargetItem istype = expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables);//type(pkg,needsActivation, importedClasses, openedNamespaces, variables); + GraphTargetItem istype = expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables);//type(thisType,pkg,needsActivation, importedClasses, openedNamespaces, variables); ret = new IsTypeAVM2Item(null, expr, istype); allowRemainder = false; break; @@ -1825,7 +1825,7 @@ public class ActionScriptParser { case ASSIGN_SHIFT_RIGHT: case ASSIGN_USHIFT_RIGHT: case ASSIGN_XOR: - GraphTargetItem assigned = expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); + GraphTargetItem assigned = expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); switch (s.type) { case ASSIGN: //assigned = assigned; @@ -1882,14 +1882,14 @@ public class ActionScriptParser { case BRACKET_OPEN: //member case PARENT_OPEN: //function call lexer.pushback(s); - ret = memberOrCall(pkg, needsActivation, importedClasses, openedNamespaces, expr, registerVars, inFunction, inMethod, variables); + ret = memberOrCall(thisType,pkg, needsActivation, importedClasses, openedNamespaces, expr, registerVars, inFunction, inMethod, variables); break; default: lexer.pushback(s); if (expr instanceof ParenthesisItem) { if (isType(((ParenthesisItem) expr).value)) { - GraphTargetItem expr2 = expression(pkg, needsActivation, importedClasses, openedNamespaces, false, registerVars, inFunction, inMethod, true, variables); + GraphTargetItem expr2 = expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, false, registerVars, inFunction, inMethod, true, variables); if (expr2 != null) { ret = new CoerceAVM2Item(null, ((ParenthesisItem) expr).value, expr2); } @@ -1930,7 +1930,7 @@ public class ActionScriptParser { return false; } - private int brackets(String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, List ret, HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, AVM2ParseException { + private int brackets(TypeItem thisType,String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, List ret, HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, AVM2ParseException { ParsedSymbol s = lex(); int arrCnt = 0; if (s.type == SymbolType.BRACKET_OPEN) { @@ -1941,7 +1941,7 @@ public class ActionScriptParser { lexer.pushback(s); } arrCnt++; - ret.add(expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables)); + ret.add(expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables)); s = lex(); if (!s.isType(SymbolType.COMMA, SymbolType.BRACKET_CLOSE)) { expected(s, lexer.yyline(), SymbolType.COMMA, SymbolType.BRACKET_CLOSE); @@ -1954,12 +1954,12 @@ public class ActionScriptParser { return arrCnt; } - private GraphTargetItem commaExpression(String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, Stack loops, Map loopLabels, HashMap registerVars, boolean inFunction, boolean inMethod, int forInLevel, List variables) throws IOException, AVM2ParseException { + private GraphTargetItem commaExpression(TypeItem thisType,String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, Stack loops, Map loopLabels, HashMap registerVars, boolean inFunction, boolean inMethod, int forInLevel, List variables) throws IOException, AVM2ParseException { GraphTargetItem cmd = null; List expr = new ArrayList<>(); ParsedSymbol s; do { - cmd = command(pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forInLevel, false, variables); + cmd = command(thisType,pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forInLevel, false, variables); if (cmd != null) { expr.add(cmd); } @@ -1967,7 +1967,7 @@ public class ActionScriptParser { } while (s.type == SymbolType.COMMA && cmd != null); lexer.pushback(s); if (cmd == null) { - expr.add(expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables)); + expr.add(expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables)); } else { if (!cmd.hasReturnValue()) { throw new AVM2ParseException("Expression expected", lexer.yyline()); @@ -1976,7 +1976,7 @@ public class ActionScriptParser { return new CommaExpressionItem(null, expr); } - private GraphTargetItem expression(String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, boolean allowEmpty, HashMap registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List variables) throws IOException, AVM2ParseException { + private GraphTargetItem expression(TypeItem thisType,String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, boolean allowEmpty, HashMap registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List variables) throws IOException, AVM2ParseException { if (debugMode) { System.out.println("expression:"); } @@ -1987,7 +1987,7 @@ public class ActionScriptParser { switch (s.type) { case XML_STARTTAG_BEGIN: lexer.pushback(s); - ret = xml(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, variables); + ret = xml(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, variables); existsRemainder = true; break; case STRING: @@ -1995,7 +1995,7 @@ public class ActionScriptParser { existsRemainder = true; break; case NEGATE: - ret = expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables); + ret = expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables); ret = new NegAVM2Item(null, ret); existsRemainder = true; break; @@ -2009,7 +2009,7 @@ public class ActionScriptParser { existsRemainder = true; } else { lexer.pushback(s); - GraphTargetItem num = expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); + GraphTargetItem num = expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); if (num instanceof IntegerValueAVM2Item) { ((IntegerValueAVM2Item) num).value = -((IntegerValueAVM2Item) num).value; ret = num; @@ -2027,7 +2027,7 @@ public class ActionScriptParser { } break; case TYPEOF: - ret = new TypeOfAVM2Item(null, expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); + ret = new TypeOfAVM2Item(null, expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); existsRemainder = true; break; case TRUE: @@ -2057,9 +2057,9 @@ public class ActionScriptParser { expected(s, lexer.yyline(), SymbolType.IDENTIFIER, SymbolType.STRING); GraphTargetItem n = new StringAVM2Item(null, s.value.toString()); -//expression(pkg,needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, allowRemainder, variables); +//expression(thisType,pkg,needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, allowRemainder, variables); expectedType(SymbolType.COLON); - GraphTargetItem v = expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, allowRemainder, variables); + GraphTargetItem v = expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, allowRemainder, variables); NameValuePair nv = new NameValuePair(n, v); nvs.add(nv); @@ -2069,14 +2069,14 @@ public class ActionScriptParser { } } ret = new NewObjectAVM2Item(null, nvs); - ret = memberOrCall(pkg, needsActivation, importedClasses, openedNamespaces, ret, registerVars, inFunction, inMethod, variables); + ret = memberOrCall(thisType,pkg, needsActivation, importedClasses, openedNamespaces, ret, registerVars, inFunction, inMethod, variables); break; case BRACKET_OPEN: //Array literal or just brackets lexer.pushback(s); List inBrackets = new ArrayList<>(); - int arrCnt = brackets(pkg, needsActivation, importedClasses, openedNamespaces, inBrackets, registerVars, inFunction, inMethod, variables); + int arrCnt = brackets(thisType,pkg, needsActivation, importedClasses, openedNamespaces, inBrackets, registerVars, inFunction, inMethod, variables); ret = new NewArrayAVM2Item(null, inBrackets); - ret = memberOrCall(pkg, needsActivation, importedClasses, openedNamespaces, ret, registerVars, inFunction, inMethod, variables); + ret = memberOrCall(thisType,pkg, needsActivation, importedClasses, openedNamespaces, ret, registerVars, inFunction, inMethod, variables); break; case FUNCTION: @@ -2088,7 +2088,7 @@ public class ActionScriptParser { lexer.pushback(s); } needsActivation.setVal(true); - ret = function(pkg, false, needsActivation, importedClasses, 0/*?*/, TypeItem.UNBOUNDED, openedNamespaces, fname, false, variables); + ret = function(pkg, false, needsActivation, importedClasses, 0/*?*/, thisType, openedNamespaces, fname, false, variables); break; case NAN: ret = new NanAVM2Item(null); @@ -2107,7 +2107,7 @@ public class ActionScriptParser { existsRemainder = true; break; case DELETE: - GraphTargetItem varDel = expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables);//name(false, openedNamespaces, registerVars, inFunction, inMethod, variables); + GraphTargetItem varDel = expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables);//name(thisType,false, openedNamespaces, registerVars, inFunction, inMethod, variables); if (!isNameOrProp(varDel)) { throw new AVM2ParseException("Not a property or name", lexer.yyline()); } @@ -2115,7 +2115,7 @@ public class ActionScriptParser { break; case INCREMENT: case DECREMENT: //preincrement - GraphTargetItem varincdec = expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false/*?*/, variables);//name(false, openedNamespaces, registerVars, inFunction, inMethod, variables); + GraphTargetItem varincdec = expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false/*?*/, variables);//name(thisType,false, openedNamespaces, registerVars, inFunction, inMethod, variables); if (!isNameOrProp(varincdec)) { throw new AVM2ParseException("Not a property or name", lexer.yyline()); } @@ -2128,13 +2128,13 @@ public class ActionScriptParser { existsRemainder = true; break; case NOT: - ret = new NotItem(null, expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); + ret = new NotItem(null, expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, false, variables)); existsRemainder = true; break; case PARENT_OPEN: - ret = new ParenthesisItem(null, expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables)); + ret = new ParenthesisItem(null, expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables)); expectedType(SymbolType.PARENT_CLOSE); - ret = memberOrCall(pkg, needsActivation, importedClasses, openedNamespaces, ret, registerVars, inFunction, inMethod, variables); + ret = memberOrCall(thisType,pkg, needsActivation, importedClasses, openedNamespaces, ret, registerVars, inFunction, inMethod, variables); existsRemainder = true; break; case NEW: @@ -2152,29 +2152,29 @@ public class ActionScriptParser { lexer.pushback(s); } needsActivation.setVal(true); - ret = function(pkg, false, needsActivation, importedClasses, 0/*?*/, TypeItem.UNBOUNDED, openedNamespaces, ffname, false, variables); + ret = function(pkg, false, needsActivation, importedClasses, 0/*?*/, thisType, openedNamespaces, ffname, false, variables); } else if (s.type == SymbolType.LOWER_THAN) { - GraphTargetItem subtype = type(pkg, needsActivation, importedClasses, openedNamespaces, variables); + GraphTargetItem subtype = type(thisType,pkg, needsActivation, importedClasses, openedNamespaces, variables); expectedType(SymbolType.GREATER_THAN); s = lex(); expected(s, lexer.yyline(), SymbolType.BRACKET_OPEN); lexer.pushback(s); List params = new ArrayList<>(); - brackets(pkg, needsActivation, importedClasses, openedNamespaces, params, registerVars, inFunction, inMethod, variables); + brackets(thisType,pkg, needsActivation, importedClasses, openedNamespaces, params, registerVars, inFunction, inMethod, variables); ret = new InitVectorAVM2Item(subtype, params, openedNamespaces); } else if (s.type == SymbolType.PARENT_OPEN) { - GraphTargetItem newvar = expression(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); - newvar = applyType(pkg, needsActivation, importedClasses, openedNamespaces, newvar, registerVars, inFunction, inMethod, variables); + GraphTargetItem newvar = expression(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); + newvar = applyType(thisType,pkg, needsActivation, importedClasses, openedNamespaces, newvar, registerVars, inFunction, inMethod, variables); expectedType(SymbolType.PARENT_CLOSE); expectedType(SymbolType.PARENT_OPEN); - ret = new ConstructSomethingAVM2Item(lexer.yyline(), openedNamespaces, newvar, call(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, variables)); + ret = new ConstructSomethingAVM2Item(lexer.yyline(), openedNamespaces, newvar, call(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, variables)); } else { lexer.pushback(s); - GraphTargetItem newvar = name(pkg, needsActivation, false /*?*/, openedNamespaces, registerVars, inFunction, inMethod, variables, importedClasses); - newvar = applyType(pkg, needsActivation, importedClasses, openedNamespaces, newvar, registerVars, inFunction, inMethod, variables); + GraphTargetItem newvar = name(thisType,pkg, needsActivation, false /*?*/, openedNamespaces, registerVars, inFunction, inMethod, variables, importedClasses); + newvar = applyType(thisType,pkg, needsActivation, importedClasses, openedNamespaces, newvar, registerVars, inFunction, inMethod, variables); expectedType(SymbolType.PARENT_OPEN); - ret = new ConstructSomethingAVM2Item(lexer.yyline(), openedNamespaces, newvar, call(pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, variables)); + ret = new ConstructSomethingAVM2Item(lexer.yyline(), openedNamespaces, newvar, call(thisType,pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, variables)); } existsRemainder = true; break; @@ -2183,8 +2183,8 @@ public class ActionScriptParser { case SUPER: case ATTRIBUTE: lexer.pushback(s); - GraphTargetItem var = name(pkg, needsActivation, false, openedNamespaces, registerVars, inFunction, inMethod, variables, importedClasses); - var = memberOrCall(pkg, needsActivation, importedClasses, openedNamespaces, var, registerVars, inFunction, inMethod, variables); + GraphTargetItem var = name(thisType,pkg, needsActivation, false, openedNamespaces, registerVars, inFunction, inMethod, variables, importedClasses); + var = memberOrCall(thisType,pkg, needsActivation, importedClasses, openedNamespaces, var, registerVars, inFunction, inMethod, variables); ret = var; existsRemainder = true; break; @@ -2200,7 +2200,7 @@ public class ActionScriptParser { if (allowRemainder && existsRemainder) { GraphTargetItem rem = ret; do { - rem = expressionRemainder(pkg, needsActivation, openedNamespaces, rem, registerVars, inFunction, inMethod, assocRight, variables, importedClasses); + rem = expressionRemainder(thisType,pkg, needsActivation, openedNamespaces, rem, registerVars, inFunction, inMethod, assocRight, variables, importedClasses); if (rem != null) { ret = rem; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java index abd640128..bfef23b46 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java @@ -273,7 +273,7 @@ public class MethodBody implements Cloneable { abc.method_info.get(method_info).setFlagSetsdxns(stats.has_set_dxns); abc.method_info.get(method_info).setFlagNeed_activation(stats.has_activation); MethodInfo mi = abc.method_info.get(method_info); - int min_regs = mi.param_types.length + (hasThis ? 1 : 0) + (mi.flagNeed_rest() ? 1 : 0); + int min_regs = mi.param_types.length + 1 + (mi.flagNeed_rest() ? 1 : 0); if (max_regs < min_regs) { max_regs = min_regs; }