#include "Context.h" #include "Type.h" using qlow::sem::Context; size_t std::hash>::operator() (const std::reference_wrapper& t) const { return t.get().hash(); } qlow::sem::TypeId Context::addType(Type&& type) { if (typesMap.contains(type)) { return typesMap[type]; } else { types.emplace_back(type); return types.size() - 1; } } std::optional> Context::getType(TypeId tid) { if (tid >= 0 && tid <= types.size()) { return std::make_optional>(*types[tid]); } else { return std::nullopt; } } qlow::sem::TypeId Context::getPointerTo(TypeId id) { return addType(Type::createPointerType(*this, id)); } qlow::sem::TypeId Context::getArrayOf(TypeId id) { return addType(Type::createArrayType(*this, id)); }