mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
Migrate Declaration to newer property style, class-ify ClassDefinition (#859)
This commit is contained in:
@@ -11,16 +11,16 @@ namespace Carbon {
|
||||
using llvm::cast;
|
||||
|
||||
void Declaration::Print(llvm::raw_ostream& out) const {
|
||||
switch (Tag()) {
|
||||
switch (kind()) {
|
||||
case Kind::FunctionDeclaration:
|
||||
out << cast<FunctionDeclaration>(*this).Definition();
|
||||
out << cast<FunctionDeclaration>(*this).definition();
|
||||
break;
|
||||
|
||||
case Kind::ClassDeclaration: {
|
||||
const ClassDefinition& class_def =
|
||||
cast<ClassDeclaration>(*this).Definition();
|
||||
out << "class " << class_def.name << " {\n";
|
||||
for (Nonnull<Member*> m : class_def.members) {
|
||||
cast<ClassDeclaration>(*this).definition();
|
||||
out << "class " << class_def.name() << " {\n";
|
||||
for (Nonnull<Member*> m : class_def.members()) {
|
||||
out << *m;
|
||||
}
|
||||
out << "}\n";
|
||||
@@ -29,8 +29,8 @@ void Declaration::Print(llvm::raw_ostream& out) const {
|
||||
|
||||
case Kind::ChoiceDeclaration: {
|
||||
const auto& choice = cast<ChoiceDeclaration>(*this);
|
||||
out << "choice " << choice.Name() << " {\n";
|
||||
for (const auto& alt : choice.Alternatives()) {
|
||||
out << "choice " << choice.name() << " {\n";
|
||||
for (const auto& alt : choice.alternatives()) {
|
||||
out << "alt " << alt.name() << " " << alt.signature() << ";\n";
|
||||
}
|
||||
out << "}\n";
|
||||
@@ -39,7 +39,7 @@ void Declaration::Print(llvm::raw_ostream& out) const {
|
||||
|
||||
case Kind::VariableDeclaration: {
|
||||
const auto& var = cast<VariableDeclaration>(*this);
|
||||
out << "var " << *var.Binding() << " = " << *var.Initializer() << "\n";
|
||||
out << "var " << var.binding() << " = " << var.initializer() << "\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user