Start working on type checker

This commit is contained in:
2026-08-01 22:12:05 +10:00
parent 372be46394
commit a8da871aa4
6 changed files with 205 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
#pragma once
#include "type.hpp"
#include "../parser/parser.hpp"
#include <string>
#include <unordered_map>
namespace Solstice {
class TypeChecker {
std::unordered_map<std::string, Type> variables;
std::unordered_map<std::string, Type> types;
std::unordered_map<TypePair, Type> addOverloads;
std::unordered_map<TypePair, Type> subtractOverloads;
std::unordered_map<TypePair, Type> multiplyOverloads;
std::unordered_map<TypePair, Type> divideOverloads;
std::unordered_map<TypePair, Type> equalOverloads;
std::unordered_map<TypePair, Type> notEqualOverloads;
std::unordered_map<TypePair, Type> greaterThanOverloads;
std::unordered_map<TypePair, Type> lesserThanOverloads;
Node& input;
void initOverloads();
public:
TypeChecker() = delete;
TypeChecker(Node& node) : input(node) {
initOverloads();
}
void checkTypes();
};
}