feat(tvix): implement string interpolation
This adds a new instruction which assembles an interpolated string from a specified number of fragments, which are already going to be located on the stack in the right position. This will raise a type error if any of the fragments do not evaluate to a string. Change-Id: I5756248fa3e9fcc3d063c14db40b332f7e20a588 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6098 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
This commit is contained in:
parent
3577841bde
commit
a93933b487
3 changed files with 25 additions and 1 deletions
|
|
@ -32,6 +32,12 @@ impl Compiler {
|
|||
self.compile_string(op)
|
||||
}
|
||||
|
||||
// The interpolation node is just a wrapper around the
|
||||
// inner value of a fragment, it only requires unwrapping.
|
||||
rnix::SyntaxKind::NODE_STRING_INTERPOL => {
|
||||
self.compile(node.first_child().expect("TODO (should not be possible)"))
|
||||
}
|
||||
|
||||
rnix::SyntaxKind::NODE_BIN_OP => {
|
||||
let op = rnix::types::BinOp::cast(node).expect("TODO (should not be possible)");
|
||||
self.compile_binop(op)
|
||||
|
|
@ -112,7 +118,7 @@ impl Compiler {
|
|||
}
|
||||
|
||||
if count != 1 {
|
||||
todo!("assemble string interpolation instruction")
|
||||
self.chunk.add_op(OpCode::OpInterpolate(count));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue