Skip to content

Commit

Permalink
rename LocalVariable of Code to ReadLocalVariable
Browse files Browse the repository at this point in the history
  • Loading branch information
xffxff committed Sep 25, 2023
1 parent 1a58029 commit 38de040
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion components/lox-compile/src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl Compiler {
syntax::Expr::Variable(word) => {
let name = word.as_str(db);
if let Some(index) = self.resolve_local(name) {
chunk.emit_byte(Code::LocalVariable(index))
chunk.emit_byte(Code::ReadLocalVariable(index))
} else {
chunk.emit_byte(Code::GlobalVariable(name.to_string()))
}
Expand Down
2 changes: 1 addition & 1 deletion components/lox-execute/src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ impl VM {
let value = self.peek();
self.globals.insert(name, value.clone());
}
bytecode::Code::LocalVariable(index) => {
bytecode::Code::ReadLocalVariable(index) => {
let value = self.stack[index].clone();
self.push(value);
}
Expand Down
2 changes: 1 addition & 1 deletion components/lox-ir/src/bytecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub enum Code {
Print,
GlobalVarDeclaration(String), // name of the variable
GlobalVariable(String), // name of the variable
LocalVariable(usize), // index of the variable in the stack
ReadLocalVariable(usize), // index of the variable in the stack
Nil,
Assign(String),
Pop,
Expand Down
4 changes: 2 additions & 2 deletions lox_tests/local_var/bytecode
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ Chunk {
2.0,
),
),
LocalVariable(
ReadLocalVariable(
1,
),
Print,
Pop,
LocalVariable(
ReadLocalVariable(
0,
),
Print,
Expand Down
4 changes: 2 additions & 2 deletions lox_tests/local_var/execute
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ stack: [
),
]

execute: LocalVariable(
execute: ReadLocalVariable(
1,
)
stack: [
Expand Down Expand Up @@ -55,7 +55,7 @@ stack: [
),
]

execute: LocalVariable(
execute: ReadLocalVariable(
0,
)
stack: [
Expand Down

0 comments on commit 38de040

Please sign in to comment.