OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 // TODO(jmesserly): import from its own package | 5 // TODO(jmesserly): import from its own package |
6 import '../js_ast/js_ast.dart'; | 6 import '../js_ast/js_ast.dart'; |
7 import '../js_ast/precedence.dart'; | 7 import '../js_ast/precedence.dart'; |
8 | 8 |
9 import 'js_names.dart' show TemporaryId; | 9 import 'js_names.dart' show TemporaryId; |
10 | 10 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 if (visitor is InterpolatedNodeAnalysis || | 136 if (visitor is InterpolatedNodeAnalysis || |
137 visitor is InstantiatorGeneratorVisitor) { | 137 visitor is InstantiatorGeneratorVisitor) { |
138 variables.values.forEach((v) => v.accept(visitor)); | 138 variables.values.forEach((v) => v.accept(visitor)); |
139 body.forEach((v) => v.accept(visitor)); | 139 body.forEach((v) => v.accept(visitor)); |
140 } else { | 140 } else { |
141 toExpression().visitChildren(visitor); | 141 toExpression().visitChildren(visitor); |
142 } | 142 } |
143 } | 143 } |
144 | 144 |
145 /// This generates as either a comma expression or a call. | 145 /// This generates as either a comma expression or a call. |
146 int get precedenceLevel => variables.isEmpty ? EXPRESSION : CALL; | 146 int get precedenceLevel => toExpression().precedenceLevel; |
147 | 147 |
148 /// Patch to pretend [Template] supports visitMetaLet. | 148 /// Patch to pretend [Template] supports visitMetaLet. |
149 Instantiator _templateVisitMetaLet(InstantiatorGeneratorVisitor visitor) { | 149 Instantiator _templateVisitMetaLet(InstantiatorGeneratorVisitor visitor) { |
150 var valueInstantiators = variables.values.map(visitor.visit); | 150 var valueInstantiators = variables.values.map(visitor.visit); |
151 var bodyInstantiators = body.map(visitor.visit); | 151 var bodyInstantiators = body.map(visitor.visit); |
152 | 152 |
153 return (args) => new MetaLet( | 153 return (args) => new MetaLet( |
154 new Map.fromIterables( | 154 new Map.fromIterables( |
155 variables.keys, valueInstantiators.map((i) => i(args))), | 155 variables.keys, valueInstantiators.map((i) => i(args))), |
156 bodyInstantiators.map((i) => i(args) as Expression).toList(), | 156 bodyInstantiators.map((i) => i(args) as Expression).toList(), |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 if (!_nestedFunction) hasYield = true; | 352 if (!_nestedFunction) hasYield = true; |
353 super.visitYield(node); | 353 super.visitYield(node); |
354 } | 354 } |
355 | 355 |
356 @override | 356 @override |
357 visitNode(Node node) { | 357 visitNode(Node node) { |
358 if (hasYield && hasThis) return; // found both, nothing more to do. | 358 if (hasYield && hasThis) return; // found both, nothing more to do. |
359 super.visitNode(node); | 359 super.visitNode(node); |
360 } | 360 } |
361 } | 361 } |
OLD | NEW |