about summary refs log tree commit diff
path: root/users/tazjin/rlox/src/bytecode/chunk.rs
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2021-10-20T13·57+0200
committertazjin <mail@tazj.in>2021-10-22T09·42+0000
commitd57e43e1615ae28cfdc74c1c65cbe7863d782018 (patch)
tree3ff9e6843475aec1573355cf73e6bea209de26da /users/tazjin/rlox/src/bytecode/chunk.rs
parent4ea7fc392a562fac2158973191ad626baca16644 (diff)
refactor(tazjin/rlox): Return index after adding operations r/2985
Change-Id: I100eb9b55ace37e5c7c878d3c224b567ee8d1e36
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3738
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
Diffstat (limited to 'users/tazjin/rlox/src/bytecode/chunk.rs')
-rw-r--r--users/tazjin/rlox/src/bytecode/chunk.rs6
1 files changed, 3 insertions, 3 deletions
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 {