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

Unified Diff: pkg/compiler/lib/src/dump_info.dart

Issue 1093363002: Refactor DartTypeVisitor and ElementVisitor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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/compiler/lib/src/dump_info.dart
diff --git a/pkg/compiler/lib/src/dump_info.dart b/pkg/compiler/lib/src/dump_info.dart
index 5792cace9ffc0fb47d9b93729ec2ad750bffa785..46c1ff2630351526157abca046f56196f9c924fd 100644
--- a/pkg/compiler/lib/src/dump_info.dart
+++ b/pkg/compiler/lib/src/dump_info.dart
@@ -80,7 +80,8 @@ class GroupedIdMapper {
}
}
-class ElementToJsonVisitor extends ElementVisitor<Map<String, dynamic>> {
+class ElementToJsonVisitor
+ extends BaseElementVisitor<Map<String, dynamic>, dynamic> {
final GroupedIdMapper mapper = new GroupedIdMapper();
final Compiler compiler;
@@ -96,10 +97,12 @@ class ElementToJsonVisitor extends ElementVisitor<Map<String, dynamic>> {
dart2jsVersion = compiler.hasBuildId ? compiler.buildId : null;
for (var library in compiler.libraryLoader.libraries.toList()) {
- library.accept(this);
+ apply(library);
}
}
+ Map<String, dynamic> apply(Element e, [_]) => e.accept(this, null);
floitsch 2015/04/21 13:10:31 usually we call this "visit".
Johnni Winther 2015/04/21 13:37:05 Done.
+
// If keeping the element is in question (like if a function has a size
// of zero), only keep it if it holds dependencies to elsewhere.
bool shouldKeep(Element element) {
@@ -113,7 +116,7 @@ class ElementToJsonVisitor extends ElementVisitor<Map<String, dynamic>> {
// Memoization of the JSON creating process.
Map<String, dynamic> process(Element element) {
- return jsonCache.putIfAbsent(element, () => element.accept(this));
+ return jsonCache.putIfAbsent(element, () => apply(element));
}
// Returns the id of an [element] if it has already been processed.
@@ -127,15 +130,16 @@ class ElementToJsonVisitor extends ElementVisitor<Map<String, dynamic>> {
}
}
- Map<String, dynamic> visitElement(Element element) {
+ Map<String, dynamic> visitElement(Element element, _) {
return null;
}
- Map<String, dynamic> visitConstructorBodyElement(ConstructorBodyElement e) {
- return visitFunctionElement(e.constructor);
+ Map<String, dynamic> visitConstructorBodyElement(
+ ConstructorBodyElement e, _) {
+ return visitFunctionElement(e.constructor, _);
}
- Map<String, dynamic> visitLibraryElement(LibraryElement element) {
+ Map<String, dynamic> visitLibraryElement(LibraryElement element, _) {
var id = mapper._library.add(element);
List<String> children = <String>[];
@@ -165,7 +169,7 @@ class ElementToJsonVisitor extends ElementVisitor<Map<String, dynamic>> {
};
}
- Map<String, dynamic> visitTypedefElement(TypedefElement element) {
+ Map<String, dynamic> visitTypedefElement(TypedefElement element, _) {
String id = mapper._typedef.add(element);
return element.alias == null
? null
@@ -177,7 +181,7 @@ class ElementToJsonVisitor extends ElementVisitor<Map<String, dynamic>> {
};
}
- Map<String, dynamic> visitFieldElement(FieldElement element) {
+ Map<String, dynamic> visitFieldElement(FieldElement element, _) {
String id = mapper._field.add(element);
List<String> children = [];
StringBuffer emittedCode = compiler.dumpInfoTask.codeOf(element);
@@ -223,7 +227,7 @@ class ElementToJsonVisitor extends ElementVisitor<Map<String, dynamic>> {
};
}
- Map<String, dynamic> visitClassElement(ClassElement element) {
+ Map<String, dynamic> visitClassElement(ClassElement element, _) {
String id = mapper._class.add(element);
List<String> children = [];
@@ -282,7 +286,7 @@ class ElementToJsonVisitor extends ElementVisitor<Map<String, dynamic>> {
};
}
- Map<String, dynamic> visitFunctionElement(FunctionElement element) {
+ Map<String, dynamic> visitFunctionElement(FunctionElement element, _) {
String id = mapper._function.add(element);
String name = element.name;
String kind = "function";

Powered by Google App Engine
This is Rietveld 408576698