aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-01-28 04:21:46 +0000
committerDavid Robillard <d@drobilla.net>2009-01-28 04:21:46 +0000
commita66ac0edecd4dcd446e4d7b6fe55657346bb1d0b (patch)
treeb66a28cf519d25f4d0591a06ec0c97094746bafc
parent8f6768e23303f6a334ae3c60ead55d37a2dfa3b1 (diff)
downloadresp-a66ac0edecd4dcd446e4d7b6fe55657346bb1d0b.tar.gz
resp-a66ac0edecd4dcd446e4d7b6fe55657346bb1d0b.tar.bz2
resp-a66ac0edecd4dcd446e4d7b6fe55657346bb1d0b.zip
Shrink.
git-svn-id: http://svn.drobilla.net/resp/llvm-lisp@29 ad02d1e2-f140-0410-9f75-f8b11f17cedd
-rw-r--r--ll.cpp26
1 files changed, 9 insertions, 17 deletions
diff --git a/ll.cpp b/ll.cpp
index b8b7c01..8bd14ac 100644
--- a/ll.cpp
+++ b/ll.cpp
@@ -703,15 +703,9 @@ compileFunction(CEnv& cenv, const std::string& name, ASTTuple& prot, const Type*
Value*
ASTSymbol::compile(CEnv& cenv)
{
- Value** v = cenv.vals.ref(this);
- if (v) return *v;
-
AST** c = cenv.code.ref(this);
- if (c) {
- Value* v = cenv.compile(*c);
- cenv.vals.def(this, v);
- return v;
- }
+ if (c)
+ return cenv.vals.def(this, cenv.compile(*c));
throw SyntaxError((string("Undefined symbol '") + cppstr + "'").c_str());
}
@@ -719,11 +713,11 @@ ASTSymbol::compile(CEnv& cenv)
void
ASTClosure::lift(CEnv& cenv)
{
- // Can't lift a closure with variable types (lift later when called)
- if (cenv.tenv.type(tup[2])->var) return;
+ if (cenv.tenv.type(tup[2])->var)
+ throw CompileError("Closure with untyped body lifted");
for (size_t i = 0; i < prot->tup.size(); ++i)
if (cenv.tenv.type(prot->tup[i])->var)
- return;
+ throw CompileError("Closure with untyped parameter lifted");
assert(!func);
cenv.push();
@@ -799,15 +793,13 @@ ASTCall::compile(CEnv& cenv)
c = (val) ? dynamic_cast<ASTClosure*>(*val) : c;
}
- if (!c) throw CompileError("Call to non-closure");
- Value* v = cenv.compile(c);
- if (!v) throw CompileError("Callee failed to compile");
+ assert(c);
Function* f = dynamic_cast<Function*>(cenv.compile(c));
- if (!f) throw CompileError("Callee compiled to non-function");
+ if (!f) throw CompileError("Callee failed to compile");
- vector<Value*> params;
+ vector<Value*> params(tup.size() - 1);
for (size_t i = 1; i < tup.size(); ++i)
- params.push_back(cenv.compile(tup[i]));
+ params[i-1] = cenv.compile(tup[i]);
return cenv.builder.CreateCall(f, params.begin(), params.end(), "calltmp");
}