Fixed: Script/Class initializers order of assignment

Changed: Compound script has slot/const traits inside main script initializer
This commit is contained in:
Jindra Petřík
2024-08-17 01:59:54 +02:00
parent 54faceb9a8
commit 4e528c181c
50 changed files with 1521 additions and 465 deletions

View File

@@ -147,6 +147,7 @@ package
TestImports2;
TestInitializer;
TestRegexpHilight;
TestScriptInitializer;
TestPropertyCoerce;
TestUnaryMinus;
@@ -170,6 +171,8 @@ package
{
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point
new TestScriptInitializer();
}
}

View File

@@ -0,0 +1,61 @@
package tests_classes
{
public class TestScriptInitializer
{
private static var sa:int = 5;
if (Math.random() * 10 >= 5) {
sa += 100;
} else {
sa += 200;
}
private static const sc:int = Math.floor(Math.random() * 50) + sa + x;
private static var sb:int = sa + 20;
if (sb > 100) {
sb += 10;
} else {
sb += 20;
}
private static var sv:int;
for each (sv in [1,3,5])
{
trace(sv);
}
public function test() : void {
const x:int = 5;
}
}
//TestImports;
}
var x:int = Math.random() * 100;
var a:int = 5;
if (Math.random() * 10 >= 5) {
a += 100;
} else {
a += 200;
}
const c:int = Math.floor(Math.random() * 50) + a;
var b:int = a + 20;
if (b > 100) {
b += 10;
} else {
b += 20;
}
var v:int;
for each (v in [1,3,5])
{
trace(v);
}

Binary file not shown.

View File

@@ -0,0 +1,74 @@
const int compound_abc_length = 1097;
const int compound_abc_method_count = 0;
const int compound_abc_class_count = 6;
const int compound_abc_script_count = 2;
const unsigned char compound_abc_data[1097] = {
0x10, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x7f, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f, 0x1c, 0x06, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x00,
0x06, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x03, 0x69, 0x6e, 0x74, 0x12, 0x5f, 0x5f, 0x41, 0x53,
0x33, 0x5f, 0x5f, 0x2e, 0x76, 0x65, 0x63, 0x3a, 0x56, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x0b, 0x5f,
0x5f, 0x41, 0x53, 0x33, 0x5f, 0x5f, 0x2e, 0x76, 0x65, 0x63, 0x06, 0x56, 0x65, 0x63, 0x74, 0x6f,
0x72, 0x03, 0x4e, 0x61, 0x4e, 0x08, 0x49, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x79, 0x09, 0x75,
0x6e, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x64, 0x03, 0x41, 0x53, 0x33, 0x21, 0x68, 0x74, 0x74,
0x70, 0x3a, 0x2f, 0x2f, 0x61, 0x64, 0x6f, 0x62, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x41, 0x53,
0x33, 0x2f, 0x32, 0x30, 0x30, 0x36, 0x2f, 0x62, 0x75, 0x69, 0x6c, 0x74, 0x69, 0x6e, 0x0d, 0x6d,
0x79, 0x70, 0x6b, 0x67, 0x3a, 0x4d, 0x79, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x04, 0x76, 0x6f, 0x69,
0x64, 0x04, 0x74, 0x65, 0x73, 0x74, 0x05, 0x6d, 0x79, 0x70, 0x6b, 0x67, 0x07, 0x4d, 0x79, 0x43,
0x6c, 0x61, 0x73, 0x73, 0x0e, 0x6d, 0x79, 0x70, 0x6b, 0x67, 0x3a, 0x4d, 0x79, 0x43, 0x6c, 0x61,
0x73, 0x73, 0x32, 0x08, 0x4d, 0x79, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x32, 0x05, 0x74, 0x72, 0x61,
0x63, 0x65, 0x01, 0x78, 0x01, 0x61, 0x01, 0x62, 0x06, 0x6d, 0x79, 0x70, 0x6b, 0x67, 0x32, 0x0d,
0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x75, 0x6e, 0x64, 0x2e, 0x61, 0x73, 0x24, 0x31, 0x01, 0x79, 0x01,
0x63, 0x14, 0x05, 0x01, 0x16, 0x02, 0x18, 0x01, 0x05, 0x03, 0x18, 0x03, 0x05, 0x04, 0x18, 0x04,
0x05, 0x05, 0x16, 0x06, 0x18, 0x05, 0x08, 0x0c, 0x05, 0x0d, 0x16, 0x10, 0x18, 0x0d, 0x05, 0x12,
0x18, 0x12, 0x17, 0x10, 0x17, 0x18, 0x05, 0x19, 0x03, 0x01, 0x02, 0x01, 0x09, 0x1d, 0x07, 0x02,
0x01, 0x07, 0x02, 0x03, 0x07, 0x02, 0x04, 0x07, 0x09, 0x07, 0x09, 0x01, 0x01, 0x09, 0x03, 0x01,
0x09, 0x04, 0x01, 0x09, 0x07, 0x02, 0x09, 0x08, 0x01, 0x07, 0x02, 0x08, 0x09, 0x09, 0x01, 0x07,
0x02, 0x09, 0x09, 0x0a, 0x01, 0x07, 0x02, 0x0a, 0x07, 0x02, 0x0b, 0x07, 0x02, 0x0e, 0x07, 0x02,
0x0f, 0x07, 0x0d, 0x11, 0x07, 0x0d, 0x13, 0x07, 0x02, 0x14, 0x07, 0x11, 0x15, 0x07, 0x11, 0x16,
0x07, 0x11, 0x17, 0x07, 0x12, 0x15, 0x07, 0x12, 0x16, 0x07, 0x12, 0x17, 0x07, 0x13, 0x1a, 0x07,
0x13, 0x1b, 0x11, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00,
0x00, 0x10, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x10, 0x02, 0x00,
0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x06, 0x01, 0x00, 0x09, 0x03, 0x00, 0x01,
0x00, 0x02, 0x01, 0x09, 0x05, 0x00, 0x03, 0x00, 0x03, 0x01, 0x09, 0x07, 0x00, 0x05, 0x00, 0x04,
0x01, 0x09, 0x0a, 0x00, 0x07, 0x00, 0x12, 0x01, 0x09, 0x0e, 0x00, 0x0c, 0x01, 0x11, 0x01, 0x02,
0x0b, 0x13, 0x01, 0x09, 0x10, 0x00, 0x0f, 0x01, 0x11, 0x01, 0x02, 0x0e, 0x00, 0x00, 0x02, 0x00,
0x04, 0x00, 0x06, 0x00, 0x0a, 0x00, 0x0d, 0x00, 0x02, 0x10, 0x0b, 0x14, 0x01, 0x01, 0x09, 0x15,
0x00, 0x01, 0x03, 0x00, 0x16, 0x00, 0x02, 0x03, 0x00, 0x17, 0x00, 0x03, 0x03, 0x00, 0x18, 0x00,
0x04, 0x03, 0x00, 0x19, 0x00, 0x05, 0x03, 0x00, 0x1a, 0x00, 0x06, 0x03, 0x00, 0x12, 0x04, 0x07,
0x04, 0x13, 0x04, 0x08, 0x05, 0x1b, 0x00, 0x09, 0x03, 0x00, 0x1c, 0x00, 0x0a, 0x03, 0x00, 0x08,
0x08, 0x0f, 0x06, 0x00, 0x00, 0x0b, 0x08, 0x01, 0x04, 0x00, 0x00, 0x02, 0x04, 0x00, 0x01, 0x03,
0x04, 0x00, 0x02, 0x04, 0x04, 0x00, 0x03, 0x0a, 0x06, 0x00, 0x02, 0x01, 0x06, 0x0c, 0x06, 0x00,
0x02, 0x02, 0x06, 0x0e, 0x06, 0x00, 0x00, 0x00, 0x11, 0x00, 0x01, 0x01, 0x02, 0x03, 0x03, 0xd0,
0x30, 0x47, 0x00, 0x00, 0x01, 0x01, 0x01, 0x03, 0x04, 0x03, 0xd0, 0x30, 0x47, 0x00, 0x00, 0x02,
0x01, 0x01, 0x03, 0x04, 0x03, 0xd0, 0x30, 0x47, 0x00, 0x00, 0x03, 0x01, 0x01, 0x04, 0x05, 0x06,
0xd0, 0x30, 0xd0, 0x49, 0x00, 0x47, 0x00, 0x00, 0x04, 0x01, 0x01, 0x03, 0x04, 0x03, 0xd0, 0x30,
0x47, 0x00, 0x00, 0x05, 0x01, 0x01, 0x04, 0x05, 0x06, 0xd0, 0x30, 0xd0, 0x49, 0x00, 0x47, 0x00,
0x00, 0x06, 0x01, 0x01, 0x03, 0x04, 0x03, 0xd0, 0x30, 0x47, 0x00, 0x00, 0x07, 0x01, 0x01, 0x04,
0x05, 0x06, 0xd0, 0x30, 0xd0, 0x49, 0x00, 0x47, 0x00, 0x00, 0x08, 0x03, 0x01, 0x01, 0x03, 0x51,
0xd0, 0x30, 0x5d, 0x05, 0x20, 0x58, 0x00, 0x68, 0x01, 0x5d, 0x06, 0x5d, 0x01, 0x66, 0x01, 0x30,
0x5d, 0x01, 0x66, 0x01, 0x58, 0x01, 0x1d, 0x68, 0x02, 0x5d, 0x07, 0x5d, 0x01, 0x66, 0x01, 0x30,
0x5d, 0x01, 0x66, 0x01, 0x58, 0x02, 0x1d, 0x68, 0x03, 0x5d, 0x08, 0x5d, 0x01, 0x66, 0x01, 0x30,
0x5d, 0x01, 0x66, 0x01, 0x58, 0x03, 0x1d, 0x68, 0x04, 0x5d, 0x09, 0x24, 0x00, 0x24, 0x00, 0xa3,
0x68, 0x0a, 0x5d, 0x0b, 0x24, 0x01, 0x24, 0x00, 0xa3, 0x68, 0x0c, 0x5d, 0x0d, 0x21, 0x68, 0x0e,
0x47, 0x00, 0x00, 0x09, 0x01, 0x02, 0x01, 0x02, 0x03, 0xd0, 0x30, 0x47, 0x00, 0x00, 0x0a, 0x01,
0x01, 0x03, 0x04, 0x03, 0xd0, 0x30, 0x47, 0x00, 0x00, 0x0b, 0x01, 0x01, 0x04, 0x05, 0x03, 0xd0,
0x30, 0x47, 0x00, 0x00, 0x0c, 0x01, 0x01, 0x04, 0x05, 0x06, 0xd0, 0x30, 0xd0, 0x49, 0x00, 0x47,
0x00, 0x00, 0x0d, 0x01, 0x01, 0x03, 0x04, 0x03, 0xd0, 0x30, 0x47, 0x00, 0x00, 0x0e, 0x01, 0x01,
0x04, 0x05, 0x03, 0xd0, 0x30, 0x47, 0x00, 0x00, 0x0f, 0x01, 0x01, 0x04, 0x05, 0x06, 0xd0, 0x30,
0xd0, 0x49, 0x00, 0x47, 0x00, 0x00, 0x10, 0x02, 0x03, 0x01, 0x03, 0xda, 0x01, 0xd0, 0x30, 0x65,
0x00, 0x5d, 0x01, 0x66, 0x01, 0x30, 0x5d, 0x01, 0x66, 0x01, 0x58, 0x04, 0x1d, 0x68, 0x12, 0x65,
0x00, 0x5d, 0x01, 0x66, 0x01, 0x30, 0x5d, 0x01, 0x66, 0x01, 0x58, 0x05, 0x1d, 0x68, 0x13, 0x24,
0x07, 0x64, 0x2b, 0x6d, 0x01, 0x24, 0x01, 0x64, 0x2b, 0x6d, 0x02, 0x64, 0x6c, 0x01, 0x24, 0x05,
0x0f, 0x0e, 0x00, 0x00, 0x64, 0x6c, 0x02, 0x24, 0x64, 0xa0, 0x64, 0x2b, 0x6d, 0x02, 0x10, 0x0b,
0x00, 0x00, 0x64, 0x6c, 0x02, 0x25, 0xc8, 0x01, 0xa0, 0x64, 0x2b, 0x6d, 0x02, 0x64, 0x6c, 0x02,
0x24, 0x0a, 0xa0, 0x64, 0x2b, 0x6d, 0x03, 0x24, 0x07, 0x64, 0x2b, 0x6d, 0x04, 0x24, 0x01, 0x64,
0x2b, 0x6d, 0x05, 0x64, 0x6c, 0x04, 0x24, 0x05, 0x0f, 0x0e, 0x00, 0x00, 0x64, 0x6c, 0x05, 0x24,
0x64, 0xa0, 0x64, 0x2b, 0x6d, 0x05, 0x10, 0x0b, 0x00, 0x00, 0x64, 0x6c, 0x05, 0x25, 0xc8, 0x01,
0xa0, 0x64, 0x2b, 0x6d, 0x05, 0x64, 0x6c, 0x05, 0x24, 0x0a, 0xa0, 0x64, 0x2b, 0x6d, 0x06, 0x5d,
0x14, 0x24, 0x1d, 0x46, 0x14, 0x01, 0x82, 0xd5, 0x24, 0x01, 0x64, 0x2b, 0x6d, 0x09, 0x24, 0x01,
0x64, 0x2b, 0x6d, 0x0a, 0x64, 0x6c, 0x09, 0x24, 0x05, 0x0f, 0x15, 0x00, 0x00, 0x64, 0x6c, 0x0a,
0x24, 0x64, 0xa0, 0x2a, 0xd6, 0x64, 0x2b, 0x6d, 0x0a, 0xd2, 0x08, 0x02, 0x82, 0xd5, 0x10, 0x11,
0x00, 0x00, 0x64, 0x6c, 0x0a, 0x24, 0x64, 0xa0, 0x2a, 0xd6, 0x64, 0x2b, 0x6d, 0x0a, 0xd2, 0x08,
0x02, 0x82, 0xd5, 0xd1, 0x48, 0x08, 0x01, 0x00, 0x00 };

View File

@@ -0,0 +1,13 @@
const int abcclass_Object = 0;
const int abcclass_Number = 1;
const int abcclass_int = 2;
const int abcclass___AS3___vec_Vector = 3;
const int abcclass_mypkg_MyClass = 4;
const int abcclass_mypkg_MyClass2 = 5;
const int abcpackage_compound_as = 0;
const int abcpackage_stubs_as = 1;
extern const int compound_abc_length;
extern const int compound_abc_method_count;
extern const int compound_abc_class_count;
extern const int compound_abc_script_count;
extern const unsigned char compound_abc_data[];

View File

@@ -0,0 +1,2 @@
java -cp c:\flex\lib\asc.jar macromedia.asc.embedding.ScriptCompiler -strict -builtin -outdir bin/ -out compound src/stubs.as src/compound.as>buildlog.flex.txt 2>&1
rem call c:\flex\bin\mxmlc.bat -debug=true -output bin/compound.swf src/compound.as 1> buildlog.flex.txt 2>&1

View File

@@ -0,0 +1,27 @@
package
{
import flash.display.Sprite;
import flash.events.Event;
/**
* ...
* @author Jindra
*/
public class Main extends Sprite
{
public function Main()
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point
}
}
}

View File

@@ -0,0 +1,4 @@
package {
public class Number {
}
}

