Implement syntax changes from #2760 in Explorer (#2906)

Implement syntax changes from #2760 in Explorer
This commit is contained in:
josh11b
2023-06-15 08:42:14 -07:00
committed by GitHub
parent b03d0d542b
commit 1505a634a4
196 changed files with 755 additions and 483 deletions
+35 -13
View File
@@ -108,8 +108,8 @@ void Declaration::Print(llvm::raw_ostream& out) const {
break;
}
case DeclarationKind::InterfaceExtendsDeclaration:
case DeclarationKind::InterfaceImplDeclaration:
case DeclarationKind::InterfaceExtendDeclaration:
case DeclarationKind::InterfaceRequireDeclaration:
case DeclarationKind::AssociatedConstantDeclaration: {
PrintID(out);
out << ";\n";
@@ -127,6 +127,12 @@ void Declaration::Print(llvm::raw_ostream& out) const {
out << " = " << alias.target() << ";\n";
break;
}
case DeclarationKind::ExtendBaseDeclaration: {
PrintID(out);
out << ";\n";
break;
}
}
}
@@ -149,9 +155,9 @@ void Declaration::PrintID(llvm::raw_ostream& out) const {
const auto& impl_decl = cast<ImplDeclaration>(*this);
switch (impl_decl.kind()) {
case ImplKind::InternalImpl:
out << "extend ";
break;
case ImplKind::ExternalImpl:
out << "external ";
break;
}
out << "impl ";
@@ -163,7 +169,10 @@ void Declaration::PrintID(llvm::raw_ostream& out) const {
}
out << "] ";
}
out << *impl_decl.impl_type() << " as " << impl_decl.interface();
if (impl_decl.kind() != ImplKind::InternalImpl) {
out << *impl_decl.impl_type() << " ";
}
out << "as " << impl_decl.interface();
break;
}
case DeclarationKind::MatchFirstDeclaration:
@@ -204,15 +213,15 @@ void Declaration::PrintID(llvm::raw_ostream& out) const {
break;
}
case DeclarationKind::InterfaceExtendsDeclaration: {
const auto& extends = cast<InterfaceExtendsDeclaration>(*this);
out << "extends " << *extends.base();
case DeclarationKind::InterfaceExtendDeclaration: {
const auto& extend = cast<InterfaceExtendDeclaration>(*this);
out << "extend " << *extend.base();
break;
}
case DeclarationKind::InterfaceImplDeclaration: {
const auto& impl = cast<InterfaceImplDeclaration>(*this);
out << "impl " << *impl.impl_type() << " as " << *impl.constraint();
case DeclarationKind::InterfaceRequireDeclaration: {
const auto& impl = cast<InterfaceRequireDeclaration>(*this);
out << "require " << *impl.impl_type() << " impls " << *impl.constraint();
break;
}
@@ -232,6 +241,12 @@ void Declaration::PrintID(llvm::raw_ostream& out) const {
out << "alias " << alias.name();
break;
}
case DeclarationKind::ExtendBaseDeclaration: {
const auto& extend = cast<ExtendBaseDeclaration>(*this);
out << "extend base: " << *extend.base_class();
break;
}
}
}
@@ -268,8 +283,8 @@ auto GetName(const Declaration& declaration)
return cast<VariableDeclaration>(declaration).binding().name();
case DeclarationKind::AssociatedConstantDeclaration:
return cast<AssociatedConstantDeclaration>(declaration).binding().name();
case DeclarationKind::InterfaceExtendsDeclaration:
case DeclarationKind::InterfaceImplDeclaration:
case DeclarationKind::InterfaceExtendDeclaration:
case DeclarationKind::InterfaceRequireDeclaration:
case DeclarationKind::ImplDeclaration:
case DeclarationKind::MatchFirstDeclaration:
return std::nullopt;
@@ -278,6 +293,9 @@ auto GetName(const Declaration& declaration)
case DeclarationKind::AliasDeclaration: {
return cast<AliasDeclaration>(declaration).name().inner_name();
}
case DeclarationKind::ExtendBaseDeclaration: {
return "extend base";
}
}
}
@@ -417,10 +435,14 @@ ClassDeclaration::ClassDeclaration(CloneContext& context,
extensibility_(other.extensibility_),
self_decl_(context.Clone(other.self_decl_)),
type_params_(context.Clone(other.type_params_)),
base_expr_(context.Clone(other.base_expr_)),
members_(context.Clone(other.members_)),
base_type_(context.Clone(other.base_type_)) {}
ExtendBaseDeclaration::ExtendBaseDeclaration(CloneContext& context,
const ExtendBaseDeclaration& other)
: Declaration(context, other),
base_class_(context.Clone(other.base_class_)) {}
ConstraintTypeDeclaration::ConstraintTypeDeclaration(
CloneContext& context, const ConstraintTypeDeclaration& other)
: Declaration(context, other),