aboutsummaryrefslogtreecommitdiff
path: root/src/value.zig
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2022-03-11 11:55:27 +0200
committerVeikka Tuominen <git@vexu.eu>2022-03-11 13:06:22 +0200
commitdb4262417009c0060e09a8cf8af088b76320aad0 (patch)
tree6a06b0bf90d6589cc9bbb13208b5ee2c02e98526 /src/value.zig
parent98a5998d831fd0fa7b897aafacf4c2af18e64ed1 (diff)
downloadzig-db4262417009c0060e09a8cf8af088b76320aad0.tar.gz
zig-db4262417009c0060e09a8cf8af088b76320aad0.zip
Sema: enable shl and bitwise for vectors at runtime
Diffstat (limited to 'src/value.zig')
-rw-r--r--src/value.zig15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/value.zig b/src/value.zig
index 7c5401cd75..973e477099 100644
--- a/src/value.zig
+++ b/src/value.zig
@@ -1819,7 +1819,22 @@ pub const Value = extern union {
}
/// Asserts the value is comparable.
+ /// For vectors this is only valid with op == .eq.
pub fn compareWithZero(lhs: Value, op: std.math.CompareOperator) bool {
+ switch (lhs.tag()) {
+ .repeated => {
+ assert(op == .eq);
+ return lhs.castTag(.repeated).?.data.compareWithZero(.eq);
+ },
+ .array => {
+ assert(op == .eq);
+ for (lhs.cast(Payload.Array).?.data) |elem_val| {
+ if (!elem_val.compareWithZero(.eq)) return false;
+ }
+ return true;
+ },
+ else => {},
+ }
return orderAgainstZero(lhs).compare(op);
}