Fixed #1762 AS call on integer numbers parenthesis

This commit is contained in:
Jindra Petřík
2021-12-01 08:44:30 +01:00
parent 2011684b7f
commit 1928962d6f
17 changed files with 65 additions and 8 deletions

View File

@@ -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

View File

@@ -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(")");

View File

@@ -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());

View File

@@ -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());

View File

@@ -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(")");

View File

@@ -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("[");

View File

@@ -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"
);
}
}

View File

@@ -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",

View File

@@ -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",

Binary file not shown.

Binary file not shown.

View File

@@ -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>

View File

@@ -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>

View File

@@ -76,6 +76,7 @@ package
TestMultipleCondition;
TestNamedAnonFunctions;
TestNames;
TestNumberCall;
TestOptionalParameters;
TestParamNames;
TestParamsCount;

View File

@@ -0,0 +1,12 @@
package tests
{
public class TestNumberCall
{
public function run():*
{
var a:String = (5).toString();
var b:String = 5.2.toString();
}
}
}