最近的进度

ngscript测试代码

 function c1(a, b, c, d) {
this.a = 1;
this.b = new array();
this.b[0] = 1;
this.b[1] = 2;
} c = new c1();
print(c.a); a = (function(a, b, c) {
return a + b * c;
})(1, 2, 3); print(a); if (1) {
print("if_test");
} if (0) {
print("this will not appear");
}else{
print("else ");
} function frac(i) {
if (i == 0) {
return 1;
} else {
return frac(i-1) * i;
}
} print(frac(5)); for (i = 0; i < 2; i = i + 1) {
print(i);
break;
} switch (i) {
case 1:
print(1);
case 2:
//case 1 goes here
print(2);
case 3:
print("will break");
break;
default:
//default
} function ex() {
print("cause exception");
throw 1;
} try {
print("before throw");
ex();
print("after throw");
} catch (e) {
print("catch" + e);
} finally {
print("finally..");
}

语法树

|-[program]
|-[statement] line:1
| |-[function_decl] line:1
| |-[ident,c1] line:1
| |-[param_list] line:1
| | |-[ident,a] line:1
| | |-[ident,b] line:1
| | |-[ident,c] line:1
| | |-[ident,d] line:1
| |-[statements] line:2
| |-[statement] line:2
| | |-[expr] line:2
| | |-[assign,=] line:2
| | |-[expr] line:2
| | | |-[dot,.] line:2
| | | |-[expr] line:2
| | | | |-[ident,this] line:2
| | | |-[ident,a] line:2
| | |-[expr] line:2
| | |-[integer,1] line:2
| |-[statement] line:3
| | |-[expr] line:3
| | |-[assign,=] line:3
| | |-[expr] line:3
| | | |-[dot,.] line:3
| | | |-[expr] line:3
| | | | |-[ident,this] line:3
| | | |-[ident,b] line:3
| | |-[expr] line:3
| | |-[new,new] line:3
| | |-[expr] line:3
| | | |-[ident,array] line:3
| | |-[params] line:3
| | |-[NULL] line:3
| |-[statement] line:4
| | |-[expr] line:4
| | |-[assign,=] line:4
| | |-[expr] line:4
| | | |-[array]
| | | |-[expr] line:4
| | | | |-[dot,.] line:4
| | | | |-[expr] line:4
| | | | | |-[ident,this] line:4
| | | | |-[ident,b] line:4
| | | |-[expr] line:4
| | | |-[integer,0] line:4
| | |-[expr] line:4
| | |-[integer,1] line:4
| |-[statement] line:5
| | |-[expr] line:5
| | |-[assign,=] line:5
| | |-[expr] line:5
| | | |-[array]
| | | |-[expr] line:5
| | | | |-[dot,.] line:5
| | | | |-[expr] line:5
| | | | | |-[ident,this] line:5
| | | | |-[ident,b] line:5
| | | |-[expr] line:5
| | | |-[integer,1] line:5
| | |-[expr] line:5
| | |-[integer,2] line:5
| |-[NULL] line:6
|-[statement] line:8
| |-[expr] line:8
| |-[assign,=] line:8
| |-[expr] line:8
| | |-[ident,c] line:8
| |-[expr] line:8
| |-[new,new] line:8
| |-[expr] line:8
| | |-[ident,c1] line:8
| |-[params] line:8
| |-[NULL] line:8
|-[statement] line:9
| |-[expr] line:9
| |-[funcall]
| |-[expr] line:9
| | |-[ident,print] line:9
| |-[params] line:9
| |-[expr] line:9
| |-[dot,.] line:9
| |-[expr] line:9
| | |-[ident,c] line:9
| |-[ident,a] line:9
|-[statement] line:11
| |-[expr] line:11
| |-[assign,=] line:11
| |-[expr] line:11
| | |-[ident,a] line:11
| |-[expr] line:11
| |-[funcall]
| |-[expr] line:11
| | |-[lambda]
| | |-[param_list] line:11
| | | |-[ident,a] line:11
| | | |-[ident,b] line:11
| | | |-[ident,c] line:11
| | |-[statements] line:12
| | |-[statement] line:12
| | | |-[return_val] line:12
| | | |-[expr] line:12
| | | |-[add,+] line:12
| | | |-[expr] line:12
| | | | |-[ident,a] line:12
| | | |-[expr] line:12
| | | |-[mul,*] line:12
| | | |-[expr] line:12
| | | | |-[ident,b] line:12
| | | |-[expr] line:12
| | | |-[ident,c] line:12
| | |-[NULL] line:13
| |-[params] line:13
| |-[expr] line:13
| | |-[integer,1] line:13
| |-[expr] line:13
| | |-[integer,2] line:13
| |-[expr] line:13
| |-[integer,3] line:13
|-[statement] line:15
| |-[expr] line:15
| |-[funcall]
| |-[expr] line:15
| | |-[ident,print] line:15
| |-[params] line:15
| |-[expr] line:15
| |-[ident,a] line:15
|-[statement] line:17
| |-[if_block] line:17
| |-[expr] line:17
| | |-[integer,1] line:17
| |-[statements] line:18
| |-[statement] line:18
| | |-[expr] line:18
| | |-[funcall]
| | |-[expr] line:18
| | | |-[ident,print] line:18
| | |-[params] line:18
| | |-[expr] line:18
| | |-[string,"if_test"] line:18
| |-[NULL] line:19
|-[statement] line:22
| |-[if_else_block] line:22
| |-[expr] line:22
| | |-[integer,0] line:22
| |-[statements] line:23
| | |-[statement] line:23
| | | |-[expr] line:23
| | | |-[funcall]
| | | |-[expr] line:23
| | | | |-[ident,print] line:23
| | | |-[params] line:23
| | | |-[expr] line:23
| | | |-[string,"this will not appear"] line:23
| | |-[NULL] line:24
| |-[statements] line:25
| |-[statement] line:25
| | |-[expr] line:25
| | |-[funcall]
| | |-[expr] line:25
| | | |-[ident,print] line:25
| | |-[params] line:25
| | |-[expr] line:25
| | |-[string,"else "] line:25
| |-[NULL] line:26
|-[statement] line:28
| |-[function_decl] line:28
| |-[ident,frac] line:28
| |-[param_list] line:28
| | |-[ident,i] line:28
| |-[statements] line:29
| |-[statement] line:29
| | |-[if_else_block] line:29
| | |-[expr] line:29
| | | |-[eq,==] line:29
| | | |-[expr] line:29
| | | | |-[ident,i] line:29
| | | |-[expr] line:29
| | | |-[integer,0] line:29
| | |-[statements] line:30
| | | |-[statement] line:30
| | | | |-[return_val] line:30
| | | | |-[expr] line:30
| | | | |-[integer,1] line:30
| | | |-[NULL] line:31
| | |-[statements] line:32
| | |-[statement] line:32
| | | |-[return_val] line:32
| | | |-[expr] line:32
| | | |-[mul,*] line:32
| | | |-[expr] line:32
| | | | |-[funcall]
| | | | |-[expr] line:32
| | | | | |-[ident,frac] line:32
| | | | |-[params] line:32
| | | | |-[expr] line:32
| | | | |-[sub,-] line:32
| | | | |-[expr] line:32
| | | | | |-[ident,i] line:32
| | | | |-[expr] line:32
| | | | |-[integer,1] line:32
| | | |-[expr] line:32
| | | |-[ident,i] line:32
| | |-[NULL] line:33
| |-[NULL] line:34
|-[statement] line:36
| |-[expr] line:36
| |-[funcall]
| |-[expr] line:36
| | |-[ident,print] line:36
| |-[params] line:36
| |-[expr] line:36
| |-[funcall]
| |-[expr] line:36
| | |-[ident,frac] line:36
| |-[params] line:36
| |-[expr] line:36
| |-[integer,5] line:36
|-[statement] line:38
| |-[for_block] line:38
| |-[expr] line:38
| | |-[assign,=] line:38
| | |-[expr] line:38
| | | |-[ident,i] line:38
| | |-[expr] line:38
| | |-[integer,0] line:38
| |-[expr] line:38
| | |-[lt,<] line:38
| | |-[expr] line:38
| | | |-[ident,i] line:38
| | |-[expr] line:38
| | |-[integer,2] line:38
| |-[expr] line:38
| | |-[assign,=] line:38
| | |-[expr] line:38
| | | |-[ident,i] line:38
| | |-[expr] line:38
| | |-[add,+] line:38
| | |-[expr] line:38
| | | |-[ident,i] line:38
| | |-[expr] line:38
| | |-[integer,1] line:38
| |-[statements] line:39
| |-[statement] line:39
| | |-[expr] line:39
| | |-[funcall]
| | |-[expr] line:39
| | | |-[ident,print] line:39
| | |-[params] line:39
| | |-[expr] line:39
| | |-[ident,i] line:39
| |-[statement] line:40
| | |-[break,break] line:40
| |-[NULL] line:41
|-[statement] line:43
| |-[switch_block] line:43
| |-[expr] line:43
| | |-[ident,i] line:43
| |-[switch_cases] line:44
| | |-[switch_case] line:44
| | | |-[expr] line:44
| | | | |-[integer,1] line:44
| | | |-[statements] line:45
| | | |-[statement] line:45
| | | | |-[expr] line:45
| | | | |-[funcall]
| | | | |-[expr] line:45
| | | | | |-[ident,print] line:45
| | | | |-[params] line:45
| | | | |-[expr] line:45
| | | | |-[integer,1] line:45
| | | |-[NULL] line:46
| | |-[switch_case] line:46
| | | |-[expr] line:46
| | | | |-[integer,2] line:46
| | | |-[statements] line:48
| | | |-[statement] line:48
| | | | |-[expr] line:48
| | | | |-[funcall]
| | | | |-[expr] line:48
| | | | | |-[ident,print] line:48
| | | | |-[params] line:48
| | | | |-[expr] line:48
| | | | |-[integer,2] line:48
| | | |-[NULL] line:49
| | |-[switch_case] line:49
| | | |-[expr] line:49
| | | | |-[integer,3] line:49
| | | |-[statements] line:50
| | | |-[statement] line:50
| | | | |-[expr] line:50
| | | | |-[funcall]
| | | | |-[expr] line:50
| | | | | |-[ident,print] line:50
| | | | |-[params] line:50
| | | | |-[expr] line:50
| | | | |-[string,"will break"] line:50
| | | |-[statement] line:51
| | | | |-[break,break] line:51
| | | |-[NULL] line:52
| | |-[NULL] line:52
| |-[default_case] line:54
| |-[statements] line:54
| |-[NULL] line:54
|-[statement] line:56
| |-[function_decl] line:56
| |-[ident,ex] line:56
| |-[param_list] line:56
| | |-[NULL] line:56
| |-[statements] line:57
| |-[statement] line:57
| | |-[expr] line:57
| | |-[funcall]
| | |-[expr] line:57
| | | |-[ident,print] line:57
| | |-[params] line:57
| | |-[expr] line:57
| | |-[string,"cause exception"] line:57
| |-[statement] line:58
| | |-[throw_exception] line:58
| | |-[expr] line:58
| | |-[integer,1] line:58
| |-[NULL] line:59
|-[statement] line:62
| |-[try_block] line:62
| |-[statements] line:62
| | |-[statement] line:62
| | | |-[expr] line:62
| | | |-[funcall]
| | | |-[expr] line:62
| | | | |-[ident,print] line:62
| | | |-[params] line:62
| | | |-[expr] line:62
| | | |-[string,"before throw"] line:62
| | |-[statements] line:63
| | |-[statement] line:63
| | | |-[expr] line:63
| | | |-[funcall]
| | | |-[expr] line:63
| | | | |-[ident,ex] line:63
| | | |-[params] line:63
| | | |-[NULL] line:63
| | |-[statements] line:64
| | |-[statement] line:64
| | | |-[expr] line:64
| | | |-[funcall]
| | | |-[expr] line:64
| | | | |-[ident,print] line:64
| | | |-[params] line:64
| | | |-[expr] line:64
| | | |-[string,"after throw"] line:64
| | |-[statements] line:65
| | |-[NULL] line:65
| |-[ident,e] line:65
| |-[statements] line:66
| | |-[statement] line:66
| | | |-[expr] line:66
| | | |-[funcall]
| | | |-[expr] line:66
| | | | |-[ident,print] line:66
| | | |-[params] line:66
| | | |-[expr] line:66
| | | |-[add,+] line:66
| | | |-[expr] line:66
| | | | |-[string,"catch"] line:66
| | | |-[expr] line:66
| | | |-[ident,e] line:66
| | |-[statements] line:67
| | |-[NULL] line:67
| |-[statements] line:68
| |-[statement] line:68
| | |-[expr] line:68
| | |-[funcall]
| | |-[expr] line:68
| | | |-[ident,print] line:68
| | |-[params] line:68
| | |-[expr] line:68
| | |-[string,"finally.."] line:68
| |-[NULL] line:69
|-[NULL]

