diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-02-25 21:04:23 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-02-25 21:04:23 -0700 |
| commit | 0b58b617998b79a765b54f88fbe90ca2798b3d3e (patch) | |
| tree | ca6cc4b6bcc2b93166d196049ee49416afe781ad /src/type/Struct.zig | |
| parent | dc325669e360f7a9dfa24f85a62fa386529dade6 (diff) | |
| parent | fd208d9d5913a0929e444deb97b91092c427bb14 (diff) | |
| download | zig-0b58b617998b79a765b54f88fbe90ca2798b3d3e.tar.gz zig-0b58b617998b79a765b54f88fbe90ca2798b3d3e.zip | |
Merge remote-tracking branch 'origin/master' into llvm12
Conflicts:
* src/clang.zig
* src/llvm.zig
- this file got moved to src/llvm/bindings.zig in master branch so I
had to put the new LLVM arch/os enum tags into it.
* lib/std/target.zig, src/stage1/target.cpp
- haiku had an inconsistency with its default target ABI, gnu vs
eabi. In this commit we make it gnu in both places to match the
latest changes by @hoanga.
* src/translate_c.zig
Diffstat (limited to 'src/type/Struct.zig')
| -rw-r--r-- | src/type/Struct.zig | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/type/Struct.zig b/src/type/Struct.zig new file mode 100644 index 0000000000..24e3a0dcad --- /dev/null +++ b/src/type/Struct.zig @@ -0,0 +1,56 @@ +const std = @import("std"); +const zir = @import("../zir.zig"); +const Value = @import("../value.zig").Value; +const Type = @import("../type.zig").Type; +const Module = @import("../Module.zig"); +const Scope = Module.Scope; +const Struct = @This(); + +base: Type.Payload = .{ .tag = .@"struct" }, + +analysis: union(enum) { + queued: Zir, + zero_bits_in_progress, + zero_bits: Zero, + in_progress, + // alignment: Align, + resolved: Size, + failed, +}, +scope: Scope.Container, + +pub const Field = struct { + value: Value, +}; + +pub const Zir = struct { + body: zir.Body, + inst: *zir.Inst, +}; + +pub const Zero = struct { + is_zero_bits: bool, + fields: std.StringArrayHashMapUnmanaged(Field), +}; + +pub const Size = struct { + is_zero_bits: bool, + alignment: u32, + size: u32, + fields: std.StringArrayHashMapUnmanaged(Field), +}; + +pub fn resolveZeroBits(self: *Struct, mod: *Module, scope: *Scope) !void { + const zir = switch (self.analysis) { + .failed => return error.AnalysisFail, + .zero_bits_in_progress => { + return mod.fail(scope, src, "struct '{}' depends on itself", .{}); + }, + .queued => |zir| zir, + else => return, + }; + + self.analysis = .zero_bits_in_progress; + + // TODO +} |
