| Index: pkg/compiler/lib/src/compiler.dart
|
| diff --git a/pkg/compiler/lib/src/compiler.dart b/pkg/compiler/lib/src/compiler.dart
|
| index 14c6b729d5c69634895bd492eba2a540e18a6963..714fe2ee51627621f6d7ccf5a15e1e0c22761d50 100644
|
| --- a/pkg/compiler/lib/src/compiler.dart
|
| +++ b/pkg/compiler/lib/src/compiler.dart
|
| @@ -32,26 +32,21 @@ import 'dump_info.dart' show DumpInfoTask;
|
| import 'elements/elements.dart';
|
| import 'elements/entities.dart';
|
| import 'elements/modelx.dart' show ErroneousElementX;
|
| -import 'elements/resolution_types.dart'
|
| - show
|
| - ResolutionDartType,
|
| - ResolutionDynamicType,
|
| - ResolutionFunctionType,
|
| - ResolutionInterfaceType,
|
| - Types;
|
| +import 'elements/resolution_types.dart' show ResolutionDartType, Types;
|
| import 'elements/types.dart' show DartTypes;
|
| import 'enqueue.dart' show Enqueuer, EnqueueTask, ResolutionEnqueuer;
|
| import 'environment.dart';
|
| +import 'frontend_strategy.dart';
|
| import 'id_generator.dart';
|
| import 'io/source_information.dart' show SourceInformation;
|
| import 'js_backend/backend.dart' show JavaScriptBackend;
|
| +import 'kernel/kernel_strategy.dart';
|
| import 'library_loader.dart'
|
| show
|
| ElementScanner,
|
| LibraryLoader,
|
| LibraryLoaderTask,
|
| LoadedLibraries,
|
| - LibraryProvider,
|
| ScriptLoader;
|
| import 'mirrors_used.dart' show MirrorUsageAnalyzerTask;
|
| import 'null_compiler_output.dart' show NullCompilerOutput, NullSink;
|
| @@ -60,6 +55,7 @@ import 'parser/diet_parser_task.dart' show DietParserTask;
|
| import 'parser/parser_task.dart' show ParserTask;
|
| import 'patch_parser.dart' show PatchParserTask;
|
| import 'resolution/resolution.dart' show ResolverTask;
|
| +import 'resolution/resolution_strategy.dart';
|
| import 'resolved_uri_translator.dart';
|
| import 'scanner/scanner_task.dart' show ScannerTask;
|
| import 'script.dart' show Script;
|
| @@ -88,8 +84,9 @@ abstract class Compiler {
|
|
|
| final IdGenerator idGenerator = new IdGenerator();
|
| DartTypes types;
|
| + FrontEndStrategy frontEndStrategy;
|
| CommonElements _commonElements;
|
| - _CompilerElementEnvironment _elementEnvironment;
|
| + ElementEnvironment _elementEnvironment;
|
| CompilerDiagnosticReporter _reporter;
|
| CompilerResolution _resolution;
|
| ParsingContext _parsingContext;
|
| @@ -195,8 +192,11 @@ abstract class Compiler {
|
| } else {
|
| _reporter = new CompilerDiagnosticReporter(this, options);
|
| }
|
| + frontEndStrategy = options.loadFromDill
|
| + ? new KernelFrontEndStrategy(reporter)
|
| + : new ResolutionFrontEndStrategy(this);
|
| _resolution = createResolution();
|
| - _elementEnvironment = new _CompilerElementEnvironment(this);
|
| + _elementEnvironment = frontEndStrategy.elementEnvironment;
|
| _commonElements = new CommonElements(_elementEnvironment);
|
| types = new Types(_resolution);
|
|
|
| @@ -212,8 +212,7 @@ abstract class Compiler {
|
| scanner = createScannerTask(),
|
| serialization = new SerializationTask(this),
|
| patchParser = new PatchParserTask(this),
|
| - libraryLoader = new LibraryLoaderTask(
|
| - options.loadFromDill,
|
| + libraryLoader = frontEndStrategy.createLibraryLoader(
|
| resolvedUriTranslator,
|
| options.compileOnly
|
| ? new _NoScriptLoader(this)
|
| @@ -1750,225 +1749,3 @@ class _EmptyEnvironment implements Environment {
|
|
|
| String valueOf(String key) => null;
|
| }
|
| -
|
| -/// An element environment base on a [Compiler].
|
| -class _CompilerElementEnvironment implements ElementEnvironment {
|
| - final Compiler _compiler;
|
| -
|
| - _CompilerElementEnvironment(this._compiler);
|
| -
|
| - LibraryProvider get _libraryProvider => _compiler.libraryLoader;
|
| - Resolution get _resolution => _compiler.resolution;
|
| -
|
| - ResolutionDynamicType get dynamicType => const ResolutionDynamicType();
|
| -
|
| - @override
|
| - LibraryEntity get mainLibrary => _compiler.mainApp;
|
| -
|
| - @override
|
| - FunctionEntity get mainFunction => _compiler.mainFunction;
|
| -
|
| - @override
|
| - Iterable<LibraryEntity> get libraries => _compiler.libraryLoader.libraries;
|
| -
|
| - @override
|
| - ResolutionInterfaceType getThisType(ClassElement cls) {
|
| - cls.ensureResolved(_resolution);
|
| - return cls.thisType;
|
| - }
|
| -
|
| - @override
|
| - ResolutionInterfaceType getRawType(ClassElement cls) {
|
| - cls.ensureResolved(_resolution);
|
| - return cls.rawType;
|
| - }
|
| -
|
| - @override
|
| - ResolutionDartType getTypeVariableBound(TypeVariableElement typeVariable) {
|
| - return typeVariable.bound;
|
| - }
|
| -
|
| - @override
|
| - ResolutionInterfaceType createInterfaceType(
|
| - ClassElement cls, List<ResolutionDartType> typeArguments) {
|
| - cls.ensureResolved(_resolution);
|
| - return cls.thisType.createInstantiation(typeArguments);
|
| - }
|
| -
|
| - @override
|
| - bool isSubtype(ResolutionDartType a, ResolutionDartType b) {
|
| - return _compiler.types.isSubtype(a, b);
|
| - }
|
| -
|
| - @override
|
| - MemberElement lookupClassMember(ClassElement cls, String name,
|
| - {bool setter: false, bool required: false}) {
|
| - cls.ensureResolved(_resolution);
|
| - Element member = cls.implementation.lookupLocalMember(name);
|
| - if (member != null && member.isAbstractField) {
|
| - AbstractFieldElement abstractField = member;
|
| - if (setter) {
|
| - member = abstractField.setter;
|
| - } else {
|
| - member = abstractField.getter;
|
| - }
|
| - if (member == null && required) {
|
| - throw new SpannableAssertionFailure(
|
| - cls,
|
| - "The class '${cls.name}' does not contain required "
|
| - "${setter ? 'setter' : 'getter'}: '$name'.");
|
| - }
|
| - }
|
| - if (member == null && required) {
|
| - throw new SpannableAssertionFailure(
|
| - cls,
|
| - "The class '${cls.name}' does not "
|
| - "contain required member: '$name'.");
|
| - }
|
| - return member?.declaration;
|
| - }
|
| -
|
| - @override
|
| - ConstructorElement lookupConstructor(ClassElement cls, String name,
|
| - {bool required: false}) {
|
| - cls.ensureResolved(_resolution);
|
| - ConstructorElement constructor = cls.implementation.lookupConstructor(name);
|
| - if (constructor == null && required) {
|
| - throw new SpannableAssertionFailure(
|
| - cls,
|
| - "The class '${cls.name}' does not contain "
|
| - "required constructor: '$name'.");
|
| - }
|
| - return constructor?.declaration;
|
| - }
|
| -
|
| - @override
|
| - void forEachClassMember(
|
| - ClassElement cls, void f(ClassElement declarer, MemberElement member)) {
|
| - cls.ensureResolved(_resolution);
|
| - cls.forEachMember((ClassElement declarer, MemberElement member) {
|
| - if (member.isSynthesized) return;
|
| - if (member.isMalformed) return;
|
| - f(declarer, member);
|
| - }, includeSuperAndInjectedMembers: true);
|
| - }
|
| -
|
| - @override
|
| - ClassEntity getSuperClass(ClassElement cls) => cls.superclass;
|
| -
|
| - @override
|
| - void forEachSupertype(
|
| - ClassElement cls, void f(ResolutionInterfaceType supertype)) {
|
| - cls.allSupertypes
|
| - .forEach((ResolutionInterfaceType supertype) => f(supertype));
|
| - }
|
| -
|
| - @override
|
| - void forEachMixin(ClassElement cls, void f(ClassElement mixin)) {
|
| - for (; cls != null; cls = cls.superclass) {
|
| - if (cls.isMixinApplication) {
|
| - MixinApplicationElement mixinApplication = cls;
|
| - f(mixinApplication.mixin);
|
| - }
|
| - }
|
| - }
|
| -
|
| - @override
|
| - MemberElement lookupLibraryMember(LibraryElement library, String name,
|
| - {bool setter: false, bool required: false}) {
|
| - Element member = library.implementation.findLocal(name);
|
| - if (member != null && member.isAbstractField) {
|
| - AbstractFieldElement abstractField = member;
|
| - if (setter) {
|
| - member = abstractField.setter;
|
| - } else {
|
| - member = abstractField.getter;
|
| - }
|
| - if (member == null && required) {
|
| - throw new SpannableAssertionFailure(
|
| - library,
|
| - "The library '${library.canonicalUri}' does not contain required "
|
| - "${setter ? 'setter' : 'getter'}: '$name'.");
|
| - }
|
| - }
|
| - if (member == null && required) {
|
| - throw new SpannableAssertionFailure(
|
| - member,
|
| - "The library '${library.libraryName}' does not "
|
| - "contain required member: '$name'.");
|
| - }
|
| - return member?.declaration;
|
| - }
|
| -
|
| - @override
|
| - ClassElement lookupClass(LibraryElement library, String name,
|
| - {bool required: false}) {
|
| - ClassElement cls = library.implementation.findLocal(name);
|
| - if (cls == null && required) {
|
| - throw new SpannableAssertionFailure(
|
| - cls,
|
| - "The library '${library.libraryName}' does not "
|
| - "contain required class: '$name'.");
|
| - }
|
| - return cls?.declaration;
|
| - }
|
| -
|
| - @override
|
| - void forEachClass(LibraryElement library, void f(ClassElement cls)) {
|
| - library.implementation.forEachLocalMember((member) {
|
| - if (member.isClass) {
|
| - f(member);
|
| - }
|
| - });
|
| - }
|
| -
|
| - @override
|
| - LibraryElement lookupLibrary(Uri uri, {bool required: false}) {
|
| - LibraryElement library = _libraryProvider.lookupLibrary(uri);
|
| - // If the script of the library is synthesized, the library does not exist
|
| - // and we do not try to load the helpers.
|
| - //
|
| - // This could for example happen if dart:async is disabled, then loading it
|
| - // should not try to find the given element.
|
| - if (library != null && library.isSynthesized) {
|
| - return null;
|
| - }
|
| - if (library == null && required) {
|
| - throw new SpannableAssertionFailure(
|
| - library, "The library '${uri}' was not found.");
|
| - }
|
| - return library;
|
| - }
|
| -
|
| - @override
|
| - CallStructure getCallStructure(MethodElement method) {
|
| - ResolutionFunctionType type = method.computeType(_resolution);
|
| - return new CallStructure(
|
| - type.parameterTypes.length +
|
| - type.optionalParameterTypes.length +
|
| - type.namedParameterTypes.length,
|
| - type.namedParameters);
|
| - }
|
| -
|
| - @override
|
| - bool isDeferredLoadLibraryGetter(MemberElement member) {
|
| - return member.isDeferredLoaderGetter;
|
| - }
|
| -
|
| - @override
|
| - ResolutionFunctionType getFunctionType(MethodElement method) {
|
| - method.computeType(_resolution);
|
| - return method.type;
|
| - }
|
| -
|
| - @override
|
| - ResolutionFunctionType getLocalFunctionType(LocalFunctionElement function) {
|
| - return function.type;
|
| - }
|
| -
|
| - @override
|
| - ResolutionDartType getUnaliasedType(ResolutionDartType type) {
|
| - type.computeUnaliased(_resolution);
|
| - return type.unaliased;
|
| - }
|
| -}
|
|
|