mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 08:31:04 +01:00
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:
committed by
GitHub
co-authored by
Jon Meow
parent
c48d024eea
commit
50d0561249
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user