fix(tvix/eval): coerce string interpolation parts to string
With this puzzle piece of string compilation in place, `compile_str` becomes less redundant, as every part now needs to be compiled the same. The thunking logic becomes a bit trickier, since we need to thunk even in the case of `count == 1` if the single part is interpolating. Splitting the inner (shared) code in a separate function turned out to be easier for making rustc content. Change-Id: I6a554ca599926ae5907d7acffce349c9616f568f Reviewed-on: https://cl.tvl.fyi/c/depot/+/6582 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
This commit is contained in:
parent
bcd7e520f0
commit
4eb33e82ff
3 changed files with 59 additions and 36 deletions
|
@ -9,7 +9,7 @@ use crate::{
|
|||
observer::Observer,
|
||||
opcode::{CodeIdx, Count, JumpOffset, OpCode, StackIdx, UpvalueIdx},
|
||||
upvalues::{UpvalueCarrier, Upvalues},
|
||||
value::{Builtin, Closure, Lambda, NixAttrs, NixList, Thunk, Value},
|
||||
value::{Builtin, Closure, CoercionKind, Lambda, NixAttrs, NixList, Thunk, Value},
|
||||
};
|
||||
|
||||
struct CallFrame {
|
||||
|
@ -344,6 +344,16 @@ impl<'o> VM<'o> {
|
|||
|
||||
OpCode::OpInterpolate(Count(count)) => self.run_interpolate(count)?,
|
||||
|
||||
OpCode::OpCoerceToString => {
|
||||
// TODO: handle string context, copying to store
|
||||
let string = fallible!(
|
||||
self,
|
||||
// note that coerce_to_string also forces
|
||||
self.pop().coerce_to_string(CoercionKind::Weak, self)
|
||||
);
|
||||
self.push(Value::String(string));
|
||||
}
|
||||
|
||||
OpCode::OpJump(JumpOffset(offset)) => {
|
||||
debug_assert!(offset != 0);
|
||||
self.frame_mut().ip += offset;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue