@@ -2080,6 +2080,8 @@ static char* Suger_multiAssign(Args* out_buffs, char* line) {
20802080 Arg * out_list = arg_newStr ("" );
20812081 Arg * out_item = arg_newStr ("" );
20822082 Arg * line_out_arg = arg_newStr ("" );
2083+ char * line_item = NULL ;
2084+ char * out_list_str = NULL ;
20832085 int out_num = 0 ;
20842086 Cursor_forEachToken (cs , line ) {
20852087 Cursor_iterStart (& cs );
@@ -2107,11 +2109,11 @@ static char* Suger_multiAssign(Args* out_buffs, char* line) {
21072109 goto exit ;
21082110 }
21092111
2110- char * line_item =
2112+ line_item =
21112113 strsFormat (& buffs , PIKA_LINE_BUFF_SIZE , "$tmp= %s\n" , arg_getStr (stmt ));
21122114 line_out_arg = arg_strAppend (line_out_arg , line_item );
21132115
2114- char * out_list_str = arg_getStr (out_list );
2116+ out_list_str = arg_getStr (out_list );
21152117 while (1 ) {
21162118 char * item = Cursor_popToken (& buffs , & out_list_str , "," );
21172119 if (item [0 ] == '\0' ) {
@@ -2547,6 +2549,25 @@ char* GenRule_toAsm(GenRule rule,
25472549}
25482550
25492551char * AST_genAsm (AST * ast , Args * outBuffs ) {
2552+
2553+ const GenRule rules_topAst [] = {
2554+ {.ins = "CTN" , .type = VAL_NONEVAL , .ast = "continue" },
2555+ {.ins = "BRK" , .type = VAL_NONEVAL , .ast = "break" },
2556+ {.ins = "DEL" , .type = VAL_DYNAMIC , .ast = "del" },
2557+ {.ins = "GLB" , .type = VAL_DYNAMIC , .ast = "global" },
2558+ {.ins = "RIS" , .type = VAL_DYNAMIC , .ast = "raise" },
2559+ {.ins = "ASS" , .type = VAL_NONEVAL , .ast = "assert" },
2560+ {.ins = "RET" , .type = VAL_NONEVAL , .ast = "return" }};
2561+
2562+ /* generate code for block ast */
2563+ const GenRule rules_block [] = {
2564+ {.ins = "TRY" , .type = VAL_NONEVAL , .ast = "try" },
2565+ {.ins = "EXP" , .type = VAL_NONEVAL , .ast = "except" },
2566+ {.ins = "NEL" , .type = VAL_STATIC_ , .ast = "else" , .val = "1" },
2567+ {.ins = "JEZ" , .type = VAL_STATIC_ , .ast = "if" , .val = "1" },
2568+ {.ins = "JEZ" , .type = VAL_STATIC_ , .ast = "while" , .val = "2" },
2569+ };
2570+
25502571 Args buffs = {0 };
25512572 char * pikaAsm = strsCopy (& buffs , "" );
25522573 QueueObj * exitBlock ;
@@ -2777,14 +2798,7 @@ char* AST_genAsm(AST* ast, Args* outBuffs) {
27772798 is_block_matched = 1 ;
27782799 goto exit ;
27792800 }
2780- /* generate code for block ast */
2781- const GenRule rules_block [] = {
2782- {.ins = "TRY" , .type = VAL_NONEVAL , .ast = "try" },
2783- {.ins = "EXP" , .type = VAL_NONEVAL , .ast = "except" },
2784- {.ins = "NEL" , .type = VAL_STATIC_ , .ast = "else" , .val = "1" },
2785- {.ins = "JEZ" , .type = VAL_STATIC_ , .ast = "if" , .val = "1" },
2786- {.ins = "JEZ" , .type = VAL_STATIC_ , .ast = "while" , .val = "2" },
2787- };
2801+
27882802
27892803 for (size_t i = 0 ; i < sizeof (rules_block ) / sizeof (GenRule ); i ++ ) {
27902804 GenRule rule = rules_block [i ];
@@ -2795,15 +2809,6 @@ char* AST_genAsm(AST* ast, Args* outBuffs) {
27952809 }
27962810 }
27972811
2798- const GenRule rules_topAst [] = {
2799- {.ins = "CTN" , .type = VAL_NONEVAL , .ast = "continue" },
2800- {.ins = "BRK" , .type = VAL_NONEVAL , .ast = "break" },
2801- {.ins = "DEL" , .type = VAL_DYNAMIC , .ast = "del" },
2802- {.ins = "GLB" , .type = VAL_DYNAMIC , .ast = "global" },
2803- {.ins = "RIS" , .type = VAL_DYNAMIC , .ast = "raise" },
2804- {.ins = "ASS" , .type = VAL_NONEVAL , .ast = "assert" },
2805- {.ins = "RET" , .type = VAL_NONEVAL , .ast = "return" }};
2806-
28072812 /* generate code for top level ast */
28082813 for (size_t i = 0 ; i < sizeof (rules_topAst ) / sizeof (rules_topAst [0 ]);
28092814 i ++ ) {
0 commit comments