feat: usable?
This commit is contained in:
@@ -5,7 +5,7 @@ use rpds::HashTrieMap;
|
||||
use crate::bytecode::{OpCodes, ThunkIdx};
|
||||
use crate::ty::internal::{Thunk, Value};
|
||||
|
||||
use crate::vm::{LockedEnv, VM};
|
||||
use crate::vm::{CapturedEnv, VM};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum Param {
|
||||
@@ -19,13 +19,13 @@ pub enum Param {
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Func {
|
||||
pub env: LockedEnv,
|
||||
pub env: CapturedEnv,
|
||||
pub param: Option<Param>,
|
||||
pub opcodes: OpCodes,
|
||||
}
|
||||
|
||||
impl Func {
|
||||
pub fn new(env: LockedEnv, opcodes: OpCodes) -> Func {
|
||||
pub fn new(env: CapturedEnv, opcodes: OpCodes) -> Func {
|
||||
Func {
|
||||
env,
|
||||
opcodes,
|
||||
@@ -36,7 +36,7 @@ impl Func {
|
||||
pub fn call(self, vm: &VM, arg: Value) -> Value {
|
||||
use Param::*;
|
||||
|
||||
let mut env = self.env.unlocked();
|
||||
let env = self.env.released();
|
||||
|
||||
match self.param.unwrap() {
|
||||
Ident(ident) => env.enter(HashTrieMap::new_sync().insert(ident.into(), arg)),
|
||||
@@ -58,9 +58,6 @@ impl Func {
|
||||
todo!()
|
||||
}
|
||||
for (formal, default) in formals {
|
||||
// let arg = if let Some(default) = default {
|
||||
// arg.select(format)
|
||||
// }
|
||||
let arg = arg
|
||||
.select(formal.clone().into())
|
||||
.or_else(|| default.map(|idx| Value::Thunk(Thunk(idx))))
|
||||
@@ -74,7 +71,7 @@ impl Func {
|
||||
}
|
||||
}
|
||||
|
||||
vm.eval(self.opcodes, &mut env).unwrap()
|
||||
vm.eval(self.opcodes, env).unwrap()
|
||||
}
|
||||
|
||||
pub fn push_ident_param(&mut self, param: EcoString) {
|
||||
|
||||
Reference in New Issue
Block a user