eval refs
This commit is contained in:
parent
a9e4875f1e
commit
04ec9baabf
1 changed files with 2 additions and 1 deletions
|
|
@ -134,6 +134,7 @@ fn eval_expr(expr_env: &Env, state: &mut State, expr: &ast::Expr) -> Result<ast:
|
||||||
let closure_env: Env = state.envs.get(env)?.clone();
|
let closure_env: Env = state.envs.get(env)?.clone();
|
||||||
eval_expr(&closure_env, state, expr)
|
eval_expr(&closure_env, state, expr)
|
||||||
}
|
}
|
||||||
|
ast::Value::Ref(reference) => Ok(state.variables.get(reference).clone()),
|
||||||
_ => Ok(v.clone()),
|
_ => Ok(v.clone()),
|
||||||
},
|
},
|
||||||
ast::Expr::Op { lhs, rhs, op } => match op {
|
ast::Expr::Op { lhs, rhs, op } => match op {
|
||||||
|
|
@ -143,7 +144,7 @@ fn eval_expr(expr_env: &Env, state: &mut State, expr: &ast::Expr) -> Result<ast:
|
||||||
state.variables.set(reference, rhs.clone());
|
state.variables.set(reference, rhs.clone());
|
||||||
Ok(rhs)
|
Ok(rhs)
|
||||||
}
|
}
|
||||||
_ => todo!(),
|
v => Err(Error::NotAReference(v.clone())),
|
||||||
},
|
},
|
||||||
/*
|
/*
|
||||||
_ => {
|
_ => {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue