mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-01 05:43:04 +00:00
Fixed #1762 AS call on integer numbers parenthesis
This commit is contained in:
@@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file.
|
||||
|
||||
### Fixed
|
||||
- [#1761] AS3 - try..finally inside another structure like if
|
||||
- [#1762] AS call on integer numbers parenthesis
|
||||
|
||||
## [15.0.0] - 2021-11-29
|
||||
### Added
|
||||
@@ -2321,6 +2322,7 @@ All notable changes to this project will be documented in this file.
|
||||
[alpha 8]: https://github.com/jindrapetrik/jpexs-decompiler/compare/alpha7...alpha8
|
||||
[alpha 7]: https://github.com/jindrapetrik/jpexs-decompiler/releases/tag/alpha7
|
||||
[#1761]: https://www.free-decompiler.com/flash/issues/1761
|
||||
[#1762]: https://www.free-decompiler.com/flash/issues/1762
|
||||
[#1750]: https://www.free-decompiler.com/flash/issues/1750
|
||||
[#1485]: https://www.free-decompiler.com/flash/issues/1485
|
||||
[#1681]: https://www.free-decompiler.com/flash/issues/1681
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.avm2.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.IdentifiersDeobfuscation;
|
||||
@@ -89,7 +90,7 @@ public abstract class AVM2Item extends GraphTargetItem {
|
||||
}
|
||||
|
||||
if (!empty && object != null) {
|
||||
if (!empty && object != null) {
|
||||
if (object.getPrecedence() > PRECEDENCE_PRIMARY || (object instanceof IntegerValueAVM2Item)) {
|
||||
writer.append("(");
|
||||
object.toString(writer, localData);
|
||||
writer.append(")");
|
||||
|
||||
@@ -52,7 +52,13 @@ public class CallMethodAVM2Item extends AVM2Item {
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
receiver.toString(writer, localData);
|
||||
if (receiver.getPrecedence() > getPrecedence() || (receiver instanceof IntegerValueAVM2Item)) {
|
||||
writer.append("(");
|
||||
receiver.toString(writer, localData);
|
||||
writer.append(")");
|
||||
} else {
|
||||
receiver.toString(writer, localData);
|
||||
}
|
||||
writer.append(".");
|
||||
writer.append(methodName);
|
||||
writer.spaceBeforeCallParenthesies(arguments.size());
|
||||
|
||||
@@ -52,7 +52,13 @@ public class CallStaticAVM2Item extends AVM2Item {
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
receiver.toString(writer, localData);
|
||||
if (receiver.getPrecedence() > getPrecedence() || (receiver instanceof IntegerValueAVM2Item)) {
|
||||
writer.append("(");
|
||||
receiver.toString(writer, localData);
|
||||
writer.append(")");
|
||||
} else {
|
||||
receiver.toString(writer, localData);
|
||||
}
|
||||
writer.append(".");
|
||||
writer.append(methodName);
|
||||
writer.spaceBeforeCallParenthesies(arguments.size());
|
||||
|
||||
@@ -71,7 +71,8 @@ public class CallMethodActionItem extends ActionItem {
|
||||
}
|
||||
|
||||
if (!blankMethod) {
|
||||
if (scriptObject.getPrecedence() > this.precedence) {
|
||||
if (scriptObject.getPrecedence() > this.precedence
|
||||
|| ((scriptObject instanceof DirectValueActionItem) && (((DirectValueActionItem) scriptObject).value instanceof Long))) {
|
||||
writer.append("(");
|
||||
scriptObject.toString(writer, localData);
|
||||
writer.append(")");
|
||||
|
||||
@@ -91,7 +91,13 @@ public class SetMemberActionItem extends ActionItem implements SetTypeActionItem
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
|
||||
object.toString(writer, localData);
|
||||
if (((object instanceof DirectValueActionItem) && (((DirectValueActionItem) object).value instanceof Long))) {
|
||||
writer.append("(");
|
||||
object.toString(writer, localData);
|
||||
writer.append(")");
|
||||
} else {
|
||||
object.toString(writer, localData);
|
||||
}
|
||||
|
||||
if ((!(objectName instanceof DirectValueActionItem)) || (!((DirectValueActionItem) objectName).isString()) || (!IdentifiersDeobfuscation.isValidName(false, ((DirectValueActionItem) objectName).toStringNoQuotes(localData)))) {
|
||||
writer.append("[");
|
||||
|
||||
@@ -2385,4 +2385,12 @@ public class ActionScript2Test extends ActionScript2TestBase {
|
||||
+ "trace(\"after\");\r\n"
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void frame85_numbersCallTest() {
|
||||
compareSrc(85, "trace(\"numbersCallTest\");\r\n"
|
||||
+ "var a = (5).toString();\r\n"
|
||||
+ "var b = 5.2.toString();\r\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1214,6 +1214,13 @@ public class ActionScript3ClassicAirDecompileTest extends ActionScript3Decompile
|
||||
false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNumberCall() {
|
||||
decompileMethod("classic_air", "testNumberCall", "var a:String = (5).toString();\r\n"
|
||||
+ "var b:String = 5.2.toString();\r\n",
|
||||
false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParamNames() {
|
||||
decompileMethod("classic_air", "testParamNames", "return firstp + secondp + thirdp;\r\n",
|
||||
|
||||
@@ -1204,6 +1204,13 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes
|
||||
false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNumberCall() {
|
||||
decompileMethod("classic", "testNumberCall", "var a:String = (5).toString();\r\n"
|
||||
+ "var b:String = 5.2.toString();\r\n",
|
||||
false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParamNames() {
|
||||
decompileMethod("classic", "testParamNames", "return firstp + secondp + thirdp;\r\n",
|
||||
|
||||
BIN
libsrc/ffdec_lib/testdata/as2/as2.fla
vendored
BIN
libsrc/ffdec_lib/testdata/as2/as2.fla
vendored
Binary file not shown.
BIN
libsrc/ffdec_lib/testdata/as2/as2.swf
vendored
BIN
libsrc/ffdec_lib/testdata/as2/as2.swf
vendored
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -16,7 +16,7 @@
|
||||
</define>
|
||||
<define append="true">
|
||||
<name>CONFIG::timeStamp</name>
|
||||
<value>'13.03.2021'</value>
|
||||
<value>'01.12.2021'</value>
|
||||
</define>
|
||||
<define append="true">
|
||||
<name>CONFIG::air</name>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
</define>
|
||||
<define append="true">
|
||||
<name>CONFIG::timeStamp</name>
|
||||
<value>'30.11.2021'</value>
|
||||
<value>'01.12.2021'</value>
|
||||
</define>
|
||||
<define append="true">
|
||||
<name>CONFIG::air</name>
|
||||
|
||||
@@ -76,6 +76,7 @@ package
|
||||
TestMultipleCondition;
|
||||
TestNamedAnonFunctions;
|
||||
TestNames;
|
||||
TestNumberCall;
|
||||
TestOptionalParameters;
|
||||
TestParamNames;
|
||||
TestParamsCount;
|
||||
|
||||
12
libsrc/ffdec_lib/testdata/as3_new/src/tests/TestNumberCall.as
vendored
Normal file
12
libsrc/ffdec_lib/testdata/as3_new/src/tests/TestNumberCall.as
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
package tests
|
||||
{
|
||||
|
||||
public class TestNumberCall
|
||||
{
|
||||
public function run():*
|
||||
{
|
||||
var a:String = (5).toString();
|
||||
var b:String = 5.2.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user