aboutsummaryrefslogtreecommitdiff
path: root/src/BuiltinFn.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-10-25 10:50:47 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-10-25 10:50:47 -0700
commit8f3e1ea0f07cdc7e94b0816ae3c58733df0f2786 (patch)
tree056a6a26d0186e17249aa36d918d364c34b48841 /src/BuiltinFn.zig
parentd4bf44024a005fcd6931fd0975d78c890dedb4e6 (diff)
downloadzig-8f3e1ea0f07cdc7e94b0816ae3c58733df0f2786.tar.gz
zig-8f3e1ea0f07cdc7e94b0816ae3c58733df0f2786.zip
AstGen: move nodeMayEvalToError logic for builtins
to the declarative BuiltinFn.zig file which lists info about all the builtin functions.
Diffstat (limited to 'src/BuiltinFn.zig')
-rw-r--r--src/BuiltinFn.zig16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/BuiltinFn.zig b/src/BuiltinFn.zig
index e1f4f5bd16..7c5dde03d1 100644
--- a/src/BuiltinFn.zig
+++ b/src/BuiltinFn.zig
@@ -119,10 +119,21 @@ pub const MemLocRequirement = enum {
forward1,
};
+pub const EvalToError = enum {
+ /// The builtin cannot possibly evaluate to an error.
+ never,
+ /// The builtin will always evaluate to an error.
+ always,
+ /// The builtin may or may not evaluate to an error depending on the parameters.
+ maybe,
+};
+
tag: Tag,
/// Info about the builtin call's ability to take advantage of a result location pointer.
needs_mem_loc: MemLocRequirement = .never,
+/// Info about the builtin call's possibility of returning an error.
+eval_to_error: EvalToError = .never,
/// `true` if the builtin call can be the left-hand side of an expression (assigned to).
allows_lvalue: bool = false,
/// The number of parameters to this builtin function. `null` means variable number
@@ -158,6 +169,7 @@ pub const list = list: {
.{
.tag = .as,
.needs_mem_loc = .forward1,
+ .eval_to_error = .maybe,
.param_count = 2,
},
},
@@ -258,6 +270,7 @@ pub const list = list: {
.{
.tag = .call,
.needs_mem_loc = .always,
+ .eval_to_error = .maybe,
.param_count = 3,
},
},
@@ -391,6 +404,7 @@ pub const list = list: {
"@errSetCast",
.{
.tag = .err_set_cast,
+ .eval_to_error = .always,
.param_count = 2,
},
},
@@ -420,6 +434,7 @@ pub const list = list: {
.{
.tag = .field,
.needs_mem_loc = .always,
+ .eval_to_error = .maybe,
.param_count = 2,
.allows_lvalue = true,
},
@@ -512,6 +527,7 @@ pub const list = list: {
"@intToError",
.{
.tag = .int_to_error,
+ .eval_to_error = .always,
.param_count = 1,
},
},