From d57e43e1615ae28cfdc74c1c65cbe7863d782018 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Wed, 20 Oct 2021 15:57:49 +0200 Subject: refactor(tazjin/rlox): Return index after adding operations Change-Id: I100eb9b55ace37e5c7c878d3c224b567ee8d1e36 Reviewed-on: https://cl.tvl.fyi/c/depot/+/3738 Tested-by: BuildkiteCI Reviewed-by: tazjin --- users/tazjin/rlox/src/bytecode/chunk.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'users/tazjin/rlox/src/bytecode/chunk.rs') diff --git a/users/tazjin/rlox/src/bytecode/chunk.rs b/users/tazjin/rlox/src/bytecode/chunk.rs index b9a3994fe1c1..fc5cd34fdf4f 100644 --- a/users/tazjin/rlox/src/bytecode/chunk.rs +++ b/users/tazjin/rlox/src/bytecode/chunk.rs @@ -1,6 +1,6 @@ use std::ops::Index; -use super::opcode::{ConstantIdx, OpCode}; +use super::opcode::{CodeIdx, ConstantIdx, OpCode}; use super::value; // In the book, this type is a hand-rolled dynamic array @@ -25,11 +25,11 @@ struct Span { } impl Chunk { - pub fn add_op(&mut self, data: OpCode, line: usize) -> usize { + pub fn add_op(&mut self, data: OpCode, line: usize) -> CodeIdx { let idx = self.code.len(); self.code.push(data); self.add_line(line); - idx + CodeIdx(idx) } pub fn add_constant(&mut self, data: value::Value) -> usize { -- cgit 1.4.1