mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-29 05:16:43 +00:00
Fixed #1888 String casts - ConvertS on XML, XMLList
This commit is contained in:
@@ -13,6 +13,7 @@ All notable changes to this project will be documented in this file.
|
||||
- DottedChain.PathPart NoSerializable exception
|
||||
- [#1951] Clearing Namespace/Multiname cache after renaming identifiers
|
||||
- [#1951] Renaming invalid identifiers with existing string collisions
|
||||
- [#1888] String casts - ConvertS on XML, XMLList
|
||||
|
||||
## [18.3.3] - 2023-01-22
|
||||
### Added
|
||||
|
||||
@@ -242,6 +242,10 @@ public class GetPropertyIns extends InstructionDefinition {
|
||||
//TODO: handle method calls to return proper param type results
|
||||
}
|
||||
}
|
||||
if (localData.abc.constants.getMultiname(multiname.multinameIndex).isAttribute()) {
|
||||
type.setVal(new TypeItem("XMLList"));
|
||||
return;
|
||||
}
|
||||
if (receiverType.equals(new TypeItem("XMLList"))) {
|
||||
if (multiname.name != null && multiname.name.returnType().equals(TypeItem.INT)) {
|
||||
type.setVal(new TypeItem("XML"));
|
||||
|
||||
@@ -77,8 +77,8 @@ public class ConvertAVM2Item extends AVM2Item {
|
||||
break;
|
||||
case "String":
|
||||
displayConvert = !valueReturnType.equals(TypeItem.STRING)
|
||||
&& !valueReturnType.equals(new TypeItem("XML"))
|
||||
&& !valueReturnType.equals(new TypeItem("XMLList"))
|
||||
//&& !valueReturnType.equals(new TypeItem("XML"))
|
||||
//&& !valueReturnType.equals(new TypeItem("XMLList"))
|
||||
&& !valueReturnType.equals(new TypeItem("null"))
|
||||
&& !valueReturnType.equals(TypeItem.UNBOUNDED);
|
||||
break;
|
||||
|
||||
@@ -245,18 +245,14 @@ public class ActionScript3ClassicAirDecompileTest extends ActionScript3Decompile
|
||||
|
||||
@Test
|
||||
public void testConvert() {
|
||||
decompileMethod("classic_air", "testConvert", "var a:*;\r\n"
|
||||
+ "var o:Object;\r\n"
|
||||
+ "var v:Vector.<String>;\r\n"
|
||||
+ "var x:XML;\r\n"
|
||||
+ "var xlist:XMLList;\r\n"
|
||||
+ "var lc:LocalClass;\r\n"
|
||||
+ "var f:Function;\r\n"
|
||||
+ "var d:Number;\r\n"
|
||||
+ "var s:String = \"a\";\r\n"
|
||||
+ "var i:int = int(s);\r\n"
|
||||
+ "var j:int = n;\r\n"
|
||||
+ "s = String(j);\r\n"
|
||||
decompileMethod("classic_air", "testConvert", "var s:String = null;\r\n"
|
||||
+ "var i:int = 0;\r\n"
|
||||
+ "var a:* = undefined;\r\n"
|
||||
+ "var dict:Dictionary = new Dictionary();\r\n"
|
||||
+ "s = \"a\";\r\n"
|
||||
+ "i = int(s);\r\n"
|
||||
+ "var j:int;\r\n"
|
||||
+ "s = String(j = n);\r\n"
|
||||
+ "s = ns;\r\n"
|
||||
+ "s = String(i == 4 ? \"\" : i);\r\n"
|
||||
+ "s = i == 4 ? \"\" : String(i);\r\n"
|
||||
@@ -265,14 +261,14 @@ public class ActionScript3ClassicAirDecompileTest extends ActionScript3Decompile
|
||||
+ "i = 4 * 5;\r\n"
|
||||
+ "i = a * 6;\r\n"
|
||||
+ "i = a;\r\n"
|
||||
+ "o = {\r\n"
|
||||
+ "var o:Object = {\r\n"
|
||||
+ "0:\"A\",\r\n"
|
||||
+ "1:\"B\",\r\n"
|
||||
+ "2:\"C\"\r\n"
|
||||
+ "};\r\n"
|
||||
+ "i = int(s.charAt(10));\r\n"
|
||||
+ "v = new Vector.<String>();\r\n"
|
||||
+ "v.push(\"A\");\r\n"
|
||||
+ "var v:Vector.<String>;\r\n"
|
||||
+ "(v = new Vector.<String>()).push(\"A\");\r\n"
|
||||
+ "v.push(\"B\");\r\n"
|
||||
+ "i = int(v[0]);\r\n"
|
||||
+ "s = v[1];\r\n"
|
||||
@@ -283,25 +279,24 @@ public class ActionScript3ClassicAirDecompileTest extends ActionScript3Decompile
|
||||
+ "i = sprot;\r\n"
|
||||
+ "s = String(sprot);\r\n"
|
||||
+ "s = String(getTimer());\r\n"
|
||||
+ "x = <list>\r\n"
|
||||
+ "var x:XML;\r\n"
|
||||
+ "s = x = <list>\r\n"
|
||||
+ "<item id=\"1\">1</item>\r\n"
|
||||
+ "<item id=\"2\">2</item>\r\n"
|
||||
+ "<item id=\"3\">3</item>\r\n"
|
||||
+ "</list>;\r\n"
|
||||
+ "s = x;\r\n"
|
||||
+ "trace(\"a\");\r\n"
|
||||
+ "xlist = x.item;\r\n"
|
||||
+ "var xlist:XMLList = x.item;\r\n"
|
||||
+ "trace(\"b\");\r\n"
|
||||
+ "i = int(xlist[i].@id);\r\n"
|
||||
+ "trace(\"c\");\r\n"
|
||||
+ "i = int(x.item[i].@id);\r\n"
|
||||
+ "lc = new LocalClass();\r\n"
|
||||
+ "i = lc.attr;\r\n"
|
||||
+ "dict[String(x.item[i].@id)] = \"Hello\";\r\n"
|
||||
+ "var lc:LocalClass;\r\n"
|
||||
+ "i = (lc = new LocalClass()).attr;\r\n"
|
||||
+ "s = String(lc.attr);\r\n"
|
||||
+ "f = function():void\r\n"
|
||||
+ "{\r\n"
|
||||
+ "};\r\n"
|
||||
+ "if(Boolean(f))\r\n"
|
||||
+ "var f:Function;\r\n"
|
||||
+ "if(Boolean(f = this.f))\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"OK\");\r\n"
|
||||
+ "}\r\n"
|
||||
@@ -318,7 +313,7 @@ public class ActionScript3ClassicAirDecompileTest extends ActionScript3Decompile
|
||||
+ "trace(\"obj\");\r\n"
|
||||
+ "}\r\n"
|
||||
+ "s = xlist;\r\n"
|
||||
+ "d = 0;\r\n"
|
||||
+ "var d:Number = 0;\r\n"
|
||||
+ "d = 1;\r\n"
|
||||
+ "d = 1.5;\r\n"
|
||||
+ "i = 1;\r\n"
|
||||
|
||||
@@ -244,14 +244,10 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes
|
||||
|
||||
@Test
|
||||
public void testConvert() {
|
||||
decompileMethod("classic", "testConvert", "var x:XML;\r\n"
|
||||
+ "var xlist:XMLList;\r\n"
|
||||
+ "var lc:LocalClass;\r\n"
|
||||
+ "var f:Function;\r\n"
|
||||
+ "var d:Number;\r\n"
|
||||
+ "var s:String = null;\r\n"
|
||||
decompileMethod("classic", "testConvert", "var s:String = null;\r\n"
|
||||
+ "var i:int = 0;\r\n"
|
||||
+ "var a:* = undefined;\r\n"
|
||||
+ "var dict:Dictionary = new Dictionary();\r\n"
|
||||
+ "s = \"a\";\r\n"
|
||||
+ "i = int(s);\r\n"
|
||||
+ "var j:int = this.n;\r\n"
|
||||
@@ -282,24 +278,23 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes
|
||||
+ "i = sprot;\r\n"
|
||||
+ "s = String(sprot);\r\n"
|
||||
+ "s = String(getTimer());\r\n"
|
||||
+ "x = <list>\r\n"
|
||||
+ "var x:XML = <list>\r\n"
|
||||
+ "<item id=\"1\">1</item>\r\n"
|
||||
+ "<item id=\"2\">2</item>\r\n"
|
||||
+ "<item id=\"3\">3</item>\r\n"
|
||||
+ "</list>;\r\n"
|
||||
+ "s = x;\r\n"
|
||||
+ "trace(\"a\");\r\n"
|
||||
+ "xlist = x.item;\r\n"
|
||||
+ "var xlist:XMLList = x.item;\r\n"
|
||||
+ "trace(\"b\");\r\n"
|
||||
+ "i = int(xlist[i].@id);\r\n"
|
||||
+ "trace(\"c\");\r\n"
|
||||
+ "i = int(x.item[i].@id);\r\n"
|
||||
+ "lc = new LocalClass();\r\n"
|
||||
+ "dict[String(x.item[i].@id)] = \"Hello\";\r\n"
|
||||
+ "var lc:LocalClass = new LocalClass();\r\n"
|
||||
+ "i = lc.attr;\r\n"
|
||||
+ "s = String(lc.attr);\r\n"
|
||||
+ "f = function():void\r\n"
|
||||
+ "{\r\n"
|
||||
+ "};\r\n"
|
||||
+ "var f:Function = this.f;\r\n"
|
||||
+ "if(Boolean(f))\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"OK\");\r\n"
|
||||
@@ -317,7 +312,7 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes
|
||||
+ "trace(\"obj\");\r\n"
|
||||
+ "}\r\n"
|
||||
+ "s = xlist;\r\n"
|
||||
+ "d = 0;\r\n"
|
||||
+ "var d:Number = 0;\r\n"
|
||||
+ "d = 1;\r\n"
|
||||
+ "d = 1.5;\r\n"
|
||||
+ "i = 1;\r\n"
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -2,6 +2,7 @@ package tests
|
||||
{
|
||||
import tests_classes.TestConvertParent;
|
||||
import flash.utils.getTimer;
|
||||
import flash.utils.Dictionary;
|
||||
|
||||
public class TestConvert extends TestConvertParent
|
||||
{
|
||||
@@ -12,10 +13,13 @@ package tests
|
||||
|
||||
public var TEST:int = 5;
|
||||
|
||||
private var f:Function = null;
|
||||
|
||||
public function run():void
|
||||
{
|
||||
var s:String;
|
||||
var i:int;
|
||||
var i:int;
|
||||
var dict:Dictionary = new Dictionary();
|
||||
s = "a";
|
||||
i = int(s);
|
||||
var j:int = n;
|
||||
@@ -69,13 +73,15 @@ package tests
|
||||
i = int(xlist[i].@id);
|
||||
trace("c");
|
||||
i = int(x.item[i].@id);
|
||||
|
||||
dict[String(x.item[i].@id)] = "Hello";
|
||||
|
||||
var lc:LocalClass = new LocalClass();
|
||||
i = lc.attr;
|
||||
s = String(lc.attr);
|
||||
|
||||
|
||||
var f:Function = function():void {};
|
||||
var f:Function = this.f;
|
||||
if (Boolean(f)) {
|
||||
trace("OK");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user