continue working on ir

This commit is contained in:
2026-08-07 17:35:48 +10:00
parent 376d6ec73b
commit c8b0cfd928
8 changed files with 243 additions and 56 deletions

43
src/ir/irbuilder.hpp Normal file
View 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();
};
}