fix debug line numbers for if and while. still `losing' them for return for

some reason.
This commit is contained in:
Bill Currie 2001-07-15 01:51:01 +00:00
parent a0ba8e534c
commit cb80800732

View file

@ -77,6 +77,7 @@ type_t *current_type;
def_t *current_def; def_t *current_def;
def_t param_scope; def_t param_scope;
function_t *current_func; function_t *current_func;
expr_t *local_expr;
%} %}
@ -202,9 +203,10 @@ opt_initializer
| '=' signed_const | '=' signed_const
{ {
if (pr_scope) { if (pr_scope) {
def_t *imm = PR_ReuseConstant ($2, 0); expr_t *e = new_expr ();
opcode_t *op = PR_Opcode_Find ("=", 5, imm, imm, current_def); e->type = ex_def;
emit_statement (pr_source_line, op, imm, current_def, 0); e->e.def = current_def;
append_expr (local_expr, new_binary_expr ('=', e, $2));
} else { } else {
current_def = PR_ReuseConstant ($2, current_def); current_def = PR_ReuseConstant ($2, current_def);
} }
@ -325,13 +327,20 @@ statement
{ {
expr_t *l1 = new_label_expr (); expr_t *l1 = new_label_expr ();
expr_t *l2 = new_label_expr (); expr_t *l2 = new_label_expr ();
expr_t *e;
$$ = new_block_expr (); $$ = new_block_expr ();
append_expr ($$, new_binary_expr ('n', $3, l2)); e = new_binary_expr ('n', $3, l2);
e->line = $3->line;
e->file = $3->file;
append_expr ($$, e);
append_expr ($$, l1); append_expr ($$, l1);
append_expr ($$, $5); append_expr ($$, $5);
append_expr ($$, new_binary_expr ('i', $3, l1)); e = new_binary_expr ('i', $3, l1);
e->line = $3->line;
e->file = $3->file;
append_expr ($$, e);
append_expr ($$, l2); append_expr ($$, l2);
} }
| DO statement WHILE '(' expr ')' ';' | DO statement WHILE '(' expr ')' ';'
@ -347,15 +356,24 @@ statement
| LOCAL type | LOCAL type
{ {
current_type = $2; current_type = $2;
local_expr = new_block_expr ();
}
def_list ';'
{
$$ = local_expr;
local_expr = 0;
} }
def_list ';' { $$ = 0; }
| IF '(' expr ')' statement | IF '(' expr ')' statement
{ {
expr_t *l1 = new_label_expr (); expr_t *l1 = new_label_expr ();
expr_t *e;
$$ = new_block_expr (); $$ = new_block_expr ();
append_expr ($$, new_binary_expr ('n', $3, l1)); e = new_binary_expr ('n', $3, l1);
e->line = $3->line;
e->file = $3->file;
append_expr ($$, e);
append_expr ($$, $5); append_expr ($$, $5);
append_expr ($$, l1); append_expr ($$, l1);
} }
@ -363,12 +381,20 @@ statement
{ {
expr_t *l1 = new_label_expr (); expr_t *l1 = new_label_expr ();
expr_t *l2 = new_label_expr (); expr_t *l2 = new_label_expr ();
expr_t *e;
$$ = new_block_expr (); $$ = new_block_expr ();
append_expr ($$, new_binary_expr ('n', $3, l1)); e = new_binary_expr ('n', $3, l1);
e->line = $3->line;
e->file = $3->file;
append_expr ($$, e);
append_expr ($$, $5); append_expr ($$, $5);
append_expr ($$, new_unary_expr ('g', l2));
e = new_unary_expr ('g', l2);
append_expr ($$, e);
append_expr ($$, l1); append_expr ($$, l1);
append_expr ($$, $7); append_expr ($$, $7);
append_expr ($$, l2); append_expr ($$, l2);