From 4228a70779325bd321084cc86a2e817cd4a20fe0 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 15 Mar 2009 15:48:56 +0000 Subject: Remove stupid maybeLookup function. Fix crash on calling concretely typed functions in the REPL. git-svn-id: http://svn.drobilla.net/resp/tuplr@105 ad02d1e2-f140-0410-9f75-f8b11f17cedd --- llvm.cpp | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/llvm.cpp b/llvm.cpp index c354b79..dd368a8 100644 --- a/llvm.cpp +++ b/llvm.cpp @@ -213,22 +213,19 @@ AClosure::liftCall(CEnv& cenv, const vector& argsT) assert(gt != cenv.tenv.genericTypes.end()); AType* genericType = new AType(*gt->second); - AType* thisType = NULL; + AType* thisType = genericType; Subst argsSubst; - if (!genericType->concrete()) { + if (!thisType->concrete()) { // Find type and build substitution assert(argsT.size() == prot()->size()); - ATuple* genericProtT = genericType->at(1)->to(); - assert(genericProtT); + ATuple* genericProtT = genericType->at(1)->as(); for (size_t i = 0; i < argsT.size(); ++i) argsSubst[genericProtT->at(i)->to()] = argsT.at(i)->to(); - thisType = argsSubst.apply(genericType)->as(); - if (!thisType->concrete()) throw Error("unable to resolve concrete type for function", loc); } else { - thisType = cenv.type(this); + thisType = genericType; } if (funcs.find(thisType)) @@ -277,20 +274,10 @@ AClosure::compile(CEnv& cenv) return NULL; } -static -AST* -maybeLookup(CEnv& cenv, AST* ast) -{ - ASymbol* s = ast->to(); - if (s && s->addr) - return cenv.tenv.deref(s->addr).first; - return ast; -} - void ACall::lift(CEnv& cenv) { - AClosure* c = maybeLookup(cenv, at(0))->to(); + AClosure* c = cenv.tenv.resolve(at(0))->to(); vector argsT; // Lift arguments @@ -312,7 +299,7 @@ ACall::lift(CEnv& cenv) CValue ACall::compile(CEnv& cenv) { - AClosure* c = maybeLookup(cenv, at(0))->to(); + AClosure* c = cenv.tenv.resolve(at(0))->to(); if (!c) return NULL; // Primitive @@ -512,7 +499,7 @@ AConsCall::compile(CEnv& cenv) CValue ACarCall::compile(CEnv& cenv) { - AST* arg = maybeLookup(cenv, at(1)); + AST* arg = cenv.tenv.resolve(at(1)); Value* sP = LLVal(cenv.compile(arg)); Value* s = llengine(cenv)->builder.CreateGEP(sP, ConstantInt::get(Type::Int32Ty, 0), "pair"); Value* carP = llengine(cenv)->builder.CreateStructGEP(s, 0, "car"); @@ -522,7 +509,7 @@ ACarCall::compile(CEnv& cenv) CValue ACdrCall::compile(CEnv& cenv) { - AST* arg = maybeLookup(cenv, at(1)); + AST* arg = cenv.tenv.resolve(at(1)); Value* sP = LLVal(cenv.compile(arg)); Value* s = llengine(cenv)->builder.CreateGEP(sP, ConstantInt::get(Type::Int32Ty, 0), "pair"); Value* cdrP = llengine(cenv)->builder.CreateStructGEP(s, 1, "cdr"); -- cgit v1.2.1