Add function compilation
Functions are compiled in the most naiive way right now. I want to fix up how scope lookups are done before it becomes too much to update. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -143,16 +143,16 @@ impl<'p> Vm<'p> {
|
||||
fn begin_call(&mut self, caller: ObjRef, args: Vec<ObjRef>) {
|
||||
// create stack frame
|
||||
let stack_frame = if let Some(user_fun) = std::any::Any::downcast_ref::<UserFunRef>(&caller) {
|
||||
let locals = {
|
||||
let names: Names = {
|
||||
read_obj!(let fun_ref = user_fun);
|
||||
fun_ref.locals()
|
||||
.iter()
|
||||
.zip(args.into_iter())
|
||||
.map(|((k, _), v)| (*k, v))
|
||||
.map(|((_, v), arg)| (*v, arg.clone()))
|
||||
.collect()
|
||||
};
|
||||
|
||||
Frame::new(locals, FrameKind::User {
|
||||
Frame::new(names, FrameKind::User {
|
||||
last_pc: self.pc(),
|
||||
stack_base: self.stack().len(),
|
||||
fun: user_fun.clone(),
|
||||
|
||||
Reference in New Issue
Block a user