虚拟机汇编

//------------------------------------------------
// function c1(a, b, c, d) { 0x00000000 jmp function_decl_$1_func_exit
0x00000001 label function_decl_$1_func_enter
0x00000002 dequeue stack,
0x00000003 set_var a,eax
0x00000004 dequeue stack,
0x00000005 set_var b,eax
0x00000006 dequeue stack,
0x00000007 set_var c,eax
0x00000008 dequeue stack,
0x00000009 set_var d,eax
//------------------------------------------------
// this.a = ; 0x0000000A mov eax,[this]
0x0000000B push eax
0x0000000C string eax,a
0x0000000D member_ref
0x0000000E push eax
0x0000000F integer
0x00000010 assign
//------------------------------------------------
// this.b = new array(); 0x00000011 mov eax,[this]
0x00000012 push eax
0x00000013 string eax,b
0x00000014 member_ref
0x00000015 push eax
0x00000016 mov eax,[array]
0x00000017 push eax
0x00000018 c_queue
0x00000019 push eax
0x0000001A push env
0x0000001B new_env
0x0000001C call
0x0000001D push env
0x0000001E peek
0x0000001F mov env,eax
0x00000020 pop eax
0x00000021 pop
0x00000022 pop
0x00000023 pop
0x00000024 assign
//------------------------------------------------
// this.b[] = ; 0x00000025 mov eax,[this]
0x00000026 push eax
0x00000027 string eax,b
0x00000028 member_ref
0x00000029 mov eax,[]
0x0000002A push eax
0x0000002B integer
0x0000002C array_ref
0x0000002D push eax
0x0000002E integer
0x0000002F assign
//------------------------------------------------
// this.b[] = ; 0x00000030 mov eax,[this]
0x00000031 push eax
0x00000032 string eax,b
0x00000033 member_ref
0x00000034 mov eax,[]
0x00000035 push eax
0x00000036 integer
0x00000037 array_ref
0x00000038 push eax
0x00000039 integer
0x0000003A assign
//------------------------------------------------
// } 0x0000003B ret
0x0000003C label function_decl_$1_func_exit
0x0000003D c_closure function_decl_$1_func_enter,env
0x0000003E set_var c1,eax
//------------------------------------------------
// //------------------------------------------------
// c = new c1(); 0x0000003F mov eax,c
0x00000040 push eax
0x00000041 mov eax,[c1]
0x00000042 push eax
0x00000043 c_queue
0x00000044 push eax
0x00000045 push env
0x00000046 new_env
0x00000047 call
0x00000048 push env
0x00000049 peek
0x0000004A mov env,eax
0x0000004B pop eax
0x0000004C pop
0x0000004D pop
0x0000004E pop
0x0000004F assign
//------------------------------------------------
// print(c.a); 0x00000050 mov eax,[print]
0x00000051 push eax
0x00000052 mov eax,[c]
0x00000053 push eax
0x00000054 string eax,a
0x00000055 member_ref
0x00000056 mov eax,[]
0x00000057 push eax
0x00000058 c_queue
0x00000059 push eax
0x0000005A push env
0x0000005B new_env
0x0000005C call
0x0000005D pop eax
0x0000005E mov env,eax
0x0000005F pop
0x00000060 pop
//------------------------------------------------
// //------------------------------------------------
// a = (function(a, b, c) { 0x00000061 mov eax,a
0x00000062 push eax
0x00000063 jmp expr_$11_func_exit
0x00000064 label expr_$11_func_enter
0x00000065 dequeue stack,
0x00000066 set_var a,eax
0x00000067 dequeue stack,
0x00000068 set_var b,eax
0x00000069 dequeue stack,
0x0000006A set_var c,eax
//------------------------------------------------
// return a + b * c; 0x0000006B mov eax,[a]
0x0000006C push eax
0x0000006D mov eax,[b]
0x0000006E push eax
0x0000006F mov eax,[c]
0x00000070 mul
0x00000071 add
0x00000072 ret
//------------------------------------------------
// })(, , ); 0x00000073 ret
0x00000074 label expr_$11_func_exit
0x00000075 c_closure expr_$11_func_enter,env
0x00000076 push eax
0x00000077 integer
0x00000078 push eax
0x00000079 integer
0x0000007A push eax
0x0000007B integer
0x0000007C push eax
0x0000007D c_queue
0x0000007E push eax
0x0000007F push env
0x00000080 new_env
0x00000081 call
0x00000082 pop eax
0x00000083 mov env,eax
0x00000084 pop
0x00000085 pop
0x00000086 assign
//------------------------------------------------
// //------------------------------------------------
// print(a); 0x00000087 mov eax,[print]
0x00000088 push eax
0x00000089 mov eax,[a]
0x0000008A push eax
0x0000008B c_queue
0x0000008C push eax
0x0000008D push env
0x0000008E new_env
0x0000008F call
0x00000090 pop eax
0x00000091 mov env,eax
0x00000092 pop
0x00000093 pop
//------------------------------------------------
// //------------------------------------------------
// if () { 0x00000094 integer
0x00000095 jz if_block_$17_exit
//------------------------------------------------
// print("if_test"); 0x00000096 mov eax,[print]
0x00000097 push eax
0x00000098 string "if_test"
0x00000099 push eax
0x0000009A c_queue
0x0000009B push eax
0x0000009C push env
0x0000009D new_env
0x0000009E call
0x0000009F pop eax
0x000000A0 mov env,eax
0x000000A1 pop
0x000000A2 pop
//------------------------------------------------
// } 0x000000A3 label if_block_$17_exit
//------------------------------------------------
// //------------------------------------------------
// //------------------------------------------------
// if () { 0x000000A4 integer
0x000000A5 jz if_else_block_$22_else
//------------------------------------------------
// print("this will not appear"); 0x000000A6 mov eax,[print]
0x000000A7 push eax
0x000000A8 string "this will not appear"
0x000000A9 push eax
0x000000AA c_queue
0x000000AB push eax
0x000000AC push env
0x000000AD new_env
0x000000AE call
0x000000AF pop eax
0x000000B0 mov env,eax
0x000000B1 pop
0x000000B2 pop
//------------------------------------------------
// }else{ 0x000000B3 jmp if_else_block_$22_exit
0x000000B4 label if_else_block_$22_else
//------------------------------------------------
// print("else "); 0x000000B5 mov eax,[print]
0x000000B6 push eax
0x000000B7 string "else "
0x000000B8 push eax
0x000000B9 c_queue
0x000000BA push eax
0x000000BB push env
0x000000BC new_env
0x000000BD call
0x000000BE pop eax
0x000000BF mov env,eax
0x000000C0 pop
0x000000C1 pop
//------------------------------------------------
// } 0x000000C2 label if_else_block_$22_exit
//------------------------------------------------
// //------------------------------------------------
// function frac(i) { 0x000000C3 jmp function_decl_$28_func_exit
0x000000C4 label function_decl_$28_func_enter
0x000000C5 dequeue stack,
0x000000C6 set_var i,eax
//------------------------------------------------
// if (i == ) { 0x000000C7 mov eax,[i]
0x000000C8 push eax
0x000000C9 integer
0x000000CA eq
0x000000CB jz if_else_block_$29_else
//------------------------------------------------
// return ; 0x000000CC integer
0x000000CD ret
//------------------------------------------------
// } else { 0x000000CE jmp if_else_block_$29_exit
0x000000CF label if_else_block_$29_else
//------------------------------------------------
// return frac(i-) * i; 0x000000D0 mov eax,[frac]
0x000000D1 push eax
0x000000D2 mov eax,[i]
0x000000D3 push eax
0x000000D4 integer
0x000000D5 sub
0x000000D6 push eax
0x000000D7 c_queue
0x000000D8 push eax
0x000000D9 push env
0x000000DA new_env
0x000000DB call
0x000000DC pop eax
0x000000DD mov env,eax
0x000000DE pop
0x000000DF pop
0x000000E0 push eax
0x000000E1 mov eax,[i]
0x000000E2 mul
0x000000E3 ret
//------------------------------------------------
// } 0x000000E4 label if_else_block_$29_exit
//------------------------------------------------
// } 0x000000E5 ret
0x000000E6 label function_decl_$28_func_exit
0x000000E7 c_closure function_decl_$28_func_enter,env
0x000000E8 set_var frac,eax
//------------------------------------------------
// //------------------------------------------------
// print(frac()); 0x000000E9 mov eax,[print]
0x000000EA push eax
0x000000EB mov eax,[frac]
0x000000EC push eax
0x000000ED integer
0x000000EE push eax
0x000000EF c_queue
0x000000F0 push eax
0x000000F1 push env
0x000000F2 new_env
0x000000F3 call
0x000000F4 pop eax
0x000000F5 mov env,eax
0x000000F6 pop
0x000000F7 pop
0x000000F8 push eax
0x000000F9 c_queue
0x000000FA push eax
0x000000FB push env
0x000000FC new_env
0x000000FD call
0x000000FE pop eax
0x000000FF mov env,eax
0x00000100 pop
0x00000101 pop
//------------------------------------------------
// //------------------------------------------------
// for (i = ; i < 2; i = i + 1) { 0x00000102 mov eax,i
0x00000103 push eax
0x00000104 integer
0x00000105 assign
0x00000106 label for_block_$38_test
0x00000107 mov eax,[i]
0x00000108 push eax
0x00000109 integer
0x0000010A lt
0x0000010B jz for_block_$38_break
//------------------------------------------------
// print(i); 0x0000010C mov eax,[print]
0x0000010D push eax
0x0000010E mov eax,[i]
0x0000010F push eax
0x00000110 c_queue
0x00000111 push eax
0x00000112 push env
0x00000113 new_env
0x00000114 call
0x00000115 pop eax
0x00000116 mov env,eax
0x00000117 pop
0x00000118 pop
//------------------------------------------------
// break; 0x00000119 jmp for_block_$38_break
//------------------------------------------------
// } 0x0000011A label for_block_$38_continue
0x0000011B mov eax,i
0x0000011C push eax
0x0000011D mov eax,[i]
0x0000011E push eax
0x0000011F integer
0x00000120 add
0x00000121 assign
0x00000122 jmp for_block_$38_test
0x00000123 label for_block_$38_break
//------------------------------------------------
// //------------------------------------------------
// switch (i) { 0x00000124 mov eax,[i]
0x00000125 push eax
//------------------------------------------------
// case : 0x00000126 integer
0x00000127 eq
0x00000128 jz switch_block_$43_case_0
//------------------------------------------------
// print(); 0x00000129 mov eax,[print]
0x0000012A push eax
0x0000012B integer
0x0000012C push eax
0x0000012D c_queue
0x0000012E push eax
0x0000012F push env
0x00000130 new_env
0x00000131 call
0x00000132 pop eax
0x00000133 mov env,eax
0x00000134 pop
0x00000135 pop
//------------------------------------------------
// case : 0x00000136 jmp switch_block_$43_body_0
0x00000137 label switch_block_$43_case_0
0x00000138 integer
0x00000139 eq
0x0000013A jz switch_block_$43_case_1
0x0000013B label switch_block_$43_body_0
//------------------------------------------------
// //case goes here //------------------------------------------------
// print(); 0x0000013C mov eax,[print]
0x0000013D push eax
0x0000013E integer
0x0000013F push eax
0x00000140 c_queue
0x00000141 push eax
0x00000142 push env
0x00000143 new_env
0x00000144 call
0x00000145 pop eax
0x00000146 mov env,eax
0x00000147 pop
0x00000148 pop
//------------------------------------------------
// case : 0x00000149 jmp switch_block_$43_body_1
0x0000014A label switch_block_$43_case_1
0x0000014B integer
0x0000014C eq
0x0000014D jz switch_block_$43_case_2
0x0000014E label switch_block_$43_body_1
//------------------------------------------------
// print("will break"); 0x0000014F mov eax,[print]
0x00000150 push eax
0x00000151 string "will break"
0x00000152 push eax
0x00000153 c_queue
0x00000154 push eax
0x00000155 push env
0x00000156 new_env
0x00000157 call
0x00000158 pop eax
0x00000159 mov env,eax
0x0000015A pop
0x0000015B pop
//------------------------------------------------
// break; 0x0000015C jmp switch_block_$43_break
//------------------------------------------------
// default: 0x0000015D jmp switch_block_$43_body_2
0x0000015E label switch_block_$43_case_2
0x0000015F label switch_block_$43_body_2
//------------------------------------------------
// //default //------------------------------------------------
// } 0x00000160 label switch_block_$43_break
//------------------------------------------------
// //------------------------------------------------
// function ex() { 0x00000161 jmp function_decl_$56_func_exit
0x00000162 label function_decl_$56_func_enter
0x00000163 dequeue stack,
0x00000164 set_var ,eax
//------------------------------------------------
// print("cause exception"); 0x00000165 mov eax,[print]
0x00000166 push eax
0x00000167 string "cause exception"
0x00000168 push eax
0x00000169 c_queue
0x0000016A push eax
0x0000016B push env
0x0000016C new_env
0x0000016D call
0x0000016E pop eax
0x0000016F mov env,eax
0x00000170 pop
0x00000171 pop
//------------------------------------------------
// throw ; 0x00000172 integer
0x00000173 mov exception,eax
0x00000174 restore_machine_state
//------------------------------------------------
// } 0x00000175 ret
0x00000176 label function_decl_$56_func_exit
0x00000177 c_closure function_decl_$56_func_enter,env
0x00000178 set_var ex,eax
//------------------------------------------------
// //------------------------------------------------
// try { //------------------------------------------------
// print("before throw"); 0x00000179 save_machine_state
0x0000017A test exception
0x0000017B jnz try_block_$62_catch
0x0000017C mov eax,[print]
0x0000017D push eax
0x0000017E string "before throw"
0x0000017F push eax
0x00000180 c_queue
0x00000181 push eax
0x00000182 push env
0x00000183 new_env
0x00000184 call
0x00000185 pop eax
0x00000186 mov env,eax
0x00000187 pop
0x00000188 pop
//------------------------------------------------
// ex(); 0x00000189 mov eax,[ex]
0x0000018A push eax
0x0000018B c_queue
0x0000018C push eax
0x0000018D push env
0x0000018E new_env
0x0000018F call
0x00000190 pop eax
0x00000191 mov env,eax
0x00000192 pop
0x00000193 pop
//------------------------------------------------
// print("after throw"); 0x00000194 mov eax,[print]
0x00000195 push eax
0x00000196 string "after throw"
0x00000197 push eax
0x00000198 c_queue
0x00000199 push eax
0x0000019A push env
0x0000019B new_env
0x0000019C call
0x0000019D pop eax
0x0000019E mov env,eax
0x0000019F pop
0x000001A0 pop
//------------------------------------------------
// } catch (e) { 0x000001A1 drop_machine_state
0x000001A2 push eip
0x000001A3 jmp try_block_$62_finally
0x000001A4 jmp try_block_$62_exit
0x000001A5 label try_block_$62_catch
0x000001A6 set_var e,exception
0x000001A7 clear exception
//------------------------------------------------
// print("catch"+e); 0x000001A8 mov eax,[print]
0x000001A9 push eax
0x000001AA string "catch"
0x000001AB push eax
0x000001AC mov eax,[e]
0x000001AD add
0x000001AE push eax
0x000001AF c_queue
0x000001B0 push eax
0x000001B1 push env
0x000001B2 new_env
0x000001B3 call
0x000001B4 pop eax
0x000001B5 mov env,eax
0x000001B6 pop
0x000001B7 pop
//------------------------------------------------
// } finally { 0x000001B8 push eip
0x000001B9 jmp try_block_$62_finally
0x000001BA jmp try_block_$62_exit
0x000001BB label try_block_$62_finally
//------------------------------------------------
// print("finally.."); 0x000001BC mov eax,[print]
0x000001BD push eax
0x000001BE string "finally.."
0x000001BF push eax
0x000001C0 c_queue
0x000001C1 push eax
0x000001C2 push env
0x000001C3 new_env
0x000001C4 call
0x000001C5 pop eax
0x000001C6 mov env,eax
0x000001C7 pop
0x000001C8 pop
//------------------------------------------------
// } 0x000001C9 pop eax
0x000001CA jmp [eax],
0x000001CB label try_block_$62_exit

