diff --git a/CHANGELOG.md b/CHANGELOG.md index 9cd459790..3d45bf7b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -90,6 +90,7 @@ All notable changes to this project will be documented in this file. - [PR194] Default directory for storing config on Linux changed to `~/.config/FFDec`, when `~/.FFDec` does not exist yet - Run/Debug command - executed SWF temp files (`~ffdec_run...swf` etc.) are now generated in the directory where original SWF resides to allow loading relative assets +- [#2228] AS1/2/3 bitwise operations use hexadecimal operands ## [20.1.0] - 2023-12-30 ### Added @@ -3475,6 +3476,7 @@ Major version of SWF to XML export changed to 2. [#2237]: https://www.free-decompiler.com/flash/issues/2237 [#2234]: https://www.free-decompiler.com/flash/issues/2234 [#2206]: https://www.free-decompiler.com/flash/issues/2206 +[#2228]: https://www.free-decompiler.com/flash/issues/2228 [#2100]: https://www.free-decompiler.com/flash/issues/2100 [#2123]: https://www.free-decompiler.com/flash/issues/2123 [#2119]: https://www.free-decompiler.com/flash/issues/2119 diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitAndAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitAndAVM2Item.java index a90502a96..71a3bcd8d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitAndAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitAndAVM2Item.java @@ -24,8 +24,6 @@ import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.TypeItem; -import com.jpexs.decompiler.graph.model.BinaryOpItem; -import com.jpexs.decompiler.graph.model.CompoundableBinaryOp; import java.util.ArrayList; import java.util.List; @@ -33,7 +31,7 @@ import java.util.List; * * @author JPEXS */ -public class BitAndAVM2Item extends BinaryOpItem implements CompoundableBinaryOp { +public class BitAndAVM2Item extends BitwiseBinaryOpAVM2Item { public BitAndAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem leftSide, GraphTargetItem rightSide) { super(instruction, lineStartIns, PRECEDENCE_BITWISEAND, leftSide, rightSide, "&", "Number", "Number"); @@ -62,5 +60,5 @@ public class BitAndAVM2Item extends BinaryOpItem implements CompoundableBinaryOp List ret = new ArrayList<>(); ret.add(new AVM2Instruction(0, AVM2Instructions.BitAnd, null)); return ret; - } + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitNotAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitNotAVM2Item.java index 5f474156f..ddace5206 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitNotAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitNotAVM2Item.java @@ -19,11 +19,14 @@ package com.jpexs.decompiler.flash.abc.avm2.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; +import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.TypeItem; +import com.jpexs.decompiler.graph.model.LocalData; import com.jpexs.decompiler.graph.model.UnaryOpItem; import java.util.List; @@ -54,4 +57,20 @@ public class BitNotAVM2Item extends UnaryOpItem { return TypeItem.INT; //? //return TypeItem.UNBOUNDED; } + + @Override + protected void operandToString(GraphTargetItem operand, GraphTextWriter writer, LocalData localData) throws InterruptedException { + if (operand instanceof IntegerValueAVM2Item) { + Integer val = ((IntegerValueAVM2Item)operand).value; + if (val > 9) { + String valHex = Integer.toHexString(val).toUpperCase(); + if (valHex.length() % 2 == 1) { + valHex = "0" + valHex; + } + writer.append("0x" + valHex); + return; + } + } + operand.toString(writer, localData, ""); + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitOrAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitOrAVM2Item.java index 61c0ae844..ad075b55f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitOrAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitOrAVM2Item.java @@ -24,8 +24,6 @@ import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.TypeItem; -import com.jpexs.decompiler.graph.model.BinaryOpItem; -import com.jpexs.decompiler.graph.model.CompoundableBinaryOp; import java.util.ArrayList; import java.util.List; @@ -33,7 +31,7 @@ import java.util.List; * * @author JPEXS */ -public class BitOrAVM2Item extends BinaryOpItem implements CompoundableBinaryOp { +public class BitOrAVM2Item extends BitwiseBinaryOpAVM2Item { public BitOrAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem leftSide, GraphTargetItem rightSide) { super(instruction, lineStartIns, PRECEDENCE_BITWISEOR, leftSide, rightSide, "|", "Number", "Number"); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitXorAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitXorAVM2Item.java index 391dfd441..66a65da6e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitXorAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitXorAVM2Item.java @@ -24,8 +24,6 @@ import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.TypeItem; -import com.jpexs.decompiler.graph.model.BinaryOpItem; -import com.jpexs.decompiler.graph.model.CompoundableBinaryOp; import java.util.ArrayList; import java.util.List; @@ -33,7 +31,7 @@ import java.util.List; * * @author JPEXS */ -public class BitXorAVM2Item extends BinaryOpItem implements CompoundableBinaryOp { +public class BitXorAVM2Item extends BitwiseBinaryOpAVM2Item { public BitXorAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem leftSide, GraphTargetItem rightSide) { super(instruction, lineStartIns, PRECEDENCE_BITWISEXOR, leftSide, rightSide, "^", "Number", "Number"); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitwiseBinaryOpAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitwiseBinaryOpAVM2Item.java new file mode 100644 index 000000000..a1f674fc3 --- /dev/null +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/BitwiseBinaryOpAVM2Item.java @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2010-2024 JPEXS, All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. + */ +package com.jpexs.decompiler.flash.abc.avm2.model.operations; + +import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.graph.GraphSourceItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.model.BinaryOpItem; +import com.jpexs.decompiler.graph.model.CompoundableBinaryOp; +import com.jpexs.decompiler.graph.model.LocalData; + +/** + * + * @author JPEXS + */ +public abstract class BitwiseBinaryOpAVM2Item extends BinaryOpItem implements CompoundableBinaryOp { + + public BitwiseBinaryOpAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartItem, int precedence, GraphTargetItem leftSide, GraphTargetItem rightSide, String operator, String coerceLeft, String coerceRight) { + super(instruction, lineStartItem, precedence, leftSide, rightSide, operator, coerceLeft, coerceRight); + } + + @Override + protected void operandToString(GraphTargetItem operand, GraphTextWriter writer, LocalData localData) throws InterruptedException { + if (operand instanceof IntegerValueAVM2Item) { + Integer val = ((IntegerValueAVM2Item)operand).value; + if (val > 9) { + String valHex = Integer.toHexString(val).toUpperCase(); + if (valHex.length() % 2 == 1) { + valHex = "0" + valHex; + } + writer.append("0x" + valHex); + return; + } + } + operand.toString(writer, localData, ""); + } +} diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/operations/BitAndActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/operations/BitAndActionItem.java index fcc915fe7..fcc0f634e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/operations/BitAndActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/operations/BitAndActionItem.java @@ -17,7 +17,6 @@ package com.jpexs.decompiler.flash.action.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; -import com.jpexs.decompiler.flash.action.model.CompoundableBinaryOpAs12; import com.jpexs.decompiler.flash.action.swf5.ActionBitAnd; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.CompilationException; @@ -25,7 +24,6 @@ import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.TypeItem; -import com.jpexs.decompiler.graph.model.BinaryOpItem; import java.util.ArrayList; import java.util.List; @@ -33,7 +31,7 @@ import java.util.List; * * @author JPEXS */ -public class BitAndActionItem extends BinaryOpItem implements CompoundableBinaryOpAs12 { +public class BitAndActionItem extends BitwiseBinaryOpActionItem { public BitAndActionItem(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem leftSide, GraphTargetItem rightSide) { super(instruction, lineStartIns, PRECEDENCE_BITWISEAND, leftSide, rightSide, "&", "int", "int"); @@ -63,5 +61,5 @@ public class BitAndActionItem extends BinaryOpItem implements CompoundableBinary List ret = new ArrayList<>(); ret.add(new ActionBitAnd()); return ret; - } + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/operations/BitOrActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/operations/BitOrActionItem.java index 77591bf70..4a3a5fd40 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/operations/BitOrActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/operations/BitOrActionItem.java @@ -17,7 +17,6 @@ package com.jpexs.decompiler.flash.action.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; -import com.jpexs.decompiler.flash.action.model.CompoundableBinaryOpAs12; import com.jpexs.decompiler.flash.action.swf5.ActionBitOr; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.CompilationException; @@ -25,7 +24,6 @@ import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.TypeItem; -import com.jpexs.decompiler.graph.model.BinaryOpItem; import java.util.ArrayList; import java.util.List; @@ -33,7 +31,7 @@ import java.util.List; * * @author JPEXS */ -public class BitOrActionItem extends BinaryOpItem implements CompoundableBinaryOpAs12 { +public class BitOrActionItem extends BitwiseBinaryOpActionItem { public BitOrActionItem(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem leftSide, GraphTargetItem rightSide) { super(instruction, lineStartIns, PRECEDENCE_BITWISEOR, leftSide, rightSide, "|", "int", "int"); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/operations/BitXorActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/operations/BitXorActionItem.java index 1e77dcc6b..f384cfd0c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/operations/BitXorActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/operations/BitXorActionItem.java @@ -17,7 +17,6 @@ package com.jpexs.decompiler.flash.action.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; -import com.jpexs.decompiler.flash.action.model.CompoundableBinaryOpAs12; import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; import com.jpexs.decompiler.flash.action.swf5.ActionBitXor; import com.jpexs.decompiler.flash.ecma.EcmaScript; @@ -27,7 +26,6 @@ import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.TypeItem; -import com.jpexs.decompiler.graph.model.BinaryOpItem; import com.jpexs.decompiler.graph.model.LocalData; import java.util.ArrayList; import java.util.List; @@ -36,7 +34,7 @@ import java.util.List; * * @author JPEXS */ -public class BitXorActionItem extends BinaryOpItem implements CompoundableBinaryOpAs12 { +public class BitXorActionItem extends BitwiseBinaryOpActionItem { public BitXorActionItem(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem leftSide, GraphTargetItem rightSide) { super(instruction, lineStartIns, PRECEDENCE_BITWISEXOR, leftSide, rightSide, "^", "int", "int"); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/operations/BitwiseBinaryOpActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/operations/BitwiseBinaryOpActionItem.java new file mode 100644 index 000000000..e3972c061 --- /dev/null +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/operations/BitwiseBinaryOpActionItem.java @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2010-2024 JPEXS, All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. + */ +package com.jpexs.decompiler.flash.action.model.operations; + +import com.jpexs.decompiler.flash.action.model.CompoundableBinaryOpAs12; +import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.graph.GraphSourceItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.model.BinaryOpItem; +import com.jpexs.decompiler.graph.model.LocalData; + +/** + * + * @author JPEXS + */ +public abstract class BitwiseBinaryOpActionItem extends BinaryOpItem implements CompoundableBinaryOpAs12 { + + public BitwiseBinaryOpActionItem(GraphSourceItem instruction, GraphSourceItem lineStartItem, int precedence, GraphTargetItem leftSide, GraphTargetItem rightSide, String operator, String coerceLeft, String coerceRight) { + super(instruction, lineStartItem, precedence, leftSide, rightSide, operator, coerceLeft, coerceRight); + } + + @Override + protected void operandToString(GraphTargetItem operand, GraphTextWriter writer, LocalData localData) throws InterruptedException { + if ((operand instanceof DirectValueActionItem) && (((DirectValueActionItem)operand).value instanceof Long)) { + long val = (long)(Long)((DirectValueActionItem)operand).value; + if (val > 9) { + String valHex = Long.toHexString(val).toUpperCase(); + if (valHex.length() % 2 == 1) { + valHex = "0" + valHex; + } + writer.append("0x" + valHex); + return; + } + } + operand.toString(writer, localData, ""); + } +} diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/model/BinaryOpItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/model/BinaryOpItem.java index 29b8ced66..b88404aa2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/model/BinaryOpItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/model/BinaryOpItem.java @@ -73,10 +73,10 @@ public abstract class BinaryOpItem extends GraphTargetItem implements BinaryOp { int leftPrecedence = leftSide.getPrecedence(); if (leftPrecedence > precedence && leftPrecedence != GraphTargetItem.NOPRECEDENCE) { writer.append("("); - leftSide.toString(writer, localData, ""); //coerceLeft); + operandToString(leftSide, writer, localData); writer.append(")"); } else { - leftSide.toString(writer, localData, ""); //coerceLeft); + operandToString(leftSide, writer, localData); } writer.append(" "); @@ -86,13 +86,17 @@ public abstract class BinaryOpItem extends GraphTargetItem implements BinaryOp { int rightPrecedence = rightSide.getPrecedence(); if (rightPrecedence >= precedence && rightPrecedence != GraphTargetItem.NOPRECEDENCE) { writer.append("("); - rightSide.toString(writer, localData, ""); //coerceRight); + operandToString(rightSide, writer, localData); writer.append(")"); } else { - rightSide.toString(writer, localData, ""); //coerceRight); + operandToString(rightSide, writer, localData); } return writer; } + + protected void operandToString(GraphTargetItem operand, GraphTextWriter writer, LocalData localData) throws InterruptedException { + operand.toString(writer, localData, ""); + } @Override public List getNeededSources() { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/model/UnaryOpItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/model/UnaryOpItem.java index f67930313..78684bb61 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/model/UnaryOpItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/model/UnaryOpItem.java @@ -53,10 +53,10 @@ public abstract class UnaryOpItem extends GraphTargetItem implements UnaryOp { if (value != null) { if (value.getPrecedence() > precedence) { writer.append("("); - value.toString(writer, localData, ""); //coerce); + operandToString(value, writer, localData); writer.append(")"); } else { - value.toString(writer, localData, ""); //coerce); + operandToString(value, writer, localData); } } else { writer.append("null"); @@ -146,4 +146,8 @@ public abstract class UnaryOpItem extends GraphTargetItem implements UnaryOp { int hash = 3; return hash; } + + protected void operandToString(GraphTargetItem operand, GraphTextWriter writer, LocalData localData) throws InterruptedException { + operand.toString(writer, localData, ""); + } } diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2Test.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2Test.java index 1bf269871..42ad04b7f 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2Test.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2Test.java @@ -2465,4 +2465,17 @@ public class ActionScript2Test extends ActionScript2TestBase { + "trace(\"functionPostIncrementTest\");\r\n" ); } + + @Test + public void frame90_bitwiseOperandsTest() { + compareSrc(90, "trace(\"bitwiseOperandsTest\");\r\n" + + "var a = 100;\r\n" + + "var b = a & 0x08FF;\r\n" + + "var c = 0x08FF & a;\r\n" + + "var d = a | 0x0480;\r\n" + + "var e = 0x0480 | a;\r\n" + + "var f = a ^ 0x0641;\r\n" + + "var g = 0x0641 ^ a;\r\n" + ); + } } diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3AssembledDecompileTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3AssembledDecompileTest.java index 8e98ef381..919a3868c 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3AssembledDecompileTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3AssembledDecompileTest.java @@ -180,8 +180,8 @@ public class ActionScript3AssembledDecompileTest extends ActionScript3DecompileT + "§§push(50);\r\n" + "while(§§dup(§§pop()))\r\n" + "{\r\n" - + "§§dup(§§pop())[§§dup(§§dup(§§pop())).length] = 41 ^ 111;\r\n" - + "§§dup(§§pop())[§§dup(§§dup(§§pop())).length] = 9 ^ 84;\r\n" + + "§§dup(§§pop())[§§dup(§§dup(§§pop())).length] = 0x29 ^ 0x6F;\r\n" + + "§§dup(§§pop())[§§dup(§§dup(§§pop())).length] = 9 ^ 0x54;\r\n" + "§§push(§§pop() - 1);\r\n" + "}\r\n" + "§§pop();\r\n" diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassicAirDecompileTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassicAirDecompileTest.java index 261e6552e..9a2bb9f38 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassicAirDecompileTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassicAirDecompileTest.java @@ -51,6 +51,19 @@ public class ActionScript3ClassicAirDecompileTest extends ActionScript3Decompile false); } + @Test + public void testBitwiseOperands() { + decompileMethod("classic_air", "testBitwiseOperands", "var a:int = 100;\r\n" + + "var b:* = a & 0x08FF;\r\n" + + "var c:* = 0x08FF & a;\r\n" + + "var d:* = a | 0x0480;\r\n" + + "var e:* = 0x0480 | a;\r\n" + + "var f:* = a ^ 0x0641;\r\n" + + "var g:* = 0x0641 ^ a;\r\n" + + "var h:int = -385;\r\n", + false); + } + @Test public void testCallCall() { decompileMethod("classic_air", "testCallCall", "var o:* = new getDefinitionByName(\"Object\");\r\n" diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassicDecompileTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassicDecompileTest.java index 72ee463cc..5edcc7707 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassicDecompileTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassicDecompileTest.java @@ -51,6 +51,19 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes false); } + @Test + public void testBitwiseOperands() { + decompileMethod("classic", "testBitwiseOperands", "var a:int = 100;\r\n" + + "var b:int = a & 0x08FF;\r\n" + + "var c:int = 0x08FF & a;\r\n" + + "var d:int = a | 0x0480;\r\n" + + "var e:int = 0x0480 | a;\r\n" + + "var f:int = a ^ 0x0641;\r\n" + + "var g:int = 0x0641 ^ a;\r\n" + + "var h:int = ~0x0180;\r\n", + false); + } + @Test public void testCallCall() { decompileMethod("classic", "testCallCall", "var o:* = new getDefinitionByName(\"Object\")();\r\n" @@ -182,7 +195,7 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes + "trace(\"arr[call()] /= 5\");\r\n" + "b[this.calc()] = b[this.calc()] / 5;\r\n" + "trace(\"arr[call()][call()] &= 10;\");\r\n" - + "b[this.calc()][this.calc()] = b[this.calc()][this.calc()] & 10;\r\n" + + "b[this.calc()][this.calc()] = b[this.calc()][this.calc()] & 0x0A;\r\n" + "try\r\n" + "{\r\n" + "trace(\"in try\");\r\n" diff --git a/libsrc/ffdec_lib/testdata/as2/as2.swf b/libsrc/ffdec_lib/testdata/as2/as2.swf index be08037ad..b664f2ada 100644 Binary files a/libsrc/ffdec_lib/testdata/as2/as2.swf and b/libsrc/ffdec_lib/testdata/as2/as2.swf differ diff --git a/libsrc/ffdec_lib/testdata/as2/as2/DOMDocument.xml b/libsrc/ffdec_lib/testdata/as2/as2/DOMDocument.xml index 718ca4fbb..93a88d6db 100644 --- a/libsrc/ffdec_lib/testdata/as2/as2/DOMDocument.xml +++ b/libsrc/ffdec_lib/testdata/as2/as2/DOMDocument.xml @@ -31,7 +31,7 @@ - + @@ -3377,6 +3377,20 @@ function myFunc() + + + + + + @@ -3384,6 +3398,9 @@ function myFunc() + + + @@ -3401,8 +3418,5 @@ function myFunc() - - - \ No newline at end of file diff --git a/libsrc/ffdec_lib/testdata/as2/as2/bin/SymDepend.cache b/libsrc/ffdec_lib/testdata/as2/as2/bin/SymDepend.cache index 009e01aac..e8105f01f 100644 Binary files a/libsrc/ffdec_lib/testdata/as2/as2/bin/SymDepend.cache and b/libsrc/ffdec_lib/testdata/as2/as2/bin/SymDepend.cache differ diff --git a/libsrc/ffdec_lib/testdata/as3_new/bin/as3_new.air.swf b/libsrc/ffdec_lib/testdata/as3_new/bin/as3_new.air.swf index bbd14b1f1..6ff7b4b7e 100644 Binary files a/libsrc/ffdec_lib/testdata/as3_new/bin/as3_new.air.swf and b/libsrc/ffdec_lib/testdata/as3_new/bin/as3_new.air.swf differ diff --git a/libsrc/ffdec_lib/testdata/as3_new/bin/as3_new.flex.swf b/libsrc/ffdec_lib/testdata/as3_new/bin/as3_new.flex.swf index 881a8dfd8..6f9000c18 100644 Binary files a/libsrc/ffdec_lib/testdata/as3_new/bin/as3_new.flex.swf and b/libsrc/ffdec_lib/testdata/as3_new/bin/as3_new.flex.swf differ diff --git a/libsrc/ffdec_lib/testdata/as3_new/src/Main.as b/libsrc/ffdec_lib/testdata/as3_new/src/Main.as index 42aea0cdb..3da35cc52 100644 --- a/libsrc/ffdec_lib/testdata/as3_new/src/Main.as +++ b/libsrc/ffdec_lib/testdata/as3_new/src/Main.as @@ -18,6 +18,7 @@ package { TestActivationArguments; TestArguments; + TestBitwiseOperands; TestCallCall; TestCallLocal; TestCatchFinally; diff --git a/libsrc/ffdec_lib/testdata/as3_new/src/tests/TestBitwiseOperands.as b/libsrc/ffdec_lib/testdata/as3_new/src/tests/TestBitwiseOperands.as new file mode 100644 index 000000000..1f961d25d --- /dev/null +++ b/libsrc/ffdec_lib/testdata/as3_new/src/tests/TestBitwiseOperands.as @@ -0,0 +1,18 @@ +package tests +{ + + public class TestBitwiseOperands + { + public function run():* + { + var a:int = 100; + var b:int = a & 0x08ff; + var c:int = 0x08ff & a; + var d:int = a | 0x0480; + var e:int = 0x0480 | a; + var f:int = a ^ 0x0641; + var g:int = 0x0641 ^ a; + var h:int = ~0x0180; + } + } +}