authorgravatar for curtistatewilkinson@gmail.comCurtis Wilkinson <curtistatewilkinson@gmail.com> 2022-03-02 17:51:46+10:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-03-02 14:46:09-05:00
log7fc8dd66427dd0abed5ca9195e6afdbb687bd5f5
treee025b298b28a20c70c4e4ab766b11a1c8c881b95
parent5c8a507e7a8e2e58a0ca855689bcd2edd2ab6ab8

Zir: rename the 'ret_coerce' tag to 'ret_tok' as per TODO


4 files changed, 11 insertions(+), 13 deletions(-)

src/AstGen.zig+5-5
...@@ -2303,7 +2303,7 @@ fn unusedResultExpr(gz: *GenZir, scope: *Scope, statement: Ast.Node.Index) Inner...@@ -2303,7 +2303,7 @@ fn unusedResultExpr(gz: *GenZir, scope: *Scope, statement: Ast.Node.Index) Inner
2303 .compile_error,2303 .compile_error,
2304 .ret_node,2304 .ret_node,
2305 .ret_load,2305 .ret_load,
2306 .ret_coerce,2306 .ret_tok,
2307 .ret_err_value,2307 .ret_err_value,
2308 .@"unreachable",2308 .@"unreachable",
2309 .repeat,2309 .repeat,
...@@ -3420,8 +3420,8 @@ fn fnDecl(...@@ -3420,8 +3420,8 @@ fn fnDecl(
34203420
3421 if (!fn_gz.endsWithNoReturn()) {3421 if (!fn_gz.endsWithNoReturn()) {
3422 // Since we are adding the return instruction here, we must handle the coercion.3422 // Since we are adding the return instruction here, we must handle the coercion.
3423 // We do this by using the `ret_coerce` instruction.3423 // We do this by using the `ret_tok` instruction.
3424 _ = try fn_gz.addUnTok(.ret_coerce, .void_value, tree.lastToken(body_node));3424 _ = try fn_gz.addUnTok(.ret_tok, .void_value, tree.lastToken(body_node));
3425 }3425 }
34263426
3427 break :func try decl_gz.addFunc(.{3427 break :func try decl_gz.addFunc(.{
...@@ -3850,8 +3850,8 @@ fn testDecl(...@@ -3850,8 +3850,8 @@ fn testDecl(
3850 const block_result = try expr(&fn_block, &fn_block.base, .none, body_node);3850 const block_result = try expr(&fn_block, &fn_block.base, .none, body_node);
3851 if (fn_block.isEmpty() or !fn_block.refIsNoReturn(block_result)) {3851 if (fn_block.isEmpty() or !fn_block.refIsNoReturn(block_result)) {
3852 // Since we are adding the return instruction here, we must handle the coercion.3852 // Since we are adding the return instruction here, we must handle the coercion.
3853 // We do this by using the `ret_coerce` instruction.3853 // We do this by using the `ret_tok` instruction.
3854 _ = try fn_block.addUnTok(.ret_coerce, .void_value, tree.lastToken(body_node));3854 _ = try fn_block.addUnTok(.ret_tok, .void_value, tree.lastToken(body_node));
3855 }3855 }
38563856
3857 const func_inst = try decl_block.addFunc(.{3857 const func_inst = try decl_block.addFunc(.{
src/Sema.zig+2-2
...@@ -812,7 +812,7 @@ fn analyzeBodyInner(...@@ -812,7 +812,7 @@ fn analyzeBodyInner(
812 // These functions match the return type of analyzeBody so that we can812 // These functions match the return type of analyzeBody so that we can
813 // tail call them here.813 // tail call them here.
814 .compile_error => break sema.zirCompileError(block, inst),814 .compile_error => break sema.zirCompileError(block, inst),
815 .ret_coerce => break sema.zirRetCoerce(block, inst),815 .ret_tok => break sema.zirRetTok(block, inst),
816 .ret_node => break sema.zirRetNode(block, inst),816 .ret_node => break sema.zirRetNode(block, inst),
817 .ret_load => break sema.zirRetLoad(block, inst),817 .ret_load => break sema.zirRetLoad(block, inst),
818 .ret_err_value => break sema.zirRetErrValue(block, inst),818 .ret_err_value => break sema.zirRetErrValue(block, inst),
...@@ -11189,7 +11189,7 @@ fn zirRetErrValue(...@@ -11189,7 +11189,7 @@ fn zirRetErrValue(
11189 return sema.analyzeRet(block, result_inst, src);11189 return sema.analyzeRet(block, result_inst, src);
11190}11190}
1119111191
11192fn zirRetCoerce(11192fn zirRetTok(
11193 sema: *Sema,11193 sema: *Sema,
11194 block: *Block,11194 block: *Block,
11195 inst: Zir.Inst.Index,11195 inst: Zir.Inst.Index,
src/Zir.zig+3-5
...@@ -477,9 +477,7 @@ pub const Inst = struct {...@@ -477,9 +477,7 @@ pub const Inst = struct {
477 /// Includes an operand as the return value.477 /// Includes an operand as the return value.
478 /// Includes a token source location.478 /// Includes a token source location.
479 /// Uses the `un_tok` union field.479 /// Uses the `un_tok` union field.
480 /// The operand needs to get coerced to the function's return type.480 ret_tok,
481 /// TODO rename this to `ret_tok` because coercion is now done unconditionally in Sema.
482 ret_coerce,
483 /// Sends control flow back to the function's callee.481 /// Sends control flow back to the function's callee.
484 /// The return operand is `error.foo` where `foo` is given by the string.482 /// The return operand is `error.foo` where `foo` is given by the string.
485 /// If the current function has an inferred error set, the error given by the483 /// If the current function has an inferred error set, the error given by the
...@@ -1217,7 +1215,7 @@ pub const Inst = struct {...@@ -1217,7 +1215,7 @@ pub const Inst = struct {
1217 .compile_error,1215 .compile_error,
1218 .ret_node,1216 .ret_node,
1219 .ret_load,1217 .ret_load,
1220 .ret_coerce,1218 .ret_tok,
1221 .ret_err_value,1219 .ret_err_value,
1222 .@"unreachable",1220 .@"unreachable",
1223 .repeat,1221 .repeat,
...@@ -1323,7 +1321,7 @@ pub const Inst = struct {...@@ -1323,7 +1321,7 @@ pub const Inst = struct {
1323 .ref = .un_tok,1321 .ref = .un_tok,
1324 .ret_node = .un_node,1322 .ret_node = .un_node,
1325 .ret_load = .un_node,1323 .ret_load = .un_node,
1326 .ret_coerce = .un_tok,1324 .ret_tok = .un_tok,
1327 .ret_err_value = .str_tok,1325 .ret_err_value = .str_tok,
1328 .ret_err_value_code = .str_tok,1326 .ret_err_value_code = .str_tok,
1329 .ptr_type_simple = .ptr_type_simple,1327 .ptr_type_simple = .ptr_type_simple,
src/print_zir.zig+1-1
...@@ -241,7 +241,7 @@ const Writer = struct {...@@ -241,7 +241,7 @@ const Writer = struct {
241 => try self.writeUnNode(stream, inst),241 => try self.writeUnNode(stream, inst),
242242
243 .ref,243 .ref,
244 .ret_coerce,244 .ret_tok,
245 .ensure_err_payload_void,245 .ensure_err_payload_void,
246 .closure_capture,246 .closure_capture,
247 => try self.writeUnTok(stream, inst),247 => try self.writeUnTok(stream, inst),