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

Side by Side Diff: pkg/js_ast/lib/src/template.dart

Issue 1140703006: dart2js: Construct the entire output as a single AST before printing. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Florian's comments Created 5 years, 7 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 unified diff | Download patch
« no previous file with comments | « pkg/js_ast/lib/src/printer.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of js_ast; 5 part of js_ast;
6 6
7 class TemplateManager { 7 class TemplateManager {
8 Map<String, Template> expressionTemplates = new Map<String, Template>(); 8 Map<String, Template> expressionTemplates = new Map<String, Template>();
9 Map<String, Template> statementTemplates = new Map<String, Template>(); 9 Map<String, Template> statementTemplates = new Map<String, Template>();
10 10
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 Instantiator instantiator; 49 Instantiator instantiator;
50 50
51 int positionalArgumentCount = -1; 51 int positionalArgumentCount = -1;
52 52
53 // Null, unless there are named holes. 53 // Null, unless there are named holes.
54 List<String> holeNames; 54 List<String> holeNames;
55 bool get isPositional => holeNames == null; 55 bool get isPositional => holeNames == null;
56 56
57 Template(this.source, this.ast, 57 Template(this.source, this.ast,
58 {this.isExpression: true, this.forceCopy: false}) { 58 {this.isExpression: true, this.forceCopy: false}) {
sra1 2015/05/19 20:56:55 Assert here? assert(this.isExpression ? ast is Ex
herhut 2015/05/20 08:09:16 Done.
59 _compile(); 59 _compile();
60 } 60 }
61 61
62 Template.withExpressionResult(this.ast) 62 Template.withExpressionResult(this.ast, {hasPlaceholders : false})
sra1 2015/05/19 20:56:54 I think we should keep 'withExpressionResult' for
herhut 2015/05/20 08:09:16 Done.
63 : source = null, isExpression = true, forceCopy = false { 63 : source = null, isExpression = true, forceCopy = false {
64 assert(ast is Expression); 64 assert(ast is Expression);
65 assert(_checkNoPlaceholders()); 65 if (hasPlaceholders) {
66 positionalArgumentCount = 0; 66 _compile();
67 instantiator = (arguments) => ast; 67 } else {
68 assert(_checkNoPlaceholders());
69 positionalArgumentCount = 0;
70 instantiator = (arguments) => ast;
71 }
68 } 72 }
69 73
70 Template.withStatementResult(this.ast) 74 Template.withStatementResult(this.ast, {hasPlaceholders : false})
sra1 2015/05/19 20:56:55 Is this used?
herhut 2015/05/20 08:09:16 Removed.
71 : source = null, isExpression = false, forceCopy = false { 75 : source = null, isExpression = false, forceCopy = false {
72 assert(ast is Statement); 76 assert(ast is Statement);
73 assert(_checkNoPlaceholders()); 77
74 positionalArgumentCount = 0; 78 if (hasPlaceholders) {
75 instantiator = (arguments) => ast; 79 _compile();
80 } else {
81 assert(_checkNoPlaceholders());
82 positionalArgumentCount = 0;
83 instantiator = (arguments) => ast;
84 }
76 } 85 }
77 86
78 bool _checkNoPlaceholders() { 87 bool _checkNoPlaceholders() {
79 InstantiatorGeneratorVisitor generator = 88 InstantiatorGeneratorVisitor generator =
80 new InstantiatorGeneratorVisitor(false); 89 new InstantiatorGeneratorVisitor(false);
81 generator.compile(ast); 90 generator.compile(ast);
82 return generator.analysis.count == 0; 91 return generator.analysis.count == 0;
83 } 92 }
84 93
85 void _compile() { 94 void _compile() {
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 if (count != before) containsInterpolatedNode.add(node); 754 if (count != before) containsInterpolatedNode.add(node);
746 return null; 755 return null;
747 } 756 }
748 757
749 visitInterpolatedNode(InterpolatedNode node) { 758 visitInterpolatedNode(InterpolatedNode node) {
750 containsInterpolatedNode.add(node); 759 containsInterpolatedNode.add(node);
751 if (node.isNamed) holeNames.add(node.nameOrPosition); 760 if (node.isNamed) holeNames.add(node.nameOrPosition);
752 ++count; 761 ++count;
753 } 762 }
754 } 763 }
OLDNEW
« no previous file with comments | « pkg/js_ast/lib/src/printer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698