From 594370a2a381545aea8d0631a86f422f84ee2792 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 19 Aug 2010 22:34:22 +0000 Subject: Generalise `cons': a call to any symbol beginning with an uppercase character (i.e. a type symbol), e.g. (Thing 2), is a call to a type constructor which creates a Tup containing the arguments, with the symbol as the first element in the type expression, e.g. (Thing 2) has type (Thing Int) and compiles to a tuple containing a single Int. The type constructor `Tup' can be used as a `cons' replacement to construct generic tuples. git-svn-id: http://svn.drobilla.net/resp/resp@264 ad02d1e2-f140-0410-9f75-f8b11f17cedd --- src/lift.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/lift.cpp') diff --git a/src/lift.cpp b/src/lift.cpp index 3dd0297..939d529 100644 --- a/src/lift.cpp +++ b/src/lift.cpp @@ -119,7 +119,7 @@ AFn::lift(CEnv& cenv, Code& code) throw() AType* implT = new AType(*type); // Type of the implementation function AType* tupT = tup(loc, cenv.tenv.Tup, cenv.tenv.var(), NULL); AType* consT = tup(loc, cenv.tenv.Tup, implT, NULL); - ACons* cons = tup(loc, cenv.penv.sym("cons"), implName, NULL); // Closure + ACons* cons = tup(loc, cenv.penv.sym("Closure"), implName, NULL); *(implT->begin() + 1) = implProtT; @@ -162,10 +162,11 @@ ACall::lift(CEnv& cenv, Code& code) throw() copy->push_front(cenv.penv.sym(cenv.liftStack.top().implName)); } else if (head()->to()) { /* Special case: ((fn ...) ...) - * Lifting (fn ...) yields: (cons _impl ...). - * We don't want ((cons _impl ...) (cons _impl ...) ...), - * so call the implementation function (_impl) directly: - * (_impl (cons _impl ...) ...) + * Lifting (fn ...) yields: (Fn _impl ...). + * We don't want ((Fn _impl ...) (Fn _impl ...) ...), + * so call the implementation function (_impl) directly and pass the + * closure as the first parameter: + * (_impl (Fn _impl ...) ...) */ ACons* closure = (*copy->begin())->as(); ASymbol* implSym = (*(closure->begin() + 1))->as(); -- cgit v1.2.1