Implement import a, b, c from foo syntax

This brings stuff into the local scope, but it is a little funky with
local scopes that are above the current level (in the same function or
module).

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2024-10-04 20:11:06 -07:00
parent c176efb13a
commit 17408a8695
5 changed files with 62 additions and 14 deletions

View File

@@ -37,6 +37,11 @@ fn disassemble_chunk(chunk: &Chunk, globals: &Vec<String>, constants: &Vec<ObjP>
arg = format!("{}", &constants[*constant_id as usize].borrow());
info = format!("(constant ID {constant_id})");
}
Op::Dup => {
op_str = "DUP";
arg = String::new();
info = String::new();
}
Op::GetLocal(local_id) => {
op_str = "GET_LOCAL";
let local = &chunk.locals[*local_id as usize];
@@ -109,8 +114,8 @@ fn disassemble_chunk(chunk: &Chunk, globals: &Vec<String>, constants: &Vec<ObjP>
arg = String::new();
info = String::new();
}
Op::EnterModule => {
op_str = "ENTER_MODULE";
Op::EvalModule => {
op_str = "EVAL_MODULE";
arg = String::new();
info = String::new();
}