| ... | @@ -119,10 +119,21 @@ pub const MemLocRequirement = enum { | ... | @@ -119,10 +119,21 @@ pub const MemLocRequirement = enum { |
| 119 | forward1, | 119 | forward1, |
| 120 | }; | 120 | }; |
| 121 | | 121 | |
| | 122 | pub const EvalToError = enum { |
| | 123 | /// The builtin cannot possibly evaluate to an error. |
| | 124 | never, |
| | 125 | /// The builtin will always evaluate to an error. |
| | 126 | always, |
| | 127 | /// The builtin may or may not evaluate to an error depending on the parameters. |
| | 128 | maybe, |
| | 129 | }; |
| | 130 | |
| 122 | tag: Tag, | 131 | tag: Tag, |
| 123 | | 132 | |
| 124 | /// Info about the builtin call's ability to take advantage of a result location pointer. | 133 | /// Info about the builtin call's ability to take advantage of a result location pointer. |
| 125 | needs_mem_loc: MemLocRequirement = .never, | 134 | needs_mem_loc: MemLocRequirement = .never, |
| | 135 | /// Info about the builtin call's possibility of returning an error. |
| | 136 | eval_to_error: EvalToError = .never, |
| 126 | /// `true` if the builtin call can be the left-hand side of an expression (assigned to). | 137 | /// `true` if the builtin call can be the left-hand side of an expression (assigned to). |
| 127 | allows_lvalue: bool = false, | 138 | allows_lvalue: bool = false, |
| 128 | /// The number of parameters to this builtin function. `null` means variable number | 139 | /// The number of parameters to this builtin function. `null` means variable number |
| ... | @@ -158,6 +169,7 @@ pub const list = list: { | ... | @@ -158,6 +169,7 @@ pub const list = list: { |
| 158 | .{ | 169 | .{ |
| 159 | .tag = .as, | 170 | .tag = .as, |
| 160 | .needs_mem_loc = .forward1, | 171 | .needs_mem_loc = .forward1, |
| | 172 | .eval_to_error = .maybe, |
| 161 | .param_count = 2, | 173 | .param_count = 2, |
| 162 | }, | 174 | }, |
| 163 | }, | 175 | }, |
| ... | @@ -258,6 +270,7 @@ pub const list = list: { | ... | @@ -258,6 +270,7 @@ pub const list = list: { |
| 258 | .{ | 270 | .{ |
| 259 | .tag = .call, | 271 | .tag = .call, |
| 260 | .needs_mem_loc = .always, | 272 | .needs_mem_loc = .always, |
| | 273 | .eval_to_error = .maybe, |
| 261 | .param_count = 3, | 274 | .param_count = 3, |
| 262 | }, | 275 | }, |
| 263 | }, | 276 | }, |
| ... | @@ -391,6 +404,7 @@ pub const list = list: { | ... | @@ -391,6 +404,7 @@ pub const list = list: { |
| 391 | "@errSetCast", | 404 | "@errSetCast", |
| 392 | .{ | 405 | .{ |
| 393 | .tag = .err_set_cast, | 406 | .tag = .err_set_cast, |
| | 407 | .eval_to_error = .always, |
| 394 | .param_count = 2, | 408 | .param_count = 2, |
| 395 | }, | 409 | }, |
| 396 | }, | 410 | }, |
| ... | @@ -420,6 +434,7 @@ pub const list = list: { | ... | @@ -420,6 +434,7 @@ pub const list = list: { |
| 420 | .{ | 434 | .{ |
| 421 | .tag = .field, | 435 | .tag = .field, |
| 422 | .needs_mem_loc = .always, | 436 | .needs_mem_loc = .always, |
| | 437 | .eval_to_error = .maybe, |
| 423 | .param_count = 2, | 438 | .param_count = 2, |
| 424 | .allows_lvalue = true, | 439 | .allows_lvalue = true, |
| 425 | }, | 440 | }, |
| ... | @@ -512,6 +527,7 @@ pub const list = list: { | ... | @@ -512,6 +527,7 @@ pub const list = list: { |
| 512 | "@intToError", | 527 | "@intToError", |
| 513 | .{ | 528 | .{ |
| 514 | .tag = .int_to_error, | 529 | .tag = .int_to_error, |
| | 530 | .eval_to_error = .always, |
| 515 | .param_count = 1, | 531 | .param_count = 1, |
| 516 | }, | 532 | }, |
| 517 | }, | 533 | }, |