| 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_codegen; | 5 library dev_compiler.src.codegen.js_codegen; |
| 6 | 6 |
| 7 import 'dart:collection' show HashSet, HashMap, SplayTreeSet; | 7 import 'dart:collection' show HashSet, HashMap, SplayTreeSet; |
| 8 | 8 |
| 9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; | 9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; |
| 10 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator; | 10 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 final LibraryElement currentLibrary; | 58 final LibraryElement currentLibrary; |
| 59 | 59 |
| 60 /// The global extension type table. | 60 /// The global extension type table. |
| 61 final HashSet<ClassElement> _extensionTypes; | 61 final HashSet<ClassElement> _extensionTypes; |
| 62 | 62 |
| 63 /// Information that is precomputed for this library, indicates which fields | 63 /// Information that is precomputed for this library, indicates which fields |
| 64 /// need storage slots. | 64 /// need storage slots. |
| 65 final HashSet<FieldElement> _fieldsNeedingStorage; | 65 final HashSet<FieldElement> _fieldsNeedingStorage; |
| 66 | 66 |
| 67 /// The variable for the target of the current `..` cascade expression. | 67 /// The variable for the target of the current `..` cascade expression. |
| 68 SimpleIdentifier _cascadeTarget; | 68 /// |
| 69 /// Usually a [SimpleIdentifier], but it can also be other expressions |
| 70 /// that are safe to evaluate multiple times, such as `this`. |
| 71 Expression _cascadeTarget; |
| 69 | 72 |
| 70 /// The variable for the current catch clause | 73 /// The variable for the current catch clause |
| 71 SimpleIdentifier _catchParameter; | 74 SimpleIdentifier _catchParameter; |
| 72 | 75 |
| 73 /// In an async* function, this represents the stream controller parameter. | 76 /// In an async* function, this represents the stream controller parameter. |
| 74 JS.TemporaryId _asyncStarController; | 77 JS.TemporaryId _asyncStarController; |
| 75 | 78 |
| 76 /// Imported libraries, and the temporaries used to refer to them. | 79 /// Imported libraries, and the temporaries used to refer to them. |
| 77 final _imports = new Map<LibraryElement, JS.TemporaryId>(); | 80 final _imports = new Map<LibraryElement, JS.TemporaryId>(); |
| 78 final _exports = new Set<String>(); | 81 final _exports = new Set<String>(); |
| (...skipping 2430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2509 } | 2512 } |
| 2510 | 2513 |
| 2511 // Cascades can contain [IndexExpression], [MethodInvocation] and | 2514 // Cascades can contain [IndexExpression], [MethodInvocation] and |
| 2512 // [PropertyAccess]. The code generation for those is handled in their | 2515 // [PropertyAccess]. The code generation for those is handled in their |
| 2513 // respective visit methods. | 2516 // respective visit methods. |
| 2514 @override | 2517 @override |
| 2515 JS.Node visitCascadeExpression(CascadeExpression node) { | 2518 JS.Node visitCascadeExpression(CascadeExpression node) { |
| 2516 var savedCascadeTemp = _cascadeTarget; | 2519 var savedCascadeTemp = _cascadeTarget; |
| 2517 | 2520 |
| 2518 var vars = <String, JS.Expression>{}; | 2521 var vars = <String, JS.Expression>{}; |
| 2519 _cascadeTarget = | 2522 _cascadeTarget = _bindValue(vars, '_', node.target, context: node); |
| 2520 _bindValue(vars, '_', node.target, context: node) as SimpleIdentifier; | |
| 2521 var sections = _visitList(node.cascadeSections) as List<JS.Expression>; | 2523 var sections = _visitList(node.cascadeSections) as List<JS.Expression>; |
| 2522 sections.add(_visit(_cascadeTarget)); | 2524 sections.add(_visit(_cascadeTarget)); |
| 2523 var result = new JS.MetaLet(vars, sections, statelessResult: true); | 2525 var result = new JS.MetaLet(vars, sections, statelessResult: true); |
| 2524 _cascadeTarget = savedCascadeTemp; | 2526 _cascadeTarget = savedCascadeTemp; |
| 2525 return result; | 2527 return result; |
| 2526 } | 2528 } |
| 2527 | 2529 |
| 2528 @override | 2530 @override |
| 2529 visitParenthesizedExpression(ParenthesizedExpression node) => | 2531 visitParenthesizedExpression(ParenthesizedExpression node) => |
| 2530 // The printer handles precedence so we don't need to. | 2532 // The printer handles precedence so we don't need to. |
| (...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3289 | 3291 |
| 3290 /// A special kind of element created by the compiler, signifying a temporary | 3292 /// A special kind of element created by the compiler, signifying a temporary |
| 3291 /// variable. These objects use instance equality, and should be shared | 3293 /// variable. These objects use instance equality, and should be shared |
| 3292 /// everywhere in the tree where they are treated as the same variable. | 3294 /// everywhere in the tree where they are treated as the same variable. |
| 3293 class TemporaryVariableElement extends LocalVariableElementImpl { | 3295 class TemporaryVariableElement extends LocalVariableElementImpl { |
| 3294 TemporaryVariableElement.forNode(Identifier name) : super.forNode(name); | 3296 TemporaryVariableElement.forNode(Identifier name) : super.forNode(name); |
| 3295 | 3297 |
| 3296 int get hashCode => identityHashCode(this); | 3298 int get hashCode => identityHashCode(this); |
| 3297 bool operator ==(Object other) => identical(this, other); | 3299 bool operator ==(Object other) => identical(this, other); |
| 3298 } | 3300 } |
| OLD | NEW |