Fixed: AS3 break loop in catch clause

This commit is contained in:
Jindra Petřík
2021-02-09 18:33:26 +01:00
parent 1b505080de
commit a97f57c40f
27 changed files with 653 additions and 39 deletions

View File

@@ -22,5 +22,6 @@ program
#include "tests/TestSwitchJoin.script.asasm"
#include "tests/TestDeobfuscatorJumpsExceptionStart.script.asasm"
#include "tests/TestUnnamedException.script.asasm"
#include "tests/TestTryCatchLoopBreakLevel2.script.asasm"
; place to add next
end ; program

View File

@@ -0,0 +1,139 @@
class
refid "tests:TestTryCatchLoopBreakLevel2"
instance QName(PackageNamespace("tests"), "TestTryCatchLoopBreakLevel2")
extends QName(PackageNamespace(""), "Object")
flag SEALED
flag PROTECTEDNS
protectedns ProtectedNamespace("tests:TestTryCatchLoopBreakLevel2")
iinit
refid "tests:TestTryCatchLoopBreakLevel2/instance/init"
body
maxstack 1
localcount 1
initscopedepth 4
maxscopedepth 5
code
getlocal0
pushscope
getlocal0
constructsuper 0
returnvoid
end ; code
end ; body
end ; method
trait method QName(PackageNamespace(""), "run")
method
refid "tests:TestTryCatchLoopBreakLevel2/instance/run"
returns QName(PackageNamespace(""), "void")
body
maxstack 4
localcount 4
initscopedepth 0
maxscopedepth 2
code
getlocal0
pushscope
debug 1, "a", 0, 0
pushbyte 0
setlocal1
debugline 15
pushbyte 0
setlocal1
getlex QName(PackageNamespace(""),"trace")
getglobalscope
debugline 16
pushstring "before loop"
call 1
pop
debugline 17
label
jump ofs007d
ofs0023:
label
ofs0024:
getlex QName(PackageNamespace(""),"trace")
getglobalscope
debugline 21
pushstring "in try"
call 1
pop
debugline 19
ofs0030:
jump ofs007d
ofs0034:
getlocal0
pushscope
newcatch 0
dup
setlocal3
dup
pushscope
swap
setslot 1
getlex QName(PackageNamespace(""),"trace")
getglobalscope
debugline 25
pushstring "in catch1"
call 1
pop
label
jump ofs006b
ofs004f:
label
getlocal1
debugline 27
pushbyte 5
ifgt ofs006f
getlocal1
debugline 30
pushbyte 5
ifngt ofs006b
popscope
kill 3
jump ofs0081
debugline 26
ofs006b:
jump ofs004f
ofs006f:
getlex QName(PackageNamespace(""),"trace")
getglobalscope
debugline 34
pushstring "in catch1c"
call 1
pop
popscope
debugline 18
ofs007d:
jump ofs0023
ofs0081:
getlex QName(PackageNamespace(""),"trace")
getglobalscope
debugline 37
pushstring "after"
call 1
returnvoid
end ; code
try from ofs0024 to ofs0030 target ofs0034 type QName(PackageNamespace(""),"Error") name QName(PackageInternalNs("tests"),"e") end
end ; body
end ; method
end ; trait
end ; instance
cinit
refid "tests:TestTryCatchLoopBreakLevel2/class/init"
body
maxstack 1
localcount 1
initscopedepth 3
maxscopedepth 4
code
getlocal0
pushscope
returnvoid
end ; code
end ; body
end ; method
end ; class

View File

@@ -0,0 +1,29 @@
script
sinit
refid "tests:TestTryCatchLoopBreakLevel2/init"
body
maxstack 2
localcount 1
initscopedepth 1
maxscopedepth 3
code
getlocal0
pushscope
findpropstrict Multiname("TestTryCatchLoopBreakLevel2", [PackageNamespace("tests")])
getlex QName(PackageNamespace(""), "Object")
pushscope
getlex Multiname("Object", [PrivateNamespace(null, "tests:TestTryCatchLoopBreakLevel2"), PackageNamespace(""), PackageNamespace("tests"), PackageInternalNs("tests"), Namespace("http://adobe.com/AS3/2006/builtin")])
newclass "tests:TestTryCatchLoopBreakLevel2"
popscope
initproperty QName(PackageNamespace("tests"), "TestTryCatchLoopBreakLevel2")
returnvoid
end ; code
end ; body
end ; method
trait class QName(PackageNamespace("tests"), "TestTryCatchLoopBreakLevel2")
#include "TestTryCatchLoopBreakLevel2.class.asasm"
end ; trait
end ; script

View File

@@ -12,6 +12,7 @@
<movie minorVersion="0" />
<movie platform="Flash Player" />
<movie background="#FFFFFF" />
<movie preferredSDK="Flex 4.6.0, AIR 3.1;4.6.0, 3.1;" />
</output>
<!-- Other classes to be compiled into your SWF -->
<classpaths>

