aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/compile.cpp10
-rw-r--r--src/depoly.cpp2
-rw-r--r--src/flatten.cpp2
-rw-r--r--src/lift.cpp9
4 files changed, 13 insertions, 10 deletions
diff --git a/src/compile.cpp b/src/compile.cpp
index d7b535d..de53388 100644
--- a/src/compile.cpp
+++ b/src/compile.cpp
@@ -136,12 +136,12 @@ compile_quote(CEnv& cenv, const ATuple* quote) throw()
static CVal
compile_call(CEnv& cenv, const ATuple* call) throw()
{
- const ATuple* protT = cenv.type(call->fst())->as_tuple()->prot();
- CFunc f = resp_compile(cenv, call->fst());
+ const ATuple* protT = cenv.type(call->frst())->as_tuple()->prot();
+ CFunc f = resp_compile(cenv, call->frst());
vector<CVal> args;
ATuple::const_iterator p = protT->iter_at(0);
- for (ATuple::const_iterator a = call->iter_at(1); a != call->end(); ++a, ++p) {
+ for (ATuple::const_iterator a = call->iter_at(2); a != call->end(); ++a, ++p) {
CVal arg = resp_compile(cenv, *a);
if (cenv.type(*a) != cenv.resolveType(*p)) {
args.push_back(cenv.engine()->compileCast(cenv, arg, *p));
@@ -228,12 +228,12 @@ resp_compile(CEnv& cenv, const AST* ast) throw()
return cenv.engine()->compileIfElse(cenv, resp_compile(cenv, call->frrst()));
else if (form == "if-end")
return cenv.engine()->compileIfEnd(cenv);
- else
+ else if (form == "call")
return compile_call(cenv, call);
}
}
- cenv.err << "Attempt to compile unknown type: " << ast << endl;
+ cenv.err << "Attempt to compile unknown form: " << ast << endl;
assert(false);
return NULL;
}
diff --git a/src/depoly.cpp b/src/depoly.cpp
index 2b8554b..c6de0c1 100644
--- a/src/depoly.cpp
+++ b/src/depoly.cpp
@@ -124,7 +124,7 @@ resp_depoly(CEnv& cenv, Code& code, const AST* ast) throw()
return ast;
}
- cenv.err << "Attempt to depoly unknown type: " << ast << endl;
+ cenv.err << "Attempt to depoly unknown form: " << ast << endl;
assert(false);
return NULL;
}
diff --git a/src/flatten.cpp b/src/flatten.cpp
index dfbd7a3..8d92ff9 100644
--- a/src/flatten.cpp
+++ b/src/flatten.cpp
@@ -189,7 +189,7 @@ resp_flatten(CEnv& cenv, Code& code, const AST* ast) throw()
return ast;
}
- cenv.err << "Attempt to compile unknown type: " << ast << endl;
+ cenv.err << "Attempt to flatten unknown form: " << ast << endl;
assert(false);
return NULL;
}
diff --git a/src/lift.cpp b/src/lift.cpp
index 1d4e19c..802130d 100644
--- a/src/lift.cpp
+++ b/src/lift.cpp
@@ -213,19 +213,21 @@ lift_call(CEnv& cenv, Code& code, const ATuple* call) throw()
* reusing the current "_me" closure parameter (no cons or .).
*/
copy.push_front(cenv.penv.sym(cenv.liftStack.top().implName));
+ copy.push_front(cenv.penv.sym("call"));
cenv.setTypeSameAs(copy, call);
} else if (is_form(call->fst(), "fn")) {
/* Special case: ((fn ...) ...)
- * Lifting (fn ...) yields: (Fn _impl ...).
- * We don't want ((Fn _impl ...) (Fn _impl ...) ...),
+ * Lifting (fn ...) yields: (Closure _impl ...).
+ * We don't want (call (. (Closure _impl ...) 1) (Closure _impl ...) ...),
* so call the implementation function (_impl) directly and pass the
* closure as the first parameter:
- * (_impl (Fn _impl ...) ...)
+ * (call _impl (Closure _impl ...) ...)
*/
const ATuple* closure = copy.head->list_ref(0)->as_tuple();
const ASymbol* implSym = closure->list_ref(1)->as_symbol();
const ATuple* implT = cenv.type(cenv.resolve(implSym))->as_tuple();
copy.push_front(implSym);
+ copy.push_front(cenv.penv.sym("call"));
cenv.setType(copy, implT->list_ref(2));
} else {
// Call to a closure, prepend code to access implementation function
@@ -237,6 +239,7 @@ lift_call(CEnv& cenv, Code& code, const ATuple* call) throw()
const ATuple* implT = calleeT->list_ref(1)->as_tuple();
copy.push_front(getFn);
cenv.setType(getFn, implT);
+ copy.push_front(cenv.penv.sym("call"));
cenv.setType(copy, implT->list_ref(2));
}