Move constraint declarations to Constraint.hpp
This commit is contained in:
parent
32f961aad9
commit
fc24bb9091
2 changed files with 55 additions and 46 deletions
|
@ -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;
|
||||
|
|
54
include/bolt/Constraint.hpp
Normal file
54
include/bolt/Constraint.hpp
Normal file
|
@ -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;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in a new issue