stage2: no Payload for Type.Tag.inferred_alloc
Simpler, less memory usage. The Value has all the info needed.
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
* no need for payload on inferred_alloc for the type
|
||||
* compile error for "variable of type '{}' must be const or comptime" after resolving types
|
||||
* test with branches
|
||||
|
||||
21
src/type.zig
21
src/type.zig
@@ -3073,7 +3073,11 @@ pub const Type = extern union {
|
||||
single_const_pointer_to_comptime_int,
|
||||
anyerror_void_error_union,
|
||||
@"anyframe",
|
||||
const_slice_u8, // See last_no_payload_tag below.
|
||||
const_slice_u8,
|
||||
/// This is a special value that tracks a set of types that have been stored
|
||||
/// to an inferred allocation. It does not support most of the normal type queries.
|
||||
/// However it does respond to `isConstPtr`, `ptrSize`, `zigTypeTag`, etc.
|
||||
inferred_alloc, // See last_no_payload_tag below.
|
||||
// After this, the tag requires a payload.
|
||||
|
||||
array_u8,
|
||||
@@ -3100,12 +3104,8 @@ pub const Type = extern union {
|
||||
error_set,
|
||||
error_set_single,
|
||||
empty_struct,
|
||||
/// This is a special value that tracks a set of types that have been stored
|
||||
/// to an inferred allocation. It does not support most of the normal type queries.
|
||||
/// However it does respond to `isConstPtr`, `ptrSize`, `zigTypeTag`, etc.
|
||||
inferred_alloc,
|
||||
|
||||
pub const last_no_payload_tag = Tag.const_slice_u8;
|
||||
pub const last_no_payload_tag = Tag.inferred_alloc;
|
||||
pub const no_payload_count = @enumToInt(last_no_payload_tag) + 1;
|
||||
|
||||
pub fn Type(comptime t: Tag) type {
|
||||
@@ -3152,6 +3152,7 @@ pub const Type = extern union {
|
||||
.anyerror_void_error_union,
|
||||
.@"anyframe",
|
||||
.const_slice_u8,
|
||||
.inferred_alloc,
|
||||
=> @compileError("Type Tag " ++ @tagName(t) ++ " has no payload"),
|
||||
|
||||
.array_u8,
|
||||
@@ -3184,7 +3185,6 @@ pub const Type = extern union {
|
||||
.error_set => Payload.Decl,
|
||||
.error_set_single => Payload.Name,
|
||||
.empty_struct => Payload.ContainerScope,
|
||||
.inferred_alloc => Payload.InferredAlloc,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3298,13 +3298,6 @@ pub const Type = extern union {
|
||||
base: Payload,
|
||||
data: *Module.Scope.Container,
|
||||
};
|
||||
|
||||
pub const InferredAlloc = struct {
|
||||
pub const base_tag = Tag.inferred_alloc;
|
||||
|
||||
base: Payload = .{ .tag = base_tag },
|
||||
data: *Value.Payload.InferredAlloc,
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -441,7 +441,7 @@ fn analyzeInstAllocInferred(mod: *Module, scope: *Scope, inst: *zir.Inst.NoOp) I
|
||||
// to a normal instruction when we hit `resolve_inferred_alloc`. So we append
|
||||
// to the block even though it is currently a `.constant`.
|
||||
const result = try mod.constInst(scope, inst.base.src, .{
|
||||
.ty = try Type.Tag.inferred_alloc.create(scope.arena(), val_payload),
|
||||
.ty = Type.initTag(.inferred_alloc),
|
||||
.val = Value.initPayload(&val_payload.base),
|
||||
});
|
||||
const block = try mod.requireFunctionBlock(scope, inst.base.src);
|
||||
|
||||
Reference in New Issue
Block a user