实现自己的脚本语言ngscript之四:代码生成的更多相关文章

  1. 实现自己的脚本语言ngscript之零

    正式开始介绍前先扯点没用的. 从小玩basic长大的小朋友大多有一个梦想,就是自己实现一个basic解释器. 不过这里我实现的不是basic,而是一个语法和功能类似javascript的东西. 暂且称 ...

  2. 实现自己的脚本语言ngscript之三:语法设计

    这是第四篇了,之所以隔了这么久才写,一方面是因为最近开始实习了,另一方面是因为设计语法真是要考虑很多东西. 于是我去读了这本书,里面实现了两种语言,一种跟js差不多语法,用ast解释执行:另一种语法类 ...

  3. 实现自己的脚本语言ngscript之二:语法分析

    ngscript的语法分析使用的是我自己的语法分析工具parseroid.与常用cc工具(yacc.bison.javacc.antlr.etc…)不同的是,parseroid生成的不是语法分析器的源 ...

  4. 实现自己的脚本语言ngscript之一:词法分析

    正则表达式的理论基础可以参考装配脑袋的 这个 自己动手开发编译器(二)正则语言和正则表达式 这个 自己动手开发编译器(三)有穷自动机 还有这个 自己动手开发编译器(四)利用DFA转换表建立扫描器 如果 ...

  5. 使用Lua脚本语言开发出高扩展性的系统,AgileEAS.NET SOA中间件Lua脚本引擎介绍

    一.前言 AgileEAS.NET SOA 中间件平台是一款基于基于敏捷并行开发思想和Microsoft .Net构件(组件)开发技术而构建的一个快速开发应用平台.用于帮助中小型软件企业建立一条适合市 ...

  6. 脚本语言:Xmas(三)

    自从将Xmas的GC换成现在的非迁移式的全局收集器后,最近几个月一直耗在Xmas上面:最明显的改变就是:更彻底地支持了面向对象.更强大的编译器. 所以,本文就来说说,真正的Xmas. 一.目标 一门语 ...

  7. InstallShield 脚本语言学习笔记

    InstallShield脚本语言是类似C语言,利用InstallShield的向导或模板都可以生成基本的脚本程序框架,可以在此基础上按自己的意愿进行修改和添加.     一.基本语法规则      ...

  8. JS脚本语言是什么意思?

    javascript,Javascript是一种浏览器端的脚本语言,用来在网页客户端处理与用户的交互,以及实现页面特效.比如提交表单前先验证数据合法性,减少服务器错误和压力.根据客户操作,给出一些提升 ...

  9. .NET 动态脚本语言Script.NET 入门指南 Quick Start

    Script.NET是一种动态的脚本语言,它使得程序可扩展,可定制,和维护性好.和Office系列的VB Script相似,可以在应用中嵌入大量的代码块,以便在运行时才执行这些代码. Script.N ...

