aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/c.zig
diff options
context:
space:
mode:
authorjacob gw <jacoblevgw@gmail.com>2021-03-26 17:54:41 -0400
committerAndrew Kelley <andrew@ziglang.org>2021-03-28 18:22:01 -0700
commit0005b346375f1fbe7bc42c22d658e3218bbd599d (patch)
treed88211b36f2be7689a138bf0d5f1a2e62f695323 /src/codegen/c.zig
parentf80f8a7a7835db5f8b13aab23b4ee79e88c25e63 (diff)
downloadzig-0005b346375f1fbe7bc42c22d658e3218bbd599d.tar.gz
zig-0005b346375f1fbe7bc42c22d658e3218bbd599d.zip
stage2: implement sema for @errorToInt and @intToError
Diffstat (limited to 'src/codegen/c.zig')
-rw-r--r--src/codegen/c.zig10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig
index 02d44f53c3..6e68a43607 100644
--- a/src/codegen/c.zig
+++ b/src/codegen/c.zig
@@ -569,6 +569,8 @@ pub fn genBody(o: *Object, body: ir.Body) error{ AnalysisFail, OutOfMemory }!voi
.optional_payload_ptr => try genOptionalPayload(o, inst.castTag(.optional_payload_ptr).?),
.is_err => try genIsErr(o, inst.castTag(.is_err).?),
.is_err_ptr => try genIsErr(o, inst.castTag(.is_err_ptr).?),
+ .error_to_int => try genErrorToInt(o, inst.castTag(.error_to_int).?),
+ .int_to_error => try genIntToError(o, inst.castTag(.int_to_error).?),
.unwrap_errunion_payload => try genUnwrapErrUnionPay(o, inst.castTag(.unwrap_errunion_payload).?),
.unwrap_errunion_err => try genUnwrapErrUnionErr(o, inst.castTag(.unwrap_errunion_err).?),
.unwrap_errunion_payload_ptr => try genUnwrapErrUnionPay(o, inst.castTag(.unwrap_errunion_payload_ptr).?),
@@ -1072,6 +1074,14 @@ fn genIsErr(o: *Object, inst: *Inst.UnOp) !CValue {
return local;
}
+fn genIntToError(o: *Object, inst: *Inst.UnOp) !CValue {
+ return o.resolveInst(inst.operand);
+}
+
+fn genErrorToInt(o: *Object, inst: *Inst.UnOp) !CValue {
+ return o.resolveInst(inst.operand);
+}
+
fn IndentWriter(comptime UnderlyingWriter: type) type {
return struct {
const Self = @This();