feat(jit): lookup
This commit is contained in:
@@ -53,17 +53,8 @@ impl<'vm, 'jit: 'vm> Func<'jit, 'vm> {
|
||||
pub fn call(&self, vm: &'vm VM<'jit>, arg: Value<'jit, 'vm>) -> Result<Value<'jit, 'vm>> {
|
||||
use Param::*;
|
||||
|
||||
let count = self.count.get();
|
||||
if count >= 1 {
|
||||
let compiled = self.compiled.get_or_init(|| vm.compile_func(self.func));
|
||||
let ret = unsafe { compiled.call(vm as _, &self.env as _, arg.into()) };
|
||||
return Ok(ret.into())
|
||||
}
|
||||
self.count.replace(count + 1);
|
||||
let mut env = self.env.clone();
|
||||
|
||||
match self.func.param.clone() {
|
||||
Ident(ident) => env = env.enter([(ident.into(), arg)].into_iter()),
|
||||
let env = match self.func.param.clone() {
|
||||
Ident(ident) => self.env.clone().enter([(ident.into(), arg)].into_iter()),
|
||||
Formals {
|
||||
formals,
|
||||
ellipsis,
|
||||
@@ -94,10 +85,17 @@ impl<'vm, 'jit: 'vm> Func<'jit, 'vm> {
|
||||
if let Some(alias) = alias {
|
||||
new.push((alias.clone().into(), Value::AttrSet(arg)));
|
||||
}
|
||||
env = env.enter(new.into_iter());
|
||||
self.env.clone().enter(new.into_iter())
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let count = self.count.get();
|
||||
self.count.replace(count + 1);
|
||||
if count >= 1 {
|
||||
let compiled = self.compiled.get_or_init(|| vm.compile_func(self.func));
|
||||
let ret = unsafe { compiled.call(vm as *const VM, &env as *const Env) };
|
||||
return Ok(ret.into())
|
||||
}
|
||||
vm.eval(self.func.opcodes.iter().copied(), env)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user