| Index: pkg/dev_compiler/lib/src/compiler/code_generator.dart
|
| diff --git a/pkg/dev_compiler/lib/src/compiler/code_generator.dart b/pkg/dev_compiler/lib/src/compiler/code_generator.dart
|
| index acde51b79004f0ff7831f11b6a09782300014c06..58abd938806aa80ae7833ce042d9e04a4f243100 100644
|
| --- a/pkg/dev_compiler/lib/src/compiler/code_generator.dart
|
| +++ b/pkg/dev_compiler/lib/src/compiler/code_generator.dart
|
| @@ -13,14 +13,14 @@ import 'package:analyzer/dart/ast/token.dart' show Token, TokenType;
|
| import 'package:analyzer/dart/ast/standard_resolution_map.dart';
|
| import 'package:analyzer/dart/element/element.dart';
|
| import 'package:analyzer/dart/element/type.dart';
|
| +import 'package:analyzer/src/dart/analysis/driver.dart';
|
| import 'package:analyzer/src/dart/ast/token.dart' show StringToken;
|
| import 'package:analyzer/src/dart/element/element.dart'
|
| show FieldElementImpl, LocalVariableElementImpl;
|
| import 'package:analyzer/src/dart/element/type.dart' show DynamicTypeImpl;
|
| import 'package:analyzer/src/dart/sdk/sdk.dart';
|
| -import 'package:analyzer/src/generated/engine.dart' show AnalysisContext;
|
| import 'package:analyzer/src/generated/resolver.dart'
|
| - show TypeProvider, NamespaceBuilder;
|
| + show NamespaceBuilder, TypeProvider;
|
| import 'package:analyzer/src/generated/type_system.dart'
|
| show StrongTypeSystemImpl;
|
| import 'package:analyzer/src/summary/idl.dart' show UnlinkedUnit;
|
| @@ -33,6 +33,7 @@ import 'package:analyzer/src/summary/summarize_elements.dart'
|
| import 'package:analyzer/src/summary/summary_sdk.dart';
|
| import 'package:analyzer/src/task/strong/ast_properties.dart'
|
| show isDynamicInvoke, setIsDynamicInvoke, getImplicitAssignmentCast;
|
| +import 'package:meta/meta.dart';
|
| import 'package:path/path.dart' show isWithin, relative, separator;
|
|
|
| import '../closure/closure_annotator.dart' show ClosureAnnotator;
|
| @@ -70,7 +71,7 @@ import 'type_utilities.dart';
|
| class CodeGenerator extends Object
|
| with ClosureAnnotator, JsTypeRefCodegen, NullableTypeInference
|
| implements AstVisitor<JS.Node> {
|
| - final AnalysisContext context;
|
| + final AnalysisDriver driver;
|
| final SummaryDataStore summaryData;
|
|
|
| final CompilerOptions options;
|
| @@ -123,7 +124,7 @@ class CodeGenerator extends Object
|
|
|
| final _hasDeferredSupertype = new HashSet<ClassElement>();
|
|
|
| - /// The type provider from the current Analysis [context].
|
| + /// The type provider for the SDK.
|
| final TypeProvider types;
|
|
|
| final LibraryElement dartCoreLibrary;
|
| @@ -192,26 +193,27 @@ class CodeGenerator extends Object
|
| final virtualFields = new VirtualFieldModel();
|
|
|
| CodeGenerator(
|
| - AnalysisContext c, this.summaryData, this.options, this._extensionTypes)
|
| - : context = c,
|
| - rules = new StrongTypeSystemImpl(c.typeProvider),
|
| - types = c.typeProvider,
|
| - _asyncStreamIterator =
|
| - _getLibrary(c, 'dart:async').getType('StreamIterator').type,
|
| - _jsArray = _getLibrary(c, 'dart:_interceptors').getType('JSArray'),
|
| - interceptorClass =
|
| - _getLibrary(c, 'dart:_interceptors').getType('Interceptor'),
|
| - dartCoreLibrary = _getLibrary(c, 'dart:core'),
|
| - boolClass = _getLibrary(c, 'dart:core').getType('bool'),
|
| - intClass = _getLibrary(c, 'dart:core').getType('int'),
|
| - numClass = _getLibrary(c, 'dart:core').getType('num'),
|
| - nullClass = _getLibrary(c, 'dart:core').getType('Null'),
|
| - objectClass = _getLibrary(c, 'dart:core').getType('Object'),
|
| - stringClass = _getLibrary(c, 'dart:core').getType('String'),
|
| - functionClass = _getLibrary(c, 'dart:core').getType('Function'),
|
| - privateSymbolClass =
|
| - _getLibrary(c, 'dart:_internal').getType('PrivateSymbol'),
|
| - dartJSLibrary = _getLibrary(c, 'dart:js');
|
| + this.driver, this.summaryData, this.options, this._extensionTypes,
|
| + {@required this.types,
|
| + @required LibraryElement coreLibrary,
|
| + @required LibraryElement asyncLibrary,
|
| + @required LibraryElement interceptorsLibrary,
|
| + @required LibraryElement internalLibrary,
|
| + @required LibraryElement jsLibrary})
|
| + : rules = new StrongTypeSystemImpl(types),
|
| + _asyncStreamIterator = asyncLibrary.getType('StreamIterator').type,
|
| + _jsArray = interceptorsLibrary.getType('JSArray'),
|
| + interceptorClass = interceptorsLibrary.getType('Interceptor'),
|
| + dartCoreLibrary = coreLibrary,
|
| + boolClass = coreLibrary.getType('bool'),
|
| + intClass = coreLibrary.getType('int'),
|
| + numClass = coreLibrary.getType('num'),
|
| + nullClass = coreLibrary.getType('Null'),
|
| + objectClass = coreLibrary.getType('Object'),
|
| + stringClass = coreLibrary.getType('String'),
|
| + functionClass = coreLibrary.getType('Function'),
|
| + privateSymbolClass = internalLibrary.getType('PrivateSymbol'),
|
| + dartJSLibrary = jsLibrary;
|
|
|
| Element get currentElement => _currentElements.last;
|
|
|
| @@ -242,7 +244,7 @@ class CodeGenerator extends Object
|
| .elementDeclaredByCompilationUnit(u)
|
| .librarySource
|
| .isInSystemLibrary)) {
|
| - var sdk = context.sourceFactory.dartSdk;
|
| + var sdk = driver.sourceFactory.dartSdk;
|
| summaryData.addBundle(
|
| null,
|
| sdk is SummaryBasedDartSdk
|
| @@ -266,7 +268,7 @@ class CodeGenerator extends Object
|
| uriToUnit.keys.toSet(),
|
| (uri) => summaryData.linkedMap[uri],
|
| (uri) => summaryData.unlinkedMap[uri] ?? uriToUnit[uri],
|
| - context.declaredVariables.get,
|
| + driver.declaredVariables.get,
|
| true)
|
| .forEach(assembler.addLinkedLibrary);
|
|
|
| @@ -321,7 +323,7 @@ class CodeGenerator extends Object
|
|
|
| // Collect all class/type Element -> Node mappings
|
| // in case we need to forward declare any classes.
|
| - _declarationNodes = new HashMap<TypeDefiningElement, AstNode>.identity();
|
| + _declarationNodes = new HashMap<TypeDefiningElement, AstNode>();
|
| for (var unit in compilationUnits) {
|
| for (var declaration in unit.declarations) {
|
| var element = declaration.element;
|
| @@ -331,7 +333,7 @@ class CodeGenerator extends Object
|
| }
|
| }
|
| if (compilationUnits.isNotEmpty) {
|
| - _constants = new ConstFieldVisitor(context,
|
| + _constants = new ConstFieldVisitor(types, driver.declaredVariables,
|
| dummySource: resolutionMap
|
| .elementDeclaredByCompilationUnit(compilationUnits.first)
|
| .source);
|
| @@ -549,7 +551,7 @@ class CodeGenerator extends Object
|
| /// Subsequent [emitDeclaration] calls will cause those elements to be
|
| /// generated before this one, until [finishTopLevel] is called.
|
| void _startTopLevelCodeForClass(TypeDefiningElement e) {
|
| - assert(identical(e, currentElement));
|
| + assert(e == currentElement);
|
| _topLevelElements.add(e);
|
| }
|
|
|
| @@ -573,7 +575,7 @@ class CodeGenerator extends Object
|
| if (e == null) return;
|
|
|
| var topLevel = _topLevelElements;
|
| - if (topLevel.isNotEmpty && identical(currentElement, topLevel.last)) {
|
| + if (topLevel.isNotEmpty && currentElement == topLevel.last) {
|
| // If the item is from our library, try to emit it now.
|
| _emitTypeDeclaration(e);
|
| }
|
| @@ -1920,7 +1922,7 @@ class CodeGenerator extends Object
|
| } else {
|
| // Method
|
| // Swap in "Object" for parameter types that are covariant overrides.
|
| - var objectType = context.typeProvider.objectType;
|
| + var objectType = types.objectType;
|
| elementToType =
|
| (MethodElement element) => element.getReifiedType(objectType);
|
| getOverride = classElem.lookUpInheritedConcreteMethod;
|
| @@ -4333,7 +4335,7 @@ class CodeGenerator extends Object
|
| Element staticElement = identifier.staticElement;
|
| if (staticElement is PropertyAccessorElement && staticElement.isGetter) {
|
| PropertyInducingElement variable = staticElement.variable;
|
| - int value = variable?.computeConstantValue()?.toIntValue();
|
| + int value = variable?.constantValue?.toIntValue();
|
| if (value != null && value >= low && value <= high) return value;
|
| }
|
| return null;
|
| @@ -5914,9 +5916,6 @@ class TemporaryVariableElement extends LocalVariableElementImpl {
|
| bool isLibraryPrefix(Expression node) =>
|
| node is SimpleIdentifier && node.staticElement is PrefixElement;
|
|
|
| -LibraryElement _getLibrary(AnalysisContext c, String uri) =>
|
| - c.computeLibraryElement(c.sourceFactory.forUri(uri));
|
| -
|
| /// Returns `true` if [target] is a prefix for a deferred library and [name]
|
| /// is "loadLibrary".
|
| ///
|
|
|