vec_push(code_linenums, linenum);
}
+void code_pop_statement()
+{
+ vec_pop(code_statements);
+ vec_pop(code_linenums);
+}
+
void code_init() {
prog_section_function empty_function = {0,0,0,0,0,0,0,{0}};
prog_section_statement empty_statement = {0,{0},{0},{0}};
/* this function is used to keep statements and linenumbers together */
void code_push_statement(prog_section_statement *stmt, int linenum);
+void code_pop_statement();
/*
* A shallow copy of a lex_file to remember where which ast node
ontrue = tmp;
}
stidx = vec_size(code_statements);
- if (stmt.o2.s1 != 1)
- code_push_statement(&stmt, instr->context.line);
+ code_push_statement(&stmt, instr->context.line);
/* on false we jump, so add ontrue-path */
if (!gen_blocks_recursive(func, ontrue))
return false;
if (onfalse->generated) {
/* fixup the jump address */
code_statements[stidx].o2.s1 = (onfalse->code_start) - (stidx);
+ if (code_statements[stidx].o2.s1 == 1) {
+ code_statements[stidx] = code_statements[stidx+1];
+ if (code_statements[stidx].o1.s1 < 0)
+ code_statements[stidx].o1.s1++;
+ code_pop_statement();
+ }
stmt.opcode = vec_last(code_statements).opcode;
if (stmt.opcode == INSTR_GOTO ||
stmt.opcode == INSTR_IF ||
code_push_statement(&stmt, instr->context.line);
return true;
}
+ else if (code_statements[stidx].o2.s1 == 1) {
+ code_statements[stidx] = code_statements[stidx+1];
+ if (code_statements[stidx].o1.s1 < 0)
+ code_statements[stidx].o1.s1++;
+ code_pop_statement();
+ }
/* if not, generate now */
block = onfalse;
goto tailcall;