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 | 2 |
3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
5 | 5 |
6 import 'dart:collection' show HashMap, HashSet; | 6 import 'dart:collection' show HashMap, HashSet; |
7 import 'dart:math' show min, max; | 7 import 'dart:math' show min, max; |
8 | 8 |
9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; | 9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; |
10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
(...skipping 5518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5529 // TODO(jmesserly): verify this is unreachable. | 5529 // TODO(jmesserly): verify this is unreachable. |
5530 throw 'Unimplemented ${node.runtimeType}: $node'; | 5530 throw 'Unimplemented ${node.runtimeType}: $node'; |
5531 } | 5531 } |
5532 | 5532 |
5533 _visit(AstNode node) { | 5533 _visit(AstNode node) { |
5534 if (node == null) return null; | 5534 if (node == null) return null; |
5535 var result = node.accept(this); | 5535 var result = node.accept(this); |
5536 return result is JS.Node ? annotate(result, node) : result; | 5536 return result is JS.Node ? annotate(result, node) : result; |
5537 } | 5537 } |
5538 | 5538 |
5539 List/*<T>*/ _visitList/*<T extends AstNode>*/(Iterable/*<T>*/ nodes) { | 5539 // TODO(jmesserly): we should make sure this only returns JS AST nodes. |
| 5540 List/*<R>*/ _visitList/*<T extends AstNode, R>*/(Iterable/*<T>*/ nodes) { |
5540 if (nodes == null) return null; | 5541 if (nodes == null) return null; |
5541 var result = /*<T>*/ []; | 5542 var result = /*<R>*/ []; |
5542 for (var node in nodes) result.add(_visit(node) as dynamic/*=T*/); | 5543 for (var node in nodes) result.add(_visit(node) as dynamic/*=R*/); |
5543 return result; | 5544 return result; |
5544 } | 5545 } |
5545 | 5546 |
5546 /// Visits a list of expressions, creating a comma expression if needed in JS. | 5547 /// Visits a list of expressions, creating a comma expression if needed in JS. |
5547 JS.Expression _visitListToBinary(List<Expression> nodes, String operator) { | 5548 JS.Expression _visitListToBinary(List<Expression> nodes, String operator) { |
5548 if (nodes == null || nodes.isEmpty) return null; | 5549 if (nodes == null || nodes.isEmpty) return null; |
5549 return new JS.Expression.binary( | 5550 return new JS.Expression.binary( |
5550 _visitList(nodes) as List<JS.Expression>, operator); | 5551 _visitList(nodes) as List<JS.Expression>, operator); |
5551 } | 5552 } |
5552 | 5553 |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6038 if (targetIdentifier.staticElement is! PrefixElement) return false; | 6039 if (targetIdentifier.staticElement is! PrefixElement) return false; |
6039 var prefix = targetIdentifier.staticElement as PrefixElement; | 6040 var prefix = targetIdentifier.staticElement as PrefixElement; |
6040 | 6041 |
6041 // The library the prefix is referring to must come from a deferred import. | 6042 // The library the prefix is referring to must come from a deferred import. |
6042 var containingLibrary = resolutionMap | 6043 var containingLibrary = resolutionMap |
6043 .elementDeclaredByCompilationUnit(target.root as CompilationUnit) | 6044 .elementDeclaredByCompilationUnit(target.root as CompilationUnit) |
6044 .library; | 6045 .library; |
6045 var imports = containingLibrary.getImportsWithPrefix(prefix); | 6046 var imports = containingLibrary.getImportsWithPrefix(prefix); |
6046 return imports.length == 1 && imports[0].isDeferred; | 6047 return imports.length == 1 && imports[0].isDeferred; |
6047 } | 6048 } |
OLD | NEW |