diff options
Diffstat (limited to 'src/value.zig')
| -rw-r--r-- | src/value.zig | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/value.zig b/src/value.zig index d24c5a1c17..28601c1723 100644 --- a/src/value.zig +++ b/src/value.zig @@ -111,10 +111,12 @@ pub const Value = extern union { int_i64, int_big_positive, int_big_negative, - runtime_int, function, extern_fn, variable, + /// A wrapper for values which are comptime-known but should + /// semantically be runtime-known. + runtime_value, /// Represents a pointer to a Decl. /// When machine codegen backend sees this, it must set the Decl's `alive` field to true. decl_ref, @@ -282,6 +284,7 @@ pub const Value = extern union { .eu_payload, .opt_payload, .empty_array_sentinel, + .runtime_value, => Payload.SubValue, .eu_payload_ptr, @@ -305,7 +308,6 @@ pub const Value = extern union { .int_type => Payload.IntType, .int_u64 => Payload.U64, .int_i64 => Payload.I64, - .runtime_int => Payload.U64, .function => Payload.Function, .variable => Payload.Variable, .decl_ref_mut => Payload.DeclRefMut, @@ -485,7 +487,6 @@ pub const Value = extern union { }, .int_type => return self.copyPayloadShallow(arena, Payload.IntType), .int_u64 => return self.copyPayloadShallow(arena, Payload.U64), - .runtime_int => return self.copyPayloadShallow(arena, Payload.U64), .int_i64 => return self.copyPayloadShallow(arena, Payload.I64), .int_big_positive, .int_big_negative => { const old_payload = self.cast(Payload.BigInt).?; @@ -567,6 +568,7 @@ pub const Value = extern union { .eu_payload, .opt_payload, .empty_array_sentinel, + .runtime_value, => { const payload = self.cast(Payload.SubValue).?; const new_payload = try arena.create(Payload.SubValue); @@ -765,7 +767,7 @@ pub const Value = extern union { .int_i64 => return std.fmt.formatIntValue(val.castTag(.int_i64).?.data, "", options, out_stream), .int_big_positive => return out_stream.print("{}", .{val.castTag(.int_big_positive).?.asBigInt()}), .int_big_negative => return out_stream.print("{}", .{val.castTag(.int_big_negative).?.asBigInt()}), - .runtime_int => return out_stream.writeAll("[runtime value]"), + .runtime_value => return out_stream.writeAll("[runtime value]"), .function => return out_stream.print("(function decl={d})", .{val.castTag(.function).?.data.owner_decl}), .extern_fn => return out_stream.writeAll("(extern function)"), .variable => return out_stream.writeAll("(variable)"), @@ -1081,8 +1083,6 @@ pub const Value = extern union { .int_big_positive => return val.castTag(.int_big_positive).?.asBigInt(), .int_big_negative => return val.castTag(.int_big_negative).?.asBigInt(), - .runtime_int => return BigIntMutable.init(&space.limbs, val.castTag(.runtime_int).?.data).toConst(), - .undef => unreachable, .lazy_align => { @@ -1138,8 +1138,6 @@ pub const Value = extern union { .int_big_positive => return val.castTag(.int_big_positive).?.asBigInt().to(u64) catch null, .int_big_negative => return val.castTag(.int_big_negative).?.asBigInt().to(u64) catch null, - .runtime_int => return val.castTag(.runtime_int).?.data, - .undef => unreachable, .lazy_align => { @@ -2357,6 +2355,8 @@ pub const Value = extern union { const zig_ty_tag = ty.zigTypeTag(); std.hash.autoHash(hasher, zig_ty_tag); if (val.isUndef()) return; + // The value is runtime-known and shouldn't affect the hash. + if (val.tag() == .runtime_value) return; switch (zig_ty_tag) { .BoundFn => unreachable, // TODO remove this from the language @@ -2632,9 +2632,6 @@ pub const Value = extern union { .lazy_size, => return hashInt(ptr_val, hasher, target), - // The value is runtime-known and shouldn't affect the hash. - .runtime_int => {}, - else => unreachable, } } |
