aboutsummaryrefslogtreecommitdiff
path: root/src/Module.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-04-07 11:26:07 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-04-07 11:26:07 -0700
commit4e8fb9e6a5f9a65bbf6469e386e83ba469e7543b (patch)
tree804cac2f05b76ab8c76925b3104dd19ec0e4be44 /src/Module.zig
parent01a39fa1d4d0d2e3305af8e6d6af1079f020db7f (diff)
downloadzig-4e8fb9e6a5f9a65bbf6469e386e83ba469e7543b.tar.gz
zig-4e8fb9e6a5f9a65bbf6469e386e83ba469e7543b.zip
Sema: DRY up enum field analysis and add "declared here" notes
Diffstat (limited to 'src/Module.zig')
-rw-r--r--src/Module.zig21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/Module.zig b/src/Module.zig
index 8c58b63995..9d26738e14 100644
--- a/src/Module.zig
+++ b/src/Module.zig
@@ -366,6 +366,13 @@ pub const ErrorSet = struct {
/// The string bytes are stored in the owner Decl arena.
/// They are in the same order they appear in the AST.
names_ptr: [*]const []const u8,
+
+ pub fn srcLoc(self: ErrorSet) SrcLoc {
+ return .{
+ .container = .{ .decl = self.owner_decl },
+ .lazy = .{ .node_offset = self.node_offset },
+ };
+ }
};
/// Represents the data that a struct declaration provides.
@@ -408,6 +415,13 @@ pub const EnumSimple = struct {
fields: std.StringArrayHashMapUnmanaged(void),
/// Offset from `owner_decl`, points to the enum decl AST node.
node_offset: i32,
+
+ pub fn srcLoc(self: EnumSimple) SrcLoc {
+ return .{
+ .container = .{ .decl = self.owner_decl },
+ .lazy = .{ .node_offset = self.node_offset },
+ };
+ }
};
/// Represents the data that an enum declaration provides, when there is
@@ -429,6 +443,13 @@ pub const EnumFull = struct {
node_offset: i32,
pub const ValueMap = std.ArrayHashMapUnmanaged(Value, void, Value.hash_u32, Value.eql, false);
+
+ pub fn srcLoc(self: EnumFull) SrcLoc {
+ return .{
+ .container = .{ .decl = self.owner_decl },
+ .lazy = .{ .node_offset = self.node_offset },
+ };
+ }
};
/// Some Fn struct memory is owned by the Decl's TypedValue.Managed arena allocator.