aboutsummaryrefslogtreecommitdiffstats
path: root/src/runtime.rs
diff options
context:
space:
mode:
authorJan Tuomi <jans.tuomi@gmail.com>2021-11-23 23:49:58 +0200
committerJan Tuomi <jans.tuomi@gmail.com>2021-11-25 09:53:44 +0200
commite81d731b29c484ef2bab159d78a5417674e840ed (patch)
tree3f211c6e5a70b27e62f6b95b1b8d7772fd59ee9e /src/runtime.rs
parentc1f50fea93ad308f215e2d2878d773b55a370edb (diff)
Builtins with more than one parameter seemingly working
Diffstat (limited to 'src/runtime.rs')
-rw-r--r--src/runtime.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/runtime.rs b/src/runtime.rs
index 7e4e6f4..84f1820 100644
--- a/src/runtime.rs
+++ b/src/runtime.rs
@@ -27,7 +27,7 @@ pub enum Term {
Application(Rc<Term>, Rc<Term>),
Primitive(Value),
Lazy(String),
- Builtin(String),
+ Builtin(String, Vec<Value>),
}
impl Term {
@@ -40,7 +40,7 @@ impl Term {
Value::Integer(int_val) => format!("{}Integer({})", indent_str, int_val),
Value::String(str_val) => format!("{}String({})", indent_str, str_val),
},
- Term::Builtin(symbol) => format!("{}Builtin({})", indent_str, symbol),
+ Term::Builtin(symbol, _) => format!("{}Builtin({})", indent_str, symbol),
Term::Abstraction(v, body) => format!(
"{}Abstraction({})\n{}",
indent_str,
@@ -137,7 +137,9 @@ pub fn reduce_term(
&Some((*abs_v, subst_rhs_rc)),
resolve_lazy,
),
- Term::Builtin(symbol) => builtins::evaluate_builtin(symbol, subst_rhs_rc),
+ Term::Builtin(symbol, bound_arguments) => {
+ builtins::evaluate_builtin(symbol, bound_arguments, subst_rhs_rc)
+ }
_ => Ok((
Rc::new(Term::Application(subst_lhs_rc, subst_rhs_rc)),
subst_n,
@@ -155,7 +157,7 @@ pub fn reduce_term(
)?;
Ok((Rc::new(Term::Abstraction(*abs_v, subst_body)), subst_n))
}
- Term::Builtin(_) => Ok((term_rc, 0)),
+ Term::Builtin(_, _) => Ok((term_rc, 0)),
// Term::Lazy(symbol) => {
// if resolve_lazy {
// let table_lookup_value = symbol_table.get(symbol);