diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-05-02 18:50:01 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-05-02 18:50:01 -0700 |
| commit | 807a8b6f7549732d73239a649886cc64f0303f34 (patch) | |
| tree | d947dae63f799b66432744ae3b000f141d71e4cf /src/Module.zig | |
| parent | 5f4c52209eab66666cc4a8fd24bf27c372cfd54f (diff) | |
| download | zig-807a8b6f7549732d73239a649886cc64f0303f34.tar.gz zig-807a8b6f7549732d73239a649886cc64f0303f34.zip | |
stage2: make struct field analysis lazy
This commit breaks struct field analysis; will be fixed in a future
commit.
Diffstat (limited to 'src/Module.zig')
| -rw-r--r-- | src/Module.zig | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/Module.zig b/src/Module.zig index 86b15e9b0b..57bb2435fb 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -497,12 +497,22 @@ pub const Struct = struct { /// Offset from `owner_decl`, points to the struct AST node. node_offset: i32, + layout: std.builtin.TypeInfo.ContainerLayout, + status: enum { + none, + have_field_types, + have_layout, + }, + pub const Field = struct { /// Uses `noreturn` to indicate `anytype`. + /// undefined until `status` is `have_field_types` or `have_layout`. ty: Type, abi_align: Value, /// Uses `unreachable_value` to indicate no default. default_val: Value, + /// undefined until `status` is `have_layout`. + offset: u32, is_comptime: bool, }; @@ -2408,6 +2418,8 @@ pub fn semaFile(mod: *Module, file: *Scope.File) InnerError!void { .owner_decl = undefined, // set below .fields = .{}, .node_offset = 0, // it's the struct for the root file + .layout = .Auto, + .status = .none, .namespace = .{ .parent = null, .ty = struct_ty, @@ -2458,7 +2470,7 @@ pub fn semaFile(mod: *Module, file: *Scope.File) InnerError!void { const main_struct_inst = file.zir.extra[@enumToInt(Zir.ExtraIndex.main_struct)] - @intCast(u32, Zir.Inst.Ref.typed_value_map.len); - try sema.analyzeStructDecl(&block_scope, &new_decl_arena, new_decl, main_struct_inst, .Auto, struct_obj); + try sema.analyzeStructDecl(new_decl, main_struct_inst, struct_obj); try new_decl.finalizeNewArena(&new_decl_arena); file.status = .success_air; |
