Node* MathExactNode::non_throwing_branch() const { IfNode* ifnode = if_node(); if (bool_node()->_test._test == BoolTest::overflow) { return ifnode->proj_out(0); } return ifnode->proj_out(1); }
void if_node(Token *tk) {// if statement int *gap; next(tk); if (tk->id != '(') PANIC("expected left parenthesis after if", tk->line); tk->stype = Arg; next(tk); expr(tk); if (tk->id != ')') PANIC("expected right parenthesis in if statement", tk->line); tk->stype = 0; assembly(pop()); *ps.pc++ = BZ; gap = ps.pc++; next(tk); if (tk->id == '{') block(tk); else stmt(tk); if (peek(tk) == Else) { next(tk); *ps.pc++ = JMP; *gap = (ps.pc - gap + 1); gap = ps.pc++; next(tk); if (tk->id == If) { if_node(tk); } else { if (tk->id == '{') block(tk); else stmt(tk); } } *gap = (ps.pc - gap); }
void stmt(Token *tk) {// statement make_empty(); if (tk->id == If) if_node(tk); else if (tk->id == While) while_node(tk); else if (tk->id == For) for_node(tk); else if (tk->id == Int) int_node(tk); else if (tk->id == Ret) return_node(tk); else if (tk->id == Prtf) printf_node(tk); else if (tk->id == Stru) struct_dec(tk); else if (tk->id == ';') next(tk); else if (tk->id == '}') return ; else { expr(tk); assembly(pop()); } }
Node* MathExactNode::control_node() const { IfNode* ifnode = if_node(); return ifnode->in(0); }