mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-28 11:35:37 +00:00
Fixed #1769 Missing some body trait variable declaration
This commit is contained in:
@@ -1922,14 +1922,47 @@ public class AVM2Code implements Cloneable {
|
||||
}
|
||||
|
||||
value = value.getNotCoerced();
|
||||
if (!((value instanceof NumberValueAVM2Item)
|
||||
/*if (!((value instanceof NumberValueAVM2Item)
|
||||
|| (value instanceof StringAVM2Item)
|
||||
|| (value instanceof TrueItem)
|
||||
|| (value instanceof FalseItem)
|
||||
|| (value instanceof UndefinedAVM2Item)
|
||||
|| (value instanceof NullAVM2Item)
|
||||
|| (value instanceof NewFunctionAVM2Item)
|
||||
)) {
|
||||
|| (value instanceof NewFunctionAVM2Item))) {
|
||||
break;
|
||||
}*/
|
||||
Reference<Boolean> hasPrevReference = new Reference<>(false);
|
||||
value.visitRecursivelyNoBlock(new AbstractGraphTargetVisitor() {
|
||||
@Override
|
||||
public void visit(GraphTargetItem subItem) {
|
||||
Multiname propertyMultiName;
|
||||
String propertyName;
|
||||
if (subItem instanceof GetPropertyAVM2Item) {
|
||||
GetPropertyAVM2Item propItem = (GetPropertyAVM2Item) subItem;
|
||||
if (propItem.object instanceof FindPropertyAVM2Item) {
|
||||
propertyMultiName = abc.constants.getMultiname(((FullMultinameAVM2Item) propItem.propertyName).multinameIndex);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else if (subItem instanceof GetLexAVM2Item) {
|
||||
GetLexAVM2Item lex = (GetLexAVM2Item) subItem;
|
||||
propertyMultiName = lex.propertyName;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
propertyName = propertyMultiName.getName(abc.constants, new ArrayList<>(), true, true);
|
||||
|
||||
if (traits.containsKey(propertyName)) {
|
||||
Slot sl = new Slot(new NewActivationAVM2Item(null, null), propertyMultiName);
|
||||
if (!paramNames.contains(propertyName)) {
|
||||
if (traits.containsKey(propertyName) && !beginDeclaredSlotsNames.contains(propertyName)) {
|
||||
hasPrevReference.setVal(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
if (hasPrevReference.getVal()) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -1066,10 +1066,9 @@ public class ActionScript3ClassicAirDecompileTest extends ActionScript3Decompile
|
||||
decompileMethod("classic_air", "testInlineFunctions", "var first:String = \"value1\";\r\n"
|
||||
+ "var traceParameter:Function = function(aParam:String):String\r\n"
|
||||
+ "{\r\n"
|
||||
+ "var traceParam2:Function;\r\n"
|
||||
+ "var second:String = \"value2\";\r\n"
|
||||
+ "second = second + \"cc\";\r\n"
|
||||
+ "traceParam2 = function(bParam:String):String\r\n"
|
||||
+ "var traceParam2:Function = function(bParam:String):String\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(bParam + \",\" + aParam);\r\n"
|
||||
+ "return first + second + aParam + bParam;\r\n"
|
||||
@@ -1217,8 +1216,7 @@ public class ActionScript3ClassicAirDecompileTest extends ActionScript3Decompile
|
||||
|
||||
@Test
|
||||
public void testNamedAnonFunctions() {
|
||||
decompileMethod("classic_air", "testNamedAnonFunctions", "var test:*;\r\n"
|
||||
+ "test = new (function():*\r\n"
|
||||
decompileMethod("classic_air", "testNamedAnonFunctions", "var test:* = new (function():*\r\n"
|
||||
+ "{\r\n"
|
||||
+ "var testFunc:Function;\r\n"
|
||||
+ "return testFunc = function(param1:*, param2:int, param3:Array):Boolean\r\n"
|
||||
|
||||
@@ -120,11 +120,9 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes
|
||||
|
||||
@Test
|
||||
public void testCompoundAssignments() {
|
||||
decompileMethod("classic", "testCompoundAssignments", "var b:*;\r\n"
|
||||
+ "var a:int;\r\n"
|
||||
+ "var t:MyTest;\r\n"
|
||||
+ "b = [10,20,30];\r\n"
|
||||
+ "a = 0;\r\n"
|
||||
decompileMethod("classic", "testCompoundAssignments", "var t:MyTest;\r\n"
|
||||
+ "var b:* = [10,20,30];\r\n"
|
||||
+ "var a:int = 0;\r\n"
|
||||
+ "trace(\"a += 5\");\r\n"
|
||||
+ "a += 5;\r\n"
|
||||
+ "trace(\"arr[call()] = arr[call()] + 2;\");\r\n"
|
||||
@@ -393,8 +391,7 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes
|
||||
|
||||
@Test
|
||||
public void testFinallyZeroJump() {
|
||||
decompileMethod("classic", "testFinallyZeroJump", "var str:String;\r\n"
|
||||
+ "str = param1;\r\n"
|
||||
decompileMethod("classic", "testFinallyZeroJump", "var str:String = param1;\r\n"
|
||||
+ "try\r\n"
|
||||
+ "{\r\n"
|
||||
+ "}\r\n"
|
||||
@@ -652,23 +649,18 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes
|
||||
|
||||
@Test
|
||||
public void testForXml() {
|
||||
decompileMethod("classic", "testForXml", "var myXML:XML;\r\n"
|
||||
+ "var k:*;\r\n"
|
||||
+ "var len:int;\r\n"
|
||||
+ "var a:int;\r\n"
|
||||
+ "var b:int;\r\n"
|
||||
+ "var i:int;\r\n"
|
||||
decompileMethod("classic", "testForXml", "var i:int;\r\n"
|
||||
+ "var c:int = 0;\r\n"
|
||||
+ "var name:String = \"ahoj\";\r\n"
|
||||
+ "myXML = <order id=\"604\">\r\n"
|
||||
+ "var myXML:XML = <order id=\"604\">\r\n"
|
||||
+ "<book isbn=\"12345\">\r\n"
|
||||
+ "<title>{name}</title>\r\n"
|
||||
+ "</book>\r\n"
|
||||
+ "</order>;\r\n"
|
||||
+ "k = null;\r\n"
|
||||
+ "len = 5;\r\n"
|
||||
+ "a = 5;\r\n"
|
||||
+ "b = 6;\r\n"
|
||||
+ "var k:* = null;\r\n"
|
||||
+ "var len:int = 5;\r\n"
|
||||
+ "var a:int = 5;\r\n"
|
||||
+ "var b:int = 6;\r\n"
|
||||
+ "for(i = 0; i < len; k = myXML.book.(@isbn == \"12345\"))\r\n"
|
||||
+ "{\r\n"
|
||||
+ "c = 1;\r\n"
|
||||
@@ -903,8 +895,7 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes
|
||||
|
||||
@Test
|
||||
public void testIfFinally() {
|
||||
decompileMethod("classic", "testIfFinally", "var a:int;\r\n"
|
||||
+ "a = Math.random();\r\n"
|
||||
decompileMethod("classic", "testIfFinally", "var a:int = Math.random();\r\n"
|
||||
+ "if(a == 5)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "try\r\n"
|
||||
@@ -1073,11 +1064,10 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes
|
||||
+ "first = \"value1\";\r\n"
|
||||
+ "var traceParameter:Function = function(aParam:String):String\r\n"
|
||||
+ "{\r\n"
|
||||
+ "var traceParam2:Function;\r\n"
|
||||
+ "var second:String = null;\r\n"
|
||||
+ "second = \"value2\";\r\n"
|
||||
+ "second += \"cc\";\r\n"
|
||||
+ "traceParam2 = function(bParam:String):String\r\n"
|
||||
+ "var traceParam2:Function = function(bParam:String):String\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(bParam + \",\" + aParam);\r\n"
|
||||
+ "return first + second + aParam + bParam;\r\n"
|
||||
@@ -1225,8 +1215,7 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes
|
||||
|
||||
@Test
|
||||
public void testNamedAnonFunctions() {
|
||||
decompileMethod("classic", "testNamedAnonFunctions", "var test:*;\r\n"
|
||||
+ "test = new function testFunc(param1:*, param2:int, param3:Array):Boolean\r\n"
|
||||
decompileMethod("classic", "testNamedAnonFunctions", "var test:* = new function testFunc(param1:*, param2:int, param3:Array):Boolean\r\n"
|
||||
+ "{\r\n"
|
||||
+ "return (param1 as TestClass2).attrib1 == 5;\r\n"
|
||||
+ "};\r\n",
|
||||
@@ -1467,8 +1456,7 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes
|
||||
|
||||
@Test
|
||||
public void testTryIf() {
|
||||
decompileMethod("classic", "testTryIf", "var a:int;\r\n"
|
||||
+ "a = Math.random();\r\n"
|
||||
decompileMethod("classic", "testTryIf", "var a:int = Math.random();\r\n"
|
||||
+ "try\r\n"
|
||||
+ "{\r\n"
|
||||
+ "if(a > 5 && a < 50)\r\n"
|
||||
@@ -1561,12 +1549,11 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes
|
||||
|
||||
@Test
|
||||
public void testUndefined() {
|
||||
decompileMethod("classic", "testUndefined", "var f:*;\r\n"
|
||||
+ "var i:int = 0;\r\n"
|
||||
decompileMethod("classic", "testUndefined", "var i:int = 0;\r\n"
|
||||
+ "var j:int = 0;\r\n"
|
||||
+ "var c:int = 0;\r\n"
|
||||
+ "c = 5 + i;\r\n"
|
||||
+ "f = function():*\r\n"
|
||||
+ "var f:* = function():*\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(c);\r\n"
|
||||
+ "trace(j);\r\n"
|
||||
@@ -1714,9 +1701,8 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes
|
||||
|
||||
@Test
|
||||
public void testWhileTry2() {
|
||||
decompileMethod("classic", "testWhileTry2", "var j:*;\r\n"
|
||||
+ "var i:*;\r\n"
|
||||
+ "j = undefined;\r\n"
|
||||
decompileMethod("classic", "testWhileTry2", "var i:*;\r\n"
|
||||
+ "var j:* = undefined;\r\n"
|
||||
+ "for(i = 0; i < 100; i++)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "try\r\n"
|
||||
@@ -1742,20 +1728,17 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes
|
||||
|
||||
@Test
|
||||
public void testXml() {
|
||||
decompileMethod("classic", "testXml", "var myXML:XML;\r\n"
|
||||
+ "var k:*;\r\n"
|
||||
+ "var all:String;\r\n"
|
||||
+ "var g:XML = null;\r\n"
|
||||
decompileMethod("classic", "testXml", "var g:XML = null;\r\n"
|
||||
+ "var testCdata:XML = null;\r\n"
|
||||
+ "var testComment:XML = null;\r\n"
|
||||
+ "var name:String = \"ahoj\";\r\n"
|
||||
+ "myXML = <order id=\"604\">\r\n"
|
||||
+ "var myXML:XML = <order id=\"604\">\r\n"
|
||||
+ "<book isbn=\"12345\">\r\n"
|
||||
+ "<title>{name}</title>\r\n"
|
||||
+ "</book>\r\n"
|
||||
+ "</order>;\r\n"
|
||||
+ "k = myXML.@id;\r\n"
|
||||
+ "all = myXML.@*.toXMLString();\r\n"
|
||||
+ "var k:* = myXML.@id;\r\n"
|
||||
+ "var all:String = myXML.@*.toXMLString();\r\n"
|
||||
+ "k = myXML.book;\r\n"
|
||||
+ "k = myXML.book.(@isbn == \"12345\");\r\n"
|
||||
+ "g = <script>\r\n"
|
||||
|
||||
@@ -96,8 +96,7 @@ public class ActionScript3CrossCompileDecompileTest extends ActionScript3Decompi
|
||||
|
||||
@Test(dataProvider = "swfNamesProvider")
|
||||
public void testTryCatchInIf2(String swfUsed) {
|
||||
decompileMethod(swfUsed, "testTryCatchInIf2", "var a:int;\r\n"
|
||||
+ "a = Math.random();\r\n"
|
||||
decompileMethod(swfUsed, "testTryCatchInIf2", "var a:int = Math.random();\r\n"
|
||||
+ "if(a > 10)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "try\r\n"
|
||||
@@ -516,8 +515,7 @@ public class ActionScript3CrossCompileDecompileTest extends ActionScript3Decompi
|
||||
|
||||
@Test(dataProvider = "swfNamesProvider")
|
||||
public void testTryCatchWith(String swfUsed) {
|
||||
decompileMethod(swfUsed, "testTryCatchWith", "var a:MyTest;\r\n"
|
||||
+ "a = new MyTest();\r\n"
|
||||
decompileMethod(swfUsed, "testTryCatchWith", "var a:MyTest = new MyTest();\r\n"
|
||||
+ "trace(\"before with\");\r\n"
|
||||
+ "with(a)\r\n"
|
||||
+ "{\r\n"
|
||||
@@ -746,8 +744,7 @@ public class ActionScript3CrossCompileDecompileTest extends ActionScript3Decompi
|
||||
|
||||
@Test(dataProvider = "swfNamesProvider")
|
||||
public void testTryFinallyReturnNested(String swfUsed) {
|
||||
decompileMethod(swfUsed, "testTryFinallyReturnNested", "var a:int;\r\n"
|
||||
+ "a = Math.random() * 5;\r\n"
|
||||
decompileMethod(swfUsed, "testTryFinallyReturnNested", "var a:int = Math.random() * 5;\r\n"
|
||||
+ "try\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"before try2\");\r\n"
|
||||
@@ -779,8 +776,7 @@ public class ActionScript3CrossCompileDecompileTest extends ActionScript3Decompi
|
||||
|
||||
@Test(dataProvider = "swfNamesProvider")
|
||||
public void testTryFinallyReturnNested2(String swfUsed) {
|
||||
decompileMethod(swfUsed, "testTryFinallyReturnNested2", "var a:int;\r\n"
|
||||
+ "a = Math.random() * 5;\r\n"
|
||||
decompileMethod(swfUsed, "testTryFinallyReturnNested2", "var a:int = Math.random() * 5;\r\n"
|
||||
+ "try\r\n"
|
||||
+ "{\r\n"
|
||||
+ "try\r\n"
|
||||
@@ -832,8 +828,7 @@ public class ActionScript3CrossCompileDecompileTest extends ActionScript3Decompi
|
||||
|
||||
@Test(dataProvider = "swfNamesProvider")
|
||||
public void testTryFinallyReturnVoid(String swfUsed) {
|
||||
decompileMethod(swfUsed, "testTryFinallyReturnVoid", "var a:int;\r\n"
|
||||
+ "a = Math.random() * 5;\r\n"
|
||||
decompileMethod(swfUsed, "testTryFinallyReturnVoid", "var a:int = Math.random() * 5;\r\n"
|
||||
+ "trace(\"before try\");\r\n"
|
||||
+ "try\r\n"
|
||||
+ "{\r\n"
|
||||
|
||||
Reference in New Issue
Block a user