aboutsummaryrefslogtreecommitdiff
path: root/src/value.zig
diff options
context:
space:
mode:
authorMartin Wickham <spexguy070@gmail.com>2021-09-28 12:00:35 -0500
committerGitHub <noreply@github.com>2021-09-28 12:00:35 -0500
commit1cc5d4e758a95be373756e7c32f9bb46d21633c9 (patch)
tree9c142d3d009e1622f27a22c9228a6ff10b878721 /src/value.zig
parent60b6e74468570a124f602a62b6bd2da95ba8c17c (diff)
downloadzig-1cc5d4e758a95be373756e7c32f9bb46d21633c9.tar.gz
zig-1cc5d4e758a95be373756e7c32f9bb46d21633c9.zip
Stage 2: Support inst.func() syntax (#9827)
* Merge call zir instructions to make space for field_call * Fix bug with comptime known anytype args * Delete the param_type zir instruction * Move some passing tests to stage 2 * Implement a.b() function calls * Add field_call_bind support for call and field builtins
Diffstat (limited to 'src/value.zig')
-rw-r--r--src/value.zig20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/value.zig b/src/value.zig
index 69f8945e01..336f5f9cf7 100644
--- a/src/value.zig
+++ b/src/value.zig
@@ -159,6 +159,10 @@ pub const Value = extern union {
/// Used to coordinate alloc_inferred, store_to_inferred_ptr, and resolve_inferred_alloc
/// instructions for comptime code.
inferred_alloc_comptime,
+ /// Used sometimes as the result of field_call_bind. This value is always temporary,
+ /// and refers directly to the air. It will never be referenced by the air itself.
+ /// TODO: This is probably a bad encoding, maybe put temp data in the sema instead.
+ bound_fn,
pub const last_no_payload_tag = Tag.empty_array;
pub const no_payload_count = @enumToInt(last_no_payload_tag) + 1;
@@ -279,6 +283,7 @@ pub const Value = extern union {
.inferred_alloc => Payload.InferredAlloc,
.@"struct" => Payload.Struct,
.@"union" => Payload.Union,
+ .bound_fn => Payload.BoundFn,
};
}
@@ -422,6 +427,7 @@ pub const Value = extern union {
.extern_options_type,
.type_info_type,
.generic_poison,
+ .bound_fn,
=> unreachable,
.ty => {
@@ -716,6 +722,10 @@ pub const Value = extern union {
try out_stream.writeAll("(opt_payload_ptr)");
val = val.castTag(.opt_payload_ptr).?.data;
},
+ .bound_fn => {
+ const bound_func = val.castTag(.bound_fn).?.data;
+ return out_stream.print("(bound_fn %{}(%{})", .{ bound_func.func_inst, bound_func.arg0_inst });
+ },
};
}
@@ -2199,6 +2209,16 @@ pub const Value = extern union {
val: Value,
},
};
+
+ pub const BoundFn = struct {
+ pub const base_tag = Tag.bound_fn;
+
+ base: Payload = Payload{ .tag = base_tag },
+ data: struct {
+ func_inst: Air.Inst.Ref,
+ arg0_inst: Air.Inst.Ref,
+ },
+ };
};
/// Big enough to fit any non-BigInt value