AS1/2: Properly handling of Flash7 scripts exported to Flash5/6 - ActionDefineFunction local registers

This commit is contained in:
Jindra Petřík
2018-01-29 22:13:59 +01:00
parent da3cf1454c
commit eca98106d2
115 changed files with 573 additions and 130 deletions

View File

@@ -0,0 +1,37 @@
class MyClass {
function testNoReturn(){
var a = 5;
var b = a + 27;
trace("hi:"+b);
}
function testSimpleReturn(){
var a = 5;
var b = 5 * 6;
return "bagr"+b;
}
function testReturns(){
var a = 10;
if(a > 2){
a++;
for(var i=0;i<100;i++){
if(a + i == 27){
return a + 7;
}
i+= 27;
}
} else if (a == 4){
return 4;
}
return 3;
}
function testSomeReturns(){
var a = 5;
if(a < 10){
return a;
}
}
}

View File

@@ -0,0 +1,18 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>as2_definefunc_regs</title>
</head>
<body bgcolor="#ffffff">
<!--url's used in the movie-->
<!--text used in the movie-->
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="550" height="400" id="as2_definefunc_regs" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="as2_definefunc_regs.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<embed src="as2_definefunc_regs.swf" quality="high" bgcolor="#ffffff" width="550" height="400" name="as2_definefunc_regs" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</body>
</html>

View File

@@ -0,0 +1,6 @@
This is Flash MX Professional 2004 project with one class and export settings set to Flash 6.
The swf file has unusual structure:
From Flash 7 onwards, functions are stored as ActionDefineFunction2 with use up to 255 local
registers. When exporting SWF to lower formats Flash5-Flash6 in Flash IDE (for example MX 2004), all ActionDefineFunction2 are replaced with ActionDefineFunction, and it also use local registers (4 of them are
available). The code of ActionDefineFunction is also modified that it pushes all previous values of registers on the code start and pops them back on code exit or when return action shows up. All returns are replaced with jump to popping part. This makes code flow tangled and the decompiler must do some special treatment.