mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-05-31 19:54:37 +00:00
Fixed: AS3 direct editation - popscope in catch on continue and break
This commit is contained in:
@@ -28,6 +28,7 @@ All notable changes to this project will be documented in this file.
|
||||
- AS3 direct editation - coerce in setproperty
|
||||
- AS3 direct editation - unary minus (negate) compiled as 0 - value
|
||||
- AS3 direct editation - using finally clause for continue and break
|
||||
- AS3 direct editation - popscope in catch on continue and break
|
||||
- #1159, #1608 Regexp syntax hilight when not a regexp (only division) again
|
||||
- Graphviz Graph not showing AS3 exception end
|
||||
- #1609 First frame missing in frame to PDF export
|
||||
|
||||
@@ -82,6 +82,9 @@ public class SourceGeneratorLocalData implements Serializable {
|
||||
|
||||
public List<Long> openedLoops = new ArrayList<>();
|
||||
|
||||
public List<List<Long>> catchesOpenedLoops = new ArrayList<>();
|
||||
public List<Integer> catchesTempRegs = new ArrayList<>();
|
||||
|
||||
public String getFullClass() {
|
||||
return pkg == null ? currentClass : pkg.addWithSuffix(currentClass).toRawString();
|
||||
}
|
||||
|
||||
@@ -27,8 +27,10 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.ConstructSuperIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.JumpIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.KillIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ReturnValueIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ReturnVoidIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PopScopeIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.ApplyTypeAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.BooleanAVM2Item;
|
||||
@@ -723,6 +725,16 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
}
|
||||
ret.add(ins(AVM2Instructions.Label));
|
||||
}
|
||||
|
||||
for (int i = 0; i < localData.catchesOpenedLoops.size(); i++) {
|
||||
List<Long> openedLoops = localData.catchesOpenedLoops.get(i);
|
||||
|
||||
if (openedLoops.contains(item.loopId)) {
|
||||
ret.add(ins(new PopScopeIns()));
|
||||
}
|
||||
ret.add(ins(new KillIns(), localData.catchesTempRegs.get(i)));
|
||||
}
|
||||
|
||||
AVM2Instruction abreak = ins(new BreakJumpIns(item.loopId), 0);
|
||||
ret.add(abreak);
|
||||
return ret;
|
||||
@@ -830,9 +842,13 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
}
|
||||
}
|
||||
}
|
||||
localData.catchesTempRegs.add(tempReg.getVal());
|
||||
localData.scopeStack.add(new LocalRegAVM2Item(null, null, tempReg.getVal(), null));
|
||||
localData.catchesOpenedLoops.add(new ArrayList<>(localData.openedLoops));
|
||||
catchCmd.addAll(generateToInsList(localData, item.catchCommands.get(c)));
|
||||
localData.catchesOpenedLoops.remove(localData.catchesOpenedLoops.size() - 1);
|
||||
localData.scopeStack.remove(localData.scopeStack.size() - 1);
|
||||
localData.catchesTempRegs.remove(localData.catchesTempRegs.size() - 1);
|
||||
catchCmd.add(ins(AVM2Instructions.PopScope));
|
||||
catchCmd.addAll(toInsList(AssignableAVM2Item.killTemp(localData, this, Arrays.asList(tempReg))));
|
||||
catchCmds.add(catchCmd);
|
||||
@@ -1090,6 +1106,15 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
ret.add(ins(AVM2Instructions.Label));
|
||||
}
|
||||
|
||||
for (int i = 0; i < localData.catchesOpenedLoops.size(); i++) {
|
||||
List<Long> openedLoops = localData.catchesOpenedLoops.get(i);
|
||||
|
||||
if (openedLoops.contains(item.loopId)) {
|
||||
ret.add(ins(new PopScopeIns()));
|
||||
}
|
||||
ret.add(ins(new KillIns(), localData.catchesTempRegs.get(i)));
|
||||
}
|
||||
|
||||
AVM2Instruction acontinue = ins(new ContinueJumpIns(item.loopId), 0);
|
||||
ret.add(acontinue);
|
||||
return ret;
|
||||
|
||||
Binary file not shown.
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>'09.02.2021'</value>
|
||||
<value>'20.02.2021'</value>
|
||||
</define>
|
||||
<define append="true">
|
||||
<name>CONFIG::air</name>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
</define>
|
||||
<define append="true">
|
||||
<name>CONFIG::timeStamp</name>
|
||||
<value>'09.02.2021'</value>
|
||||
<value>'20.02.2021'</value>
|
||||
</define>
|
||||
<define append="true">
|
||||
<name>CONFIG::air</name>
|
||||
|
||||
@@ -25,6 +25,8 @@ package
|
||||
TestTryCatchLoopBreak3;
|
||||
TestTryCatchLoopBreak4;
|
||||
TestTryCatchLoopBreak5;
|
||||
TestTryCatchLoopBreak6;
|
||||
TestTryCatchReturn;
|
||||
TestTryCatchExceptionUsage
|
||||
TestTryFinally;
|
||||
TestTryFinallyDirectReturnInFinally;
|
||||
|
||||
50
libsrc/ffdec_lib/testdata/as3_cross_compile/src/tests/TestTryCatchLoopBreak6.as
vendored
Normal file
50
libsrc/ffdec_lib/testdata/as3_cross_compile/src/tests/TestTryCatchLoopBreak6.as
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
package tests
|
||||
{
|
||||
import flash.errors.EOFError;
|
||||
/**
|
||||
* ...
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class TestTryCatchLoopBreak6
|
||||
{
|
||||
|
||||
|
||||
public function run() : void
|
||||
{
|
||||
var a:int;
|
||||
a = 0;
|
||||
trace("before loop");
|
||||
while (a < 10) {
|
||||
try
|
||||
{
|
||||
trace("in try");
|
||||
}
|
||||
catch(e:Error)
|
||||
{
|
||||
trace("in catch1");
|
||||
if (a > 3)
|
||||
{
|
||||
break;
|
||||
}
|
||||
try
|
||||
{
|
||||
trace("in try2");
|
||||
}
|
||||
catch(e:Error)
|
||||
{
|
||||
trace("in catch2");
|
||||
if (a > 4)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
a++;
|
||||
}
|
||||
trace("after");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
33
libsrc/ffdec_lib/testdata/as3_cross_compile/src/tests/TestTryCatchReturn.as
vendored
Normal file
33
libsrc/ffdec_lib/testdata/as3_cross_compile/src/tests/TestTryCatchReturn.as
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
package tests
|
||||
{
|
||||
/**
|
||||
* ...
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class TestTryCatchReturn
|
||||
{
|
||||
|
||||
public function run() : int
|
||||
{
|
||||
var a:int = 5;
|
||||
trace("before try");
|
||||
try
|
||||
{
|
||||
trace("in try");
|
||||
}
|
||||
catch (e:Error)
|
||||
{
|
||||
trace("in catch");
|
||||
if (a == 5)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
trace("in catch2");
|
||||
}
|
||||
trace("after");
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user