authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-10-31 10:00:51-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-10-31 10:00:51-04:00
log4e12f909df6ab2f71848bbc70433a718f7549627
treebc8110bff4d4a8341139cdc78f36870ec886e737
parent7405bc761804fa351f9633dc7992ed198742e332
signature Commit is signed but in an unrecognized format.

simplify logic of pass1 ir for while on error unions


1 files changed, 14 insertions(+), 16 deletions(-)

src/ir.cpp+14-16
...@@ -5101,24 +5101,22 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n...@@ -5101,24 +5101,22 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n
5101 ir_mark_gen(ir_build_br(irb, payload_scope, node, cond_block, is_comptime));5101 ir_mark_gen(ir_build_br(irb, payload_scope, node, cond_block, is_comptime));
5102 }5102 }
51035103
5104 IrInstruction *else_result = nullptr;5104 ir_set_cursor_at_end_and_append_block(irb, else_block);
5105 if (else_node) {5105 assert(else_node != nullptr);
5106 ir_set_cursor_at_end_and_append_block(irb, else_block);
51075106
5108 // TODO make it an error to write to error variable5107 // TODO make it an error to write to error variable
5109 AstNode *err_symbol_node = else_node; // TODO make more accurate5108 AstNode *err_symbol_node = else_node; // TODO make more accurate
5110 ZigVar *err_var = ir_create_var(irb, err_symbol_node, scope, err_symbol,5109 ZigVar *err_var = ir_create_var(irb, err_symbol_node, scope, err_symbol,
5111 true, false, false, is_comptime);5110 true, false, false, is_comptime);
5112 Scope *err_scope = err_var->child_scope;5111 Scope *err_scope = err_var->child_scope;
5113 IrInstruction *err_var_value = ir_build_unwrap_err_code(irb, err_scope, err_symbol_node, err_val_ptr);5112 IrInstruction *err_var_value = ir_build_unwrap_err_code(irb, err_scope, err_symbol_node, err_val_ptr);
5114 ir_build_var_decl(irb, err_scope, symbol_node, err_var, nullptr, nullptr, err_var_value);5113 ir_build_var_decl(irb, err_scope, symbol_node, err_var, nullptr, nullptr, err_var_value);
51155114
5116 else_result = ir_gen_node(irb, else_node, err_scope);5115 IrInstruction *else_result = ir_gen_node(irb, else_node, err_scope);
5117 if (else_result == irb->codegen->invalid_instruction)5116 if (else_result == irb->codegen->invalid_instruction)
5118 return else_result;5117 return else_result;
5119 if (!instr_is_unreachable(else_result))5118 if (!instr_is_unreachable(else_result))
5120 ir_mark_gen(ir_build_br(irb, scope, node, end_block, is_comptime));5119 ir_mark_gen(ir_build_br(irb, scope, node, end_block, is_comptime));
5121 }
5122 IrBasicBlock *after_else_block = irb->current_basic_block;5120 IrBasicBlock *after_else_block = irb->current_basic_block;
5123 ir_set_cursor_at_end_and_append_block(irb, end_block);5121 ir_set_cursor_at_end_and_append_block(irb, end_block);
5124 if (else_result) {5122 if (else_result) {