From f173d078c780c9946742c4ce686ccd0dccdb7e98 Mon Sep 17 00:00:00 2001 From: Vexu Date: Sun, 15 Nov 2020 13:03:48 +0200 Subject: stage2: outline container types --- src/type/Struct.zig | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/type/Struct.zig (limited to 'src/type/Struct.zig') diff --git a/src/type/Struct.zig b/src/type/Struct.zig new file mode 100644 index 0000000000..bb1fe56995 --- /dev/null +++ b/src/type/Struct.zig @@ -0,0 +1,57 @@ +const std = @import("std"); +const Value = @import("../value.zig").Value; +const Type = @import("../type.zig").Type; +const Module = @import("../Module.zig"); +const Scope = Module.Scope; + +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.Module.Body, + inst: *zir.Inst, + arena: std.heap.ArenaAllocator.State, +}; + +pub const Zero = struct { + is_zero_bits: bool, + fields: std.AutoArrayHashMap([]const u8, Field), +}; + +pub const Size = struct { + is_zero_bits: bool, + alignment: u32, + size: u32, + fields: std.AutoArrayHashMap([]const u8, Field), +}; + +pub fn resolveZeroBits(self: *Enum, mod: *Module, scope: *Scope) !void { + const zir = switch (self.analysis) { + .failed => return error.AnalysisFail, + .zero_bits_in_progress => { + return mod.fail(scope, src, "union '{}' depends on itself", .{}); + }, + .queued => |zir| zir, + else => return, + }; + + self.analysis = .zero_bits_in_progress; + + // TODO +} + +pub fn resolveSize(self: *Enum,) \ No newline at end of file -- cgit v1.2.3