Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(471)

Unified Diff: pkg/kernel/lib/text/ast_to_text.dart

Issue 2825053002: Add typedef AST node boilerplate. (Closed)
Patch Set: Update FastaVerifyingVisitor to work with the changes in VerifyingVisitor Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/kernel/lib/text/ast_to_text.dart
diff --git a/pkg/kernel/lib/text/ast_to_text.dart b/pkg/kernel/lib/text/ast_to_text.dart
index 03f7fa6382646163e47475975ef80690ae46503e..198c21462d0cd9b6da7859e38e559d4603721602 100644
--- a/pkg/kernel/lib/text/ast_to_text.dart
+++ b/pkg/kernel/lib/text/ast_to_text.dart
@@ -210,6 +210,12 @@ class Printer extends Visitor<Null> {
return '$library::$name';
}
+ String getTypedefReference(Typedef node) {
+ if (node == null) return '<No Typedef>';
+ String library = getLibraryReference(node.enclosingLibrary);
+ return '$library::${node.name}';
+ }
+
static final String emptyNameString = '•';
static final Name emptyName = new Name(emptyNameString);
@@ -281,6 +287,7 @@ class Printer extends Visitor<Null> {
}
endLine();
var inner = new Printer._inner(this, imports);
+ library.typedefs.forEach(inner.writeNode);
library.classes.forEach(inner.writeNode);
library.fields.forEach(inner.writeNode);
library.procedures.forEach(inner.writeNode);
@@ -313,6 +320,7 @@ class Printer extends Visitor<Null> {
writeWord(prefix);
endLine(' {');
++inner.indentation;
+ library.typedefs.forEach(inner.writeNode);
library.classes.forEach(inner.writeNode);
library.fields.forEach(inner.writeNode);
library.procedures.forEach(inner.writeNode);
@@ -429,6 +437,15 @@ class Printer extends Visitor<Null> {
writeWord('Vector');
}
+ visitTypedefType(TypedefType type) {
+ writeTypedefReference(type.typedefNode);
+ if (type.typeArguments.isNotEmpty) {
+ writeSymbol('<');
+ writeList(type.typeArguments, writeType);
+ writeSymbol('>');
+ }
+ }
+
void writeModifier(bool isThere, String name) {
if (isThere) {
writeWord(name);
@@ -610,6 +627,10 @@ class Printer extends Visitor<Null> {
writeWord(getClassReference(classNode));
}
+ void writeTypedefReference(Typedef typedefNode) {
+ writeWord(getTypedefReference(typedefNode));
+ }
+
void writeLibraryReference(Library library) {
writeWord(getLibraryReference(library));
}
@@ -751,6 +772,16 @@ class Printer extends Visitor<Null> {
endLine('}');
}
+ visitTypedef(Typedef node) {
+ writeIndentation();
+ writeWord('typedef');
+ writeWord(node.name);
+ writeTypeParameterList(node.typeParameters);
+ writeSpaced('=');
+ writeNode(node.type);
+ endLine(';');
+ }
+
visitInvalidExpression(InvalidExpression node) {
writeWord('invalid-expression');
}
« no previous file with comments | « pkg/kernel/lib/canonical_name.dart ('k') | pkg/kernel/lib/transformations/reify/transformation/remove_generics.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698