diff --git a/include/bolt/Checker.hpp b/include/bolt/Checker.hpp index 03ade6e25..2a5187a82 100644 --- a/include/bolt/Checker.hpp +++ b/include/bolt/Checker.hpp @@ -11,55 +11,10 @@ #include "bolt/CST.hpp" #include "bolt/DiagnosticEngine.hpp" #include "bolt/Type.hpp" +#include "bolt/Constraint.hpp" namespace bolt { -enum class ConstraintKind { - TypesEqual, -}; - -class Constraint { - - ConstraintKind Kind; - -protected: - - Constraint(ConstraintKind Kind): - Kind(Kind) {} - -public: - - inline ConstraintKind getKind() const { - return Kind; - } - -}; - -class CTypesEqual : public Constraint { - - Type* A; - Type* B; - Node* Origin; - -public: - - CTypesEqual(Type* A, Type* B, Node* Origin): - Constraint(ConstraintKind::TypesEqual), A(A), B(B), Origin(Origin) {} - - Type* getLeft() const { - return A; - } - - Type* getRight() const { - return B; - } - - Node* getOrigin() const { - return Origin; - } - -}; - class TypeEnv { TypeEnv* Parent; diff --git a/include/bolt/Constraint.hpp b/include/bolt/Constraint.hpp new file mode 100644 index 000000000..848f23a01 --- /dev/null +++ b/include/bolt/Constraint.hpp @@ -0,0 +1,54 @@ + +#pragma once + +#include "bolt/Type.hpp" + +namespace bolt { + +enum class ConstraintKind { + TypesEqual, +}; + +class Constraint { + + ConstraintKind Kind; + +protected: + + Constraint(ConstraintKind Kind): + Kind(Kind) {} + +public: + + inline ConstraintKind getKind() const { + return Kind; + } + +}; + +class CTypesEqual : public Constraint { + + Type* A; + Type* B; + Node* Origin; + +public: + + CTypesEqual(Type* A, Type* B, Node* Origin): + Constraint(ConstraintKind::TypesEqual), A(A), B(B), Origin(Origin) {} + + Type* getLeft() const { + return A; + } + + Type* getRight() const { + return B; + } + + Node* getOrigin() const { + return Origin; + } + +}; + +}