Skip to content

Commit

Permalink
fixes #305: correctly output POPC in try.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kray-G committed Jul 19, 2021
1 parent 0e0c113 commit cb1e754
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
8 changes: 2 additions & 6 deletions src/ast_gencode.c
Original file line number Diff line number Diff line change
Expand Up @@ -2307,9 +2307,7 @@ LOOP_HEAD:;
int block = ana->block;
int try, catch, scatch, out, tryjmp;
try = new_block_hook(ana);
if (node->ex) {
kv_push(kx_object_t*, *(ana->finallies), node->ex);
}
kv_push(kx_object_t*, *(ana->finallies), node->ex); /* ex should be NOT NULL */

get_block(module, block)->tf[0] = try;
ana->block = tryjmp = try;
Expand All @@ -2333,9 +2331,7 @@ LOOP_HEAD:;
kv_push(kx_code_t, get_block(module, ana->block)->code, ((kx_code_t){ FILELINE(ana), .op = KX_THROWA }));
}
catch = ana->block;
if (node->ex) {
kv_remove_last(*(ana->finallies));
}
kv_remove_last(*(ana->finallies)); /* ex should be NOT NULL */

kv_A(get_block(module, tryjmp)->code, pushc).value1.i = get_block(module, scatch)->index;
get_block(module, try)->tf[0] = out;
Expand Down
4 changes: 2 additions & 2 deletions src/kinx.y
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,8 @@ CatchVariable
;

FinallyStatement_Opt
: { $$ = NULL; }
| FINALLY BlockStatement { $$ = $2; }
: { $$ = kx_gen_block_object(NULL); }
| FINALLY BlockStatement { $$ = ($2 == NULL) ? kx_gen_block_object(NULL) : $2; }
;

BreakStatement
Expand Down
4 changes: 2 additions & 2 deletions src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -2152,10 +2152,10 @@ int yyparse(YYPARSE_ARG)
{ yyval.obj = kx_gen_var_object_line_pos(YYASP(2-3).strinfo.name, KX_UNKNOWN_T, YYASP(2-3).strinfo.line, YYASP(2-3).strinfo.pos1, YYASP(2-3).strinfo.pos2); } break;
case 83:
#line 354 "src/kinx.y"
{ yyval.obj = NULL; } break;
{ yyval.obj = kx_gen_block_object(NULL); } break;
case 84:
#line 355 "src/kinx.y"
{ yyval.obj = YYASP(2-2).obj; } break;
{ yyval.obj = (YYASP(2-2).obj == NULL) ? kx_gen_block_object(NULL) : YYASP(2-2).obj; } break;
case 85:
#line 359 "src/kinx.y"
{ yyval.obj = kx_gen_modifier(YYASP(2-3).obj, kx_gen_break_object(KXST_BREAK, NULL)); } break;
Expand Down

0 comments on commit cb1e754

Please sign in to comment.