Remove unused CClass constraint
This commit is contained in:
parent
aede794e43
commit
ca2eb24da2
2 changed files with 6 additions and 60 deletions
|
@ -75,7 +75,6 @@ namespace bolt {
|
||||||
|
|
||||||
enum class ConstraintKind {
|
enum class ConstraintKind {
|
||||||
Equal,
|
Equal,
|
||||||
Class,
|
|
||||||
Many,
|
Many,
|
||||||
Empty,
|
Empty,
|
||||||
};
|
};
|
||||||
|
@ -129,17 +128,6 @@ namespace bolt {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class CClass : public Constraint {
|
|
||||||
public:
|
|
||||||
|
|
||||||
ByteString Name;
|
|
||||||
std::vector<Type*> Types;
|
|
||||||
|
|
||||||
inline CClass(ByteString Name, std::vector<Type*> Types):
|
|
||||||
Constraint(ConstraintKind::Class), Name(Name), Types(Types) {}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
using InferContextFlagsMask = unsigned;
|
using InferContextFlagsMask = unsigned;
|
||||||
|
|
||||||
class InferContext {
|
class InferContext {
|
||||||
|
@ -207,13 +195,11 @@ namespace bolt {
|
||||||
Type* inferExpression(Expression* Expression);
|
Type* inferExpression(Expression* Expression);
|
||||||
Type* inferTypeExpression(TypeExpression* TE, bool IsPoly = true);
|
Type* inferTypeExpression(TypeExpression* TE, bool IsPoly = true);
|
||||||
Type* inferLiteral(Literal* Lit);
|
Type* inferLiteral(Literal* Lit);
|
||||||
|
|
||||||
Type* inferPattern(Pattern* Pattern, ConstraintSet* Constraints = new ConstraintSet, TVSet* TVs = new TVSet);
|
Type* inferPattern(Pattern* Pattern, ConstraintSet* Constraints = new ConstraintSet, TVSet* TVs = new TVSet);
|
||||||
|
|
||||||
void infer(Node* node);
|
void infer(Node* node);
|
||||||
void inferFunctionDeclaration(FunctionDeclaration* N);
|
void inferFunctionDeclaration(FunctionDeclaration* N);
|
||||||
|
void inferConstraintExpression(ConstraintExpression* C);
|
||||||
Constraint* convertToConstraint(ConstraintExpression* C);
|
|
||||||
|
|
||||||
/// Factory methods
|
/// Factory methods
|
||||||
|
|
||||||
|
|
|
@ -1,27 +1,6 @@
|
||||||
|
|
||||||
// TODO Add list of CST variable names to TVar and unify them so that e.g. the typeclass checker may pick one when displaying a diagnostic
|
|
||||||
|
|
||||||
// TODO (maybe) make unficiation work like union-find in find()
|
|
||||||
|
|
||||||
// TODO remove Args in TCon and just use it as a constant
|
|
||||||
// TODO make TApp traversable with TupleIndex
|
|
||||||
|
|
||||||
// TODO make simplify() rewrite the types in-place such that a reference too (Bool, Int).0 becomes Bool
|
|
||||||
|
|
||||||
// TODO Add a check for datatypes that create infinite structures.
|
|
||||||
|
|
||||||
// TODO see if we can merge UnificationError diagnostics so that we get a list of **all** types that were wrong on a given node
|
|
||||||
|
|
||||||
// TODO When a forall variable is missing, do not just insert a blank one into the env. It will result in too few diagnostics being emitted.
|
|
||||||
// Same goes for reference expressions.
|
|
||||||
// If running the compiler as a language server, this matters.
|
|
||||||
|
|
||||||
// TODO Add a pattern that only performs a type assert
|
|
||||||
|
|
||||||
// TODO create the constraint in addConstraint, not the other way round
|
// TODO create the constraint in addConstraint, not the other way round
|
||||||
|
|
||||||
// TODO Find a way to create a match expression in between ( and )
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <stack>
|
#include <stack>
|
||||||
|
@ -45,15 +24,6 @@ namespace bolt {
|
||||||
|
|
||||||
Constraint* Constraint::substitute(const TVSub &Sub) {
|
Constraint* Constraint::substitute(const TVSub &Sub) {
|
||||||
switch (Kind) {
|
switch (Kind) {
|
||||||
case ConstraintKind::Class:
|
|
||||||
{
|
|
||||||
auto Class = static_cast<CClass*>(this);
|
|
||||||
std::vector<Type*> NewTypes;
|
|
||||||
for (auto Ty: Class->Types) {
|
|
||||||
NewTypes.push_back(Ty->substitute(Sub));
|
|
||||||
}
|
|
||||||
return new CClass(Class->Name, NewTypes);
|
|
||||||
}
|
|
||||||
case ConstraintKind::Equal:
|
case ConstraintKind::Equal:
|
||||||
{
|
{
|
||||||
auto Equal = static_cast<CEqual*>(this);
|
auto Equal = static_cast<CEqual*>(this);
|
||||||
|
@ -168,11 +138,6 @@ namespace bolt {
|
||||||
|
|
||||||
void Checker::addConstraint(Constraint* C) {
|
void Checker::addConstraint(Constraint* C) {
|
||||||
switch (C->getKind()) {
|
switch (C->getKind()) {
|
||||||
case ConstraintKind::Class:
|
|
||||||
{
|
|
||||||
getContext().Constraints->push_back(C);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ConstraintKind::Equal:
|
case ConstraintKind::Equal:
|
||||||
{
|
{
|
||||||
auto Y = static_cast<CEqual*>(C);
|
auto Y = static_cast<CEqual*>(C);
|
||||||
|
@ -785,7 +750,7 @@ namespace bolt {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Constraint* Checker::convertToConstraint(ConstraintExpression* C) {
|
void Checker::inferConstraintExpression(ConstraintExpression* C) {
|
||||||
switch (C->getKind()) {
|
switch (C->getKind()) {
|
||||||
case NodeKind::TypeclassConstraintExpression:
|
case NodeKind::TypeclassConstraintExpression:
|
||||||
{
|
{
|
||||||
|
@ -796,12 +761,13 @@ namespace bolt {
|
||||||
TV->Provided.emplace(D->Name->getCanonicalText());
|
TV->Provided.emplace(D->Name->getCanonicalText());
|
||||||
Types.push_back(TV);
|
Types.push_back(TV);
|
||||||
}
|
}
|
||||||
return new CClass(D->Name->getCanonicalText(), Types);
|
break;
|
||||||
}
|
}
|
||||||
case NodeKind::EqualityConstraintExpression:
|
case NodeKind::EqualityConstraintExpression:
|
||||||
{
|
{
|
||||||
auto D = static_cast<EqualityConstraintExpression*>(C);
|
auto D = static_cast<EqualityConstraintExpression*>(C);
|
||||||
return new CEqual(inferTypeExpression(D->Left), inferTypeExpression(D->Right), C);
|
addConstraint(new CEqual(inferTypeExpression(D->Left), inferTypeExpression(D->Right), C));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
ZEN_UNREACHABLE
|
ZEN_UNREACHABLE
|
||||||
|
@ -890,7 +856,7 @@ namespace bolt {
|
||||||
{
|
{
|
||||||
auto QTE = static_cast<QualifiedTypeExpression*>(N);
|
auto QTE = static_cast<QualifiedTypeExpression*>(N);
|
||||||
for (auto [C, Comma]: QTE->Constraints) {
|
for (auto [C, Comma]: QTE->Constraints) {
|
||||||
addConstraint(convertToConstraint(C));
|
inferConstraintExpression(C);
|
||||||
}
|
}
|
||||||
auto Ty = inferTypeExpression(QTE->TE, IsPoly);
|
auto Ty = inferTypeExpression(QTE->TE, IsPoly);
|
||||||
N->setType(Ty);
|
N->setType(Ty);
|
||||||
|
@ -1275,12 +1241,6 @@ namespace bolt {
|
||||||
|
|
||||||
switch (Constraint->getKind()) {
|
switch (Constraint->getKind()) {
|
||||||
|
|
||||||
case ConstraintKind::Class:
|
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case ConstraintKind::Empty:
|
case ConstraintKind::Empty:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue