From c73e84d95777c304f1b208cbc43b01012df73262 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 26 Aug 2022 20:54:39 +0300 Subject: refactor(tvix/eval): add opcode::StackIdx type for less ambiguity Change-Id: I9b9de1f681972c205d4d20bc5731d2ce79858edb Reviewed-on: https://cl.tvl.fyi/c/depot/+/6287 Tested-by: BuildkiteCI Reviewed-by: sterni --- tvix/eval/src/compiler/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tvix/eval/src/compiler') diff --git a/tvix/eval/src/compiler/mod.rs b/tvix/eval/src/compiler/mod.rs index ac22fc1a6794..37ec3915b4be 100644 --- a/tvix/eval/src/compiler/mod.rs +++ b/tvix/eval/src/compiler/mod.rs @@ -22,7 +22,7 @@ use std::rc::Rc; use crate::chunk::Chunk; use crate::errors::{Error, ErrorKind, EvalResult}; -use crate::opcode::{CodeIdx, JumpOffset, OpCode}; +use crate::opcode::{CodeIdx, JumpOffset, OpCode, StackIdx}; use crate::value::{Closure, Lambda, Value}; use crate::warnings::{EvalWarning, WarningKind}; @@ -116,11 +116,11 @@ impl Scope { } /// Resolve the stack index of a statically known local. - fn resolve_local(&mut self, name: &str) -> Option { + fn resolve_local(&mut self, name: &str) -> Option { for (idx, local) in self.locals.iter_mut().enumerate().rev() { if !local.phantom && local.name == name { local.used = true; - return Some(idx); + return Some(StackIdx(idx)); } } @@ -799,7 +799,7 @@ impl Compiler { self.scope_mut().with_stack.push(With { depth }); let with_idx = self.scope().locals.len() - 1; - self.chunk().push_op(OpCode::OpPushWith(with_idx)); + self.chunk().push_op(OpCode::OpPushWith(StackIdx(with_idx))); self.compile(node.body().unwrap()); } -- cgit 1.4.1