Fixed #2234 AS1/2 postincrement/decrement inside DefineFunction2

This commit is contained in:
Jindra Petřík
2024-08-01 21:37:16 +02:00
parent 36b6855e27
commit 5fb20268b2
10 changed files with 73 additions and 27 deletions

View File

@@ -78,6 +78,7 @@ All notable changes to this project will be documented in this file.
- FreeTransform not showing in situations like GFX or importAssets
- [#2237] AS3 direct editation - usages of import colliding with toplevel
classes must be fully qualified
- [#2234] AS1/2 postincrement/decrement inside DefineFunction2
### Changed
- [#2185] MochiCrypt no longer offered for auto decrypt, user needs to choose variant from "Use unpacker" menu
@@ -3472,6 +3473,7 @@ Major version of SWF to XML export changed to 2.
[#2253]: https://www.free-decompiler.com/flash/issues/2253
[#2239]: https://www.free-decompiler.com/flash/issues/2239
[#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
[#2100]: https://www.free-decompiler.com/flash/issues/2100
[#2123]: https://www.free-decompiler.com/flash/issues/2123

View File

@@ -25,6 +25,7 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SecondPassData;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.decompiler.graph.model.AnyItem;
import com.jpexs.helpers.utf8.Utf8Helper;
import java.util.HashMap;
import java.util.List;
@@ -59,6 +60,9 @@ public class ActionPop extends Action {
@Override
public void translate(Map<String, Map<String, Trait>> uninitializedClassTraits, SecondPassData secondPassData, boolean insideDoInitAction, GraphSourceItem lineStartAction, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
GraphTargetItem val = stack.pop();
if (val instanceof AnyItem) {
return;
}
output.add(val);
}

View File

@@ -42,6 +42,7 @@ import com.jpexs.decompiler.graph.GraphSourceItemPos;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SecondPassData;
import com.jpexs.decompiler.graph.TranslateStack;
import com.jpexs.decompiler.graph.model.AnyItem;
import com.jpexs.decompiler.graph.model.CompoundableBinaryOp;
import java.io.IOException;
import java.util.HashMap;
@@ -148,7 +149,7 @@ public class ActionStoreRegister extends Action implements StoreTypeAction {
if (!stack.isEmpty() && stack.peek().valueEquals(obj)) {
stack.pop();
stack.push(new PostIncrementActionItem(this, lineStartAction, obj));
stack.push(obj);
stack.push(new AnyItem()); //to avoid leaving popped item on output
return;
}
}
@@ -157,7 +158,7 @@ public class ActionStoreRegister extends Action implements StoreTypeAction {
if (!stack.isEmpty() && stack.peek().valueEquals(obj)) {
stack.pop();
stack.push(new PostDecrementActionItem(this, lineStartAction, obj));
stack.push(obj);
stack.push(new AnyItem()); //to avoid leaving popped item on output
return;
}
}

View File

@@ -2452,4 +2452,17 @@ public class ActionScript2Test extends ActionScript2TestBase {
+ "trace(\"finish\");\r\n"
);
}
@Test
public void frame89_functionPostIncrementTest() {
compareSrc(89, "function myFunc()\r\n"
+ "{\r\n"
+ "var _loc2_ = 0;\r\n"
+ "var _loc1_ = {};\r\n"
+ "var _loc4_ = _loc1_[_loc2_++];\r\n"
+ "var _loc3_ = _loc1_[_loc2_--];\r\n"
+ "}\r\n"
+ "trace(\"functionPostIncrementTest\");\r\n"
);
}
}

Binary file not shown.

View File

@@ -31,7 +31,7 @@
<Include href="Tween 5.xml" itemIcon="1" loadImmediate="false" itemID="60429674-00000289" lastModified="1614976628"/>
</symbols>
<timelines>
<DOMTimeline name="Scene 1" currentFrame="87">
<DOMTimeline name="Scene 1" currentFrame="88">
<layers>
<DOMLayer name="Layer 16" color="#FF4F4F">
<frames>
@@ -761,9 +761,9 @@
</fills>
<edges>
<Edge fillStyle0="1" fillStyle1="2" edges="
!3054 7490[3050 7494 3050 7457!3050 7457[3050 7441 3159 7239!3159 7239[3270 7033 3327 6947!3327 6947[3353 6908 3412 6794!3412 6794[3470 6682 3500 6639!3500 6639[3602 6491 3649 6692!3649 6692|3713 6670!3713 6670[3760 6655 3782 6655!3782
6655[3942 6655 3985 6781!3985 6781[4007 6844 3996 6914!3996 6914[3996 6948 3999 6995!3999 6995[4000 7031 3993 7054!3993 7054[3976 7106 3860 7224!3860 7224[3847 7237 3741 7292!3741 7292[3638 7346 3616 7372!3616 7372[3594 7396 3511 7442
!3511 7442[3435 7483 3427 7483!3427 7483[3409 7483 3407 7468!3407 7468[3405 7453 3386 7453!3386 7453[3361 7468 3330 7483!3330 7483[3270 7512 3235 7512!3235 7512[3220 7512 3156 7501!3156 7501[3091 7490 3054 7490"/>
!3050 7457[3050 7441 3159 7239!3159 7239[3270 7033 3327 6947!3327 6947[3353 6908 3412 6794!3412 6794[3470 6682 3500 6639!3500 6639[3602 6491 3649 6692!3649 6692|3713 6670!3713 6670[3760 6655 3782 6655!3782 6655[3942 6655 3985 6781!3985
6781[4007 6844 3996 6914!3996 6914[3996 6948 3999 6995!3999 6995[4000 7031 3993 7054!3993 7054[3976 7106 3860 7224!3860 7224[3847 7237 3741 7292!3741 7292[3638 7346 3616 7372!3616 7372[3594 7396 3511 7442!3511 7442[3435 7483 3427 7483
!3427 7483[3409 7483 3407 7468!3407 7468[3405 7453 3386 7453!3386 7453[3361 7468 3330 7483!3330 7483[3270 7512 3235 7512!3235 7512[3220 7512 3156 7501!3156 7501[3091 7490 3054 7490!3054 7490[3050 7494 3050 7457"/>
<Edge fillStyle1="1" edges="
!2675 7305[2675 6953 2924 6704!2924 6704[3174 6454 3525 6454!3525 6454[3622 6454 3711 6474!3711 6474[3733 6454 3765 6434!3765 6434[3806 6409 3930 6340!3930 6340[4062 6261 4196 6152!4196 6152[4256 6104 4311 6071!4311 6071[4428 5999 4520
6000!4520 6000[4595 5999 4654 6049!4654 6049[4666 6059 4677 6071!4677 6071[4717 6116 4741 6186!4741 6186[4765 6256 4765 6315!4765 6315[4765 6361 4719 6443!4719 6443[4667 6534 4584 6614!4584 6614[4420 6774 4222 6815!4222 6815[4376 7028
@@ -3364,6 +3364,19 @@ trace("finish");]]></script>
</Actionscript>
<elements/>
</DOMFrame>
<DOMFrame index="88" keyMode="9728">
<Actionscript>
<script><![CDATA[trace("functionPostIncrementTest");
function myFunc()
{
var _loc2_ = 0;
var _loc3_ = {};
var _loc4_ = _loc3_[_loc2_++];
var _loc5_ = _loc3_[_loc2_--];
}]]></script>
</Actionscript>
<elements/>
</DOMFrame>
</frames>
</DOMLayer>
</layers>
@@ -3371,6 +3384,12 @@ trace("finish");]]></script>
</timelines>
<PrinterSettings/>
<publishHistory>
<PublishItem publishSize="108706" publishTime="1722540140"/>
<PublishItem publishSize="108698" publishTime="1722538202"/>
<PublishItem publishSize="108707" publishTime="1722538175"/>
<PublishItem publishSize="108698" publishTime="1722538074"/>
<PublishItem publishSize="108712" publishTime="1722538048"/>
<PublishItem publishSize="108683" publishTime="1722537974"/>
<PublishItem publishSize="108493" publishTime="1710662026"/>
<PublishItem publishSize="1157" publishTime="1710661951"/>
<PublishItem publishSize="1156" publishTime="1710661951"/>
@@ -3385,11 +3404,5 @@ trace("finish");]]></script>
<PublishItem publishSize="107872" publishTime="1638135730"/>
<PublishItem publishSize="107854" publishTime="1638131849"/>
<PublishItem publishSize="107768" publishTime="1638096020"/>
<PublishItem publishSize="107914" publishTime="1638095953"/>
<PublishItem publishSize="107914" publishTime="1638095908"/>
<PublishItem publishSize="107915" publishTime="1638095846"/>
<PublishItem publishSize="107854" publishTime="1638094581"/>
<PublishItem publishSize="107868" publishTime="1638094532"/>
<PublishItem publishSize="107862" publishTime="1638094259"/>
</publishHistory>
</DOMDocument>

View File

@@ -37,23 +37,30 @@
</StrokeStyle>
</strokes>
<edges>
<Edge fillStyle0="1" fillStyle1="2" strokeStyle="1" edges="!7000 0|7000 1000!7000 1000|8000 1000"/>
<Edge fillStyle0="1" strokeStyle="1" edges="!8000 1000|8000 0"/>
<Edge fillStyle0="1" edges="!8000 0|7000 0"/>
<Edge fillStyle0="2" strokeStyle="1" edges="!7000 0|1000 0"/>
<Edge fillStyle0="4" edges="!1000 0|0 0"/>
<Edge fillStyle0="4" strokeStyle="1" edges="!0 0|0 1000"/>
<Edge fillStyle0="4" fillStyle1="2" strokeStyle="1" edges="!0 1000|1000 1000!1000 1000|1000 0"/>
<Edge fillStyle0="1" fillStyle1="2" strokeStyle="1" edges="!7000 0|7000 1000!7000 1000|8000 1000"/>
<Edge fillStyle0="3" fillStyle1="2" strokeStyle="1" edges="!8000 3000|7000 3000!7000 3000|7000 4000"/>
<Edge fillStyle1="2" strokeStyle="1" edges="!7000 4000|1000 4000"/>
<Edge fillStyle1="5" strokeStyle="1" edges="!1000 4000|0 4000!0 4000|0 3000"/>
<Edge fillStyle0="2" fillStyle1="5" strokeStyle="1" edges="!0 3000|1000 3000!1000 3000|1000 4000"/>
<Edge fillStyle1="2" strokeStyle="1" edges="!8000 1000|8000 3000"/>
<Edge fillStyle1="3" strokeStyle="1" edges="!8000 3000|8000 4000!8000 4000|7000 4000"/>
<Edge fillStyle0="3" strokeStyle="1" edges="!7000 4000|8000 4000!8000 4000|8000 3000"/>
<Edge fillStyle0="2" strokeStyle="1" edges="!8000 3000|8000 1000"/>
<Edge fillStyle0="2" fillStyle1="6" strokeStyle="1" edges="!4000 3000[2757 3000 1878 2707!1878 2707[1000 2414 1000 2000!1000 2000[1000 1586 1878 1293!1878 1293[2757 1000 4000 1000!4000 1000[5243 1000 6121 1293!6121 1293[7000 1586 7000 2000!7000 2000[7000 2414 6121 2707!6121 2707[5243 3000 4000
3000"/>
<Edge fillStyle0="4" fillStyle1="2" strokeStyle="1" edges="
!0 1000|1000 1000!1000 1000|1000 0"/>
<Edge fillStyle0="4" edges="
!1000 0|0 0"/>
<Edge fillStyle0="4" strokeStyle="1" edges="
!0 0|0 1000"/>
<Edge fillStyle0="2" strokeStyle="1" edges="
!0 1000|0 3000"/>
<Edge fillStyle0="2" fillStyle1="5" strokeStyle="1" edges="
!0 3000|1000 3000!1000 3000|1000 4000"/>
<Edge fillStyle1="5" strokeStyle="1" edges="
!1000 4000|0 4000!0 4000|0 3000"/>
<Edge fillStyle1="2" strokeStyle="1" edges="
!7000 4000|1000 4000"/>
<Edge fillStyle0="2" strokeStyle="1" edges="
!7000 0|1000 0"/>
</edges>
</DOMShape>
</elements>

View File

@@ -36,8 +36,8 @@ trace("init_blue");
</StrokeStyle>
</strokes>
<edges>
<Edge fillStyle1="1" strokeStyle="1" edges="!1523 825[1642 976 1647 1087!1647 1087[1654 1238 1475 1397!1475 1397[1351 1509 1091 1776!1091 1776[861 2014 767 2089!767 2089[619 2208 569 2155!569 2155[511 2092 568 1787!568 1787|724 930!724 930[464 939 243 859!243 859[50 787 -57 669
!-57 669[-160 555 -134 455!-134 455[-106 348 59 314!59 314[178 288 456 198!456 198[750 102 875 73!875 73[1331 -36 1262 253!1262 253[1226 402 1321 562!1321 562[1336 582 1523 825"/>
<Edge fillStyle1="1" strokeStyle="1" edges="!1262 253[1226 402 1321 562!1321 562[1336 582 1523 825!1523 825[1642 976 1647 1087!1647 1087[1654 1238 1475 1397!1475 1397[1351 1509 1091 1776!1091 1776[861 2014 767 2089!767 2089[619 2208 569 2155!569 2155[511 2092 568 1787!568 1787
|724 930!724 930[464 939 243 859!243 859[50 787 -57 669!-57 669[-160 555 -134 455!-134 455[-106 348 59 314!59 314[178 288 456 198!456 198[750 102 875 73!875 73[1331 -36 1262 253"/>
<Edge cubics="!724 930(;-16,957 -399,411 59,314q724 930Q464 939q243 859Q50 787q-57 669Q-160 555q-134 455Q-106 348q59 314);"/>
<Edge cubics="!59 314(;518,215 1372,-211 1262,253q59 314Q178 288q456 198Q750 102q875 73Q1331 -36q1262 253);"/>
<Edge cubics="!1262 253(;1152,717 1996,929 1475,1397q1262 253Q1226 402q1321 562Q1336 582q1523 825Q1642 976q1647 1087Q1654 1238q1475 1397);"/>

View File

@@ -5,8 +5,8 @@
xmlns:xmp="http://ns.adobe.com/xap/1.0/">
<xmp:CreatorTool>Adobe Flash CS4 Professional</xmp:CreatorTool>
<xmp:CreateDate>2010-08-03T10:48:58+02:00</xmp:CreateDate>
<xmp:MetadataDate>2024-03-17T00:50:46-07:00</xmp:MetadataDate>
<xmp:ModifyDate>2024-03-17T00:50:46-07:00</xmp:ModifyDate>
<xmp:MetadataDate>2024-08-01T11:46:08-07:00</xmp:MetadataDate>
<xmp:ModifyDate>2024-08-01T11:46:08-07:00</xmp:ModifyDate>
</rdf:Description>
<rdf:Description rdf:about=""
xmlns:dc="http://purl.org/dc/elements/1.1/">
@@ -22,7 +22,7 @@
<stRef:originalDocumentID>xmp.did:8DD71700DC9EDF1194ADAC9B23608190</stRef:originalDocumentID>
</xmpMM:DerivedFrom>
<xmpMM:DocumentID>xmp.did:F0EB4FF7CAC3ED11AC9DC078F41E1AA7</xmpMM:DocumentID>
<xmpMM:InstanceID>xmp.iid:7B15281033E4EE1187F5B2EA9E0AA389</xmpMM:InstanceID>
<xmpMM:InstanceID>xmp.iid:D9738656C14FEF119527A7276211BF58</xmpMM:InstanceID>
<xmpMM:OriginalDocumentID>xmp.did:8DD71700DC9EDF1194ADAC9B23608190</xmpMM:OriginalDocumentID>
<xmpMM:History>
<rdf:Seq>
@@ -458,6 +458,12 @@
<stEvt:when>2010-08-03T10:48:58+02:00</stEvt:when>
<stEvt:softwareAgent>Adobe Flash Professional CS6 - build 481</stEvt:softwareAgent>
</rdf:li>
<rdf:li rdf:parseType="Resource">
<stEvt:action>created</stEvt:action>
<stEvt:instanceID>xmp.iid:D9738656C14FEF119527A7276211BF58</stEvt:instanceID>
<stEvt:when>2010-08-03T10:48:58+02:00</stEvt:when>
<stEvt:softwareAgent>Adobe Flash Professional CS6 - build 481</stEvt:softwareAgent>
</rdf:li>
</rdf:Seq>
</xmpMM:History>
</rdf:Description>