View File

@@ -1,4 +1,6 @@
@echo off
set COMPILERKIND=air
set SWFNAME=as3_cross_compile
call c:\air\bin\mxmlc.bat -warnings=false -debug=true -output bin/%SWFNAME%.%COMPILERKIND%.swf src/Main.as 1> buildlog.%COMPILERKIND%.txt 2>&1
call c:\air\bin\mxmlc.bat -warnings=false -debug=true -output bin/%SWFNAME%.%COMPILERKIND%.swf src/Main.as 1> buildlog.%COMPILERKIND%.txt 2>&1
IF NOT ERRORLEVEL 0 echo "FAILED"
exit /b 0

View File

@@ -1,4 +1,6 @@
@echo off
set COMPILERKIND=flex_apache
set SWFNAME=as3_cross_compile
call c:\flex_apache\bin\mxmlc.bat -warnings=false -debug=true -output bin/%SWFNAME%.%COMPILERKIND%.swf src/Main.as 1> buildlog.%COMPILERKIND%.txt 2>&1
call c:\flex_apache\bin\mxmlc.bat -warnings=false -debug=true -output bin/%SWFNAME%.%COMPILERKIND%.swf src/Main.as 1> buildlog.%COMPILERKIND%.txt 2>&1
IF NOT ERRORLEVEL 0 echo "FAILED"
exit /b 0

View File

@@ -1,4 +1,6 @@
@echo off
set COMPILERKIND=flex
set SWFNAME=as3_cross_compile
c:\flex\bin\mxmlc.exe -warnings=false -debug=true -output bin/%SWFNAME%.%COMPILERKIND%.swf src/Main.as 1> buildlog.%COMPILERKIND%.txt 2>&1
c:\flex\bin\mxmlc.exe -warnings=false -debug=true -output bin/%SWFNAME%.%COMPILERKIND%.swf src/Main.as 1> buildlog.%COMPILERKIND%.txt 2>&1
IF NOT ERRORLEVEL 0 echo "FAILED"
exit /b 0

View File

@@ -2,4 +2,6 @@
set COMPILERKIND=swftools
set SWFNAME=as3_cross_compile
cd src
c:\swftools\as3compile.exe Main.as -o ..\bin\%SWFNAME%.%COMPILERKIND%.swf 1> ../buildlog.%COMPILERKIND%.txt 2>&1
c:\swftools\as3compile.exe Main.as -o ..\bin\%SWFNAME%.%COMPILERKIND%.swf 1> ../buildlog.%COMPILERKIND%.txt 2>&1
IF NOT ERRORLEVEL 0 echo "FAILED"
exit /b 0

View File

@@ -3,8 +3,6 @@
<!--Any modifications you make may be lost.-->
<flex-config>
<target-player>25.0</target-player>
<benchmark>false</benchmark>
<static-link-runtime-shared-libraries>true</static-link-runtime-shared-libraries>
<compiler>
<define append="true">
<name>CONFIG::debug</name>
@@ -16,7 +14,7 @@
</define>
<define append="true">
<name>CONFIG::timeStamp</name>
<value>'08.02.2021'</value>
<value>'09.02.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>'08.02.2021'</value>
<value>'09.02.2021'</value>
</define>
<define append="true">
<name>CONFIG::air</name>

View File

@@ -21,6 +21,10 @@ package
TestTryCatchInWhile5;
TestTryCatchLoop;
TestTryCatchLoopBreak;
TestTryCatchLoopBreak2;
TestTryCatchLoopBreak3;
TestTryCatchLoopBreak4;
TestTryCatchLoopBreak5;
TestTryCatchExceptionUsage
TestTryFinally;
TestTryFinallyDirectReturnInFinally;

View File

@@ -0,0 +1,51 @@
package tests
{
import flash.errors.EOFError;
/**
* ...
* @author JPEXS
*/
public class TestTryCatchLoopBreak4
{
public function run() : void
{
var a:int;
a = 0;
trace("before loop");
while (true) {
try
{
trace("in try");
}
catch(e:Error)
{
trace("in catch1");
if (a > 5){
trace("a");
if (a > 6){
trace("b");
break;
}
trace("c");
}
trace("in catch1b");
if (a > 10){
trace("d");
if (a > 11){
trace("e");
break;
}
trace("f");
}
trace("in catch1c");
}
}
trace("after");
}
}
}

View File

@@ -0,0 +1,39 @@
package tests
{
import flash.errors.EOFError;
/**
* ...
* @author JPEXS
*/
public class TestTryCatchLoopBreak5
{
public function run() : void
{
var a:int;
a = 0;
trace("before loop");
while (true) {
try
{
trace("in try");
}
catch(e:Error)
{
trace("in catch1");
while (true){
if (a > 5){
break;
}
}
trace("in catch1c");
}
}
trace("after");
}
}
}