diff options
Diffstat (limited to 'src/lift.cpp')
-rw-r--r-- | src/lift.cpp | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/src/lift.cpp b/src/lift.cpp index 733c7b6..94f70e0 100644 --- a/src/lift.cpp +++ b/src/lift.cpp @@ -24,8 +24,9 @@ using namespace std; void -AFn::lift(CEnv& cenv) +AFn::lift(CEnv& cenv) throw() { + // Create a new stub environment frame for parameters cenv.push(); for (const_iterator p = prot()->begin(); p != prot()->end(); ++p) cenv.def((*p)->as<ASymbol*>(), *p, NULL, NULL); @@ -45,35 +46,30 @@ AFn::lift(CEnv& cenv) } void -ACall::lift(CEnv& cenv) +ACall::lift(CEnv& cenv) throw() { AFn* c = cenv.resolve(head())->to<AFn*>(); AType argsT(loc); - // Lift arguments + // Lift arguments and build arguments type for (iterator i = begin() + 1; i != end(); ++i) { (*i)->lift(cenv); argsT.push_back(cenv.type(*i)); } - if (!c) return; // Primitive - - if (c->prot()->size() < size() - 1) - throw Error(loc, (format("too many arguments to function `%1%'") % head()->str()).str()); - if (c->prot()->size() > size() - 1) - throw Error(loc, (format("too few arguments to function `%1%'") % head()->str()).str()); - - cenv.engine()->compileFunction(cenv, c, argsT); // Lift called closure + // Lift callee (if it's not a primitive) + if (c) + cenv.engine()->compileFunction(cenv, c, argsT); } void -ADot::lift(CEnv& cenv) +ADot::lift(CEnv& cenv) throw() { (*(begin() + 1))->lift(cenv); } void -ADef::lift(CEnv& cenv) +ADef::lift(CEnv& cenv) throw() { // Define stub first for recursion cenv.def(sym(), body(), cenv.type(body()), NULL); |