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

Unified Diff: lib/compiler/implementation/dart_backend/backend.dart

Issue 10919127: Introduce AST cloning. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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: lib/compiler/implementation/dart_backend/backend.dart
diff --git a/lib/compiler/implementation/dart_backend/backend.dart b/lib/compiler/implementation/dart_backend/backend.dart
index 64d0e63f6fdd9e48d27d76ace0433744ae246013..f25000065ebcb444287cfa85bdb43462c97d87b5 100644
--- a/lib/compiler/implementation/dart_backend/backend.dart
+++ b/lib/compiler/implementation/dart_backend/backend.dart
@@ -7,6 +7,12 @@ class ElementAst {
final TreeElements treeElements;
ElementAst(this.ast, this.treeElements);
+
+ factory ElementAst.clone(ast, treeElements) {
+ final cloner = new CloningVisitor(treeElements);
+ return new ElementAst(cloner.visit(ast), cloner.cloneTreeElements);
+ }
+
ElementAst.forClassLike(this.ast)
: this.treeElements = new TreeElementMapping();
}
@@ -171,7 +177,7 @@ class DartBackend extends Backend {
resolvedElements.forEach((element, treeElements) {
if (!shouldOutput(element)) return;
- var elementAst = new ElementAst(parse(element), treeElements);
+ var elementAst = new ElementAst.clone(parse(element), treeElements);
if (element.isField()) {
final list = (element as VariableElement).variables;
elementAst = elementAsts.putIfAbsent(
@@ -198,9 +204,9 @@ class DartBackend extends Backend {
// Create all necessary placeholders.
PlaceholderCollector collector =
- new PlaceholderCollector(compiler, fixedMemberNames);
+ new PlaceholderCollector(compiler, fixedMemberNames, elementAsts);
makePlaceholders(element) {
- collector.collect(element, elementAsts[element].treeElements);
+ collector.collect(element);
if (element is ClassElement) {
classMembers[element].forEach(makePlaceholders);
}

Powered by Google App Engine
This is Rietveld 408576698