mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-22 19:05:36 +00:00
Fixed: AS3 getslot/setslot, getglobalscope instruction
This commit is contained in:
@@ -93,7 +93,7 @@ public abstract class ActionScript3DecompileTestBase extends ActionScriptTestBas
|
||||
|
||||
Configuration.autoDeobfuscate.set(methodName.toLowerCase().contains("obfus"));
|
||||
|
||||
abc.bodies.get(bodyIndex).convert(new ConvertData(), "run", ScriptExportMode.AS, isStatic, abc.bodies.get(bodyIndex).method_info, scriptIndex, clsIndex, abc, null, new ScopeStack(scriptIndex), 0, new NulWriter(), new ArrayList<>(), ts, true);
|
||||
abc.bodies.get(bodyIndex).convert(new ConvertData(), "run", ScriptExportMode.AS, isStatic, abc.bodies.get(bodyIndex).method_info, scriptIndex, clsIndex, abc, null, new ScopeStack(), 0, new NulWriter(), new ArrayList<>(), ts, true);
|
||||
writer = new HighlightedTextWriter(new CodeFormatting(), false);
|
||||
abc.bodies.get(bodyIndex).toString("run", ScriptExportMode.AS, abc, null, writer, new ArrayList<>());
|
||||
} catch (InterruptedException ex) {
|
||||
|
||||
@@ -26,14 +26,15 @@ public class ActionScript3ClassTest extends ActionScript3DecompileTestBase {
|
||||
@BeforeClass
|
||||
public void init() throws IOException, InterruptedException {
|
||||
addSwf("standard", "testdata/as3_new/bin/as3_new.flex.swf");
|
||||
addSwf("assembled", "testdata/as3_assembled/bin/as3_assembled.swf");
|
||||
}
|
||||
|
||||
private void decompileScriptPack(String path, String expectedResult) {
|
||||
private void decompileScriptPack(String swfId, String path, String expectedResult) {
|
||||
|
||||
DoABC2Tag tag = null;
|
||||
ABC abc = null;
|
||||
ScriptPack scriptPack = null;
|
||||
for (Tag t : getSwf("standard").getTags()) {
|
||||
for (Tag t : getSwf(swfId).getTags()) {
|
||||
if (t instanceof DoABC2Tag) {
|
||||
tag = (DoABC2Tag) t;
|
||||
abc = tag.getABC();
|
||||
@@ -59,7 +60,7 @@ public class ActionScript3ClassTest extends ActionScript3DecompileTestBase {
|
||||
|
||||
@Test
|
||||
public void testMyPackage1TestClass() {
|
||||
decompileScriptPack("tests_classes.mypackage1.TestClass", "package tests_classes.mypackage1\n"
|
||||
decompileScriptPack("standard", "tests_classes.mypackage1.TestClass", "package tests_classes.mypackage1\n"
|
||||
+ "{\n"
|
||||
+ " public class TestClass implements tests_classes.mypackage1.TestInterface\n"
|
||||
+ " {\n"
|
||||
@@ -96,7 +97,7 @@ public class ActionScript3ClassTest extends ActionScript3DecompileTestBase {
|
||||
|
||||
@Test
|
||||
public void testMyPackage1TestClass2() {
|
||||
decompileScriptPack("tests_classes.mypackage1.TestClass2", "package tests_classes.mypackage1\n"
|
||||
decompileScriptPack("standard", "tests_classes.mypackage1.TestClass2", "package tests_classes.mypackage1\n"
|
||||
+ "{\n"
|
||||
+ " public class TestClass2\n"
|
||||
+ " {\n"
|
||||
@@ -139,7 +140,7 @@ public class ActionScript3ClassTest extends ActionScript3DecompileTestBase {
|
||||
|
||||
@Test
|
||||
public void testMyPackage1TestInterface() {
|
||||
decompileScriptPack("tests_classes.mypackage1.TestInterface", "package tests_classes.mypackage1\n"
|
||||
decompileScriptPack("standard", "tests_classes.mypackage1.TestInterface", "package tests_classes.mypackage1\n"
|
||||
+ "{\n"
|
||||
+ " public interface TestInterface extends tests_classes.mypackage2.TestInterface\n"
|
||||
+ " {\n"
|
||||
@@ -151,7 +152,7 @@ public class ActionScript3ClassTest extends ActionScript3DecompileTestBase {
|
||||
|
||||
@Test
|
||||
public void testMyPackage1MyNamespace() {
|
||||
decompileScriptPack("tests_classes.mypackage1.myNamespace", "package tests_classes.mypackage1\n"
|
||||
decompileScriptPack("standard", "tests_classes.mypackage1.myNamespace", "package tests_classes.mypackage1\n"
|
||||
+ "{\n"
|
||||
+ " public namespace myNamespace = \"https://www.free-decompiler.com/flash/test/namespace\";\n"
|
||||
+ "}");
|
||||
@@ -159,7 +160,7 @@ public class ActionScript3ClassTest extends ActionScript3DecompileTestBase {
|
||||
|
||||
@Test
|
||||
public void testMyPackage2TestClass() {
|
||||
decompileScriptPack("tests_classes.mypackage2.TestClass", "package tests_classes.mypackage2\n"
|
||||
decompileScriptPack("standard", "tests_classes.mypackage2.TestClass", "package tests_classes.mypackage2\n"
|
||||
+ "{\n"
|
||||
+ " public class TestClass implements TestInterface\n"
|
||||
+ " {\n"
|
||||
@@ -184,7 +185,7 @@ public class ActionScript3ClassTest extends ActionScript3DecompileTestBase {
|
||||
|
||||
@Test
|
||||
public void testMyPackage2TestInterface() {
|
||||
decompileScriptPack("tests_classes.mypackage2.TestInterface", "package tests_classes.mypackage2\n"
|
||||
decompileScriptPack("standard", "tests_classes.mypackage2.TestInterface", "package tests_classes.mypackage2\n"
|
||||
+ "{\n"
|
||||
+ " public interface TestInterface\n"
|
||||
+ " {\n"
|
||||
@@ -196,7 +197,7 @@ public class ActionScript3ClassTest extends ActionScript3DecompileTestBase {
|
||||
|
||||
@Test
|
||||
public void testMyPackage3TestClass() {
|
||||
decompileScriptPack("tests_classes.mypackage3.TestClass", "package tests_classes.mypackage3\n"
|
||||
decompileScriptPack("standard", "tests_classes.mypackage3.TestClass", "package tests_classes.mypackage3\n"
|
||||
+ "{\n"
|
||||
+ " public class TestClass\n"
|
||||
+ " {\n"
|
||||
@@ -217,7 +218,7 @@ public class ActionScript3ClassTest extends ActionScript3DecompileTestBase {
|
||||
|
||||
@Test
|
||||
public void testThisOutsideClass() {
|
||||
decompileScriptPack("tests_classes.TestThisOutsideClass", "package tests_classes\n"
|
||||
decompileScriptPack("standard", "tests_classes.TestThisOutsideClass", "package tests_classes\n"
|
||||
+ "{\n"
|
||||
+ " public class TestThisOutsideClass\n"
|
||||
+ " {\n"
|
||||
@@ -243,4 +244,54 @@ public class ActionScript3ClassTest extends ActionScript3DecompileTestBase {
|
||||
+ " this.attrib++;\n"
|
||||
+ "}");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSlots() {
|
||||
decompileScriptPack("assembled", "tests.TestSlots", "package tests\n"
|
||||
+ "{\n"
|
||||
+ " public class TestSlots\n"
|
||||
+ " {\n"
|
||||
+ " \n"
|
||||
+ " public static var classVar1:String = \"cls1\";\n"
|
||||
+ " \n"
|
||||
+ " public static var classVar2:String = \"cls2\";\n"
|
||||
+ " \n"
|
||||
+ " \n"
|
||||
+ " public var instanceVar1:String = \"ins1\";\n"
|
||||
+ " \n"
|
||||
+ " public var instanceVar2:String = \"ins2\";\n"
|
||||
+ " \n"
|
||||
+ " public function TestSlots()\n"
|
||||
+ " {\n"
|
||||
+ " super();\n"
|
||||
+ " }\n"
|
||||
+ " \n"
|
||||
+ " public static function classMethod() : void\n"
|
||||
+ " {\n"
|
||||
+ " trace(classVar1);\n"
|
||||
+ " trace(classVar2);\n"
|
||||
+ " trace(globalVar1);\n"
|
||||
+ " trace(globalVar2);\n"
|
||||
+ " }\n"
|
||||
+ " \n"
|
||||
+ " public function instanceMethod() : void\n"
|
||||
+ " {\n"
|
||||
+ " trace(instanceVar1);\n"
|
||||
+ " trace(instanceVar2);\n"
|
||||
+ " trace(globalVar1);\n"
|
||||
+ " trace(globalVar2);\n"
|
||||
+ " }\n"
|
||||
+ " }\n"
|
||||
+ "}\n"
|
||||
+ "\n"
|
||||
+ "var globalVar1:String = \"glb1\";\n"
|
||||
+ "\n"
|
||||
+ "var globalVar2:String = \"glb2\";\n"
|
||||
+ "\n"
|
||||
+ "function globalFunction():void\n"
|
||||
+ "{\n"
|
||||
+ " trace(globalVar1);\n"
|
||||
+ " trace(globalVar2);\n"
|
||||
+ "}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -880,6 +880,18 @@ public class ActionScript3ClassicAirDecompileTest extends ActionScript3Decompile
|
||||
false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInnerFunctionScope() {
|
||||
decompileMethod("classic_air", "testInnerFunctionScope", "a = a;\r\n"
|
||||
+ "var innerFunc:Function = function(b:String):*\r\n"
|
||||
+ "{\r\n"
|
||||
+ "testProm = 4;\r\n"
|
||||
+ "trace(testProm);\r\n"
|
||||
+ "};\r\n"
|
||||
+ "innerFunc(a);\r\n",
|
||||
false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInnerFunctions() {
|
||||
decompileMethod("classic_air", "testInnerFunctions", "a = a;\r\n"
|
||||
|
||||
@@ -874,6 +874,17 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes
|
||||
false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInnerFunctionScope() {
|
||||
decompileMethod("classic", "testInnerFunctionScope", "var innerFunc:Function = function(b:String):*\r\n"
|
||||
+ "{\r\n"
|
||||
+ "testProm = 4;\r\n"
|
||||
+ "trace(testProm);\r\n"
|
||||
+ "};\r\n"
|
||||
+ "innerFunc(a);\r\n",
|
||||
false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInnerFunctions() {
|
||||
decompileMethod("classic", "testInnerFunctions", "var s:int = 0;\r\n"
|
||||
|
||||
@@ -417,15 +417,16 @@ public class ActionScript3CrossCompileDecompileTest extends ActionScript3Decompi
|
||||
+ "trace(\"in catch1\");\r\n"
|
||||
+ "while(true)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"xx\");\r\n"
|
||||
+ "if(a > 5)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "break;\r\n"
|
||||
+ "}\r\n"
|
||||
+ "trace(\"yy\");\r\n"
|
||||
+ "}\r\n"
|
||||
+ "trace(\"in catch1c\");\r\n"
|
||||
+ "}\r\n"
|
||||
+ "}\r\n"
|
||||
+ "trace(\"after\");\r\n",
|
||||
+ "}\r\n",
|
||||
false);
|
||||
}
|
||||
|
||||
|
||||
@@ -408,15 +408,16 @@ public class ActionScript3CrossCompileSwfToolsDecompileTest extends ActionScript
|
||||
+ "trace(\"in catch1\");\r\n"
|
||||
+ "while(true)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"xx\");\r\n"
|
||||
+ "if(_loc1_ > 5)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "break;\r\n"
|
||||
+ "}\r\n"
|
||||
+ "trace(\"yy\");\r\n"
|
||||
+ "}\r\n"
|
||||
+ "trace(\"in catch1c\");\r\n"
|
||||
+ "}\r\n"
|
||||
+ "}\r\n"
|
||||
+ "trace(\"after\");\r\n",
|
||||
+ "}\r\n",
|
||||
false);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user