| 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 library dev_compiler.src.codegen.js_metalet; | 5 library dev_compiler.src.codegen.js_metalet; |
| 6 | 6 |
| 7 // TODO(jmesserly): import from its own package | 7 // TODO(jmesserly): import from its own package |
| 8 import 'package:dev_compiler/src/js/js_ast.dart'; | 8 import 'package:dev_compiler/src/js/js_ast.dart'; |
| 9 import 'package:dev_compiler/src/js/precedence.dart'; | 9 import 'package:dev_compiler/src/js/precedence.dart'; |
| 10 | 10 |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 } | 250 } |
| 251 | 251 |
| 252 class _IdentFinder extends BaseVisitor { | 252 class _IdentFinder extends BaseVisitor { |
| 253 final String name; | 253 final String name; |
| 254 bool found = false; | 254 bool found = false; |
| 255 _IdentFinder(this.name); | 255 _IdentFinder(this.name); |
| 256 | 256 |
| 257 @override visitIdentifier(Identifier node) { | 257 @override visitIdentifier(Identifier node) { |
| 258 if (node.name == name) found = true; | 258 if (node.name == name) found = true; |
| 259 } | 259 } |
| 260 |
| 260 @override visitNode(Node node) { | 261 @override visitNode(Node node) { |
| 261 if (!found) super.visitNode(node); | 262 if (!found) super.visitNode(node); |
| 262 } | 263 } |
| 263 } | 264 } |
| 264 | 265 |
| 265 class _YieldFinder extends BaseVisitor { | 266 class _YieldFinder extends BaseVisitor { |
| 266 bool hasYield = false; | 267 bool hasYield = false; |
| 267 bool hasThis = false; | 268 bool hasThis = false; |
| 268 bool _nestedFunction = false; | 269 bool _nestedFunction = false; |
| 269 @override visitThis(This node) { | 270 @override visitThis(This node) { |
| 270 hasThis = true; | 271 hasThis = true; |
| 271 } | 272 } |
| 273 |
| 272 @override visitFunctionExpression(FunctionExpression node) { | 274 @override visitFunctionExpression(FunctionExpression node) { |
| 273 var savedNested = _nestedFunction; | 275 var savedNested = _nestedFunction; |
| 274 _nestedFunction = true; | 276 _nestedFunction = true; |
| 275 super.visitFunctionExpression(node); | 277 super.visitFunctionExpression(node); |
| 276 _nestedFunction = savedNested; | 278 _nestedFunction = savedNested; |
| 277 } | 279 } |
| 280 |
| 278 @override visitYield(Yield node) { | 281 @override visitYield(Yield node) { |
| 279 if (!_nestedFunction) hasYield = true; | 282 if (!_nestedFunction) hasYield = true; |
| 280 } | 283 } |
| 284 |
| 281 @override visitNode(Node node) { | 285 @override visitNode(Node node) { |
| 282 if (!hasYield) super.visitNode(node); | 286 if (!hasYield) super.visitNode(node); |
| 283 } | 287 } |
| 284 } | 288 } |
| OLD | NEW |