Added scopes
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#define MODULE_BUILDER_H
|
||||
|
||||
#include <map>
|
||||
#include <stack>
|
||||
|
||||
#include <llvm/IR/Module.h>
|
||||
#include <llvm/IR/IRBuilder.h>
|
||||
@@ -33,6 +34,11 @@ class StatementBlock;
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef struct {
|
||||
map<string, llvm::AllocaInst*> allocaMap;
|
||||
map<string, llvm::Function*> funMap;
|
||||
} Scope;
|
||||
|
||||
class ModuleBuilder {
|
||||
private:
|
||||
string moduleName;
|
||||
@@ -48,8 +54,7 @@ private:
|
||||
llvm::Type *typeReal32;
|
||||
|
||||
vector<shared_ptr<Statement>> statements;
|
||||
map<string, llvm::AllocaInst*> allocaMap;
|
||||
map<string, llvm::Function*> funMap;
|
||||
stack<Scope> scopes;
|
||||
|
||||
void buildStatement(shared_ptr<Statement> statement);
|
||||
void buildFunctionDeclaration(shared_ptr<StatementFunction> statement);
|
||||
@@ -72,6 +77,12 @@ private:
|
||||
llvm::Value *valueForVar(shared_ptr<ExpressionVariable> expression);
|
||||
llvm::Value *valueForCall(shared_ptr<ExpressionCall> expression);
|
||||
|
||||
bool setAlloca(string name, llvm::AllocaInst *alloca);
|
||||
llvm::AllocaInst *getAlloca(string name);
|
||||
|
||||
bool setFun(string name, llvm::Function *fun);
|
||||
llvm::Function *getFun(string name);
|
||||
|
||||
llvm::Type *typeForValueType(shared_ptr<ValueType> valueType);
|
||||
void failWithMessage(string message);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user