feat: finished when constr is for IR and code gen

This commit is contained in:
Kasey White
2022-11-28 02:49:39 -05:00
committed by Lucas
parent 3fb3a3240a
commit 29a30aa61f
4 changed files with 369 additions and 56 deletions

View File

@@ -3,6 +3,7 @@ use crate::builtins::DefaultFunction;
use super::{Constant, Name, Term};
pub const CONSTR_FIELDS_EXPOSER: &str = "__constr_fields_exposer";
pub const CONSTR_INDEX_EXPOSER: &str = "__constr_index_exposer";
pub const CONSTR_GET_FIELD: &str = "__constr_get_field";
pub fn final_wrapper<T>(term: Term<T>) -> Term<T> {
@@ -59,6 +60,18 @@ pub fn constr_fields_exposer(term: Term<Name>) -> Term<Name> {
}
}
pub fn constr_index_exposer(term: Term<Name>) -> Term<Name> {
Term::Apply {
function: Term::Force(Term::Force(Term::Builtin(DefaultFunction::FstPair).into()).into())
.into(),
argument: Term::Apply {
function: Term::Builtin(DefaultFunction::UnConstrData).into(),
argument: term.into(),
}
.into(),
}
}
pub fn constr_get_field(term: Term<Name>) -> Term<Name> {
Term::Apply {
function: Term::Lambda {