Fixed #2231 AS3 coercion to String as convert

This commit is contained in:
Jindra Petřík
2024-07-13 19:55:09 +02:00
parent e1cbba7146
commit 502d44b06d
8 changed files with 34 additions and 2 deletions

View File

@@ -42,6 +42,7 @@ All notable changes to this project will be documented in this file.
- [#2222] Missing shapes when gradient fillstyle has only two gradrecords with the same ratio
- [#2224] Exporting Embed assets - handling DefineBits(+JPEGTables) - convert to DefineBitsJPEG2
- [PR191] Saving class name during AS3 P-code class trait editation
- [#2231] AS3 coercion to String as convert
### Changed
- [#2185] MochiCrypt no longer offered for auto decrypt, user needs to choose variant from "Use unpacker" menu
@@ -3410,6 +3411,7 @@ Major version of SWF to XML export changed to 2.
[#2202]: https://www.free-decompiler.com/flash/issues/2202
[#2222]: https://www.free-decompiler.com/flash/issues/2222
[#2224]: https://www.free-decompiler.com/flash/issues/2224
[#2231]: https://www.free-decompiler.com/flash/issues/2231
[#2206]: https://www.free-decompiler.com/flash/issues/2206
[#2100]: https://www.free-decompiler.com/flash/issues/2100
[#2123]: https://www.free-decompiler.com/flash/issues/2123

View File

@@ -88,11 +88,12 @@ public class CoerceAVM2Item extends AVM2Item {
}
break;
case "String":
displayCoerce = !valueReturnType.equals(TypeItem.STRING)
/*displayCoerce = !valueReturnType.equals(TypeItem.STRING)
&& !valueReturnType.equals(new TypeItem("XML"))
&& !valueReturnType.equals(new TypeItem("XMLList"))
&& !valueReturnType.equals(new TypeItem("null"))
&& !valueReturnType.equals(TypeItem.UNBOUNDED);
&& !valueReturnType.equals(TypeItem.UNBOUNDED);*/
displayCoerce = false;
break;
default:
displayCoerce = false;

View File

@@ -1770,6 +1770,13 @@ public class ActionScript3ClassicAirDecompileTest extends ActionScript3Decompile
false);
}
@Test
public void testStringCoerce() {
decompileMethod("classic_air", "testStringCoerce", "var text1:String = this.a[\"test\"];\r\n"
+ "var text2:String = String(this.a[\"test\"]);\r\n",
false);
}
@Test
public void testStringConcat() {
decompileMethod("classic_air", "testStringConcat", "var k:int = 8;\r\n"

View File

@@ -1757,6 +1757,13 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes
false);
}
@Test
public void testStringCoerce() {
decompileMethod("classic", "testStringCoerce", "var text1:String = this.a[\"test\"];\r\n"
+ "var text2:String = String(this.a[\"test\"]);\r\n",
false);
}
@Test
public void testStringConcat() {
decompileMethod("classic", "testStringConcat", "var k:int = 8;\r\n"

View File

@@ -107,6 +107,7 @@ package
TestSlots;
TestSlots2;
TestStrictEquals;
TestStringCoerce;
TestStringConcat;
TestStrings;
TestSwitch;

View File

@@ -0,0 +1,14 @@
package tests
{
public class TestStringCoerce
{
var a:Object = null;
public function run():*
{
var text1:String = this.a["test"];
var text2:String = String(this.a["test"]);
}
}
}