aboutsummaryrefslogtreecommitdiff
path: root/src/value.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-08-03 22:34:22 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-08-03 22:34:22 -0700
commit382d201781eb57d9e950ad07ce814adc5a68b329 (patch)
treefd066174fcce78af51e925362c619d1ffd584eef /src/value.zig
parent609b84611dcde382af5d9fbc2345ede468d31a6f (diff)
downloadzig-382d201781eb57d9e950ad07ce814adc5a68b329.tar.gz
zig-382d201781eb57d9e950ad07ce814adc5a68b329.zip
stage2: basic generic functions are working
The general strategy is that Sema will pre-map comptime arguments into the inst_map, and then re-run the block body that contains the `param` and `func` instructions. This re-runs all the parameter type expressions except with comptime values populated. In Sema, param instructions are now handled specially: they detect whether they are comptime-elided or not. If so, they skip putting a value in the inst_map, since it is already pre-populated. If not, then they append to the `fields` field of `Sema` for use with the `func` instruction. So when the block body is re-run, a new function is generated with all the comptime arguments elided, and the new function type has only runtime parameters in it. TODO: give the generated Decls better names than "foo__anon_x". The new function is then added to the work queue to have its body analyzed and a runtime call AIR instruction to the new function is emitted. When the new function gets semantically analyzed, comptime parameters are pre-mapped to the corresponding `comptime_args` values rather than mapped to an `arg` AIR instruction. `comptime_args` is a new field that `Fn` has which is a `TypedValue` for each parameter. This field is non-null for generic function instantiations only. The values are the comptime arguments. For non-comptime parameters, a sentinel value is used. This is because we need to know the information of which parameters are comptime-known. Additionally: * AstGen: align and section expressions are evaluated in the scope that has comptime parameters in it. There are still some TODO items left; see the BRANCH_TODO file.
Diffstat (limited to 'src/value.zig')
0 files changed, 0 insertions, 0 deletions