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 import 'dart:collection' show HashMap, HashSet; | 5 import 'dart:collection' show HashMap, HashSet; |
6 import 'dart:math' show min, max; | 6 import 'dart:math' show min, max; |
7 | 7 |
8 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; | 8 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; |
9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
10 import 'package:analyzer/dart/ast/token.dart' show Token, TokenType; | 10 import 'package:analyzer/dart/ast/token.dart' show Token, TokenType; |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 var library = unit.element.library; | 229 var library = unit.element.library; |
230 if (unit.element != library.definingCompilationUnit) continue; | 230 if (unit.element != library.definingCompilationUnit) continue; |
231 | 231 |
232 var libraryTemp = _isDartRuntime(library) | 232 var libraryTemp = _isDartRuntime(library) |
233 ? _runtimeLibVar | 233 ? _runtimeLibVar |
234 : new JS.TemporaryId(jsLibraryName(_libraryRoot, library)); | 234 : new JS.TemporaryId(jsLibraryName(_libraryRoot, library)); |
235 _libraries[library] = libraryTemp; | 235 _libraries[library] = libraryTemp; |
236 items.add(new JS.ExportDeclaration( | 236 items.add(new JS.ExportDeclaration( |
237 js.call('const # = Object.create(null)', [libraryTemp]))); | 237 js.call('const # = Object.create(null)', [libraryTemp]))); |
238 | 238 |
239 // dart:_runtime has a magic module that holds extenstion method symbols. | 239 // dart:_runtime has a magic module that holds extension method symbols. |
240 // TODO(jmesserly): find a cleaner design for this. | 240 // TODO(jmesserly): find a cleaner design for this. |
241 if (_isDartRuntime(library)) { | 241 if (_isDartRuntime(library)) { |
242 items.add(new JS.ExportDeclaration( | 242 items.add(new JS.ExportDeclaration( |
243 js.call('const # = Object.create(null)', [_dartxVar]))); | 243 js.call('const # = Object.create(null)', [_dartxVar]))); |
244 } | 244 } |
245 } | 245 } |
246 | 246 |
247 // Collect all Element -> Node mappings, in case we need to forward declare | 247 // Collect all Element -> Node mappings, in case we need to forward declare |
248 // any nodes. | 248 // any nodes. |
249 var nodes = new HashMap<Element, AstNode>.identity(); | 249 var nodes = new HashMap<Element, AstNode>.identity(); |
(...skipping 5117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5367 } | 5367 } |
5368 | 5368 |
5369 bool isLibraryPrefix(Expression node) => | 5369 bool isLibraryPrefix(Expression node) => |
5370 node is SimpleIdentifier && node.staticElement is PrefixElement; | 5370 node is SimpleIdentifier && node.staticElement is PrefixElement; |
5371 | 5371 |
5372 LibraryElement _getLibrary(AnalysisContext c, String uri) => | 5372 LibraryElement _getLibrary(AnalysisContext c, String uri) => |
5373 c.computeLibraryElement(c.sourceFactory.forUri(uri)); | 5373 c.computeLibraryElement(c.sourceFactory.forUri(uri)); |
5374 | 5374 |
5375 bool _isDartRuntime(LibraryElement l) => | 5375 bool _isDartRuntime(LibraryElement l) => |
5376 l.isInSdk && l.source.uri.toString() == 'dart:_runtime'; | 5376 l.isInSdk && l.source.uri.toString() == 'dart:_runtime'; |
OLD | NEW |