View File

@@ -0,0 +1,6 @@
package
{
public class Object
{
}
}

View File

@@ -0,0 +1,9 @@
package {
public namespace AS3 = "http://adobe.com/AS3/2006/builtin";
public const NaN: Number = 0 / 0;
public const Infinity: Number = 1 / 0;
public const undefined = void 0;
}

View File

@@ -0,0 +1,5 @@
package __AS3__.vec {
public class Vector {
}
}

View File

@@ -0,0 +1,43 @@
package {
public function trace(s:int) {
//print something
}
}
package mypkg {
var x:int = 7;
var a:int = 1;
if (x >= 5) {
a += 100;
} else {
a += 200;
}
var b:int = a + 10;
}
package mypkg2 {
var x:int = 7;
var a:int = 1;
if (x >= 5) {
a += 100;
} else {
a += 200;
}
var b:int = a + 10;
}
package mypkg3 {
trace(29);
}
include "mypkg/MyClass.as"
include "mypkg/MyClass2.as"
var y:int = 1;
var c:int = 1;
if (y >= 5) {
c += 100;
} else {
c += 100;
}

View File

@@ -0,0 +1,4 @@
package {
public class int {
}
}

View File

@@ -0,0 +1,10 @@
package mypkg
{
public class MyClass
{
public function test(): void
{
}
}
}

View File

@@ -0,0 +1,10 @@
package mypkg
{
public class MyClass2
{
public function test(): void
{
}
}
}

View File

@@ -0,0 +1,5 @@
include "Object.as"
include "Number.as"
include "int.as"
include "__AS3__/vec/Vector.as"
include "TopLevel.as"