diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-12-02 19:56:43 +0200 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-12-03 00:09:23 +0200 |
| commit | 0e38cc16d51178525e89774ce9151651b6a0e99a (patch) | |
| tree | 41e3768824dc156b70fccf506362f4fa7277e3ae /src/value.zig | |
| parent | 7f9e841f746bb3eaf6ac205092a30bc7ed12a068 (diff) | |
| download | zig-0e38cc16d51178525e89774ce9151651b6a0e99a.tar.gz zig-0e38cc16d51178525e89774ce9151651b6a0e99a.zip | |
Sema: fix comparisons between lazy and runtime values
Closes #12498
Diffstat (limited to 'src/value.zig')
| -rw-r--r-- | src/value.zig | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/value.zig b/src/value.zig index adff60983f..d3035946f9 100644 --- a/src/value.zig +++ b/src/value.zig @@ -1201,8 +1201,8 @@ pub const Value = extern union { } /// Asserts the value is an integer and it fits in a i64 - pub fn toSignedInt(self: Value) i64 { - switch (self.tag()) { + pub fn toSignedInt(val: Value, target: Target) i64 { + switch (val.tag()) { .zero, .bool_false, .the_only_possible_value, // i0, u0 @@ -1212,10 +1212,19 @@ pub const Value = extern union { .bool_true, => return 1, - .int_u64 => return @intCast(i64, self.castTag(.int_u64).?.data), - .int_i64 => return self.castTag(.int_i64).?.data, - .int_big_positive => return self.castTag(.int_big_positive).?.asBigInt().to(i64) catch unreachable, - .int_big_negative => return self.castTag(.int_big_negative).?.asBigInt().to(i64) catch unreachable, + .int_u64 => return @intCast(i64, val.castTag(.int_u64).?.data), + .int_i64 => return val.castTag(.int_i64).?.data, + .int_big_positive => return val.castTag(.int_big_positive).?.asBigInt().to(i64) catch unreachable, + .int_big_negative => return val.castTag(.int_big_negative).?.asBigInt().to(i64) catch unreachable, + + .lazy_align => { + const ty = val.castTag(.lazy_align).?.data; + return @intCast(i64, ty.abiAlignment(target)); + }, + .lazy_size => { + const ty = val.castTag(.lazy_size).?.data; + return @intCast(i64, ty.abiSize(target)); + }, .undef => unreachable, else => unreachable, |
