mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-07 10:18:48 +00:00
Fixed #2418 AS3 - initialization of class static vars in script initializer (Haxe)
This commit is contained in:
@@ -107,7 +107,7 @@ public abstract class ActionScript3DecompileTestBase extends ActionScriptTestBas
|
||||
|
||||
List<MethodBody> callStack = new ArrayList<>();
|
||||
callStack.add(abc.bodies.get(bodyIndex));
|
||||
abc.bodies.get(bodyIndex).convert(swf.version, callStack, swf.getAbcIndex(), new ConvertData(), "run", ScriptExportMode.AS, isStatic, abc.bodies.get(bodyIndex).method_info, scriptIndex, clsIndex, abc, null, new ScopeStack(), 0, new NulWriter(), new ArrayList<>(), abc.instance_info.get(clsIndex).instance_traits, true, new HashSet<>());
|
||||
abc.bodies.get(bodyIndex).convert(swf.version, callStack, swf.getAbcIndex(), new ConvertData(), "run", ScriptExportMode.AS, isStatic, abc.bodies.get(bodyIndex).method_info, scriptIndex, clsIndex, abc, null, new ScopeStack(), 0, new NulWriter(), new ArrayList<>(), abc.instance_info.get(clsIndex).instance_traits, true, new HashSet<>(), new ArrayList<>());
|
||||
writer = new HighlightedTextWriter(new CodeFormatting(), false);
|
||||
abc.bodies.get(bodyIndex).toString(swf.version, callStack, swf.getAbcIndex(), "run", ScriptExportMode.AS, abc, null, writer, new ArrayList<>(), new HashSet<>());
|
||||
} catch (InterruptedException ex) {
|
||||
|
||||
@@ -45,6 +45,7 @@ public class ActionScript3ClassTest extends ActionScript3DecompileTestBase {
|
||||
addSwf("standard", "testdata/as3_new/bin/as3_new.flex.swf");
|
||||
addSwf("assembled", "testdata/as3_assembled/bin/as3_assembled.swf");
|
||||
addSwf("getouterscope", "testdata/getouterscope/getouterscope.swf");
|
||||
addSwf("haxe", "testdata/haxe/output.swf");
|
||||
}
|
||||
|
||||
private void decompileScriptPack(String swfId, String path, String expectedResult) {
|
||||
@@ -720,4 +721,31 @@ public class ActionScript3ClassTest extends ActionScript3DecompileTestBase {
|
||||
+ "TestHello;\n"
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHaxeStaticVars() {
|
||||
/*
|
||||
Static vars in Haxe are initialized in script initializer (normal flash uses class initializer)
|
||||
*/
|
||||
decompileScriptPack("haxe", "tests_classes.TestStaticVars", "package tests_classes\n"
|
||||
+ "{\n"
|
||||
+ " public class TestStaticVars\n"
|
||||
+ " {\n"
|
||||
+ " public static var sa:int = 1001;\n"
|
||||
+ " \n"
|
||||
+ " public static var sb:int = 1002;\n"
|
||||
+ " \n"
|
||||
+ " public var b:int;\n"
|
||||
+ " \n"
|
||||
+ " public var a:int;\n"
|
||||
+ " \n"
|
||||
+ " public function TestStaticVars(param1:int, param2:int)\n"
|
||||
+ " {\n"
|
||||
+ " a = param1;\n"
|
||||
+ " b = param2;\n"
|
||||
+ " }\n"
|
||||
+ " }\n"
|
||||
+ "}\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ public class AS3Generator {
|
||||
|
||||
List<MethodBody> callStack = new ArrayList<>();
|
||||
callStack.add(b);
|
||||
b.convert(swf.version, callStack, swf.getAbcIndex(), new ConvertData(), "", ScriptExportMode.AS, false, ((TraitMethodGetterSetter) t).method_info, pack.scriptIndex, classId, abc, null, new ScopeStack(), 0, new NulWriter(), new ArrayList<>(), abc.instance_info.get(classId).instance_traits, true, new HashSet<>());
|
||||
b.convert(swf.version, callStack, swf.getAbcIndex(), new ConvertData(), "", ScriptExportMode.AS, false, ((TraitMethodGetterSetter) t).method_info, pack.scriptIndex, classId, abc, null, new ScopeStack(), 0, new NulWriter(), new ArrayList<>(), abc.instance_info.get(classId).instance_traits, true, new HashSet<>(), new ArrayList<>());
|
||||
b.toString(swf.version, callStack, swf.getAbcIndex(), "", ScriptExportMode.AS, abc, null, src, new ArrayList<>(), new HashSet<>());
|
||||
src.finishHilights();
|
||||
String[] srcs = src.toString().split("[\r\n]+");
|
||||
|
||||
Reference in New Issue
Block a user