44 lines
937 B
C++
44 lines
937 B
C++
#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();
|
|
};
|
|
}
|