博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
实现自己的脚本语言ngscript之四:代码生成
阅读量:5291 次
发布时间:2019-06-14

本文共 37711 字,大约阅读时间需要 125 分钟。

最近的进度

ngscript测试代码

1 function c1(a, b, c, d) { 2     this.a = 1; 3     this.b = new array(); 4     this.b[0] = 1; 5     this.b[1] = 2; 6 } 7  8 c = new c1(); 9 print(c.a);10 11 a = (function(a, b, c) {12     return a + b * c;13 })(1, 2, 3);14 15 print(a);16 17 if (1) {18     print("if_test");19 }20 21 22 if (0) {23     print("this will not appear");24 }else{25     print("else ");26 }27 28 function frac(i) {29     if (i == 0) {30         return 1;31     } else {32         return frac(i-1) * i;33     }34 }35 36 print(frac(5));37 38 for (i = 0; i < 2; i = i + 1) {39     print(i);40     break;41 }42 43 switch (i) {44     case 1:45         print(1);46     case 2:47         //case 1 goes here48         print(2);49     case 3:50         print("will break");51         break;52     default:53         //default 54 }55 56 function ex() {57     print("cause exception");58     throw 1;59 }60 61 try {62     print("before throw");63     ex();64     print("after throw");65 } catch (e) {66     print("catch" + e);67 } finally {68     print("finally..");69 }

 

语法树

|-[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_exit0x00000001    label        function_decl_$1_func_enter0x00000002    dequeue        stack,20x00000003    set_var        a,eax0x00000004    dequeue        stack,20x00000005    set_var        b,eax0x00000006    dequeue        stack,20x00000007    set_var        c,eax0x00000008    dequeue        stack,20x00000009    set_var        d,eax//------------------------------------------------//     this.a = 1;0x0000000A    mov        eax,[this]0x0000000B    push        eax0x0000000C    string        eax,a0x0000000D    member_ref    0x0000000E    push        eax0x0000000F    integer        10x00000010    assign        //------------------------------------------------//     this.b = new array();0x00000011    mov        eax,[this]0x00000012    push        eax0x00000013    string        eax,b0x00000014    member_ref    0x00000015    push        eax0x00000016    mov        eax,[array]0x00000017    push        eax0x00000018    c_queue        00x00000019    push        eax0x0000001A    push        env0x0000001B    new_env        0x0000001C    call        0x0000001D    push        env0x0000001E    peek        10x0000001F    mov        env,eax0x00000020    pop        eax0x00000021    pop        0x00000022    pop        0x00000023    pop        0x00000024    assign        //------------------------------------------------//     this.b[0] = 1;0x00000025    mov        eax,[this]0x00000026    push        eax0x00000027    string        eax,b0x00000028    member_ref    0x00000029    mov        eax,[]0x0000002A    push        eax0x0000002B    integer        00x0000002C    array_ref    0x0000002D    push        eax0x0000002E    integer        10x0000002F    assign        //------------------------------------------------//     this.b[1] = 2;0x00000030    mov        eax,[this]0x00000031    push        eax0x00000032    string        eax,b0x00000033    member_ref    0x00000034    mov        eax,[]0x00000035    push        eax0x00000036    integer        10x00000037    array_ref    0x00000038    push        eax0x00000039    integer        20x0000003A    assign        //------------------------------------------------// }0x0000003B    ret        0x0000003C    label        function_decl_$1_func_exit0x0000003D    c_closure    function_decl_$1_func_enter,env0x0000003E    set_var        c1,eax//------------------------------------------------// //------------------------------------------------// c = new c1();0x0000003F    mov        eax,c0x00000040    push        eax0x00000041    mov        eax,[c1]0x00000042    push        eax0x00000043    c_queue        00x00000044    push        eax0x00000045    push        env0x00000046    new_env        0x00000047    call        0x00000048    push        env0x00000049    peek        10x0000004A    mov        env,eax0x0000004B    pop        eax0x0000004C    pop        0x0000004D    pop        0x0000004E    pop        0x0000004F    assign        //------------------------------------------------// print(c.a);0x00000050    mov        eax,[print]0x00000051    push        eax0x00000052    mov        eax,[c]0x00000053    push        eax0x00000054    string        eax,a0x00000055    member_ref    0x00000056    mov        eax,[]0x00000057    push        eax0x00000058    c_queue        10x00000059    push        eax0x0000005A    push        env0x0000005B    new_env        0x0000005C    call        0x0000005D    pop        eax0x0000005E    mov        env,eax0x0000005F    pop        0x00000060    pop        //------------------------------------------------// //------------------------------------------------// a = (function(a, b, c) {0x00000061    mov        eax,a0x00000062    push        eax0x00000063    jmp        expr_$11_func_exit0x00000064    label        expr_$11_func_enter0x00000065    dequeue        stack,20x00000066    set_var        a,eax0x00000067    dequeue        stack,20x00000068    set_var        b,eax0x00000069    dequeue        stack,20x0000006A    set_var        c,eax//------------------------------------------------//     return a + b * c;0x0000006B    mov        eax,[a]0x0000006C    push        eax0x0000006D    mov        eax,[b]0x0000006E    push        eax0x0000006F    mov        eax,[c]0x00000070    mul        0x00000071    add        0x00000072    ret        //------------------------------------------------// })(1, 2, 3);0x00000073    ret        0x00000074    label        expr_$11_func_exit0x00000075    c_closure    expr_$11_func_enter,env0x00000076    push        eax0x00000077    integer        10x00000078    push        eax0x00000079    integer        20x0000007A    push        eax0x0000007B    integer        30x0000007C    push        eax0x0000007D    c_queue        30x0000007E    push        eax0x0000007F    push        env0x00000080    new_env        0x00000081    call        0x00000082    pop        eax0x00000083    mov        env,eax0x00000084    pop        0x00000085    pop        0x00000086    assign        //------------------------------------------------// //------------------------------------------------// print(a);0x00000087    mov        eax,[print]0x00000088    push        eax0x00000089    mov        eax,[a]0x0000008A    push        eax0x0000008B    c_queue        10x0000008C    push        eax0x0000008D    push        env0x0000008E    new_env        0x0000008F    call        0x00000090    pop        eax0x00000091    mov        env,eax0x00000092    pop        0x00000093    pop        //------------------------------------------------// //------------------------------------------------// if (1) {0x00000094    integer        10x00000095    jz        if_block_$17_exit//------------------------------------------------//     print("if_test");0x00000096    mov        eax,[print]0x00000097    push        eax0x00000098    string        "if_test"0x00000099    push        eax0x0000009A    c_queue        10x0000009B    push        eax0x0000009C    push        env0x0000009D    new_env        0x0000009E    call        0x0000009F    pop        eax0x000000A0    mov        env,eax0x000000A1    pop        0x000000A2    pop        //------------------------------------------------// }0x000000A3    label        if_block_$17_exit//------------------------------------------------// //------------------------------------------------// //------------------------------------------------// if (0) {0x000000A4    integer        00x000000A5    jz        if_else_block_$22_else//------------------------------------------------//     print("this will not appear");0x000000A6    mov        eax,[print]0x000000A7    push        eax0x000000A8    string        "this will not appear"0x000000A9    push        eax0x000000AA    c_queue        10x000000AB    push        eax0x000000AC    push        env0x000000AD    new_env        0x000000AE    call        0x000000AF    pop        eax0x000000B0    mov        env,eax0x000000B1    pop        0x000000B2    pop        //------------------------------------------------// }else{0x000000B3    jmp        if_else_block_$22_exit0x000000B4    label        if_else_block_$22_else//------------------------------------------------//     print("else ");0x000000B5    mov        eax,[print]0x000000B6    push        eax0x000000B7    string        "else "0x000000B8    push        eax0x000000B9    c_queue        10x000000BA    push        eax0x000000BB    push        env0x000000BC    new_env        0x000000BD    call        0x000000BE    pop        eax0x000000BF    mov        env,eax0x000000C0    pop        0x000000C1    pop        //------------------------------------------------// }0x000000C2    label        if_else_block_$22_exit//------------------------------------------------// //------------------------------------------------// function frac(i) {0x000000C3    jmp        function_decl_$28_func_exit0x000000C4    label        function_decl_$28_func_enter0x000000C5    dequeue        stack,20x000000C6    set_var        i,eax//------------------------------------------------//     if (i == 0) {0x000000C7    mov        eax,[i]0x000000C8    push        eax0x000000C9    integer        00x000000CA    eq        0x000000CB    jz        if_else_block_$29_else//------------------------------------------------//         return 1;0x000000CC    integer        10x000000CD    ret        //------------------------------------------------//     } else {0x000000CE    jmp        if_else_block_$29_exit0x000000CF    label        if_else_block_$29_else//------------------------------------------------//         return frac(i-1) * i;0x000000D0    mov        eax,[frac]0x000000D1    push        eax0x000000D2    mov        eax,[i]0x000000D3    push        eax0x000000D4    integer        10x000000D5    sub        0x000000D6    push        eax0x000000D7    c_queue        10x000000D8    push        eax0x000000D9    push        env0x000000DA    new_env        0x000000DB    call        0x000000DC    pop        eax0x000000DD    mov        env,eax0x000000DE    pop        0x000000DF    pop        0x000000E0    push        eax0x000000E1    mov        eax,[i]0x000000E2    mul        0x000000E3    ret        //------------------------------------------------//     }0x000000E4    label        if_else_block_$29_exit//------------------------------------------------// }0x000000E5    ret        0x000000E6    label        function_decl_$28_func_exit0x000000E7    c_closure    function_decl_$28_func_enter,env0x000000E8    set_var        frac,eax//------------------------------------------------// //------------------------------------------------// print(frac(5));0x000000E9    mov        eax,[print]0x000000EA    push        eax0x000000EB    mov        eax,[frac]0x000000EC    push        eax0x000000ED    integer        50x000000EE    push        eax0x000000EF    c_queue        10x000000F0    push        eax0x000000F1    push        env0x000000F2    new_env        0x000000F3    call        0x000000F4    pop        eax0x000000F5    mov        env,eax0x000000F6    pop        0x000000F7    pop        0x000000F8    push        eax0x000000F9    c_queue        10x000000FA    push        eax0x000000FB    push        env0x000000FC    new_env        0x000000FD    call        0x000000FE    pop        eax0x000000FF    mov        env,eax0x00000100    pop        0x00000101    pop        //------------------------------------------------// //------------------------------------------------// for (i = 0; i < 2; i = i + 1) {
0x00000102 mov eax,i0x00000103 push eax0x00000104 integer 00x00000105 assign 0x00000106 label for_block_$38_test0x00000107 mov eax,[i]0x00000108 push eax0x00000109 integer 20x0000010A lt 0x0000010B jz for_block_$38_break//------------------------------------------------// print(i);0x0000010C mov eax,[print]0x0000010D push eax0x0000010E mov eax,[i]0x0000010F push eax0x00000110 c_queue 10x00000111 push eax0x00000112 push env0x00000113 new_env 0x00000114 call 0x00000115 pop eax0x00000116 mov env,eax0x00000117 pop 0x00000118 pop //------------------------------------------------// break;0x00000119 jmp for_block_$38_break//------------------------------------------------// }0x0000011A label for_block_$38_continue0x0000011B mov eax,i0x0000011C push eax0x0000011D mov eax,[i]0x0000011E push eax0x0000011F integer 10x00000120 add 0x00000121 assign 0x00000122 jmp for_block_$38_test0x00000123 label for_block_$38_break//------------------------------------------------// //------------------------------------------------// switch (i) {0x00000124 mov eax,[i]0x00000125 push eax//------------------------------------------------// case 1:0x00000126 integer 10x00000127 eq 0x00000128 jz switch_block_$43_case_0//------------------------------------------------// print(1);0x00000129 mov eax,[print]0x0000012A push eax0x0000012B integer 10x0000012C push eax0x0000012D c_queue 10x0000012E push eax0x0000012F push env0x00000130 new_env 0x00000131 call 0x00000132 pop eax0x00000133 mov env,eax0x00000134 pop 0x00000135 pop //------------------------------------------------// case 2:0x00000136 jmp switch_block_$43_body_00x00000137 label switch_block_$43_case_00x00000138 integer 20x00000139 eq 0x0000013A jz switch_block_$43_case_10x0000013B label switch_block_$43_body_0//------------------------------------------------// //case 1 goes here//------------------------------------------------// print(2);0x0000013C mov eax,[print]0x0000013D push eax0x0000013E integer 20x0000013F push eax0x00000140 c_queue 10x00000141 push eax0x00000142 push env0x00000143 new_env 0x00000144 call 0x00000145 pop eax0x00000146 mov env,eax0x00000147 pop 0x00000148 pop //------------------------------------------------// case 3:0x00000149 jmp switch_block_$43_body_10x0000014A label switch_block_$43_case_10x0000014B integer 30x0000014C eq 0x0000014D jz switch_block_$43_case_20x0000014E label switch_block_$43_body_1//------------------------------------------------// print("will break");0x0000014F mov eax,[print]0x00000150 push eax0x00000151 string "will break"0x00000152 push eax0x00000153 c_queue 10x00000154 push eax0x00000155 push env0x00000156 new_env 0x00000157 call 0x00000158 pop eax0x00000159 mov env,eax0x0000015A pop 0x0000015B pop //------------------------------------------------// break;0x0000015C jmp switch_block_$43_break//------------------------------------------------// default:0x0000015D jmp switch_block_$43_body_20x0000015E label switch_block_$43_case_20x0000015F label switch_block_$43_body_2//------------------------------------------------// //default //------------------------------------------------// }0x00000160 label switch_block_$43_break//------------------------------------------------// //------------------------------------------------// function ex() {0x00000161 jmp function_decl_$56_func_exit0x00000162 label function_decl_$56_func_enter0x00000163 dequeue stack,20x00000164 set_var ,eax//------------------------------------------------// print("cause exception");0x00000165 mov eax,[print]0x00000166 push eax0x00000167 string "cause exception"0x00000168 push eax0x00000169 c_queue 10x0000016A push eax0x0000016B push env0x0000016C new_env 0x0000016D call 0x0000016E pop eax0x0000016F mov env,eax0x00000170 pop 0x00000171 pop //------------------------------------------------// throw 1;0x00000172 integer 10x00000173 mov exception,eax0x00000174 restore_machine_state //------------------------------------------------// }0x00000175 ret 0x00000176 label function_decl_$56_func_exit0x00000177 c_closure function_decl_$56_func_enter,env0x00000178 set_var ex,eax//------------------------------------------------// //------------------------------------------------// try {//------------------------------------------------// print("before throw");0x00000179 save_machine_state 0x0000017A test exception0x0000017B jnz try_block_$62_catch0x0000017C mov eax,[print]0x0000017D push eax0x0000017E string "before throw"0x0000017F push eax0x00000180 c_queue 10x00000181 push eax0x00000182 push env0x00000183 new_env 0x00000184 call 0x00000185 pop eax0x00000186 mov env,eax0x00000187 pop 0x00000188 pop //------------------------------------------------// ex();0x00000189 mov eax,[ex]0x0000018A push eax0x0000018B c_queue 00x0000018C push eax0x0000018D push env0x0000018E new_env 0x0000018F call 0x00000190 pop eax0x00000191 mov env,eax0x00000192 pop 0x00000193 pop //------------------------------------------------// print("after throw");0x00000194 mov eax,[print]0x00000195 push eax0x00000196 string "after throw"0x00000197 push eax0x00000198 c_queue 10x00000199 push eax0x0000019A push env0x0000019B new_env 0x0000019C call 0x0000019D pop eax0x0000019E mov env,eax0x0000019F pop 0x000001A0 pop //------------------------------------------------// } catch (e) {0x000001A1 drop_machine_state 0x000001A2 push eip0x000001A3 jmp try_block_$62_finally0x000001A4 jmp try_block_$62_exit0x000001A5 label try_block_$62_catch0x000001A6 set_var e,exception0x000001A7 clear exception//------------------------------------------------// print("catch"+e);0x000001A8 mov eax,[print]0x000001A9 push eax0x000001AA string "catch"0x000001AB push eax0x000001AC mov eax,[e]0x000001AD add 0x000001AE push eax0x000001AF c_queue 10x000001B0 push eax0x000001B1 push env0x000001B2 new_env 0x000001B3 call 0x000001B4 pop eax0x000001B5 mov env,eax0x000001B6 pop 0x000001B7 pop //------------------------------------------------// } finally {0x000001B8 push eip0x000001B9 jmp try_block_$62_finally0x000001BA jmp try_block_$62_exit0x000001BB label try_block_$62_finally//------------------------------------------------// print("finally..");0x000001BC mov eax,[print]0x000001BD push eax0x000001BE string "finally.."0x000001BF push eax0x000001C0 c_queue 10x000001C1 push eax0x000001C2 push env0x000001C3 new_env 0x000001C4 call 0x000001C5 pop eax0x000001C6 mov env,eax0x000001C7 pop 0x000001C8 pop //------------------------------------------------// }0x000001C9 pop eax0x000001CA jmp [eax],20x000001CB label try_block_$62_exit

 

转载于:https://www.cnblogs.com/wssccc/p/3649527.html

你可能感兴趣的文章
卷积神经网络知识链接
查看>>
java简介
查看>>
浮动、定位
查看>>
js细节
查看>>
SQL语句大全
查看>>
java中的变量
查看>>
css背景样式
查看>>
JavaScript介绍
查看>>
js中函数与对象的使用
查看>>
Date对象及toString方法
查看>>
正则表达式
查看>>
异常及throw、与throws的介绍
查看>>
js数组
查看>>
java运算符
查看>>
mysql简介
查看>>
java数组
查看>>
java二维数组
查看>>
IO流File
查看>>
java中的方法(函数)
查看>>
IO-转换流
查看>>