From 72adcdf9652d75f9499e311beec128f9e3627301 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Thu, 1 Sep 2022 16:54:30 +0300 Subject: feat(tvix/eval): add methods for emitting code with tracked spans These are not actually used yet; this is in preparation for a multi-commit chain for emitting all the right spans in the right locations. Change-Id: Ie99d6add2696c1cc0acb9ab928917a10237159de Reviewed-on: https://cl.tvl.fyi/c/depot/+/6379 Tested-by: BuildkiteCI Reviewed-by: sterni --- tvix/eval/src/chunk.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'tvix/eval/src/chunk.rs') diff --git a/tvix/eval/src/chunk.rs b/tvix/eval/src/chunk.rs index 9075db11b3c0..fbb9f7c37fec 100644 --- a/tvix/eval/src/chunk.rs +++ b/tvix/eval/src/chunk.rs @@ -29,12 +29,19 @@ pub struct Chunk { } impl Chunk { - pub fn push_op(&mut self, data: OpCode) -> CodeIdx { + pub fn push_op_old(&mut self, data: OpCode) -> CodeIdx { let idx = self.code.len(); self.code.push(data); CodeIdx(idx) } + pub fn push_op(&mut self, data: OpCode, span: codemap::Span) -> CodeIdx { + let idx = self.code.len(); + self.code.push(data); + self.push_span(span); + CodeIdx(idx) + } + pub fn push_constant(&mut self, data: Value) -> ConstantIdx { let idx = self.constants.len(); self.constants.push(data); -- cgit 1.4.1