continue working on ir
This commit is contained in:
43
src/ir/irbuilder.hpp
Normal file
43
src/ir/irbuilder.hpp
Normal file
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
|
||||
#include "ir.hpp"
|
||||
#include "../parser/parser.hpp"
|
||||
#include "../typechecker/typechecker.hpp"
|
||||
#include <cstdint>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace Solstice {
|
||||
|
||||
struct IRContext {
|
||||
std::unordered_map<std::string, int64_t> variables;
|
||||
};
|
||||
|
||||
class IRBuilder {
|
||||
Node in;
|
||||
Program out;
|
||||
|
||||
Context tcContext;
|
||||
|
||||
IRContext* currentContext = nullptr;
|
||||
|
||||
BasicBlock* currentBlock = nullptr;
|
||||
IRFunction* currentFunction = nullptr;
|
||||
|
||||
void buildNode(Node& node);
|
||||
|
||||
void buildRootNode(Node& node);
|
||||
void buildLiteralNode(Node& node);
|
||||
void buildIdentifierNode(Node& node);
|
||||
|
||||
void buildFunctionBindNode(Node& node);
|
||||
|
||||
public:
|
||||
IRBuilder() = delete;
|
||||
IRBuilder(const Node& node, const Context& context) : in(node), tcContext(context) {}
|
||||
|
||||
void build();
|
||||
void optimise();
|
||||
|
||||
Program& getProgram();
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user