diff options
Diffstat (limited to 'src/Module.zig')
| -rw-r--r-- | src/Module.zig | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/Module.zig b/src/Module.zig index ee9b3e50bc..c200c83c10 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -708,7 +708,9 @@ pub const Decl = struct { return ty.castTag(.empty_struct).?.data; }, .@"opaque" => { - @panic("TODO opaque types"); + const opaque_obj = ty.cast(Type.Payload.Opaque).?.data; + assert(opaque_obj.owner_decl == decl); + return &opaque_obj.namespace; }, .@"union", .union_tagged => { const union_obj = ty.cast(Type.Payload.Union).?.data; @@ -1080,6 +1082,27 @@ pub const Union = struct { } }; +pub const Opaque = struct { + /// The Decl that corresponds to the opaque itself. + owner_decl: *Decl, + /// Represents the declarations inside this opaque. + namespace: Namespace, + /// Offset from `owner_decl`, points to the opaque decl AST node. + node_offset: i32, + + pub fn srcLoc(self: Opaque) SrcLoc { + return .{ + .file_scope = self.owner_decl.getFileScope(), + .parent_decl_node = self.owner_decl.src_node, + .lazy = .{ .node_offset = self.node_offset }, + }; + } + + pub fn getFullyQualifiedName(s: *Opaque, gpa: *Allocator) ![:0]u8 { + return s.owner_decl.getFullyQualifiedName(gpa); + } +}; + /// Some Fn struct memory is owned by the Decl's TypedValue.Managed arena allocator. /// Extern functions do not have this data structure; they are represented by /// the `Decl` only, with a `Value` tag of `extern_fn`. |
