aboutsummaryrefslogtreecommitdiffstats
path: root/ll.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'll.cpp')
-rw-r--r--ll.cpp29
1 files changed, 2 insertions, 27 deletions
diff --git a/ll.cpp b/ll.cpp
index bf2b48a..41106a8 100644
--- a/ll.cpp
+++ b/ll.cpp
@@ -194,23 +194,6 @@ private:
* Parser - Transform S-Expressions into AST nodes *
***************************************************************************/
-/// Error* - These are little helper functions for error handling.
-AST* Error(const char *msg)
-{
- std::cerr << "Error: " << msg << endl;
- return 0;
-}
-
-ASTPrototype* ErrorP(const char *Str)
-{
- return (ASTPrototype*)Error(Str);
-}
-
-ASTFunction* ErrorF(const char *Str)
-{
- return (ASTFunction*)Error(Str);
-}
-
static const std::string& head(const SExp& exp)
{
static const std::string empty = "";
@@ -278,7 +261,7 @@ static ASTPrototype* ParsePrototype(bool foreign, const SExp& exp)
if (i->type == SExp::ATOM)
args.push_back(i->atom);
else
- return ErrorP("Expected parameter name, found list");
+ throw SyntaxError("Expected parameter name, found list");
return new ASTPrototype(foreign, name, args);
}
@@ -357,12 +340,6 @@ struct CEnv {
map<string, Value*> env;
};
-Value* ErrorV(const char *Str)
-{
- Error(Str);
- return 0;
-}
-
Value* ASTNumber::Codegen(CEnv& cenv)
{
return ConstantFP::get(APFloat(_val));
@@ -409,7 +386,6 @@ Value* ASTIf::Codegen(CEnv& cenv)
// Emit then value.
cenv.builder.SetInsertPoint(thenBB);
-
Value* thenV = _then->Codegen(cenv);
cenv.builder.CreateBr(mergeBB);
@@ -419,7 +395,6 @@ Value* ASTIf::Codegen(CEnv& cenv)
// Emit else block.
parent->getBasicBlockList().push_back(elseBB);
cenv.builder.SetInsertPoint(elseBB);
-
Value* elseV = _else->Codegen(cenv);
cenv.builder.CreateBr(mergeBB);
@@ -489,7 +464,7 @@ Function* ASTFunction::Funcgen(CEnv& cenv)
verifyFunction(*f); // Validate generated code
cenv.fpm.run(*f); // Optimize function
return f;
- } catch (std::exception e) {
+ } catch (SyntaxError e) {
f->eraseFromParent(); // Error reading body, remove function
throw e;
}