about summary refs log blame commit diff
path: root/users/tazjin/rlox/src/bytecode/mod.rs
blob: 2d83c4272239753a252fb7a425a21a1349dac5a6 (plain) (tree)
1
2
3
4
5
6
7
8
9



                                                            
          
           

           
       



                   
               


                                              
                                                  





                                                  
 
                                                  
 
//! Bytecode interpreter for Lox.
//!
//! https://craftinginterpreters.com/chunks-of-bytecode.html

mod chunk;
mod errors;
mod opcode;
mod value;
mod vm;

use chunk::Chunk;
use opcode::OpCode;

pub fn main() {
    let mut chunk: Chunk = Default::default();

    let constant = chunk.add_constant(1.2);
    chunk.add_op(OpCode::OpConstant(constant), 1);

    let constant = chunk.add_constant(2.0);
    chunk.add_op(OpCode::OpConstant(constant), 2);

    chunk.add_op(OpCode::OpAdd, 3);
    chunk.add_op(OpCode::OpReturn, 4);

    vm::interpret(chunk).expect("it should work");
}