From d4e0a1f6db334cdbc2a9417e00234df36c64ae0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sat, 10 Aug 2024 20:49:28 +0200 Subject: [PATCH] Using NumberContext parameter in operations. Compiling use clause with usage, rounding, precision --- .../ffdec_lib/lexers/actionscript3_pcode.flex | 2 +- .../lexers/actionscript3_script.flex | 2 +- .../flash/SourceGeneratorLocalData.java | 5 + .../flash/abc/avm2/NumberContext.java | 18 + .../avm2/model/operations/AddAVM2Item.java | 7 +- .../avm2/model/operations/DivideAVM2Item.java | 6 + .../avm2/model/operations/ModuloAVM2Item.java | 7 + .../model/operations/MultiplyAVM2Item.java | 6 + .../avm2/model/operations/NegAVM2Item.java | 6 + .../model/operations/SubtractAVM2Item.java | 7 + .../parser/script/AVM2SourceGenerator.java | 1 + .../parser/script/ActionScript3Parser.java | 183 ++++-- .../avm2/parser/script/ActionScriptLexer.java | 530 +++++++++--------- .../parser/script/ImportedSlotConstItem.java | 13 +- .../abc/avm2/parser/script/IndexAVM2Item.java | 13 +- .../abc/avm2/parser/script/NameAVM2Item.java | 21 +- .../parser/script/NamespacedAVM2Item.java | 15 +- .../avm2/parser/script/PropertyAVM2Item.java | 13 +- .../flash/abc/types/traits/Trait.java | 18 +- .../flash/abc/types/traits/TraitClass.java | 13 +- .../flash/abc/types/traits/TraitFunction.java | 7 +- .../types/traits/TraitMethodGetterSetter.java | 7 +- .../abc/types/traits/TraitSlotConst.java | 5 +- .../flash/abc/types/traits/Traits.java | 5 +- .../exporters/script/DependencyParser.java | 11 +- .../exporters/script/LinkReportExporter.java | 3 +- .../flash/exporters/swf/SwfToSwcExporter.java | 3 +- .../testdata/decimal/bin/decimal.abc | Bin 908 -> 972 bytes .../testdata/decimal/bin/decimal.cpp | 22 +- .../testdata/decimal/src/mypkg/MyClass.as | 11 +- 30 files changed, 605 insertions(+), 355 deletions(-) diff --git a/libsrc/ffdec_lib/lexers/actionscript3_pcode.flex b/libsrc/ffdec_lib/lexers/actionscript3_pcode.flex index 31ff24b48..57d4c2957 100644 --- a/libsrc/ffdec_lib/lexers/actionscript3_pcode.flex +++ b/libsrc/ffdec_lib/lexers/actionscript3_pcode.flex @@ -98,7 +98,7 @@ Label = {Identifier}: /* integer literals */ -NumberLiteral = (0 | -?[1-9][0-9]*) [ui] +NumberLiteral = (0 | -?[1-9][0-9]*) [ui]? PositiveNumberLiteral = 0 | [1-9][0-9]* diff --git a/libsrc/ffdec_lib/lexers/actionscript3_script.flex b/libsrc/ffdec_lib/lexers/actionscript3_script.flex index 405f60fbb..8de42847c 100644 --- a/libsrc/ffdec_lib/lexers/actionscript3_script.flex +++ b/libsrc/ffdec_lib/lexers/actionscript3_script.flex @@ -204,7 +204,7 @@ XmlSQuoteStringChar = [^\r\n\'] /* integer literals */ -DecIntegerLiteral = (0 | [1-9][0-9]*) [ui] +DecIntegerLiteral = (0 | [1-9][0-9]*) [ui]? HexIntegerLiteral = 0 [xX] 0* {HexDigit}+ HexDigit = [0-9a-fA-F] diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SourceGeneratorLocalData.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SourceGeneratorLocalData.java index 09fe15924..10d3ac326 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SourceGeneratorLocalData.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SourceGeneratorLocalData.java @@ -174,6 +174,11 @@ public class SourceGeneratorLocalData implements Serializable { * Is second run */ public boolean secondRun = false; + + /** + * Number context + */ + public Integer numberContext = null; /** * Gets full class name. diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/NumberContext.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/NumberContext.java index 50da0d2c8..4d2bc0482 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/NumberContext.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/NumberContext.java @@ -159,6 +159,11 @@ public class NumberContext { return ret; } + /** + * Converts usage to name. + * @param usage Usage + * @return Name + */ public static String usageToName(int usage) { if (usage > usageNames.length || usage < 0) { throw new IllegalArgumentException("Invalid usage value :" + usage); @@ -166,6 +171,11 @@ public class NumberContext { return usageNames[usage]; } + /** + * Converts rounding to name. + * @param rounding Rounding + * @return Name + */ public static String roundingToName(int rounding) { if (rounding > roundingNames.length || rounding < 0) { throw new IllegalArgumentException("Invalid rounding value :" + rounding); @@ -173,6 +183,14 @@ public class NumberContext { return roundingNames[rounding]; } + /** + * Checks whether this is default NumberContext. + * @return + */ + public boolean isDefault() { + return usage == USE_NUMBER && precision == 34; + } + @Override public String toString() { StringBuilder sb = new StringBuilder(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/AddAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/AddAVM2Item.java index 706618bd5..ae4ee5d9b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/AddAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/AddAVM2Item.java @@ -94,7 +94,12 @@ public class AddAVM2Item extends BinaryOpItem implements CompoundableBinaryOp { new AVM2Instruction(0, AVM2Instructions.Increment, null) ); } - }*/ + }*/ + if (localData.numberContext != null) { + return toSourceMerge(localData, generator, leftSide, rightSide, + new AVM2Instruction(0, AVM2Instructions.AddP, new int[] {localData.numberContext}) + ); + } return toSourceMerge(localData, generator, leftSide, rightSide, new AVM2Instruction(0, AVM2Instructions.Add, null) ); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/DivideAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/DivideAVM2Item.java index bc49be69b..58778ce07 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/DivideAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/DivideAVM2Item.java @@ -85,6 +85,12 @@ public class DivideAVM2Item extends BinaryOpItem implements CompoundableBinaryOp @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { + if (localData.numberContext != null) { + return toSourceMerge(localData, generator, leftSide, rightSide, + new AVM2Instruction(0, AVM2Instructions.DivideP, new int[] {localData.numberContext}) + ); + } + return toSourceMerge(localData, generator, leftSide, rightSide, new AVM2Instruction(0, AVM2Instructions.Divide, null) ); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/ModuloAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/ModuloAVM2Item.java index c7838636c..41b0191bc 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/ModuloAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/ModuloAVM2Item.java @@ -82,6 +82,13 @@ public class ModuloAVM2Item extends BinaryOpItem implements CompoundableBinaryOp @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { + + if (localData.numberContext != null) { + return toSourceMerge(localData, generator, leftSide, rightSide, + new AVM2Instruction(0, AVM2Instructions.ModuloP, new int[] {localData.numberContext}) + ); + } + return toSourceMerge(localData, generator, leftSide, rightSide, new AVM2Instruction(0, AVM2Instructions.Modulo, null) ); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/MultiplyAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/MultiplyAVM2Item.java index d1aaa6fae..aa16d2c2b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/MultiplyAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/MultiplyAVM2Item.java @@ -78,6 +78,12 @@ public class MultiplyAVM2Item extends BinaryOpItem implements CompoundableBinary @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { + if (localData.numberContext != null) { + return toSourceMerge(localData, generator, leftSide, rightSide, + new AVM2Instruction(0, AVM2Instructions.MultiplyP, new int[] {localData.numberContext}) + ); + } + return toSourceMerge(localData, generator, leftSide, rightSide, new AVM2Instruction(0, AVM2Instructions.Multiply, null) ); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/NegAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/NegAVM2Item.java index 085ccdd4a..e6b886027 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/NegAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/NegAVM2Item.java @@ -51,6 +51,12 @@ public class NegAVM2Item extends UnaryOpItem { @Override public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { + if (localData.numberContext != null) { + return toSourceMerge(localData, generator, value, + new AVM2Instruction(0, AVM2Instructions.NegateP, new int[] {localData.numberContext}) + ); + } + return toSourceMerge(localData, generator, value, new AVM2Instruction(0, AVM2Instructions.Negate, null) ); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/SubtractAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/SubtractAVM2Item.java index 54d2a2276..a99b934d8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/SubtractAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/SubtractAVM2Item.java @@ -86,6 +86,13 @@ public class SubtractAVM2Item extends BinaryOpItem implements CompoundableBinary ); } }*/ + + if (localData.numberContext != null) { + return toSourceMerge(localData, generator, leftSide, rightSide, + new AVM2Instruction(0, AVM2Instructions.SubtractP, new int[] {localData.numberContext}) + ); + } + return toSourceMerge(localData, generator, leftSide, rightSide, new AVM2Instruction(0, AVM2Instructions.Subtract, null) ); 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 1a6767f2e..f347be064 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 @@ -1055,6 +1055,7 @@ public class AVM2SourceGenerator implements SourceGenerator { newlocalData.protectedNs = localData.protectedNs; newlocalData.isStatic = isStatic; newlocalData.subMethod = subMethod; + newlocalData.numberContext = localData.numberContext; localData = newlocalData; localData.activationReg = 0; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScript3Parser.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScript3Parser.java index a525bcb11..45e1e655a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScript3Parser.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScript3Parser.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.abc.avm2.parser.script; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.NumberContext; import com.jpexs.decompiler.flash.abc.avm2.model.ApplyTypeAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.BooleanAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.CoerceAVM2Item; @@ -939,14 +940,14 @@ public class ActionScript3Parser { } } - private void scriptTraits(List> allOpenedNamespaces, int scriptIndex, String scriptName, List traits) throws AVM2ParseException, IOException, CompilationException, InterruptedException { + private void scriptTraits(List> allOpenedNamespaces, int scriptIndex, String scriptName, List traits, Reference numberUsageRef, Reference numberRoundingRef, Reference numberPrecisionRef) throws AVM2ParseException, IOException, CompilationException, InterruptedException { - while (scriptTraitsBlock(allOpenedNamespaces, scriptIndex, scriptName, traits)) { + while (scriptTraitsBlock(allOpenedNamespaces, scriptIndex, scriptName, traits, numberUsageRef, numberRoundingRef, numberPrecisionRef)) { //empty } } - private boolean scriptTraitsBlock(List> allOpenedNamespaces, int scriptIndex, String scriptName, List traits) throws AVM2ParseException, IOException, CompilationException, InterruptedException { + private boolean scriptTraitsBlock(List> allOpenedNamespaces, int scriptIndex, String scriptName, List traits, Reference numberUsageRef, Reference numberRoundingRef, Reference numberPrecisionRef) throws AVM2ParseException, IOException, CompilationException, InterruptedException { ParsedSymbol s; boolean inPackage = false; s = lex(); @@ -995,7 +996,7 @@ public class ActionScript3Parser { } } - List importedClasses = parseImportsUsages(openedNamespaces); + List importedClasses = parseImportsUsages(openedNamespaces, numberUsageRef, numberPrecisionRef, numberRoundingRef); boolean isEmpty = true; @@ -2567,54 +2568,145 @@ public class ActionScript3Parser { private List constantPool; - private List parseImportsUsages(List openedNamespaces) throws IOException, AVM2ParseException, InterruptedException { + private List parseImportsUsages(List openedNamespaces, Reference numberUsageRef, Reference numberPrecisionRef, Reference numberRoundingRef) throws IOException, AVM2ParseException, InterruptedException { ParsedSymbol s; List importedClasses = new ArrayList<>(); s = lex(); while (s.isType(SymbolType.IMPORT, SymbolType.USE)) { - boolean all = false; - boolean isUse = s.type == SymbolType.USE; - if (isUse) { - expectedType(SymbolType.NAMESPACE); - } - s = lex(); - expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER); - DottedChain fullName = new DottedChain(new String[]{}); - fullName = fullName.add(s.value.toString(), ""); - s = lex(); - boolean isStar = false; - while (s.type == SymbolType.DOT) { - + + if (s.isType(SymbolType.IMPORT)) { s = lex(); - if (s.type == SymbolType.MULTIPLY && !isUse) { - isStar = true; - s = lex(); - break; - } expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER); + DottedChain fullName = new DottedChain(new String[]{}); fullName = fullName.add(s.value.toString(), ""); s = lex(); - } + boolean isStar = false; + while (s.type == SymbolType.DOT) { + s = lex(); + if (s.type == SymbolType.MULTIPLY) { + isStar = true; + s = lex(); + break; + } + expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER); + fullName = fullName.add(s.value.toString(), ""); + s = lex(); + } - if (isStar) { - openedNamespaces.add(new NamespaceItem(fullName, Namespace.KIND_PACKAGE)); - } else if (isUse) { - //Note: in this case, fullName attribute will be changed to real NS insude NamespaceItem - openedNamespaces.add(new NamespaceItem(fullName, Namespace.KIND_NAMESPACE)); - } else { - importedClasses.add(fullName); + /*else if (isUse) { + //Note: in this case, fullName attribute will be changed to real NS insude NamespaceItem + openedNamespaces.add(new NamespaceItem(fullName, Namespace.KIND_NAMESPACE)); + } else */ + if (isStar) { + openedNamespaces.add(new NamespaceItem(fullName, Namespace.KIND_PACKAGE)); + } else { + importedClasses.add(fullName); + } + expected(s, lexer.yyline(), SymbolType.SEMICOLON); + } else if (s.isType(SymbolType.USE)) { + do { + s = lex(); + if (s.isType(SymbolType.NAMESPACE)) { + s = lex(); + expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER); + DottedChain fullName = new DottedChain(new String[]{}); + fullName = fullName.add(s.value.toString(), ""); + s = lex(); + boolean isStar = false; + while (s.type == SymbolType.DOT) { + s = lex(); + if (s.type == SymbolType.MULTIPLY) { + isStar = true; + s = lex(); + break; + } + expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER); + fullName = fullName.add(s.value.toString(), ""); + s = lex(); + } + } else { + expected(s, lexer.yyline(), SymbolType.IDENTIFIER); + String pragmaItemName = (String) s.value; + switch (pragmaItemName) { + case "Number": + numberUsageRef.setVal(NumberContext.USE_NUMBER); + break; + case "decimal": + numberUsageRef.setVal(NumberContext.USE_DECIMAL); + break; + case "double": + numberUsageRef.setVal(NumberContext.USE_DOUBLE); + break; + case "int": + numberUsageRef.setVal(NumberContext.USE_INT); + break; + case "uint": + numberUsageRef.setVal(NumberContext.USE_UINT); + break; + case "rounding": + s = lex(); + expected(s, lexer.yyline(), SymbolType.IDENTIFIER); + String roundingIdentifier = (String) s.value; + int rounding; + switch (roundingIdentifier) { + case "CEILING": + rounding = NumberContext.ROUND_CEILING; + break; + case "UP": + rounding = NumberContext.ROUND_UP; + break; + case "HALF_UP": + rounding = NumberContext.ROUND_HALF_UP; + break; + case "HALF_EVEN": + rounding = NumberContext.ROUND_HALF_EVEN; + break; + case "HALF_DOWN": + rounding = NumberContext.ROUND_HALF_DOWN; + break; + case "DOWN": + rounding = NumberContext.ROUND_DOWN; + break; + case "FLOOR": + rounding = NumberContext.ROUND_FLOOR; + break; + default: + throw new AVM2ParseException("Rounding expected - one of: CEILING, UP, HALF_UP, HALF_EVEN, HALF_DOWN, DOWN, FLOOR", lexer.yyline()); + } + numberRoundingRef.setVal(rounding); + break; + case "precision": + s = lex(); + expected(s, lexer.yyline(), SymbolType.INTEGER); + int precision = (Integer) s.value; + if (precision < 1 || precision > 34) { + throw new AVM2ParseException("Invalid precision - must be between 1 and 34", lexer.yyline()); + } + numberPrecisionRef.setVal(precision); + break; + default: + throw new AVM2ParseException("Invalid use kind", lexer.yyline()); + } + } + s = lex(); + }while(s.isType(SymbolType.COMMA)); + expected(s, lexer.yyline(), SymbolType.SEMICOLON); } - - expected(s, lexer.yyline(), SymbolType.SEMICOLON); + /*boolean isUse = s.type == SymbolType.USE; + if (isUse) { + + expectedType(SymbolType.NAMESPACE); + }*/ + s = lex(); } lexer.pushback(s); return importedClasses; } - private List parseScript(List> allOpenedNamespaces, int scriptIndex, String fileName) throws IOException, AVM2ParseException, CompilationException, InterruptedException { + private List parseScript(List> allOpenedNamespaces, int scriptIndex, String fileName, Reference numberContextRef) throws IOException, AVM2ParseException, CompilationException, InterruptedException { //int scriptPrivateNs; if (fileName.contains("/")) { @@ -2624,7 +2716,15 @@ public class ActionScript3Parser { fileName = fileName.substring(fileName.lastIndexOf('\\') + 1); } List items = new ArrayList<>(); - scriptTraits(allOpenedNamespaces, scriptIndex, fileName, items); + Reference numberUsageRef = new Reference<>(NumberContext.USE_NUMBER); + Reference numberRoundingRef = new Reference<>(NumberContext.ROUND_HALF_EVEN); + Reference numberPrecisionRef = new Reference<>(34); + scriptTraits(allOpenedNamespaces, scriptIndex, fileName, items, numberUsageRef, numberRoundingRef, numberPrecisionRef); + + NumberContext nc = new NumberContext(numberUsageRef.getVal(), numberPrecisionRef.getVal(), numberRoundingRef.getVal()); + if (!nc.isDefault()) { + numberContextRef.setVal(nc.toParam()); + } return items; } @@ -2634,16 +2734,17 @@ public class ActionScript3Parser { * @param str String to parse * @param fileName File name * @param scriptIndex Script index + * @param numberContextRef Number context reference * @return List of script traits * @throws AVM2ParseException On parsing error * @throws IOException On I/O error * @throws CompilationException On compilation error * @throws InterruptedException On interrupt */ - public List scriptTraitsFromString(List> allOpenedNamespaces, String str, String fileName, int scriptIndex) throws AVM2ParseException, IOException, CompilationException, InterruptedException { + public List scriptTraitsFromString(List> allOpenedNamespaces, String str, String fileName, int scriptIndex, Reference numberContextRef) throws AVM2ParseException, IOException, CompilationException, InterruptedException { lexer = new ActionScriptLexer(str); - List ret = parseScript(allOpenedNamespaces, scriptIndex, fileName); + List ret = parseScript(allOpenedNamespaces, scriptIndex, fileName, numberContextRef); if (lexer.lex().type != SymbolType.EOF) { throw new AVM2ParseException("Parsing finisned before end of the file", lexer.yyline()); } @@ -2659,11 +2760,12 @@ public class ActionScript3Parser { * @throws AVM2ParseException On parsing error * @throws CompilationException On compilation error */ - public void addScriptFromTree(List> allOpenedNamespaces, List items, int classPos, String documentClass) throws AVM2ParseException, CompilationException { + public void addScriptFromTree(List> allOpenedNamespaces, List items, int classPos, String documentClass, Integer numberContext) throws AVM2ParseException, CompilationException { AVM2SourceGenerator gen = new AVM2SourceGenerator(abcIndex); SourceGeneratorLocalData localData = new SourceGeneratorLocalData( new HashMap<>(), 0, Boolean.FALSE, 0); localData.documentClass = documentClass; + localData.numberContext = numberContext; ScriptInfo si = new ScriptInfo(); int scriptIndex = abcIndex.getSelectedAbc().script_info.size(); abcIndex.getSelectedAbc().script_info.add(si); @@ -2691,8 +2793,9 @@ public class ActionScript3Parser { */ public void addScript(String s, String fileName, int classPos, int scriptIndex, String documentClass) throws AVM2ParseException, IOException, CompilationException, InterruptedException { List> allOpenedNamespaces = new ArrayList<>(); - List traits = scriptTraitsFromString(allOpenedNamespaces, s, fileName, scriptIndex); - addScriptFromTree(allOpenedNamespaces, traits, classPos, documentClass); + Reference numberContextRef = new Reference<>(null); + List traits = scriptTraitsFromString(allOpenedNamespaces, s, fileName, scriptIndex, numberContextRef); + addScriptFromTree(allOpenedNamespaces, traits, classPos, documentClass, numberContextRef.getVal()); } /** diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptLexer.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptLexer.java index e7d1bec0a..e0e29cbe6 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptLexer.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptLexer.java @@ -246,33 +246,33 @@ public final class ActionScriptLexer { "\1\44\1\1\1\42\2\45\1\46\2\47\1\42\2\1"+ "\1\50\1\51\1\42\1\52\1\1\1\53\3\42\2\54"+ "\2\42\1\55\1\56\1\1\1\57\2\42\1\0\1\60"+ - "\1\0\1\61\1\0\1\62\1\63\1\64\1\15\1\65"+ - "\1\66\1\67\1\0\1\70\1\71\1\72\1\73\1\74"+ - "\1\75\1\76\1\77\1\100\1\15\1\0\1\101\1\15"+ - "\1\102\1\0\14\6\1\103\1\104\3\0\2\6\1\105"+ - "\14\6\1\106\1\107\1\110\1\6\1\111\13\6\1\112"+ + "\1\0\1\61\1\0\1\62\1\63\1\64\1\65\1\66"+ + "\1\67\1\70\1\0\1\71\1\72\1\73\1\74\1\75"+ + "\1\76\1\77\1\100\1\15\1\65\1\0\1\101\1\65"+ + "\1\102\1\0\14\6\1\103\1\104\1\0\2\105\2\6"+ + "\1\106\14\6\1\107\1\110\1\111\1\6\1\112\13\6"+ "\1\113\1\114\1\115\1\116\1\117\1\120\1\121\1\122"+ - "\2\120\1\123\1\124\1\125\1\126\1\127\1\130\1\131"+ - "\1\0\1\132\1\0\1\133\1\134\3\0\1\135\2\0"+ - "\1\136\3\137\1\140\1\141\1\142\1\143\1\144\1\145"+ - "\1\146\1\137\2\0\1\147\2\60\2\0\1\147\2\0"+ - "\1\147\1\150\1\151\2\0\1\152\1\153\1\154\1\0"+ - "\1\15\1\155\1\156\1\157\7\6\1\160\4\6\1\161"+ - "\1\162\3\6\1\163\4\6\1\164\3\6\1\165\17\6"+ - "\1\166\1\6\1\167\1\6\1\170\1\171\1\172\2\0"+ - "\1\173\1\174\1\0\1\175\2\0\1\176\4\0\1\177"+ - "\1\200\2\0\1\60\1\147\1\201\1\0\1\202\1\6"+ - "\1\203\10\6\1\204\1\205\6\6\1\206\2\6\1\207"+ - "\1\6\1\210\10\6\1\211\5\6\1\212\1\6\1\0"+ - "\1\213\1\0\1\214\1\215\2\0\1\216\2\0\1\6"+ - "\1\217\1\220\1\6\1\221\1\6\1\222\1\223\1\6"+ - "\1\224\1\6\1\225\5\6\1\226\10\6\1\227\5\6"+ - "\1\0\1\230\1\0\5\6\1\231\1\232\1\233\2\6"+ - "\1\234\1\235\1\236\5\6\1\237\1\6\1\240\4\6"+ - "\2\0\3\6\1\241\1\242\6\6\1\243\1\244\1\6"+ - "\1\245\1\246\1\6\2\0\1\6\1\247\1\250\1\251"+ - "\4\6\1\252\1\6\1\253\1\0\1\254\1\255\1\256"+ - "\2\6\1\257\1\260\1\261\1\262\1\263"; + "\1\123\2\121\1\124\1\125\1\126\1\127\1\130\1\131"+ + "\1\132\1\0\1\133\1\0\1\134\1\135\3\0\1\136"+ + "\2\0\1\137\3\140\1\141\1\142\1\143\1\144\1\145"+ + "\1\146\1\147\1\140\2\0\1\150\2\60\2\0\1\150"+ + "\2\0\1\150\1\151\1\152\2\0\1\153\1\154\1\155"+ + "\1\0\1\65\1\156\1\157\1\160\7\6\1\161\4\6"+ + "\1\162\1\105\3\6\1\163\4\6\1\164\3\6\1\165"+ + "\17\6\1\166\1\6\1\167\1\6\1\170\1\171\1\172"+ + "\2\0\1\173\1\174\1\0\1\175\2\0\1\176\4\0"+ + "\1\177\1\200\2\0\1\60\1\150\1\201\1\0\1\202"+ + "\1\6\1\203\10\6\1\204\1\205\6\6\1\206\2\6"+ + "\1\207\1\6\1\210\10\6\1\211\5\6\1\212\1\6"+ + "\1\0\1\213\1\0\1\214\1\215\2\0\1\216\1\0"+ + "\1\217\1\0\1\6\1\220\1\221\1\6\1\222\1\6"+ + "\1\223\1\224\1\6\1\225\1\6\1\226\5\6\1\227"+ + "\10\6\1\230\5\6\2\0\5\6\1\231\1\232\1\233"+ + "\2\6\1\234\1\235\1\236\5\6\1\237\1\6\1\240"+ + "\4\6\2\0\3\6\1\241\1\242\6\6\1\243\1\244"+ + "\1\6\1\245\1\246\1\6\2\0\1\6\1\247\1\250"+ + "\1\251\4\6\1\252\1\6\1\253\1\0\1\254\1\255"+ + "\1\256\2\6\1\257\1\260\1\261\1\262\1\263"; private static int [] zzUnpackAction() { int [] result = new int[465]; @@ -345,11 +345,11 @@ public final class ActionScriptLexer { "\0\u4448\0\u4494\0\u44e0\0\u452c\0\u4578\0\u45c4\0\u4610\0\u465c"+ "\0\u0558\0\u46a8\0\u46f4\0\u4740\0\u478c\0\u47d8\0\u0558\0\u4824"+ "\0\u27c8\0\u03dc\0\u4870\0\u03dc\0\u03dc\0\u48bc\0\u2a28\0\u03dc"+ - "\0\u4908\0\u4954\0\u49a0\0\u0558\0\u0558\0\u49ec\0\u0558\0\u4a38"+ - "\0\u0558\0\u4a84\0\u4ad0\0\u0558\0\u4b1c\0\u0558\0\u4b68\0\u4bb4"+ - "\0\u4c00\0\u4c4c\0\u4c98\0\u0558\0\u4ce4\0\u4d30\0\u4d7c\0\u4dc8"+ - "\0\u4e14\0\u4e60\0\u4eac\0\u4ef8\0\u0558\0\u4f44\0\u4f90\0\u4fdc"+ - "\0\u5028\0\u5074\0\u50c0\0\u03dc\0\u510c\0\u5158\0\u51a4\0\u51f0"+ + "\0\u4908\0\u03dc\0\u4954\0\u49a0\0\u0558\0\u0558\0\u49ec\0\u0558"+ + "\0\u4a38\0\u0558\0\u4a84\0\u4ad0\0\u0558\0\u4b1c\0\u0558\0\u4b68"+ + "\0\u4bb4\0\u4c00\0\u4c4c\0\u4c98\0\u0558\0\u4ce4\0\u4d30\0\u4d7c"+ + "\0\u4dc8\0\u4e14\0\u4e60\0\u4eac\0\u4ef8\0\u0558\0\u4f44\0\u4f90"+ + "\0\u4fdc\0\u5028\0\u5074\0\u50c0\0\u510c\0\u5158\0\u51a4\0\u51f0"+ "\0\u523c\0\u5288\0\u0558\0\u0558\0\u0558\0\u52d4\0\u5320\0\u0558"+ "\0\u0558\0\u0558\0\u536c\0\u53b8\0\u5404\0\u5450\0\u549c\0\u0558"+ "\0\u54e8\0\u0558\0\u5534\0\u5580\0\u55cc\0\u5618\0\u5664\0\u56b0"+ @@ -646,152 +646,152 @@ public final class ActionScriptLexer { "\1\u0167\6\0\1\u0167\46\0\1\u0168\1\0\1\u0168\3\0"+ "\3\u0168\5\0\1\u0168\3\0\2\u0168\1\0\3\u0168\4\0"+ "\1\u0168\1\0\1\u0168\6\0\1\u0168\50\0\1\u012e\13\0"+ - "\1\u012e\1\u0169\3\0\1\u012e\20\0\1\u0169\66\0\1\u0169"+ - "\24\0\1\u0169\27\0\1\340\2\341\1\340\1\u0134\1\u0132"+ - "\43\340\1\344\42\340\4\341\1\337\1\u0133\106\341\1\340"+ - "\2\341\1\340\1\342\1\u0132\13\340\1\u0135\15\340\2\u0135"+ - "\1\340\1\u0135\1\340\2\u0135\1\340\1\u0135\1\340\1\344"+ - "\2\340\21\u0135\17\340\27\0\1\u016a\72\0\3\24\7\0"+ - "\3\24\3\0\4\24\4\0\7\24\1\u016b\2\24\4\0"+ - "\23\24\23\0\3\24\7\0\3\24\3\0\4\24\4\0"+ - "\12\24\4\0\14\24\1\u016c\6\24\23\0\3\24\7\0"+ - "\3\24\3\0\4\24\4\0\12\24\4\0\7\24\1\u016d"+ + "\1\u012e\1\u0169\3\0\1\u012e\20\0\1\u0169\15\0\1\u016a"+ + "\50\0\1\u0169\24\0\1\u0169\15\0\1\u016a\11\0\1\340"+ + "\2\341\1\340\1\u0134\1\u0132\43\340\1\344\42\340\4\341"+ + "\1\337\1\u0133\106\341\1\340\2\341\1\340\1\342\1\u0132"+ + "\13\340\1\u0135\15\340\2\u0135\1\340\1\u0135\1\340\2\u0135"+ + "\1\340\1\u0135\1\340\1\344\2\340\21\u0135\17\340\27\0"+ + "\1\u016b\72\0\3\24\7\0\3\24\3\0\4\24\4\0"+ + "\7\24\1\u016c\2\24\4\0\23\24\23\0\3\24\7\0"+ + "\3\24\3\0\4\24\4\0\12\24\4\0\14\24\1\u016d"+ + "\6\24\23\0\3\24\7\0\3\24\3\0\4\24\4\0"+ + "\12\24\4\0\7\24\1\u016e\13\24\23\0\3\24\7\0"+ + "\3\24\3\0\4\24\4\0\12\24\4\0\10\24\1\u016f"+ + "\12\24\23\0\3\24\7\0\3\24\3\0\4\24\4\0"+ + "\12\24\4\0\4\24\1\u0170\16\24\23\0\3\24\7\0"+ + "\3\24\3\0\4\24\4\0\12\24\4\0\7\24\1\u0171"+ "\13\24\23\0\3\24\7\0\3\24\3\0\4\24\4\0"+ - "\12\24\4\0\10\24\1\u016e\12\24\23\0\3\24\7\0"+ - "\3\24\3\0\4\24\4\0\12\24\4\0\4\24\1\u016f"+ - "\16\24\23\0\3\24\7\0\3\24\3\0\4\24\4\0"+ - "\12\24\4\0\7\24\1\u0170\13\24\23\0\3\24\7\0"+ - "\3\24\3\0\4\24\4\0\11\24\1\u0171\4\0\23\24"+ + "\11\24\1\u0172\4\0\23\24\23\0\3\24\7\0\3\24"+ + "\3\0\4\24\4\0\12\24\4\0\12\24\1\u0173\10\24"+ "\23\0\3\24\7\0\3\24\3\0\4\24\4\0\12\24"+ - "\4\0\12\24\1\u0172\10\24\23\0\3\24\7\0\3\24"+ - "\3\0\4\24\4\0\12\24\4\0\6\24\1\u0173\14\24"+ - "\23\0\3\24\7\0\3\24\3\0\4\24\4\0\12\24"+ - "\4\0\3\24\1\u0174\17\24\23\0\3\24\7\0\3\24"+ - "\3\0\4\24\4\0\12\24\4\0\1\24\1\u0175\21\24"+ + "\4\0\6\24\1\u0174\14\24\23\0\3\24\7\0\3\24"+ + "\3\0\4\24\4\0\12\24\4\0\3\24\1\u0175\17\24"+ "\23\0\3\24\7\0\3\24\3\0\4\24\4\0\12\24"+ "\4\0\1\24\1\u0176\21\24\23\0\3\24\7\0\3\24"+ - "\3\0\4\24\4\0\12\24\4\0\10\24\1\u0177\12\24"+ - "\23\0\3\24\7\0\3\24\3\0\4\24\4\0\4\24"+ - "\1\u0178\5\24\4\0\23\24\23\0\3\24\7\0\3\24"+ - "\3\0\4\24\4\0\12\24\4\0\1\24\1\u0179\21\24"+ + "\3\0\4\24\4\0\12\24\4\0\1\24\1\u0177\21\24"+ "\23\0\3\24\7\0\3\24\3\0\4\24\4\0\12\24"+ - "\4\0\4\24\1\u017a\16\24\23\0\3\24\7\0\3\24"+ - "\3\0\4\24\4\0\12\24\4\0\17\24\1\u017b\3\24"+ + "\4\0\10\24\1\u0178\12\24\23\0\3\24\7\0\3\24"+ + "\3\0\4\24\4\0\4\24\1\u0179\5\24\4\0\23\24"+ "\23\0\3\24\7\0\3\24\3\0\4\24\4\0\12\24"+ - "\4\0\13\24\1\u017c\7\24\23\0\3\24\7\0\3\24"+ - "\3\0\4\24\4\0\12\24\4\0\5\24\1\u017d\15\24"+ + "\4\0\1\24\1\u017a\21\24\23\0\3\24\7\0\3\24"+ + "\3\0\4\24\4\0\12\24\4\0\4\24\1\u017b\16\24"+ "\23\0\3\24\7\0\3\24\3\0\4\24\4\0\12\24"+ - "\4\0\1\24\1\u017e\21\24\23\0\3\24\7\0\3\24"+ - "\3\0\4\24\4\0\11\24\1\u017f\4\0\23\24\23\0"+ - "\3\24\7\0\3\24\3\0\4\24\4\0\12\24\4\0"+ - "\2\24\1\u0180\20\24\23\0\3\24\7\0\3\24\3\0"+ - "\4\24\4\0\12\24\4\0\1\24\1\u0181\21\24\23\0"+ - "\3\24\7\0\3\24\3\0\4\24\4\0\1\24\1\u0182"+ - "\10\24\4\0\23\24\23\0\3\24\7\0\3\24\3\0"+ - "\4\24\4\0\12\24\4\0\7\24\1\u0183\13\24\23\0"+ - "\3\24\7\0\3\24\3\0\4\24\4\0\6\24\1\u0184"+ - "\3\24\4\0\23\24\23\0\3\24\7\0\3\24\3\0"+ - "\4\24\4\0\11\24\1\u0185\4\0\23\24\23\0\3\24"+ - "\7\0\3\24\3\0\4\24\4\0\12\24\4\0\10\24"+ - "\1\u0186\12\24\23\0\3\24\7\0\3\24\3\0\4\24"+ - "\4\0\11\24\1\u0187\4\0\23\24\23\0\3\24\7\0"+ - "\3\24\3\0\4\24\4\0\12\24\4\0\2\24\1\u0188"+ - "\20\24\23\0\3\24\7\0\3\24\3\0\4\24\4\0"+ - "\12\24\4\0\2\24\1\u0189\20\24\23\0\3\24\7\0"+ - "\3\24\3\0\4\24\4\0\12\24\4\0\6\24\1\u018a"+ - "\14\24\16\0\2\u0163\10\0\1\u0163\2\0\1\u0164\124\0"+ - "\1\u018b\166\0\1\u018c\41\0\1\u018d\71\0\3\24\7\0"+ - "\3\24\3\0\4\24\4\0\12\24\4\0\10\24\1\u018e"+ - "\12\24\23\0\3\24\7\0\3\24\3\0\4\24\4\0"+ - "\12\24\4\0\6\24\1\u018f\14\24\23\0\3\24\7\0"+ - "\3\24\3\0\4\24\4\0\12\24\4\0\10\24\1\u0190"+ - "\12\24\23\0\3\24\7\0\3\24\3\0\4\24\4\0"+ - "\12\24\4\0\12\24\1\u0191\10\24\23\0\3\24\7\0"+ - "\3\24\3\0\4\24\4\0\12\24\4\0\11\24\1\u0192"+ - "\11\24\23\0\3\24\7\0\3\24\3\0\4\24\4\0"+ - "\12\24\4\0\6\24\1\u0193\14\24\23\0\3\24\7\0"+ - "\3\24\3\0\4\24\4\0\4\24\1\u0194\5\24\4\0"+ - "\23\24\23\0\3\24\7\0\3\24\3\0\4\24\4\0"+ - "\12\24\4\0\14\24\1\u0195\6\24\23\0\3\24\7\0"+ - "\3\24\3\0\4\24\4\0\12\24\4\0\10\24\1\u0196"+ - "\12\24\23\0\3\24\7\0\3\24\3\0\4\24\4\0"+ - "\12\24\4\0\15\24\1\u0197\5\24\23\0\3\24\7\0"+ - "\3\24\3\0\4\24\4\0\11\24\1\u0198\4\0\23\24"+ - "\23\0\3\24\7\0\3\24\3\0\4\24\4\0\7\24"+ - "\1\u0199\2\24\4\0\23\24\23\0\3\24\7\0\3\24"+ - "\3\0\4\24\4\0\12\24\4\0\7\24\1\u019a\13\24"+ - "\23\0\3\24\7\0\3\24\3\0\4\24\4\0\6\24"+ - "\1\u019b\3\24\4\0\23\24\23\0\3\24\7\0\3\24"+ - "\3\0\4\24\4\0\12\24\4\0\6\24\1\u019c\14\24"+ - "\23\0\3\24\7\0\3\24\3\0\4\24\4\0\7\24"+ - "\1\u019d\2\24\4\0\6\24\1\u019e\14\24\23\0\3\24"+ - "\7\0\3\24\3\0\4\24\4\0\12\24\4\0\12\24"+ - "\1\u019f\10\24\23\0\3\24\7\0\3\24\3\0\4\24"+ - "\4\0\11\24\1\u01a0\4\0\23\24\23\0\3\24\7\0"+ - "\3\24\3\0\4\24\4\0\12\24\4\0\10\24\1\u01a1"+ - "\12\24\23\0\3\24\7\0\3\24\3\0\4\24\4\0"+ - "\4\24\1\u01a2\5\24\4\0\23\24\23\0\3\24\7\0"+ - "\3\24\3\0\4\24\4\0\4\24\1\u01a3\5\24\4\0"+ - "\23\24\23\0\3\24\7\0\3\24\3\0\4\24\4\0"+ - "\12\24\4\0\7\24\1\u01a4\13\24\23\0\3\24\7\0"+ - "\3\24\3\0\4\24\4\0\12\24\4\0\20\24\1\u01a5"+ - "\2\24\23\0\3\24\7\0\3\24\3\0\4\24\4\0"+ - "\12\24\4\0\10\24\1\u01a6\12\24\45\0\1\u01a7\114\0"+ - "\1\u01a8\70\0\3\24\7\0\3\24\3\0\4\24\4\0"+ - "\12\24\4\0\6\24\1\u01a9\14\24\23\0\3\24\7\0"+ - "\3\24\3\0\4\24\4\0\1\24\1\u01aa\10\24\4\0"+ - "\23\24\23\0\3\24\7\0\3\24\3\0\4\24\4\0"+ - "\12\24\4\0\5\24\1\u01ab\15\24\23\0\3\24\7\0"+ - "\3\24\3\0\4\24\4\0\12\24\4\0\16\24\1\u01ac"+ - "\4\24\23\0\3\24\7\0\3\24\3\0\4\24\4\0"+ - "\12\24\4\0\4\24\1\u01ad\16\24\23\0\3\24\7\0"+ - "\3\24\3\0\4\24\4\0\12\24\4\0\11\24\1\u01ae"+ - "\11\24\23\0\3\24\7\0\3\24\3\0\4\24\4\0"+ - "\12\24\4\0\2\24\1\u01af\20\24\23\0\3\24\7\0"+ - "\3\24\3\0\4\24\4\0\11\24\1\u01b0\4\0\23\24"+ - "\23\0\3\24\7\0\3\24\3\0\4\24\4\0\4\24"+ - "\1\u01b1\5\24\4\0\23\24\23\0\3\24\7\0\3\24"+ - "\3\0\4\24\4\0\12\24\4\0\2\24\1\u01b2\20\24"+ + "\4\0\17\24\1\u017c\3\24\23\0\3\24\7\0\3\24"+ + "\3\0\4\24\4\0\12\24\4\0\13\24\1\u017d\7\24"+ "\23\0\3\24\7\0\3\24\3\0\4\24\4\0\12\24"+ - "\4\0\2\24\1\u01b3\20\24\23\0\3\24\7\0\3\24"+ - "\3\0\4\24\4\0\12\24\4\0\7\24\1\u01b4\13\24"+ - "\23\0\3\24\7\0\3\24\3\0\4\24\4\0\4\24"+ - "\1\u01b5\5\24\4\0\23\24\23\0\3\24\7\0\3\24"+ - "\3\0\4\24\4\0\12\24\4\0\7\24\1\u01b6\13\24"+ + "\4\0\5\24\1\u017e\15\24\23\0\3\24\7\0\3\24"+ + "\3\0\4\24\4\0\12\24\4\0\1\24\1\u017f\21\24"+ "\23\0\3\24\7\0\3\24\3\0\4\24\4\0\11\24"+ - "\1\u01b7\4\0\23\24\23\0\3\24\7\0\3\24\3\0"+ - "\4\24\4\0\11\24\1\u01b8\4\0\23\24\23\0\3\24"+ - "\7\0\3\24\3\0\4\24\4\0\12\24\4\0\7\24"+ - "\1\u01b9\13\24\46\0\1\u01ba\112\0\1\u01bb\71\0\3\24"+ - "\7\0\3\24\3\0\4\24\4\0\11\24\1\u01bc\4\0"+ - "\23\24\23\0\3\24\7\0\3\24\3\0\4\24\4\0"+ - "\11\24\1\u01bd\4\0\23\24\23\0\3\24\7\0\3\24"+ - "\3\0\4\24\4\0\12\24\4\0\6\24\1\u01be\14\24"+ - "\23\0\3\24\7\0\3\24\3\0\4\24\4\0\11\24"+ - "\1\u01bf\4\0\23\24\23\0\3\24\7\0\3\24\3\0"+ - "\4\24\4\0\4\24\1\u01c0\5\24\4\0\23\24\23\0"+ + "\1\u0180\4\0\23\24\23\0\3\24\7\0\3\24\3\0"+ + "\4\24\4\0\12\24\4\0\2\24\1\u0181\20\24\23\0"+ "\3\24\7\0\3\24\3\0\4\24\4\0\12\24\4\0"+ - "\6\24\1\u01c1\14\24\23\0\3\24\7\0\3\24\3\0"+ - "\4\24\4\0\11\24\1\u01c2\4\0\23\24\23\0\3\24"+ - "\7\0\3\24\3\0\4\24\4\0\4\24\1\u01c3\5\24"+ + "\1\24\1\u0182\21\24\23\0\3\24\7\0\3\24\3\0"+ + "\4\24\4\0\1\24\1\u0183\10\24\4\0\23\24\23\0"+ + "\3\24\7\0\3\24\3\0\4\24\4\0\12\24\4\0"+ + "\7\24\1\u0184\13\24\23\0\3\24\7\0\3\24\3\0"+ + "\4\24\4\0\6\24\1\u0185\3\24\4\0\23\24\23\0"+ + "\3\24\7\0\3\24\3\0\4\24\4\0\11\24\1\u0186"+ "\4\0\23\24\23\0\3\24\7\0\3\24\3\0\4\24"+ - "\4\0\12\24\4\0\12\24\1\u01c4\10\24\23\0\3\24"+ - "\7\0\3\24\3\0\4\24\4\0\11\24\1\u01c5\4\0"+ + "\4\0\12\24\4\0\10\24\1\u0187\12\24\23\0\3\24"+ + "\7\0\3\24\3\0\4\24\4\0\11\24\1\u0188\4\0"+ "\23\24\23\0\3\24\7\0\3\24\3\0\4\24\4\0"+ - "\12\24\4\0\16\24\1\u01c6\4\24\45\0\1\u01c7\110\0"+ - "\1\u01c8\74\0\3\24\7\0\3\24\3\0\4\24\4\0"+ - "\12\24\4\0\11\24\1\u01c9\11\24\23\0\3\24\7\0"+ - "\3\24\3\0\4\24\4\0\11\24\1\u01ca\4\0\23\24"+ + "\12\24\4\0\2\24\1\u0189\20\24\23\0\3\24\7\0"+ + "\3\24\3\0\4\24\4\0\12\24\4\0\2\24\1\u018a"+ + "\20\24\23\0\3\24\7\0\3\24\3\0\4\24\4\0"+ + "\12\24\4\0\6\24\1\u018b\14\24\16\0\2\u0163\10\0"+ + "\1\u0163\2\0\1\u0164\124\0\1\u018c\166\0\1\u016a\41\0"+ + "\1\u018d\71\0\3\24\7\0\3\24\3\0\4\24\4\0"+ + "\12\24\4\0\10\24\1\u018e\12\24\23\0\3\24\7\0"+ + "\3\24\3\0\4\24\4\0\12\24\4\0\6\24\1\u018f"+ + "\14\24\23\0\3\24\7\0\3\24\3\0\4\24\4\0"+ + "\12\24\4\0\10\24\1\u0190\12\24\23\0\3\24\7\0"+ + "\3\24\3\0\4\24\4\0\12\24\4\0\12\24\1\u0191"+ + "\10\24\23\0\3\24\7\0\3\24\3\0\4\24\4\0"+ + "\12\24\4\0\11\24\1\u0192\11\24\23\0\3\24\7\0"+ + "\3\24\3\0\4\24\4\0\12\24\4\0\6\24\1\u0193"+ + "\14\24\23\0\3\24\7\0\3\24\3\0\4\24\4\0"+ + "\4\24\1\u0194\5\24\4\0\23\24\23\0\3\24\7\0"+ + "\3\24\3\0\4\24\4\0\12\24\4\0\14\24\1\u0195"+ + "\6\24\23\0\3\24\7\0\3\24\3\0\4\24\4\0"+ + "\12\24\4\0\10\24\1\u0196\12\24\23\0\3\24\7\0"+ + "\3\24\3\0\4\24\4\0\12\24\4\0\15\24\1\u0197"+ + "\5\24\23\0\3\24\7\0\3\24\3\0\4\24\4\0"+ + "\11\24\1\u0198\4\0\23\24\23\0\3\24\7\0\3\24"+ + "\3\0\4\24\4\0\7\24\1\u0199\2\24\4\0\23\24"+ "\23\0\3\24\7\0\3\24\3\0\4\24\4\0\12\24"+ - "\4\0\7\24\1\u01cb\13\24\23\0\3\24\7\0\3\24"+ - "\3\0\4\24\4\0\12\24\4\0\5\24\1\u01cc\15\24"+ - "\23\0\3\24\7\0\3\24\3\0\4\24\4\0\11\24"+ - "\1\u01cd\4\0\23\24\23\0\3\24\7\0\3\24\3\0"+ - "\4\24\4\0\12\24\4\0\11\24\1\u01ce\11\24\42\0"+ - "\1\u01cf\74\0\3\24\7\0\3\24\3\0\4\24\4\0"+ - "\12\24\4\0\4\24\1\u01d0\16\24\23\0\3\24\7\0"+ - "\3\24\3\0\4\24\4\0\7\24\1\u01d1\2\24\4\0"+ - "\23\24\15\0"; + "\4\0\7\24\1\u019a\13\24\23\0\3\24\7\0\3\24"+ + "\3\0\4\24\4\0\6\24\1\u019b\3\24\4\0\23\24"+ + "\23\0\3\24\7\0\3\24\3\0\4\24\4\0\12\24"+ + "\4\0\6\24\1\u019c\14\24\23\0\3\24\7\0\3\24"+ + "\3\0\4\24\4\0\7\24\1\u019d\2\24\4\0\6\24"+ + "\1\u019e\14\24\23\0\3\24\7\0\3\24\3\0\4\24"+ + "\4\0\12\24\4\0\12\24\1\u019f\10\24\23\0\3\24"+ + "\7\0\3\24\3\0\4\24\4\0\11\24\1\u01a0\4\0"+ + "\23\24\23\0\3\24\7\0\3\24\3\0\4\24\4\0"+ + "\12\24\4\0\10\24\1\u01a1\12\24\23\0\3\24\7\0"+ + "\3\24\3\0\4\24\4\0\4\24\1\u01a2\5\24\4\0"+ + "\23\24\23\0\3\24\7\0\3\24\3\0\4\24\4\0"+ + "\4\24\1\u01a3\5\24\4\0\23\24\23\0\3\24\7\0"+ + "\3\24\3\0\4\24\4\0\12\24\4\0\7\24\1\u01a4"+ + "\13\24\23\0\3\24\7\0\3\24\3\0\4\24\4\0"+ + "\12\24\4\0\20\24\1\u01a5\2\24\23\0\3\24\7\0"+ + "\3\24\3\0\4\24\4\0\12\24\4\0\10\24\1\u01a6"+ + "\12\24\45\0\1\u01a7\114\0\1\u01a8\70\0\3\24\7\0"+ + "\3\24\3\0\4\24\4\0\12\24\4\0\6\24\1\u01a9"+ + "\14\24\23\0\3\24\7\0\3\24\3\0\4\24\4\0"+ + "\1\24\1\u01aa\10\24\4\0\23\24\23\0\3\24\7\0"+ + "\3\24\3\0\4\24\4\0\12\24\4\0\5\24\1\u01ab"+ + "\15\24\23\0\3\24\7\0\3\24\3\0\4\24\4\0"+ + "\12\24\4\0\16\24\1\u01ac\4\24\23\0\3\24\7\0"+ + "\3\24\3\0\4\24\4\0\12\24\4\0\4\24\1\u01ad"+ + "\16\24\23\0\3\24\7\0\3\24\3\0\4\24\4\0"+ + "\12\24\4\0\11\24\1\u01ae\11\24\23\0\3\24\7\0"+ + "\3\24\3\0\4\24\4\0\12\24\4\0\2\24\1\u01af"+ + "\20\24\23\0\3\24\7\0\3\24\3\0\4\24\4\0"+ + "\11\24\1\u01b0\4\0\23\24\23\0\3\24\7\0\3\24"+ + "\3\0\4\24\4\0\4\24\1\u01b1\5\24\4\0\23\24"+ + "\23\0\3\24\7\0\3\24\3\0\4\24\4\0\12\24"+ + "\4\0\2\24\1\u01b2\20\24\23\0\3\24\7\0\3\24"+ + "\3\0\4\24\4\0\12\24\4\0\2\24\1\u01b3\20\24"+ + "\23\0\3\24\7\0\3\24\3\0\4\24\4\0\12\24"+ + "\4\0\7\24\1\u01b4\13\24\23\0\3\24\7\0\3\24"+ + "\3\0\4\24\4\0\4\24\1\u01b5\5\24\4\0\23\24"+ + "\23\0\3\24\7\0\3\24\3\0\4\24\4\0\12\24"+ + "\4\0\7\24\1\u01b6\13\24\23\0\3\24\7\0\3\24"+ + "\3\0\4\24\4\0\11\24\1\u01b7\4\0\23\24\23\0"+ + "\3\24\7\0\3\24\3\0\4\24\4\0\11\24\1\u01b8"+ + "\4\0\23\24\23\0\3\24\7\0\3\24\3\0\4\24"+ + "\4\0\12\24\4\0\7\24\1\u01b9\13\24\46\0\1\u01ba"+ + "\112\0\1\u01bb\71\0\3\24\7\0\3\24\3\0\4\24"+ + "\4\0\11\24\1\u01bc\4\0\23\24\23\0\3\24\7\0"+ + "\3\24\3\0\4\24\4\0\11\24\1\u01bd\4\0\23\24"+ + "\23\0\3\24\7\0\3\24\3\0\4\24\4\0\12\24"+ + "\4\0\6\24\1\u01be\14\24\23\0\3\24\7\0\3\24"+ + "\3\0\4\24\4\0\11\24\1\u01bf\4\0\23\24\23\0"+ + "\3\24\7\0\3\24\3\0\4\24\4\0\4\24\1\u01c0"+ + "\5\24\4\0\23\24\23\0\3\24\7\0\3\24\3\0"+ + "\4\24\4\0\12\24\4\0\6\24\1\u01c1\14\24\23\0"+ + "\3\24\7\0\3\24\3\0\4\24\4\0\11\24\1\u01c2"+ + "\4\0\23\24\23\0\3\24\7\0\3\24\3\0\4\24"+ + "\4\0\4\24\1\u01c3\5\24\4\0\23\24\23\0\3\24"+ + "\7\0\3\24\3\0\4\24\4\0\12\24\4\0\12\24"+ + "\1\u01c4\10\24\23\0\3\24\7\0\3\24\3\0\4\24"+ + "\4\0\11\24\1\u01c5\4\0\23\24\23\0\3\24\7\0"+ + "\3\24\3\0\4\24\4\0\12\24\4\0\16\24\1\u01c6"+ + "\4\24\45\0\1\u01c7\110\0\1\u01c8\74\0\3\24\7\0"+ + "\3\24\3\0\4\24\4\0\12\24\4\0\11\24\1\u01c9"+ + "\11\24\23\0\3\24\7\0\3\24\3\0\4\24\4\0"+ + "\11\24\1\u01ca\4\0\23\24\23\0\3\24\7\0\3\24"+ + "\3\0\4\24\4\0\12\24\4\0\7\24\1\u01cb\13\24"+ + "\23\0\3\24\7\0\3\24\3\0\4\24\4\0\12\24"+ + "\4\0\5\24\1\u01cc\15\24\23\0\3\24\7\0\3\24"+ + "\3\0\4\24\4\0\11\24\1\u01cd\4\0\23\24\23\0"+ + "\3\24\7\0\3\24\3\0\4\24\4\0\12\24\4\0"+ + "\11\24\1\u01ce\11\24\42\0\1\u01cf\74\0\3\24\7\0"+ + "\3\24\3\0\4\24\4\0\12\24\4\0\4\24\1\u01d0"+ + "\16\24\23\0\3\24\7\0\3\24\3\0\4\24\4\0"+ + "\7\24\1\u01d1\2\24\4\0\23\24\15\0"; private static int [] zzUnpackTrans() { int [] result = new int[23940]; @@ -838,7 +838,7 @@ public final class ActionScriptLexer { "\3\1\1\11\2\1\2\11\1\1\1\11\2\1\1\0"+ "\1\1\1\0\1\1\1\0\1\11\1\1\1\11\1\1"+ "\1\11\2\1\1\0\2\11\1\1\2\11\1\1\4\11"+ - "\1\0\3\1\1\0\14\1\2\11\3\0\37\1\1\11"+ + "\1\0\3\1\1\0\14\1\2\11\1\0\41\1\1\11"+ "\1\1\1\11\1\1\5\11\2\1\7\11\1\0\1\11"+ "\1\0\2\11\3\0\1\1\2\0\2\11\2\1\7\11"+ "\1\1\2\0\2\1\1\11\2\0\1\1\2\0\1\1"+ @@ -846,7 +846,7 @@ public final class ActionScriptLexer { "\17\1\1\11\41\1\2\11\2\0\2\11\1\0\1\11"+ "\2\0\1\1\4\0\2\11\2\0\2\1\1\11\1\0"+ "\1\11\50\1\1\0\1\11\1\0\2\11\2\0\1\11"+ - "\2\0\40\1\1\0\1\11\1\0\31\1\2\0\21\1"+ + "\1\0\1\11\1\0\40\1\2\0\31\1\2\0\21\1"+ "\2\0\13\1\1\0\1\11\6\1\1\11\2\1"; private static int [] zzUnpackAttribute() { @@ -1383,19 +1383,16 @@ public final class ActionScriptLexer { } case 191: break; case 13: - { String dval = yytext(); - if (dval.endsWith("m")) { - dval = dval.substring(0, dval.length() - 1); - return new ParsedSymbol(SymbolGroup.DECIMAL, SymbolType.DECIMAL, new Decimal128(dval)); + { String ival = yytext(); + if (ival.endsWith("i") || ival.endsWith("u")) { + ival = ival.substring(0, ival.length() - 1); } - if (dval.endsWith("f")) { - dval = dval.substring(0, dval.length() - 1); - return new ParsedSymbol(SymbolGroup.FLOAT, SymbolType.FLOAT, Float.parseFloat(dval)); + try{ + return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, Integer.parseInt(ival)); + } catch(NumberFormatException nfe){ + //its too long for an Integer var + return new ParsedSymbol(SymbolGroup.DOUBLE, SymbolType.DOUBLE, Double.parseDouble(ival)); } - if (dval.endsWith("d")) { - dval = dval.substring(0, dval.length() - 1); - } - return new ParsedSymbol(SymbolGroup.DOUBLE, SymbolType.DOUBLE, Double.parseDouble(dval)); } case 192: break; case 14: @@ -1592,62 +1589,65 @@ public final class ActionScriptLexer { } case 231: break; case 53: - { return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.FILTER, yytext()); + { String dval = yytext(); + if (dval.endsWith("m")) { + dval = dval.substring(0, dval.length() - 1); + return new ParsedSymbol(SymbolGroup.DECIMAL, SymbolType.DECIMAL, new Decimal128(dval)); + } + if (dval.endsWith("f")) { + dval = dval.substring(0, dval.length() - 1); + return new ParsedSymbol(SymbolGroup.FLOAT, SymbolType.FLOAT, Float.parseFloat(dval)); + } + if (dval.endsWith("d")) { + dval = dval.substring(0, dval.length() - 1); + } + return new ParsedSymbol(SymbolGroup.DOUBLE, SymbolType.DOUBLE, Double.parseDouble(dval)); } case 232: break; case 54: + { return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.FILTER, yytext()); + } + case 233: break; + case 55: { yybegin(XMLOPENTAG); string.setLength(0); return new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_STARTTAG_BEGIN, yytext()); } - case 233: break; - case 55: - { return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.SHIFT_LEFT, yytext()); - } case 234: break; case 56: - { return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.LOWER_EQUAL, yytext()); + { return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.SHIFT_LEFT, yytext()); } case 235: break; case 57: - { return new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_STARTVARTAG_BEGIN, yytext()); + { return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.LOWER_EQUAL, yytext()); } case 236: break; case 58: - { return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.NOT_EQUAL, yytext()); + { return new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_STARTVARTAG_BEGIN, yytext()); } case 237: break; case 59: - { return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.DECREMENT, yytext()); + { return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.NOT_EQUAL, yytext()); } case 238: break; case 60: - { return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ASSIGN_MINUS, yytext()); + { return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.DECREMENT, yytext()); } case 239: break; case 61: - { return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.SHIFT_RIGHT, yytext()); + { return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ASSIGN_MINUS, yytext()); } case 240: break; case 62: - { return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.GREATER_EQUAL, yytext()); + { return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.SHIFT_RIGHT, yytext()); } case 241: break; case 63: - { return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.NAMESPACE_OP, yytext()); + { return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.GREATER_EQUAL, yytext()); } case 242: break; case 64: - { String ival = yytext(); - if (ival.endsWith("i") || ival.endsWith("u")) { - ival = ival.substring(0, ival.length() - 1); - } - try{ - return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, Integer.parseInt(ival)); - } catch(NumberFormatException nfe){ - //its too long for an Integer var - return new ParsedSymbol(SymbolGroup.DOUBLE, SymbolType.DOUBLE, Double.parseDouble(ival)); - } + { return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.NAMESPACE_OP, yytext()); } case 243: break; case 65: @@ -1672,86 +1672,90 @@ public final class ActionScriptLexer { } case 247: break; case 69: - { return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.AS, yytext()); + { return new ParsedSymbol(SymbolGroup.NAMESPACESUFFIX, SymbolType.NAMESPACESUFFIX, Integer.parseInt(yytext().substring(1))); } case 248: break; case 70: - { return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.IF, yytext()); + { return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.AS, yytext()); } case 249: break; case 71: - { return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.IS, yytext()); + { return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.IF, yytext()); } case 250: break; case 72: - { return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.IN, yytext()); + { return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.IS, yytext()); } case 251: break; case 73: - { return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.DO, yytext()); + { return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.IN, yytext()); } case 252: break; case 74: - { return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ASSIGN_BITAND, yytext()); + { return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.DO, yytext()); } case 253: break; case 75: - { return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.AND, yytext()); + { return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ASSIGN_BITAND, yytext()); } case 254: break; case 76: - { return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ASSIGN_BITOR, yytext()); + { return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.AND, yytext()); } case 255: break; case 77: - { return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.OR, yytext()); + { return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ASSIGN_BITOR, yytext()); } case 256: break; case 78: - { return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ASSIGN_XOR, yytext()); + { return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.OR, yytext()); } case 257: break; case 79: - { return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ASSIGN_MODULO, yytext()); + { return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ASSIGN_XOR, yytext()); } case 258: break; case 80: - { /* ignore illegal character escape */ + { return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ASSIGN_MODULO, yytext()); } case 259: break; case 81: - { string.append('\"'); + { /* ignore illegal character escape */ } case 260: break; case 82: - { string.append('\''); + { string.append('\"'); } case 261: break; case 83: - { string.append('\f'); + { string.append('\''); } case 262: break; case 84: - { string.append('\\'); + { string.append('\f'); } case 263: break; case 85: - { string.append('\b'); + { string.append('\\'); } case 264: break; case 86: - { string.append('\r'); + { string.append('\b'); } case 265: break; case 87: - { string.append('\n'); + { string.append('\r'); } case 266: break; case 88: - { string.append('\t'); + { string.append('\n'); } case 267: break; case 89: + { string.append('\t'); + } + case 268: break; + case 90: { yybegin(XML); pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_STARTFINISHTAG_END, yytext())); if (string.length() > 0){ @@ -1760,8 +1764,8 @@ public final class ActionScriptLexer { } return lex(); } - case 268: break; - case 90: + case 269: break; + case 91: { yybegin(XMLOPENTAGATTRIB); pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_ATTRIBUTENAME, yytext())); if (string.length() > 0){ @@ -1770,21 +1774,21 @@ public final class ActionScriptLexer { } return lex(); } - case 269: break; - case 91: + case 270: break; + case 92: { yybegin(XMLOPENTAG); return new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_ATTRIBUTEVALUE, yytext()); } - case 270: break; - case 92: + case 271: break; + case 93: { yybegin(XML); string.append(yytext()); String tos = string.toString(); string.setLength(0); return new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_INSTR, tos); } - case 271: break; - case 93: + case 272: break; + case 94: { yybegin(XMLOPENTAG); pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_STARTTAG_BEGIN, yytext())); if (string.length() > 0){ @@ -1793,8 +1797,8 @@ public final class ActionScriptLexer { } return lex(); } - case 272: break; - case 94: + case 273: break; + case 95: { yybegin(YYINITIAL); pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_STARTVARTAG_BEGIN, yytext())); if (string.length() > 0){ @@ -1803,68 +1807,68 @@ public final class ActionScriptLexer { } return lex(); } - case 273: break; - case 95: - { throw new AVM2ParseException("Illegal escape sequence \"" + yytext() + "\"", yyline + 1); - } case 274: break; case 96: - { for(int r=0;r obj_temp = new Reference<>(-1); boolean isInteger = false; + + AVM2Instruction changeIns; + if (isInteger) { + changeIns = ins(decrement ? AVM2Instructions.DecrementI : AVM2Instructions.IncrementI); + } else if (localData.numberContext != null) { + changeIns = ins(decrement ? AVM2Instructions.DecrementP : AVM2Instructions.IncrementP, localData.numberContext); + } else { + changeIns = ins(decrement ? AVM2Instructions.Decrement : AVM2Instructions.Increment); + } List ret = toSourceMerge(localData, generator, obj, dupSetTemp(localData, generator, obj_temp), ins(AVM2Instructions.GetProperty, propertyId), (!isInteger && post) ? ins(AVM2Instructions.ConvertD) : null, - (!post) ? (decrement ? ins(isInteger ? AVM2Instructions.DecrementI : AVM2Instructions.Decrement) : ins(isInteger ? AVM2Instructions.IncrementI : AVM2Instructions.Increment)) : null, + (!post) ? changeIns : null, needsReturn ? ins(AVM2Instructions.Dup) : null, - (post) ? (decrement ? ins(isInteger ? AVM2Instructions.DecrementI : AVM2Instructions.Decrement) : ins(isInteger ? AVM2Instructions.IncrementI : AVM2Instructions.Increment)) : null, + (post) ? changeIns : null, setTemp(localData, generator, ret_temp), getTemp(localData, generator, obj_temp), getTemp(localData, generator, ret_temp), diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/IndexAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/IndexAVM2Item.java index 837b0366b..b7fb760e7 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/IndexAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/IndexAVM2Item.java @@ -17,7 +17,9 @@ package com.jpexs.decompiler.flash.abc.avm2.parser.script; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; +import static com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item.ins; import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; @@ -112,14 +114,21 @@ public class IndexAVM2Item extends AssignableAVM2Item { AVM2SourceGenerator g = (AVM2SourceGenerator) generator; int indexPropIndex = g.abcIndex.getSelectedAbc().constants.getMultinameId(Multiname.createMultinameL(attr, allNsSet(g.abcIndex)), true); + AVM2Instruction changeIns; + if (localData.numberContext != null) { + changeIns = ins(decrement ? AVM2Instructions.DecrementP : AVM2Instructions.IncrementP, localData.numberContext); + } else { + changeIns = ins(decrement ? AVM2Instructions.Decrement : AVM2Instructions.Increment); + } + return toSourceMerge(localData, generator, object, dupSetTemp(localData, generator, obj_temp), index, dupSetTemp(localData, generator, index_temp), ins(AVM2Instructions.GetProperty, indexPropIndex), post ? ins(AVM2Instructions.ConvertD) : null, - (!post) ? (decrement ? ins(AVM2Instructions.Decrement) : ins(AVM2Instructions.Increment)) : null, + (!post) ? changeIns : null, needsReturn ? ins(AVM2Instructions.Dup) : null, - post ? (decrement ? ins(AVM2Instructions.Decrement) : ins(AVM2Instructions.Increment)) : null, + post ? changeIns : null, setTemp(localData, generator, val_temp), getTemp(localData, generator, obj_temp), getTemp(localData, generator, index_temp), diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NameAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NameAVM2Item.java index d71f32015..03a53a6bc 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NameAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NameAVM2Item.java @@ -448,15 +448,32 @@ public class NameAVM2Item extends AssignableAVM2Item { */ if (!needsReturn) { if (slotNumber > -1) { + AVM2Instruction changeIns; + if (isInteger) { + changeIns = ins(decrement ? AVM2Instructions.DecrementI : AVM2Instructions.IncrementI); + } else if (localData.numberContext != null) { + changeIns = ins(decrement ? AVM2Instructions.DecrementP : AVM2Instructions.IncrementP, localData.numberContext); + } else { + changeIns = ins(decrement ? AVM2Instructions.Decrement : AVM2Instructions.Increment); + } return toSourceMerge(localData, generator, ins(AVM2Instructions.GetScopeObject, slotScope), generateGetSlot(slotScope, slotNumber), - (decrement ? ins(isInteger ? AVM2Instructions.DecrementI : AVM2Instructions.Decrement) : ins(isInteger ? AVM2Instructions.IncrementI : AVM2Instructions.Increment)), + changeIns, ins(AVM2Instructions.SetSlot, slotNumber) ); } else { + AVM2Instruction changeIns; + if (isInteger) { + changeIns = ins(decrement ? AVM2Instructions.DecLocalI : AVM2Instructions.IncLocalI, regNumber); + } else if (localData.numberContext != null) { + changeIns = ins(decrement ? AVM2Instructions.DecLocalP : AVM2Instructions.IncLocalP, localData.numberContext, regNumber); + } else { + changeIns = ins(decrement ? AVM2Instructions.DecLocal : AVM2Instructions.IncLocal, regNumber); + } + return toSourceMerge(localData, generator, - (decrement ? ins(isInteger ? AVM2Instructions.DecLocalI : AVM2Instructions.DecLocal, regNumber) : ins(isInteger ? AVM2Instructions.IncLocalI : AVM2Instructions.IncLocal, regNumber))); + changeIns); } } return toSourceMerge(localData, generator, diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NamespacedAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NamespacedAVM2Item.java index 57ba88595..973eb8a5d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NamespacedAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NamespacedAVM2Item.java @@ -19,6 +19,7 @@ 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.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; @@ -135,6 +136,16 @@ public class NamespacedAVM2Item extends AssignableAVM2Item { */ ABC abc = g.abcIndex.getSelectedAbc(); AVM2ConstantPool constants = abc.constants; + + AVM2Instruction changeIns; + if (isInteger) { + changeIns = ins(decrement ? AVM2Instructions.DecrementI : AVM2Instructions.IncrementI); + } else if (localData.numberContext != null) { + changeIns = ins(decrement ? AVM2Instructions.DecrementP : AVM2Instructions.IncrementP, localData.numberContext); + } else { + changeIns = ins(decrement ? AVM2Instructions.Decrement : AVM2Instructions.Increment); + } + if (name != null) { return toSourceMerge(localData, generator, ns, NameAVM2Item.generateCoerce(localData, generator, new TypeItem(DottedChain.NAMESPACE)), @@ -148,9 +159,9 @@ public class NamespacedAVM2Item extends AssignableAVM2Item { ins(AVM2Instructions.GetProperty, constants.getMultinameId(Multiname.createMultinameL(false, allNsSet(g.abcIndex)), true)), !isInteger ? ins(AVM2Instructions.ConvertD) : null, //End get original - (!post) ? (decrement ? ins(isInteger ? AVM2Instructions.DecrementI : AVM2Instructions.Decrement) : ins(isInteger ? AVM2Instructions.IncrementI : AVM2Instructions.Increment)) : null, + (!post) ? changeIns : null, needsReturn ? ins(AVM2Instructions.Dup) : null, - (post) ? (decrement ? ins(isInteger ? AVM2Instructions.DecrementI : AVM2Instructions.Decrement) : ins(isInteger ? AVM2Instructions.IncrementI : AVM2Instructions.Increment)) : null, + (post) ? changeIns : null, setTemp(localData, generator, ret_temp), getTemp(localData, generator, name_temp), getTemp(localData, generator, ns_temp), diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java index e3c7b48f7..9028989f2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java @@ -599,6 +599,15 @@ public class PropertyAVM2Item extends AssignableAVM2Item { boolean isInteger = propType.getVal().toString().equals("int"); + AVM2Instruction changeIns; + if (isInteger) { + changeIns = ins(decrement ? AVM2Instructions.DecrementI : AVM2Instructions.IncrementI); + } else if (localData.numberContext != null) { + changeIns = ins(decrement ? AVM2Instructions.DecrementP : AVM2Instructions.IncrementP, localData.numberContext); + } else { + changeIns = ins(decrement ? AVM2Instructions.Decrement : AVM2Instructions.Increment); + } + List ret = toSourceMerge(localData, generator, obj, dupSetTemp(localData, generator, obj_temp), //Start get original //getTemp(localData, generator, obj_temp), @@ -606,9 +615,9 @@ public class PropertyAVM2Item extends AssignableAVM2Item { ins(AVM2Instructions.GetProperty, propertyId), (!isInteger && post) ? ins(AVM2Instructions.ConvertD) : null, //End get original - (!post) ? (decrement ? ins(isInteger ? AVM2Instructions.DecrementI : AVM2Instructions.Decrement) : ins(isInteger ? AVM2Instructions.IncrementI : AVM2Instructions.Increment)) : null, + (!post) ? changeIns : null, needsReturn ? ins(AVM2Instructions.Dup) : null, - (post) ? (decrement ? ins(isInteger ? AVM2Instructions.DecrementI : AVM2Instructions.Decrement) : ins(isInteger ? AVM2Instructions.IncrementI : AVM2Instructions.Increment)) : null, + (post) ? changeIns : null, setTemp(localData, generator, ret_temp), getTemp(localData, generator, obj_temp), getTemp(localData, generator, ret_temp), diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java index d60949865..9369fb9c2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.abc.types.traits; import com.jpexs.decompiler.flash.IdentifiersDeobfuscation; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.ClassPath; +import com.jpexs.decompiler.flash.abc.avm2.NumberContext; import com.jpexs.decompiler.flash.abc.avm2.model.NameValuePair; import com.jpexs.decompiler.flash.abc.avm2.model.NewObjectAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.StringAVM2Item; @@ -42,6 +43,7 @@ import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.ScopeStack; import com.jpexs.decompiler.graph.TypeItem; import com.jpexs.helpers.Helper; +import com.jpexs.helpers.Reference; import java.io.Serializable; import java.util.AbstractMap.SimpleEntry; import java.util.ArrayList; @@ -278,7 +280,7 @@ public abstract class Trait implements Cloneable, Serializable { * @param uses Uses * @throws InterruptedException On interrupt */ - public void getDependencies(AbcIndexing abcIndex, int scriptIndex, int classIndex, boolean isStatic, String customNamespace, ABC abc, List dependencies, DottedChain ignorePackage, List fullyQualifiedNames, List uses) throws InterruptedException { + public void getDependencies(AbcIndexing abcIndex, int scriptIndex, int classIndex, boolean isStatic, String customNamespace, ABC abc, List dependencies, DottedChain ignorePackage, List fullyQualifiedNames, List uses, Reference numberContextRef) throws InterruptedException { if (customNamespace == null) { Multiname m = getName(abc); int nskind = m.getSimpleNamespaceKind(abc.constants); @@ -395,7 +397,8 @@ public abstract class Trait implements Cloneable, Serializable { customNs = multiname.getSimpleNamespaceName(abc.constants).toRawString(); } List uses = new ArrayList<>(); - getDependencies(abcIndex, scriptIndex, classIndex, isStatic, customNs, abc, dependencies, ignorePackage, new ArrayList<>(), uses); + Reference numberContextRef = new Reference<>(null); + getDependencies(abcIndex, scriptIndex, classIndex, isStatic, customNs, abc, dependencies, ignorePackage, new ArrayList<>(), uses, numberContextRef); List imports = new ArrayList<>(); for (Dependency d : dependencies) { @@ -488,6 +491,17 @@ public abstract class Trait implements Cloneable, Serializable { } writer.newLine(); } + if (numberContextRef.getVal() != null) { + writer.appendNoHilight("use "); + NumberContext nc = new NumberContext(numberContextRef.getVal()); + writer.appendNoHilight(NumberContext.usageToName(nc.getUsage())); + writer.appendNoHilight(", rounding "); + writer.appendNoHilight(NumberContext.roundingToName(nc.getRounding())); + writer.appendNoHilight(", precision "); + writer.appendNoHilight(nc.getPrecision()); + writer.appendNoHilight(";"); + writer.newLine(); + } } /** diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java index 38fbb6aea..66d8d43a8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java @@ -48,6 +48,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.ScopeStack; import com.jpexs.decompiler.graph.TypeItem; import com.jpexs.helpers.Helper; +import com.jpexs.helpers.Reference; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -118,8 +119,8 @@ public class TraitClass extends Trait implements TraitWithSlot { * @throws InterruptedException On interrupt */ @Override - public void getDependencies(AbcIndexing abcIndex, int scriptIndex, int classIndex, boolean isStatic, String customNamespace, ABC abc, List dependencies, DottedChain ignorePackage, List fullyQualifiedNames, List uses) throws InterruptedException { - super.getDependencies(abcIndex, scriptIndex, -1, false, customNamespace, abc, dependencies, ignorePackage == null ? getPackage(abc) : ignorePackage, fullyQualifiedNames, uses); + public void getDependencies(AbcIndexing abcIndex, int scriptIndex, int classIndex, boolean isStatic, String customNamespace, ABC abc, List dependencies, DottedChain ignorePackage, List fullyQualifiedNames, List uses, Reference numberContextRef) throws InterruptedException { + super.getDependencies(abcIndex, scriptIndex, -1, false, customNamespace, abc, dependencies, ignorePackage == null ? getPackage(abc) : ignorePackage, fullyQualifiedNames, uses, numberContextRef); ClassInfo classInfo = abc.class_info.get(class_info); InstanceInfo instanceInfo = abc.instance_info.get(class_info); DottedChain packageName = instanceInfo.getName(abc.constants).getNamespace(abc.constants).getName(abc.constants); //assume not null name @@ -133,16 +134,16 @@ public class TraitClass extends Trait implements TraitWithSlot { } //static - classInfo.static_traits.getDependencies(abcIndex, scriptIndex, class_info, true, customNamespace, abc, dependencies, packageName, fullyQualifiedNames, uses); + classInfo.static_traits.getDependencies(abcIndex, scriptIndex, class_info, true, customNamespace, abc, dependencies, packageName, fullyQualifiedNames, uses, numberContextRef); //static initializer - DependencyParser.parseDependenciesFromMethodInfo(abcIndex, null, scriptIndex, class_info, true, customNamespace, abc, classInfo.cinit_index, dependencies, packageName, fullyQualifiedNames, new ArrayList<>(), uses); + DependencyParser.parseDependenciesFromMethodInfo(abcIndex, null, scriptIndex, class_info, true, customNamespace, abc, classInfo.cinit_index, dependencies, packageName, fullyQualifiedNames, new ArrayList<>(), uses, numberContextRef); //instance - instanceInfo.instance_traits.getDependencies(abcIndex, scriptIndex, class_info, false, customNamespace, abc, dependencies, packageName, fullyQualifiedNames, uses); + instanceInfo.instance_traits.getDependencies(abcIndex, scriptIndex, class_info, false, customNamespace, abc, dependencies, packageName, fullyQualifiedNames, uses, numberContextRef); //instance initializer - DependencyParser.parseDependenciesFromMethodInfo(abcIndex, null, scriptIndex, class_info, false, customNamespace, abc, instanceInfo.iinit_index, dependencies, packageName, fullyQualifiedNames, new ArrayList<>(), uses); + DependencyParser.parseDependenciesFromMethodInfo(abcIndex, null, scriptIndex, class_info, false, customNamespace, abc, instanceInfo.iinit_index, dependencies, packageName, fullyQualifiedNames, new ArrayList<>(), uses, numberContextRef); } /** diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java index 80945f03e..25399f105 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java @@ -30,6 +30,7 @@ import com.jpexs.decompiler.flash.search.MethodId; import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.ScopeStack; import com.jpexs.helpers.Helper; +import com.jpexs.helpers.Reference; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -260,12 +261,12 @@ public class TraitFunction extends Trait implements TraitWithSlot { * @throws InterruptedException On interrupt */ @Override - public void getDependencies(AbcIndexing abcIndex, int scriptIndex, int classIndex, boolean isStatic, String customNamespace, ABC abc, List dependencies, DottedChain ignorePackage, List fullyQualifiedNames, List uses) throws InterruptedException { + public void getDependencies(AbcIndexing abcIndex, int scriptIndex, int classIndex, boolean isStatic, String customNamespace, ABC abc, List dependencies, DottedChain ignorePackage, List fullyQualifiedNames, List uses, Reference numberContextRef) throws InterruptedException { if (ignorePackage == null) { ignorePackage = getPackage(abc); } - super.getDependencies(abcIndex, scriptIndex, classIndex, false, customNamespace, abc, dependencies, ignorePackage, fullyQualifiedNames, uses); - DependencyParser.parseDependenciesFromMethodInfo(abcIndex, this, scriptIndex, classIndex, false, customNamespace, abc, method_info, dependencies, ignorePackage, fullyQualifiedNames, new ArrayList<>(), uses); + super.getDependencies(abcIndex, scriptIndex, classIndex, false, customNamespace, abc, dependencies, ignorePackage, fullyQualifiedNames, uses, numberContextRef); + DependencyParser.parseDependenciesFromMethodInfo(abcIndex, this, scriptIndex, classIndex, false, customNamespace, abc, method_info, dependencies, ignorePackage, fullyQualifiedNames, new ArrayList<>(), uses, numberContextRef); } /** diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java index 141ec1980..ce40768e6 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java @@ -34,6 +34,7 @@ import com.jpexs.decompiler.flash.search.MethodId; import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.ScopeStack; import com.jpexs.helpers.Helper; +import com.jpexs.helpers.Reference; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -104,11 +105,11 @@ public class TraitMethodGetterSetter extends Trait { * @throws InterruptedException On interrupt */ @Override - public void getDependencies(AbcIndexing abcIndex, int scriptIndex, int classIndex, boolean isStatic, String customNamespace, ABC abc, List dependencies, DottedChain ignorePackage, List fullyQualifiedNames, List uses) throws InterruptedException { + public void getDependencies(AbcIndexing abcIndex, int scriptIndex, int classIndex, boolean isStatic, String customNamespace, ABC abc, List dependencies, DottedChain ignorePackage, List fullyQualifiedNames, List uses, Reference numberContextRef) throws InterruptedException { if (ignorePackage == null) { ignorePackage = getPackage(abc); } - super.getDependencies(abcIndex, scriptIndex, classIndex, isStatic, customNamespace, abc, dependencies, ignorePackage, fullyQualifiedNames, uses); + super.getDependencies(abcIndex, scriptIndex, classIndex, isStatic, customNamespace, abc, dependencies, ignorePackage, fullyQualifiedNames, uses, numberContextRef); if (customNamespace == null) { Multiname m = getName(abc); @@ -117,7 +118,7 @@ public class TraitMethodGetterSetter extends Trait { customNamespace = m.getSimpleNamespaceName(abc.constants).toRawString(); } } - DependencyParser.parseDependenciesFromMethodInfo(abcIndex, this, scriptIndex, classIndex, isStatic, customNamespace, abc, method_info, dependencies, ignorePackage, fullyQualifiedNames, new ArrayList<>(), uses); + DependencyParser.parseDependenciesFromMethodInfo(abcIndex, this, scriptIndex, classIndex, isStatic, customNamespace, abc, method_info, dependencies, ignorePackage, fullyQualifiedNames, new ArrayList<>(), uses, numberContextRef); } /** diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitSlotConst.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitSlotConst.java index 97013f703..f40cb4185 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitSlotConst.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitSlotConst.java @@ -40,6 +40,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.ScopeStack; import com.jpexs.decompiler.graph.model.LocalData; import com.jpexs.helpers.Helper; +import com.jpexs.helpers.Reference; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -369,11 +370,11 @@ public class TraitSlotConst extends Trait implements TraitWithSlot { * @throws InterruptedException On interrupt */ @Override - public void getDependencies(AbcIndexing abcIndex, int scriptIndex, int classIndex, boolean isStatic, String customNamespace, ABC abc, List dependencies, DottedChain ignorePackage, List fullyQualifiedNames, List uses) throws InterruptedException { + public void getDependencies(AbcIndexing abcIndex, int scriptIndex, int classIndex, boolean isStatic, String customNamespace, ABC abc, List dependencies, DottedChain ignorePackage, List fullyQualifiedNames, List uses, Reference numberContextRef) throws InterruptedException { if (ignorePackage == null) { ignorePackage = getPackage(abc); } - super.getDependencies(abcIndex, scriptIndex, classIndex, isStatic, customNamespace, abc, dependencies, ignorePackage, fullyQualifiedNames, uses); + super.getDependencies(abcIndex, scriptIndex, classIndex, isStatic, customNamespace, abc, dependencies, ignorePackage, fullyQualifiedNames, uses, numberContextRef); DependencyParser.parseDependenciesFromMultiname(abcIndex, customNamespace, abc, dependencies, abc.constants.getMultiname(type_index), getPackage(abc), fullyQualifiedNames, DependencyType.SIGNATURE, uses); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/Traits.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/Traits.java index 583ba62af..634c51a92 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/Traits.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/Traits.java @@ -33,6 +33,7 @@ import com.jpexs.decompiler.flash.search.MethodId; import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.ScopeStack; +import com.jpexs.helpers.Reference; import java.io.Serializable; import java.util.ArrayList; import java.util.List; @@ -478,9 +479,9 @@ public class Traits implements Cloneable, Serializable { * @param uses Uses * @throws InterruptedException On interrupt */ - public void getDependencies(AbcIndexing abcIndex, int scriptIndex, int classIndex, boolean isStatic, String customNs, ABC abc, List dependencies, DottedChain ignorePackage, List fullyQualifiedNames, List uses) throws InterruptedException { + public void getDependencies(AbcIndexing abcIndex, int scriptIndex, int classIndex, boolean isStatic, String customNs, ABC abc, List dependencies, DottedChain ignorePackage, List fullyQualifiedNames, List uses, Reference numberContextRef) throws InterruptedException { for (Trait t : traits) { - t.getDependencies(abcIndex, scriptIndex, classIndex, isStatic, customNs, abc, dependencies, ignorePackage, fullyQualifiedNames, uses); + t.getDependencies(abcIndex, scriptIndex, classIndex, isStatic, customNs, abc, dependencies, ignorePackage, fullyQualifiedNames, uses, numberContextRef); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/DependencyParser.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/DependencyParser.java index 7bd55ea4f..c243ba858 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/DependencyParser.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/DependencyParser.java @@ -34,6 +34,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.TypeItem; +import com.jpexs.helpers.Reference; import java.util.ArrayList; import java.util.List; @@ -156,9 +157,10 @@ public class DependencyParser { * @param fullyQualifiedNames Fully qualified names * @param visitedMethods Visited methods * @param uses Uses + * @param numberContextRef Number context reference * @throws InterruptedException On interrupt */ - public static void parseDependenciesFromMethodInfo(AbcIndexing abcIndex, Trait trait, int scriptIndex, int classIndex, boolean isStatic, String ignoredCustom, ABC abc, int method_index, List dependencies, DottedChain ignorePackage, List fullyQualifiedNames, List visitedMethods, List uses) throws InterruptedException { + public static void parseDependenciesFromMethodInfo(AbcIndexing abcIndex, Trait trait, int scriptIndex, int classIndex, boolean isStatic, String ignoredCustom, ABC abc, int method_index, List dependencies, DottedChain ignorePackage, List fullyQualifiedNames, List visitedMethods, List uses, Reference numberContextRef) throws InterruptedException { if ((method_index < 0) || (method_index >= abc.method_info.size())) { return; } @@ -174,7 +176,7 @@ public class DependencyParser { MethodBody body = abc.findBody(method_index); if (body != null && body.convertException == null) { body = body.convertMethodBodyCanUseLast(Configuration.autoDeobfuscate.get(), "", isStatic, scriptIndex, classIndex, abc, trait); - body.traits.getDependencies(abcIndex, scriptIndex, classIndex, isStatic, ignoredCustom, abc, dependencies, ignorePackage, fullyQualifiedNames, uses); + body.traits.getDependencies(abcIndex, scriptIndex, classIndex, isStatic, ignoredCustom, abc, dependencies, ignorePackage, fullyQualifiedNames, uses, numberContextRef); for (ABCException ex : body.exceptions) { parseDependenciesFromMultiname(abcIndex, ignoredCustom, abc, dependencies, abc.constants.getMultiname(ex.type_index), ignorePackage, fullyQualifiedNames, DependencyType.EXPRESSION /* or signature?*/, uses); } @@ -189,7 +191,7 @@ public class DependencyParser { if (ins.definition instanceof NewFunctionIns) { if (ins.operands[0] != method_index) { if (!visitedMethods.contains(ins.operands[0])) { - parseDependenciesFromMethodInfo(abcIndex, trait, scriptIndex, classIndex, isStatic, ignoredCustom, abc, ins.operands[0], dependencies, ignorePackage, fullyQualifiedNames, visitedMethods, uses); + parseDependenciesFromMethodInfo(abcIndex, trait, scriptIndex, classIndex, isStatic, ignoredCustom, abc, ins.operands[0], dependencies, ignorePackage, fullyQualifiedNames, visitedMethods, uses, numberContextRef); } } } @@ -226,6 +228,9 @@ public class DependencyParser { parseDependenciesFromMultiname(abcIndex, ignoredCustom, abc, dependencies, abc.constants.getMultiname(m), ignorePackage, fullyQualifiedNames, DependencyType.EXPRESSION, uses); } } + if (ins.definition.operands[k] == AVM2Code.DAT_NUMBER_CONTEXT) { + numberContextRef.setVal(ins.operands[k]); + } } } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/LinkReportExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/LinkReportExporter.java index 6158f0b51..85fb73248 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/LinkReportExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/LinkReportExporter.java @@ -29,6 +29,7 @@ import com.jpexs.decompiler.flash.abc.types.ScriptInfo; import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.abc.types.traits.TraitClass; import com.jpexs.decompiler.graph.DottedChain; +import com.jpexs.helpers.Reference; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; @@ -173,7 +174,7 @@ public class LinkReportExporter { List dependencies = new ArrayList<>(); sb.append(indent(3)).append("").append(newLineChar); //Automatic - tc.getDependencies(swf.getAbcIndex(), scriptIndex, -1, false, null, abc, dependencies, new DottedChain(new String[]{"FAKE!PACKAGE"}), new ArrayList<>(), new ArrayList<>()); + tc.getDependencies(swf.getAbcIndex(), scriptIndex, -1, false, null, abc, dependencies, new DottedChain(new String[]{"FAKE!PACKAGE"}), new ArrayList<>(), new ArrayList<>(), new Reference<>(null)); for (Dependency dependency : dependencies) { DottedChain dc = dependency.getId(); if (!"*".equals(dc.getLast())) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfToSwcExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfToSwcExporter.java index eceadc2e3..6f48e7de6 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfToSwcExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfToSwcExporter.java @@ -30,6 +30,7 @@ import com.jpexs.decompiler.flash.tags.DoABC2Tag; import com.jpexs.decompiler.flash.tags.SymbolClassTag; import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.helpers.Helper; +import com.jpexs.helpers.Reference; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; @@ -166,7 +167,7 @@ public class SwfToSwcExporter { sb.append(" \n"); if (!skipDependencies) { List dependencies = new ArrayList<>(); - pack.abc.script_info.get(pack.scriptIndex).traits.getDependencies(swf.getAbcIndex(), pack.scriptIndex, -1, false, null, pack.abc, dependencies, new DottedChain(new String[]{"NO:PACKAGE"}), new ArrayList<>(), new ArrayList<>()); + pack.abc.script_info.get(pack.scriptIndex).traits.getDependencies(swf.getAbcIndex(), pack.scriptIndex, -1, false, null, pack.abc, dependencies, new DottedChain(new String[]{"NO:PACKAGE"}), new ArrayList<>(), new ArrayList<>(), new Reference<>(null)); for (Dependency d : dependencies) { if ("*".equals(d.getId().getLast())) { diff --git a/libsrc/ffdec_lib/testdata/decimal/bin/decimal.abc b/libsrc/ffdec_lib/testdata/decimal/bin/decimal.abc index 05d4a3878e35cd2d87d6a501da99592601d7c889..45715058a29c1eae9fc633e47c5fe862a0fc062b 100644 GIT binary patch delta 175 zcmeBSKf^vj+>up{hk=2C5sDcOFeq^V*$5zj#%Dz1Gi}s(#S~}ERDAu?<*kjZP01{m zE^mXx?#pI{LReb%@<*hSVo03^BUET(zcR=Z#P