Initial support for aliases. (#1262)

This supports aliases for types (including interfaces), functions, parameterized types, instance member names, and interface member names.

Co-authored-by: Jon Meow <jperkins@google.com>
This commit is contained in:
Richard Smith
2022-05-16 16:31:38 -07:00
committed by GitHub
co-authored by Jon Meow
parent c48d024eea
commit 50d0561249
22 changed files with 458 additions and 0 deletions
+16
View File
@@ -78,6 +78,13 @@ void Declaration::Print(llvm::raw_ostream& out) const {
out << "Self";
break;
}
case DeclarationKind::AliasDeclaration: {
const auto& alias = cast<AliasDeclaration>(*this);
PrintID(out);
out << " = " << alias.target() << ";\n";
break;
}
}
}
@@ -127,6 +134,12 @@ void Declaration::PrintID(llvm::raw_ostream& out) const {
out << "Self";
break;
}
case DeclarationKind::AliasDeclaration: {
const auto& alias = cast<AliasDeclaration>(*this);
out << "alias " << alias.name();
break;
}
}
}
@@ -146,6 +159,9 @@ auto GetName(const Declaration& declaration) -> std::optional<std::string> {
return std::nullopt;
case DeclarationKind::SelfDeclaration:
return cast<SelfDeclaration>(declaration).name();
case DeclarationKind::AliasDeclaration: {
return cast<AliasDeclaration>(declaration).name();
}
}
}