fix binding bug
This commit is contained in:
parent
8b004b45fa
commit
fa587e38cd
12
src/main.rs
12
src/main.rs
|
@ -75,12 +75,12 @@ pub fn run(src: &'static str) {
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
env::set_var("RUST_BACKTRACE", "1");
|
env::set_var("RUST_BACKTRACE", "1");
|
||||||
let src = "
|
let src = "
|
||||||
fn add_one (x) -> add (x, 1)
|
let whatevs = nil
|
||||||
fn double (x) -> add (x, x)
|
let mult_factor = 3
|
||||||
fn square (x) -> mult (x, x)
|
fn mymult (x) -> mult (x, mult_factor)
|
||||||
|
fn thing (x) -> mymult (x)
|
||||||
double (2)
|
|
||||||
|
thing (2)
|
||||||
";
|
";
|
||||||
run(src);
|
run(src);
|
||||||
}
|
}
|
||||||
|
|
|
@ -896,7 +896,7 @@ impl Vm {
|
||||||
let mut frame = CallFrame {
|
let mut frame = CallFrame {
|
||||||
function: val,
|
function: val,
|
||||||
arity,
|
arity,
|
||||||
stack_base: self.stack.len() - arity as usize,
|
stack_base: self.stack.len() - arity as usize - 1,
|
||||||
ip: 0,
|
ip: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -976,7 +976,7 @@ impl Vm {
|
||||||
let mut frame = CallFrame {
|
let mut frame = CallFrame {
|
||||||
function: val,
|
function: val,
|
||||||
arity,
|
arity,
|
||||||
stack_base: self.stack.len() - arity as usize,
|
stack_base: self.stack.len() - arity as usize - 1,
|
||||||
ip: 0,
|
ip: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1057,8 +1057,6 @@ impl Vm {
|
||||||
GetUpvalue => {
|
GetUpvalue => {
|
||||||
let idx = self.chunk().bytecode[self.ip + 1];
|
let idx = self.chunk().bytecode[self.ip + 1];
|
||||||
self.ip += 2;
|
self.ip += 2;
|
||||||
println!("getting upvalue {idx}");
|
|
||||||
dbg!(&self.frame.function);
|
|
||||||
if let Value::Fn(ref inner) = self.frame.function {
|
if let Value::Fn(ref inner) = self.frame.function {
|
||||||
self.push(inner.as_ref().upvalue(idx));
|
self.push(inner.as_ref().upvalue(idx));
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user