| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 import 'reify_coercions.dart' show CoercionReifier; | 53 import 'reify_coercions.dart' show CoercionReifier; |
| 54 import 'side_effect_analysis.dart' show ConstFieldVisitor, isStateless; | 54 import 'side_effect_analysis.dart' show ConstFieldVisitor, isStateless; |
| 55 import 'type_utilities.dart'; | 55 import 'type_utilities.dart'; |
| 56 | 56 |
| 57 class CodeGenerator extends GeneralizingAstVisitor | 57 class CodeGenerator extends GeneralizingAstVisitor |
| 58 with ClosureAnnotator, JsTypeRefCodegen, NullableTypeInference { | 58 with ClosureAnnotator, JsTypeRefCodegen, NullableTypeInference { |
| 59 final AnalysisContext context; | 59 final AnalysisContext context; |
| 60 final SummaryDataStore summaryData; | 60 final SummaryDataStore summaryData; |
| 61 | 61 |
| 62 final CompilerOptions options; | 62 final CompilerOptions options; |
| 63 final rules = new StrongTypeSystemImpl(); | 63 final StrongTypeSystemImpl rules; |
| 64 | 64 |
| 65 /// The set of libraries we are currently compiling, and the temporaries used | 65 /// The set of libraries we are currently compiling, and the temporaries used |
| 66 /// to refer to them. | 66 /// to refer to them. |
| 67 /// | 67 /// |
| 68 /// We sometimes special case codegen for a single library, as it simplifies | 68 /// We sometimes special case codegen for a single library, as it simplifies |
| 69 /// name scoping requirements. | 69 /// name scoping requirements. |
| 70 final _libraries = new Map<LibraryElement, JS.Identifier>(); | 70 final _libraries = new Map<LibraryElement, JS.Identifier>(); |
| 71 | 71 |
| 72 /// Imported libraries, and the temporaries used to refer to them. | 72 /// Imported libraries, and the temporaries used to refer to them. |
| 73 final _imports = new Map<LibraryElement, JS.TemporaryId>(); | 73 final _imports = new Map<LibraryElement, JS.TemporaryId>(); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 /// Whether we are currently generating code for the body of a `JS()` call. | 152 /// Whether we are currently generating code for the body of a `JS()` call. |
| 153 bool _isInForeignJS = false; | 153 bool _isInForeignJS = false; |
| 154 | 154 |
| 155 /// Information about virtual and overridden fields/getters/setters in the | 155 /// Information about virtual and overridden fields/getters/setters in the |
| 156 /// class we're currently compiling, or `null` if we aren't compiling a class. | 156 /// class we're currently compiling, or `null` if we aren't compiling a class. |
| 157 ClassPropertyModel _classProperties; | 157 ClassPropertyModel _classProperties; |
| 158 | 158 |
| 159 CodeGenerator( | 159 CodeGenerator( |
| 160 AnalysisContext c, this.summaryData, this.options, this._extensionTypes) | 160 AnalysisContext c, this.summaryData, this.options, this._extensionTypes) |
| 161 : context = c, | 161 : context = c, |
| 162 rules = new StrongTypeSystemImpl(c.typeProvider), |
| 162 types = c.typeProvider, | 163 types = c.typeProvider, |
| 163 _asyncStreamIterator = | 164 _asyncStreamIterator = |
| 164 _getLibrary(c, 'dart:async').getType('StreamIterator').type, | 165 _getLibrary(c, 'dart:async').getType('StreamIterator').type, |
| 165 _jsArray = _getLibrary(c, 'dart:_interceptors').getType('JSArray'), | 166 _jsArray = _getLibrary(c, 'dart:_interceptors').getType('JSArray'), |
| 166 interceptorClass = | 167 interceptorClass = |
| 167 _getLibrary(c, 'dart:_interceptors').getType('Interceptor'), | 168 _getLibrary(c, 'dart:_interceptors').getType('Interceptor'), |
| 168 dartCoreLibrary = _getLibrary(c, 'dart:core'), | 169 dartCoreLibrary = _getLibrary(c, 'dart:core'), |
| 169 boolClass = _getLibrary(c, 'dart:core').getType('bool'), | 170 boolClass = _getLibrary(c, 'dart:core').getType('bool'), |
| 170 intClass = _getLibrary(c, 'dart:core').getType('int'), | 171 intClass = _getLibrary(c, 'dart:core').getType('int'), |
| 171 numClass = _getLibrary(c, 'dart:core').getType('num'), | 172 numClass = _getLibrary(c, 'dart:core').getType('num'), |
| (...skipping 5642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5814 if (targetIdentifier.staticElement is! PrefixElement) return false; | 5815 if (targetIdentifier.staticElement is! PrefixElement) return false; |
| 5815 var prefix = targetIdentifier.staticElement as PrefixElement; | 5816 var prefix = targetIdentifier.staticElement as PrefixElement; |
| 5816 | 5817 |
| 5817 // The library the prefix is referring to must come from a deferred import. | 5818 // The library the prefix is referring to must come from a deferred import. |
| 5818 var containingLibrary = resolutionMap | 5819 var containingLibrary = resolutionMap |
| 5819 .elementDeclaredByCompilationUnit(target.root as CompilationUnit) | 5820 .elementDeclaredByCompilationUnit(target.root as CompilationUnit) |
| 5820 .library; | 5821 .library; |
| 5821 var imports = containingLibrary.getImportsWithPrefix(prefix); | 5822 var imports = containingLibrary.getImportsWithPrefix(prefix); |
| 5822 return imports.length == 1 && imports[0].isDeferred; | 5823 return imports.length == 1 && imports[0].isDeferred; |
| 5823 } | 5824 } |
| OLD | NEW |