feat(machine): reduce term allocations

* remove term from VBuiltin
* and also means we don't need the useless wrapping

Co-authored-by: Lucas Rosa <x@rvcas.dev>
This commit is contained in:
microproofs
2023-04-12 16:09:42 -04:00
committed by Lucas
parent 70f12d3fc5
commit 09a6ea51d6
3 changed files with 33 additions and 46 deletions

View File

@@ -1,6 +1,6 @@
use std::rc::Rc;
use crate::ast::{NamedDeBruijn, Term};
use crate::ast::{Constant, NamedDeBruijn, Term};
use super::value::{Env, Value};
@@ -28,7 +28,9 @@ pub(super) fn value_as_term(value: Value) -> Rc<Term<NamedDeBruijn>> {
match stack_frame {
DischargeStep::DischargeValue(value) => match value {
Value::Con(x) => arg_stack.push(Term::Constant(x.clone()).into()),
Value::Builtin { term, .. } => arg_stack.push(term.clone()),
Value::Builtin { .. } => {
arg_stack.push(Term::Constant(Constant::Unit.into()).into())
}
Value::Delay(body, env) => {
stack.push(DischargeStep::DischargeValueEnv(
0,

View File

@@ -24,7 +24,6 @@ pub enum Value {
},
Builtin {
fun: DefaultFunction,
term: Rc<Term<NamedDeBruijn>>,
runtime: BuiltinRuntime,
},
}