feat: ref
This commit is contained in:
@@ -41,14 +41,14 @@ impl From<ir::Param> for Param {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Func {
|
||||
pub env: OnceCell<CapturedEnv>,
|
||||
pub struct Func<'vm> {
|
||||
pub env: OnceCell<CapturedEnv<'vm>>,
|
||||
pub param: Param,
|
||||
pub opcodes: OpCodes,
|
||||
}
|
||||
|
||||
impl Func {
|
||||
pub fn call(&self, vm: &VM, arg: Value) -> Result<Value> {
|
||||
impl<'vm> Func<'vm> {
|
||||
pub fn call(&'vm self, vm: &VM<'vm>, arg: Value<'vm>) -> Result<Value<'vm>> {
|
||||
use Param::*;
|
||||
|
||||
let env = self.env.get().unwrap().clone().released();
|
||||
@@ -75,7 +75,7 @@ impl Func {
|
||||
for (formal, default) in formals {
|
||||
let arg = arg
|
||||
.select(formal.clone().into())
|
||||
.or_else(|| default.map(Value::ThunkRef))
|
||||
.or_else(|| default.map(|idx| Value::ThunkRef(vm.get_thunk(idx))))
|
||||
.unwrap();
|
||||
new.insert_mut(formal.clone().into(), arg);
|
||||
}
|
||||
@@ -90,7 +90,7 @@ impl Func {
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for Func {
|
||||
impl PartialEq for Func<'_> {
|
||||
fn eq(&self, _: &Self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user