#pragma once #include #include #include #include #include namespace xlang { class ErrorListener; enum class Type { Invalid, Integer, Boolean, }; std::string typeToString(Type type); class TypeCheckVisitor : public xlangBaseVisitor { struct Signature { Type returntype; std::vector parametertypes; }; ErrorListener &errorlistener; std::unordered_map signatures; Type returntype; Scope scope; size_t loopcount; public: TypeCheckVisitor(ErrorListener &errorlistener); std::any visitFile(xlangParser::FileContext *ctx) override; std::any visitFunction(xlangParser::FunctionContext *ctx) override; std::any visitType(xlangParser::TypeContext *ctx) override; std::any visitBlock(xlangParser::BlockContext *ctx) override; std::any visitStatement(xlangParser::StatementContext *ctx) override; std::any visitValue(xlangParser::ValueContext *ctx) override; std::any visitCondition(xlangParser::ConditionContext *ctx) override; std::any visitBoolean(xlangParser::BooleanContext *ctx) override; std::any visitExpr(xlangParser::ExprContext *ctx) override; std::any visitTerm(xlangParser::TermContext *ctx) override; std::any visitFactor(xlangParser::FactorContext *ctx) override; std::any visitVariable(xlangParser::VariableContext *ctx) override; }; } // namespace xlang