diff options
Diffstat (limited to 'llvm.cpp')
-rw-r--r-- | llvm.cpp | 31 |
1 files changed, 18 insertions, 13 deletions
@@ -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 |