aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-03-15 15:48:56 +0000
committerDavid Robillard <d@drobilla.net>2009-03-15 15:48:56 +0000
commit4228a70779325bd321084cc86a2e817cd4a20fe0 (patch)
tree06e99c891bb6c57b284ed5e4c8c45a81ce69be7c
parentd5bff57e97494e5a25626c2877880a7eda5485c7 (diff)
downloadresp-4228a70779325bd321084cc86a2e817cd4a20fe0.tar.gz
resp-4228a70779325bd321084cc86a2e817cd4a20fe0.tar.bz2
resp-4228a70779325bd321084cc86a2e817cd4a20fe0.zip
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
-rw-r--r--llvm.cpp29
1 files 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<AType*>& 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<ATuple*>();
- assert(genericProtT);
+ ATuple* genericProtT = genericType->at(1)->as<ATuple*>();
for (size_t i = 0; i < argsT.size(); ++i)
argsSubst[genericProtT->at(i)->to<AType*>()] = argsT.at(i)->to<AType*>();
-
thisType = argsSubst.apply(genericType)->as<AType*>();
-
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<ASymbol*>();
- 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*>();
+ AClosure* c = cenv.tenv.resolve(at(0))->to<AClosure*>();
vector<AType*> argsT;
// Lift arguments
@@ -312,7 +299,7 @@ ACall::lift(CEnv& cenv)
CValue
ACall::compile(CEnv& cenv)
{
- AClosure* c = maybeLookup(cenv, at(0))->to<AClosure*>();
+ AClosure* c = cenv.tenv.resolve(at(0))->to<AClosure*>();
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");