about summary refs log tree commit diff
path: root/users/tazjin/rlox/src/bytecode/mod.rs
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2021-01-17T17·33+0300
committertazjin <mail@tazj.in>2021-01-17T21·17+0000
commit49c4cc6c56048dbf35dbe5d87837d47b80d90f82 (patch)
tree101447ec757699a77cffb0cec5ffad22dc42a80d /users/tazjin/rlox/src/bytecode/mod.rs
parent30a6fcccee19877daad027a37fd3ee369a7d5d1e (diff)
feat(tazjin/rlox): Initial bytecode representation r/2124
This is significantly simplified from the version in the book, since
I'm using Rust's Vec and not implementing dynamic arrays manually.

We'll see if I run into issues with that ...

Change-Id: Ie3446ac3884b850f3ba73a4b1a6ca14e68054188
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2413
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
Diffstat (limited to 'users/tazjin/rlox/src/bytecode/mod.rs')
-rw-r--r--users/tazjin/rlox/src/bytecode/mod.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/users/tazjin/rlox/src/bytecode/mod.rs b/users/tazjin/rlox/src/bytecode/mod.rs
index 412e73106ead..a58f610417fd 100644
--- a/users/tazjin/rlox/src/bytecode/mod.rs
+++ b/users/tazjin/rlox/src/bytecode/mod.rs
@@ -2,6 +2,19 @@
 //!
 //! https://craftinginterpreters.com/chunks-of-bytecode.html
 
+mod chunk;
+mod opcode;
+mod value;
+
+use chunk::Chunk;
+use opcode::OpCode;
+
 pub fn main() {
-    unimplemented!()
+    let mut chunk: Chunk = Default::default();
+
+    let constant = chunk.add_constant(1.2);
+    chunk.add_op(OpCode::OpConstant(constant));
+    chunk.add_op(OpCode::OpReturn);
+
+    chunk::disassemble(&chunk, "test chunk");
 }