authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-06-08 01:16:19-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-06-08 01:16:19-04:00
log52eb34718862928b5d83c58990d5d7a6b07e20e2
treebd42eec2f05ae34f6d80ae8b1cd202971b1bbb14
parenta2fff2628f067898aab54899fa8b74abcd2d2212
signature Commit is signed but in an unrecognized format.

hook up result locs for `try`


5 files changed, 13 insertions(+), 13 deletions(-)

src/all_types.hpp+1-1
...@@ -430,7 +430,7 @@ enum NodeType {...@@ -430,7 +430,7 @@ enum NodeType {
430 NodeTypeVariableDeclaration,430 NodeTypeVariableDeclaration,
431 NodeTypeTestDecl,431 NodeTypeTestDecl,
432 NodeTypeBinOpExpr,432 NodeTypeBinOpExpr,
433 NodeTypeUnwrapErrorExpr,433 NodeTypeCatchExpr,
434 NodeTypeFloatLiteral,434 NodeTypeFloatLiteral,
435 NodeTypeIntLiteral,435 NodeTypeIntLiteral,
436 NodeTypeStringLiteral,436 NodeTypeStringLiteral,
src/analyze.cpp+1-1
...@@ -2993,7 +2993,7 @@ void scan_decls(CodeGen *g, ScopeDecls *decls_scope, AstNode *node) {...@@ -2993,7 +2993,7 @@ void scan_decls(CodeGen *g, ScopeDecls *decls_scope, AstNode *node) {
2993 case NodeTypeBlock:2993 case NodeTypeBlock:
2994 case NodeTypeGroupedExpr:2994 case NodeTypeGroupedExpr:
2995 case NodeTypeBinOpExpr:2995 case NodeTypeBinOpExpr:
2996 case NodeTypeUnwrapErrorExpr:2996 case NodeTypeCatchExpr:
2997 case NodeTypeFnCallExpr:2997 case NodeTypeFnCallExpr:
2998 case NodeTypeArrayAccessExpr:2998 case NodeTypeArrayAccessExpr:
2999 case NodeTypeSliceExpr:2999 case NodeTypeSliceExpr:
src/ast_render.cpp+3-3
...@@ -165,8 +165,8 @@ static const char *node_type_str(NodeType node_type) {...@@ -165,8 +165,8 @@ static const char *node_type_str(NodeType node_type) {
165 return "Parens";165 return "Parens";
166 case NodeTypeBinOpExpr:166 case NodeTypeBinOpExpr:
167 return "BinOpExpr";167 return "BinOpExpr";
168 case NodeTypeUnwrapErrorExpr:168 case NodeTypeCatchExpr:
169 return "UnwrapErrorExpr";169 return "CatchExpr";
170 case NodeTypeFnCallExpr:170 case NodeTypeFnCallExpr:
171 return "FnCallExpr";171 return "FnCallExpr";
172 case NodeTypeArrayAccessExpr:172 case NodeTypeArrayAccessExpr:
...@@ -1100,7 +1100,7 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) {...@@ -1100,7 +1100,7 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) {
1100 fprintf(ar->f, "]");1100 fprintf(ar->f, "]");
1101 break;1101 break;
1102 }1102 }
1103 case NodeTypeUnwrapErrorExpr:1103 case NodeTypeCatchExpr:
1104 {1104 {
1105 render_node_ungrouped(ar, node->data.unwrap_err_expr.op1);1105 render_node_ungrouped(ar, node->data.unwrap_err_expr.op1);
1106 fprintf(ar->f, " catch ");1106 fprintf(ar->f, " catch ");
src/ir.cpp+5-5
...@@ -3383,7 +3383,7 @@ static IrInstruction *ir_gen_async_return(IrBuilder *irb, Scope *scope, AstNode...@@ -3383,7 +3383,7 @@ static IrInstruction *ir_gen_async_return(IrBuilder *irb, Scope *scope, AstNode
3383 return ir_build_cond_br(irb, scope, node, is_canceled_bool, irb->exec->coro_final_cleanup_block, irb->exec->coro_early_final, is_comptime);3383 return ir_build_cond_br(irb, scope, node, is_canceled_bool, irb->exec->coro_final_cleanup_block, irb->exec->coro_early_final, is_comptime);
3384}3384}
33853385
3386static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval) {3386static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) {
3387 assert(node->type == NodeTypeReturnExpr);3387 assert(node->type == NodeTypeReturnExpr);
33883388
3389 ZigFn *fn_entry = exec_fn_entry(irb->exec);3389 ZigFn *fn_entry = exec_fn_entry(irb->exec);
...@@ -3508,7 +3508,7 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node,...@@ -3508,7 +3508,7 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node,
3508 if (lval == LValPtr)3508 if (lval == LValPtr)
3509 return unwrapped_ptr;3509 return unwrapped_ptr;
3510 else3510 else
3511 return ir_build_load_ptr(irb, scope, node, unwrapped_ptr);3511 return ir_expr_wrap(irb, scope, ir_build_load_ptr(irb, scope, node, unwrapped_ptr), result_loc);
3512 }3512 }
3513 }3513 }
3514 zig_unreachable();3514 zig_unreachable();
...@@ -7083,7 +7083,7 @@ static IrInstruction *ir_gen_slice(IrBuilder *irb, Scope *scope, AstNode *node)...@@ -7083,7 +7083,7 @@ static IrInstruction *ir_gen_slice(IrBuilder *irb, Scope *scope, AstNode *node)
7083static IrInstruction *ir_gen_catch(IrBuilder *irb, Scope *parent_scope, AstNode *node, LVal lval,7083static IrInstruction *ir_gen_catch(IrBuilder *irb, Scope *parent_scope, AstNode *node, LVal lval,
7084 ResultLoc *result_loc)7084 ResultLoc *result_loc)
7085{7085{
7086 assert(node->type == NodeTypeUnwrapErrorExpr);7086 assert(node->type == NodeTypeCatchExpr);
70877087
7088 AstNode *op1_node = node->data.unwrap_err_expr.op1;7088 AstNode *op1_node = node->data.unwrap_err_expr.op1;
7089 AstNode *op2_node = node->data.unwrap_err_expr.op2;7089 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...@@ -7895,7 +7895,7 @@ static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scop
7895 case NodeTypeArrayAccessExpr:7895 case NodeTypeArrayAccessExpr:
7896 return ir_gen_array_access(irb, scope, node, lval, result_loc);7896 return ir_gen_array_access(irb, scope, node, lval, result_loc);
7897 case NodeTypeReturnExpr:7897 case NodeTypeReturnExpr:
7898 return ir_gen_return(irb, scope, node, lval);7898 return ir_gen_return(irb, scope, node, lval, result_loc);
7899 case NodeTypeFieldAccessExpr:7899 case NodeTypeFieldAccessExpr:
7900 {7900 {
7901 IrInstruction *ptr_instruction = ir_gen_field_access(irb, scope, node);7901 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...@@ -7968,7 +7968,7 @@ static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scop
7968 return ir_lval_wrap(irb, scope, ir_gen_defer(irb, scope, node), lval, result_loc);7968 return ir_lval_wrap(irb, scope, ir_gen_defer(irb, scope, node), lval, result_loc);
7969 case NodeTypeSliceExpr:7969 case NodeTypeSliceExpr:
7970 return ir_lval_wrap(irb, scope, ir_gen_slice(irb, scope, node), lval, result_loc);7970 return ir_lval_wrap(irb, scope, ir_gen_slice(irb, scope, node), lval, result_loc);
7971 case NodeTypeUnwrapErrorExpr:7971 case NodeTypeCatchExpr:
7972 return ir_gen_catch(irb, scope, node, lval, result_loc);7972 return ir_gen_catch(irb, scope, node, lval, result_loc);
7973 case NodeTypeContainerDecl:7973 case NodeTypeContainerDecl:
7974 return ir_lval_wrap(irb, scope, ir_gen_container_decl(irb, scope, node), lval, result_loc);7974 return ir_lval_wrap(irb, scope, ir_gen_container_decl(irb, scope, node), lval, result_loc);
src/parser.cpp+3-3
...@@ -341,7 +341,7 @@ static AstNode *ast_parse_bin_op_expr(...@@ -341,7 +341,7 @@ static AstNode *ast_parse_bin_op_expr(
341 op->data.bin_op_expr.op1 = left;341 op->data.bin_op_expr.op1 = left;
342 op->data.bin_op_expr.op2 = right;342 op->data.bin_op_expr.op2 = right;
343 break;343 break;
344 case NodeTypeUnwrapErrorExpr:344 case NodeTypeCatchExpr:
345 op->data.unwrap_err_expr.op1 = left;345 op->data.unwrap_err_expr.op1 = left;
346 op->data.unwrap_err_expr.op2 = right;346 op->data.unwrap_err_expr.op2 = right;
347 break;347 break;
...@@ -2377,7 +2377,7 @@ static AstNode *ast_parse_bitwise_op(ParseContext *pc) {...@@ -2377,7 +2377,7 @@ static AstNode *ast_parse_bitwise_op(ParseContext *pc) {
2377 Token *catch_token = eat_token_if(pc, TokenIdKeywordCatch);2377 Token *catch_token = eat_token_if(pc, TokenIdKeywordCatch);
2378 if (catch_token != nullptr) {2378 if (catch_token != nullptr) {
2379 Token *payload = ast_parse_payload(pc);2379 Token *payload = ast_parse_payload(pc);
2380 AstNode *res = ast_create_node(pc, NodeTypeUnwrapErrorExpr, catch_token);2380 AstNode *res = ast_create_node(pc, NodeTypeCatchExpr, catch_token);
2381 if (payload != nullptr)2381 if (payload != nullptr)
2382 res->data.unwrap_err_expr.symbol = token_symbol(pc, payload);2382 res->data.unwrap_err_expr.symbol = token_symbol(pc, payload);
23832383
...@@ -2864,7 +2864,7 @@ void ast_visit_node_children(AstNode *node, void (*visit)(AstNode **, void *cont...@@ -2864,7 +2864,7 @@ void ast_visit_node_children(AstNode *node, void (*visit)(AstNode **, void *cont
2864 visit_field(&node->data.bin_op_expr.op1, visit, context);2864 visit_field(&node->data.bin_op_expr.op1, visit, context);
2865 visit_field(&node->data.bin_op_expr.op2, visit, context);2865 visit_field(&node->data.bin_op_expr.op2, visit, context);
2866 break;2866 break;
2867 case NodeTypeUnwrapErrorExpr:2867 case NodeTypeCatchExpr:
2868 visit_field(&node->data.unwrap_err_expr.op1, visit, context);2868 visit_field(&node->data.unwrap_err_expr.op1, visit, context);
2869 visit_field(&node->data.unwrap_err_expr.symbol, visit, context);2869 visit_field(&node->data.unwrap_err_expr.symbol, visit, context);
2870 visit_field(&node->data.unwrap_err_expr.op2, visit, context);2870 visit_field(&node->data.unwrap_err_expr.op2, visit, context);