aboutsummaryrefslogtreecommitdiff
path: root/src/Air.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-07-30 16:05:46 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-07-30 16:17:59 -0700
commit507dc1f2e7fac212e79f152e557cbec98a3c30e9 (patch)
tree34b057caf8ebadef2d199af39b1b44fca48c1a23 /src/Air.zig
parent84039a57e4684e8df10e657bb76c6acb3fb89238 (diff)
downloadzig-507dc1f2e7fac212e79f152e557cbec98a3c30e9.tar.gz
zig-507dc1f2e7fac212e79f152e557cbec98a3c30e9.zip
stage2: fix hashing and comparison design flaw with Value
* `Value.toType` accepts a buffer parameter instead of an allocator parameter and can no longer fail. * Module: remove the unused `mod: *Module` parameter from various functions. * `Value.compare` now accepts a `Type` parameter which indicates the type of both operands. There is also a `Value.compareHetero` which accepts only Value parameters and supports comparing mixed types. Likewise, `Value.eql` requires a `Type` parameter. * `Value.hash` is removed; instead the hash map context structs now have a `ty: Type` field, and the hash function lives there, where it has access to a Value's Type when it computes a hash. - This allowed the hash function to be greatly simplified and sound in the sense that the same Values, even with different representations, always hash to the same thing. * Sema: Fix source location of zirCmp when an operand is runtime known but needs to be comptime known. * Remove unused target parameter from `Value.floatCast`.
Diffstat (limited to 'src/Air.zig')
-rw-r--r--src/Air.zig3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/Air.zig b/src/Air.zig
index fb95d60d00..d202c079bc 100644
--- a/src/Air.zig
+++ b/src/Air.zig
@@ -503,7 +503,8 @@ pub fn typeOfIndex(air: Air, inst: Air.Inst.Index) Type {
pub fn getRefType(air: Air, ref: Air.Inst.Ref) Type {
const ref_int = @enumToInt(ref);
if (ref_int < Air.Inst.Ref.typed_value_map.len) {
- return Air.Inst.Ref.typed_value_map[ref_int].val.toType(undefined) catch unreachable;
+ var buffer: Value.ToTypeBuffer = undefined;
+ return Air.Inst.Ref.typed_value_map[ref_int].val.toType(&buffer);
}
const inst_index = ref_int - Air.Inst.Ref.typed_value_map.len;
const air_tags = air.instructions.items(.tag);