hook up result locs for try

This commit is contained in:
Andrew Kelley 2019-06-08 01:16:19 -04:00
parent a2fff2628f
commit 52eb347188
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9
5 changed files with 13 additions and 13 deletions

View File

@ -430,7 +430,7 @@ enum NodeType {
NodeTypeVariableDeclaration, NodeTypeVariableDeclaration,
NodeTypeTestDecl, NodeTypeTestDecl,
NodeTypeBinOpExpr, NodeTypeBinOpExpr,
NodeTypeUnwrapErrorExpr, NodeTypeCatchExpr,
NodeTypeFloatLiteral, NodeTypeFloatLiteral,
NodeTypeIntLiteral, NodeTypeIntLiteral,
NodeTypeStringLiteral, NodeTypeStringLiteral,

View File

@ -2993,7 +2993,7 @@ void scan_decls(CodeGen *g, ScopeDecls *decls_scope, AstNode *node) {
case NodeTypeBlock: case NodeTypeBlock:
case NodeTypeGroupedExpr: case NodeTypeGroupedExpr:
case NodeTypeBinOpExpr: case NodeTypeBinOpExpr:
case NodeTypeUnwrapErrorExpr: case NodeTypeCatchExpr:
case NodeTypeFnCallExpr: case NodeTypeFnCallExpr:
case NodeTypeArrayAccessExpr: case NodeTypeArrayAccessExpr:
case NodeTypeSliceExpr: case NodeTypeSliceExpr:

View File

@ -165,8 +165,8 @@ static const char *node_type_str(NodeType node_type) {
return "Parens"; return "Parens";
case NodeTypeBinOpExpr: case NodeTypeBinOpExpr:
return "BinOpExpr"; return "BinOpExpr";
case NodeTypeUnwrapErrorExpr: case NodeTypeCatchExpr:
return "UnwrapErrorExpr"; return "CatchExpr";
case NodeTypeFnCallExpr: case NodeTypeFnCallExpr:
return "FnCallExpr"; return "FnCallExpr";
case NodeTypeArrayAccessExpr: case NodeTypeArrayAccessExpr:
@ -1100,7 +1100,7 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) {
fprintf(ar->f, "]"); fprintf(ar->f, "]");
break; break;
} }
case NodeTypeUnwrapErrorExpr: case NodeTypeCatchExpr:
{ {
render_node_ungrouped(ar, node->data.unwrap_err_expr.op1); render_node_ungrouped(ar, node->data.unwrap_err_expr.op1);
fprintf(ar->f, " catch "); fprintf(ar->f, " catch ");

View File

@ -3383,7 +3383,7 @@ static IrInstruction *ir_gen_async_return(IrBuilder *irb, Scope *scope, AstNode
return ir_build_cond_br(irb, scope, node, is_canceled_bool, irb->exec->coro_final_cleanup_block, irb->exec->coro_early_final, is_comptime); return ir_build_cond_br(irb, scope, node, is_canceled_bool, irb->exec->coro_final_cleanup_block, irb->exec->coro_early_final, is_comptime);
} }
static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval) { static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) {
assert(node->type == NodeTypeReturnExpr); assert(node->type == NodeTypeReturnExpr);
ZigFn *fn_entry = exec_fn_entry(irb->exec); ZigFn *fn_entry = exec_fn_entry(irb->exec);
@ -3508,7 +3508,7 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node,
if (lval == LValPtr) if (lval == LValPtr)
return unwrapped_ptr; return unwrapped_ptr;
else else
return ir_build_load_ptr(irb, scope, node, unwrapped_ptr); return ir_expr_wrap(irb, scope, ir_build_load_ptr(irb, scope, node, unwrapped_ptr), result_loc);
} }
} }
zig_unreachable(); zig_unreachable();
@ -7083,7 +7083,7 @@ static IrInstruction *ir_gen_slice(IrBuilder *irb, Scope *scope, AstNode *node)
static IrInstruction *ir_gen_catch(IrBuilder *irb, Scope *parent_scope, AstNode *node, LVal lval, static IrInstruction *ir_gen_catch(IrBuilder *irb, Scope *parent_scope, AstNode *node, LVal lval,
ResultLoc *result_loc) ResultLoc *result_loc)
{ {
assert(node->type == NodeTypeUnwrapErrorExpr); assert(node->type == NodeTypeCatchExpr);
AstNode *op1_node = node->data.unwrap_err_expr.op1; AstNode *op1_node = node->data.unwrap_err_expr.op1;
AstNode *op2_node = node->data.unwrap_err_expr.op2; AstNode *op2_node = node->data.unwrap_err_expr.op2;
@ -7895,7 +7895,7 @@ static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scop
case NodeTypeArrayAccessExpr: case NodeTypeArrayAccessExpr:
return ir_gen_array_access(irb, scope, node, lval, result_loc); return ir_gen_array_access(irb, scope, node, lval, result_loc);
case NodeTypeReturnExpr: case NodeTypeReturnExpr:
return ir_gen_return(irb, scope, node, lval); return ir_gen_return(irb, scope, node, lval, result_loc);
case NodeTypeFieldAccessExpr: case NodeTypeFieldAccessExpr:
{ {
IrInstruction *ptr_instruction = ir_gen_field_access(irb, scope, node); IrInstruction *ptr_instruction = ir_gen_field_access(irb, scope, node);
@ -7968,7 +7968,7 @@ static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scop
return ir_lval_wrap(irb, scope, ir_gen_defer(irb, scope, node), lval, result_loc); return ir_lval_wrap(irb, scope, ir_gen_defer(irb, scope, node), lval, result_loc);
case NodeTypeSliceExpr: case NodeTypeSliceExpr:
return ir_lval_wrap(irb, scope, ir_gen_slice(irb, scope, node), lval, result_loc); return ir_lval_wrap(irb, scope, ir_gen_slice(irb, scope, node), lval, result_loc);
case NodeTypeUnwrapErrorExpr: case NodeTypeCatchExpr:
return ir_gen_catch(irb, scope, node, lval, result_loc); return ir_gen_catch(irb, scope, node, lval, result_loc);
case NodeTypeContainerDecl: case NodeTypeContainerDecl:
return ir_lval_wrap(irb, scope, ir_gen_container_decl(irb, scope, node), lval, result_loc); return ir_lval_wrap(irb, scope, ir_gen_container_decl(irb, scope, node), lval, result_loc);

View File

@ -341,7 +341,7 @@ static AstNode *ast_parse_bin_op_expr(
op->data.bin_op_expr.op1 = left; op->data.bin_op_expr.op1 = left;
op->data.bin_op_expr.op2 = right; op->data.bin_op_expr.op2 = right;
break; break;
case NodeTypeUnwrapErrorExpr: case NodeTypeCatchExpr:
op->data.unwrap_err_expr.op1 = left; op->data.unwrap_err_expr.op1 = left;
op->data.unwrap_err_expr.op2 = right; op->data.unwrap_err_expr.op2 = right;
break; break;
@ -2377,7 +2377,7 @@ static AstNode *ast_parse_bitwise_op(ParseContext *pc) {
Token *catch_token = eat_token_if(pc, TokenIdKeywordCatch); Token *catch_token = eat_token_if(pc, TokenIdKeywordCatch);
if (catch_token != nullptr) { if (catch_token != nullptr) {
Token *payload = ast_parse_payload(pc); Token *payload = ast_parse_payload(pc);
AstNode *res = ast_create_node(pc, NodeTypeUnwrapErrorExpr, catch_token); AstNode *res = ast_create_node(pc, NodeTypeCatchExpr, catch_token);
if (payload != nullptr) if (payload != nullptr)
res->data.unwrap_err_expr.symbol = token_symbol(pc, payload); res->data.unwrap_err_expr.symbol = token_symbol(pc, payload);
@ -2864,7 +2864,7 @@ void ast_visit_node_children(AstNode *node, void (*visit)(AstNode **, void *cont
visit_field(&node->data.bin_op_expr.op1, visit, context); visit_field(&node->data.bin_op_expr.op1, visit, context);
visit_field(&node->data.bin_op_expr.op2, visit, context); visit_field(&node->data.bin_op_expr.op2, visit, context);
break; break;
case NodeTypeUnwrapErrorExpr: case NodeTypeCatchExpr:
visit_field(&node->data.unwrap_err_expr.op1, visit, context); visit_field(&node->data.unwrap_err_expr.op1, visit, context);
visit_field(&node->data.unwrap_err_expr.symbol, visit, context); visit_field(&node->data.unwrap_err_expr.symbol, visit, context);
visit_field(&node->data.unwrap_err_expr.op2, visit, context); visit_field(&node->data.unwrap_err_expr.op2, visit, context);