aboutsummaryrefslogtreecommitdiffstats
path: root/llvm.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-03-07 00:24:05 +0000
committerDavid Robillard <d@drobilla.net>2009-03-07 00:24:05 +0000
commita7e747b45b0ff3f9e106182e6a357d0b261255a5 (patch)
treebfb32d0c137987323e7363513a123b6634d0d338 /llvm.cpp
parent77162da0f773b8e79939491aca4e0232c62c255c (diff)
downloadresp-a7e747b45b0ff3f9e106182e6a357d0b261255a5.tar.gz
resp-a7e747b45b0ff3f9e106182e6a357d0b261255a5.tar.bz2
resp-a7e747b45b0ff3f9e106182e6a357d0b261255a5.zip
Fancy error reporting for type errors, among other things.
git-svn-id: http://svn.drobilla.net/resp/tuplr@66 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'llvm.cpp')
-rw-r--r--llvm.cpp31
1 files changed, 18 insertions, 13 deletions
diff --git a/llvm.cpp b/llvm.cpp
index b981d7d..a0ec539 100644
--- a/llvm.cpp
+++ b/llvm.cpp
@@ -190,12 +190,17 @@ compileFunction(CEnv& cenv, const std::string& name, const Type* retT, const AST
* AST Code Generation *
***************************************************************************/
+void
+ASTSymbol::lift(CEnv& cenv)
+{
+ if (!cenv.code.ref(this))
+ throw Error((string("undefined symbol `") + cppstr + "'").c_str(), loc);
+}
+
CValue
ASTSymbol::compile(CEnv& cenv)
{
- AST** c = cenv.code.ref(this);
- if (!c) throw Error((string("undefined symbol `") + cppstr + "'").c_str(), loc);
- return cenv.compile(*c);
+ return cenv.compile(*cenv.code.ref(this));
}
void
@@ -356,14 +361,14 @@ ASTPrimitive::compile(CEnv& cenv)
// Binary arithmetic operations
Instruction::BinaryOps op = (Instruction::BinaryOps)0;
- if (n == "+") op = Instruction::Add;
- if (n == "-") op = Instruction::Sub;
- if (n == "*") op = Instruction::Mul;
- if (n == "&") op = Instruction::And;
- if (n == "|") op = Instruction::Or;
- if (n == "^") op = Instruction::Xor;
- if (n == "/") op = isInt ? Instruction::SDiv : Instruction::FDiv;
- if (n == "%") op = isInt ? Instruction::SRem : Instruction::FRem;
+ if (n == "+") op = Instruction::Add;
+ if (n == "-") op = Instruction::Sub;
+ if (n == "*") op = Instruction::Mul;
+ if (n == "and") op = Instruction::And;
+ if (n == "or") op = Instruction::Or;
+ if (n == "xor") op = Instruction::Xor;
+ if (n == "/") op = isInt ? Instruction::SDiv : Instruction::FDiv;
+ if (n == "%") op = isInt ? Instruction::SRem : Instruction::FRem;
if (op != 0) {
Value* val = cenv.engine.builder.CreateBinOp(op, a, b);
for (size_t i = 3; i < size(); ++i)
@@ -394,8 +399,8 @@ ASTConsCall::functionType(CEnv& cenv)
{
ASTTuple* protTypes = new ASTTuple(cenv.tenv.type(at(1)), cenv.tenv.type(at(2)), NULL);
AType* cellType = new AType(ASTTuple(cenv.penv.sym("Pair"),
- cenv.tenv.type(at(1)), cenv.tenv.type(at(2)), NULL));
- return new AType(ASTTuple(cenv.penv.sym("Fn"), protTypes, cellType, NULL));
+ cenv.tenv.type(at(1)), cenv.tenv.type(at(2)), NULL), Cursor());
+ return new AType(ASTTuple(cenv.penv.sym("Fn"), protTypes, cellType, NULL), loc);
}
void