stage2: implement opaque declarations
* Module: implement opaque type namespace lookup * Add `Type.type` for convenience * Sema: fix `validateVarType` for pointer-to-opaque * x86_64 ABI: implement support for pointers * LLVM backend: fix lowering of opaque types * Type: implement equality checking for opaques
This commit is contained in:
@@ -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`.
|
||||
|
||||
Reference in New Issue
Block a user