Added builder error

This commit is contained in:
Rafał Grodziński
2025-07-05 21:58:11 +09:00
parent 1e7ecaf801
commit 48f27169d0
6 changed files with 38 additions and 10 deletions

View File

@@ -1,5 +1,6 @@
#include "ModuleBuilder.h"
#include "Error.h"
#include "Parser/ValueType.h"
#include "Parser/Expression/ExpressionGrouping.h"
@@ -474,3 +475,7 @@ void ModuleBuilder::failWithMessage(string message) {
cerr << "Error! Building module \"" << moduleName << "\" from \"" + sourceFileName + "\" failed:" << endl << message << endl;
exit(1);
}
void ModuleBuilder::markError(int line, int column, string message) {
errors.push_back(Error::builderError(line, column, message));
}

View File

@@ -11,6 +11,7 @@
#include <llvm/Support/raw_ostream.h>
#include <llvm/IR/Verifier.h>
class Error;
class ValueType;
class Expression;
@@ -41,6 +42,7 @@ typedef struct {
class ModuleBuilder {
private:
vector<shared_ptr<Error>> errors;
string moduleName;
string sourceFileName;
@@ -86,6 +88,8 @@ private:
llvm::Type *typeForValueType(shared_ptr<ValueType> valueType);
void failWithMessage(string message);
void markError(int line, int column, string message);
public:
ModuleBuilder(string moduleName, string sourceFileName, vector<shared_ptr<Statement>> statements);
shared_ptr<llvm::Module> getModule();