diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-03-24 00:44:18 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-03-24 00:44:18 -0400 |
| commit | d0551db5cd29e4c7f361ef40a37486138a4e8b1e (patch) | |
| tree | 9b591aa521477ec0bb3bd0ef046e50d140e51d67 /src-self-hosted | |
| parent | 64dddd7afe14a683826b03bc36ab80fa93a84e2c (diff) | |
| download | zig-d0551db5cd29e4c7f361ef40a37486138a4e8b1e.tar.gz zig-d0551db5cd29e4c7f361ef40a37486138a4e8b1e.zip | |
introduce the enum literal type
see #683
Diffstat (limited to 'src-self-hosted')
| -rw-r--r-- | src-self-hosted/ir.zig | 1 | ||||
| -rw-r--r-- | src-self-hosted/type.zig | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src-self-hosted/ir.zig b/src-self-hosted/ir.zig index 3f8c45aad7..8cdac92326 100644 --- a/src-self-hosted/ir.zig +++ b/src-self-hosted/ir.zig @@ -1186,6 +1186,7 @@ pub const Builder = struct { ast.Node.Id.AsyncAttribute => return error.Unimplemented, ast.Node.Id.ParamDecl => return error.Unimplemented, ast.Node.Id.FieldInitializer => return error.Unimplemented, + ast.Node.Id.EnumLiteral => return error.Unimplemented, } } diff --git a/src-self-hosted/type.zig b/src-self-hosted/type.zig index 4c9fb58a18..5a8dc47ef9 100644 --- a/src-self-hosted/type.zig +++ b/src-self-hosted/type.zig @@ -32,6 +32,7 @@ pub const Type = struct { Id.Array => @fieldParentPtr(Array, "base", base).destroy(comp), Id.ComptimeFloat => @fieldParentPtr(ComptimeFloat, "base", base).destroy(comp), Id.ComptimeInt => @fieldParentPtr(ComptimeInt, "base", base).destroy(comp), + Id.EnumLiteral => @fieldParentPtr(EnumLiteral, "base", base).destroy(comp), Id.Undefined => @fieldParentPtr(Undefined, "base", base).destroy(comp), Id.Null => @fieldParentPtr(Null, "base", base).destroy(comp), Id.Optional => @fieldParentPtr(Optional, "base", base).destroy(comp), @@ -65,6 +66,7 @@ pub const Type = struct { Id.Array => return @fieldParentPtr(Array, "base", base).getLlvmType(allocator, llvm_context), Id.ComptimeFloat => unreachable, Id.ComptimeInt => unreachable, + Id.EnumLiteral => unreachable, Id.Undefined => unreachable, Id.Null => unreachable, Id.Optional => return @fieldParentPtr(Optional, "base", base).getLlvmType(allocator, llvm_context), @@ -85,6 +87,7 @@ pub const Type = struct { Id.Type, Id.ComptimeFloat, Id.ComptimeInt, + Id.EnumLiteral, Id.Undefined, Id.Null, Id.BoundFn, @@ -118,6 +121,7 @@ pub const Type = struct { Id.Type, Id.ComptimeFloat, Id.ComptimeInt, + Id.EnumLiteral, Id.Undefined, Id.Null, Id.BoundFn, @@ -940,6 +944,20 @@ pub const Type = struct { } }; + pub const EnumLiteral = struct { + base: Type, + + /// Adds 1 reference to the resulting type + pub fn get(comp: *Compilation) *EnumLiteral { + comp.comptime_int_type.base.base.ref(); + return comp.comptime_int_type; + } + + pub fn destroy(self: *EnumLiteral, comp: *Compilation) void { + comp.gpa().destroy(self); + } + }; + pub const Undefined = struct { base: Type, |