随机推荐

  1. Struts2多文件上传

    第一步:首先创建一个多文件上传的页面 <html> <head> <meta http-equiv="Content-Type" content=&q ...

  2. Android 之 Socket 通信

    Android 之 Socket 通信 联系一下 Socket 编程,之后需要将一个 JavaEE 项目移植到 Android,暂时现尝试写一个简单的 DEMO,理解一下 Socket Server ...

  3. Repeater 动态增加删除一行

    文章参考:文章参考http://www.cnblogs.com/dataadapter/archive/2012/06/25/2562885.html 效果: 前台代码: <%@ Page La ...

  4. 生产者与消费者(二)---await与 signal

    前面阐述了实现生产者与消费者问题的一种方式:wait() / notify()方法,本文继续阐述多线程的经典问题---生产者与消费者的第二种方式:await() / signal()方法. await ...

  5. 图像载入 imread()[OpenCV 笔记4]

    Mat imread( ); filename 载入的图像名: flags 指定加载图像的颜色类型,默认载入三通道彩色图像, 如果取枚举类型 (OpenCV3中暂时失效),则定义如下 enum{ CV ...

  6. ios开发中加载的image无法显示

    昨天遇到一个较奇葩的问题,imageName加载的图片显示不出来,网上查了好多资料还是没找到解决的方法: 之前图片是放在项目中SupportingFiles文件下的,怎么加载都能显示图片,于是将图片拿 ...

  7. Eclipse中文乱码解决汇总(应该比较全):

    Eclipse中文乱码解决汇总(应该比较全,欢迎补充): 方法一: 把GBK改成utf-8. 方法二: Window->preference->general->content ty ...

  8. 『重构--改善既有代码的设计』读书笔记----Change Reference to Value

    如果你有一个引用对象,很小且不可改变,而且不易管理,你就需要考虑将他改为一个值对象.在Change Value to Reference我们说过,要在引用对象和值对象之间做选择,有时候并不容易,有了重 ...

  9. iOS: AFNetworking手动配置(iOS7.1, AF2.2.4)

    一.下载AFNetworking. 二.将AFNetworking-master下的AFNetworking目录拖入到项目中 三.为项目添加Linking to a Library or Framew ...

  10. Quartz1.8.5例子(五)

    /* * Copyright 2005 - 2009 Terracotta, Inc. * * Licensed under the Apache License, Version 2.0 (the ...