| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 library dart2js.compiler_base; | 5 library dart2js.compiler_base; |
| 6 | 6 |
| 7 import 'dart:async' show EventSink, Future; | 7 import 'dart:async' show EventSink, Future; |
| 8 | 8 |
| 9 import '../compiler_new.dart' as api; | 9 import '../compiler_new.dart' as api; |
| 10 import 'cache_strategy.dart' show CacheStrategy; | 10 import 'cache_strategy.dart' show CacheStrategy; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 import 'universe/world_builder.dart' | 71 import 'universe/world_builder.dart' |
| 72 show ResolutionWorldBuilder, CodegenWorldBuilder; | 72 show ResolutionWorldBuilder, CodegenWorldBuilder; |
| 73 import 'universe/use.dart' show StaticUse, TypeUse; | 73 import 'universe/use.dart' show StaticUse, TypeUse; |
| 74 import 'universe/world_impact.dart' | 74 import 'universe/world_impact.dart' |
| 75 show | 75 show |
| 76 ImpactStrategy, | 76 ImpactStrategy, |
| 77 WorldImpact, | 77 WorldImpact, |
| 78 WorldImpactBuilder, | 78 WorldImpactBuilder, |
| 79 WorldImpactBuilderImpl; | 79 WorldImpactBuilderImpl; |
| 80 import 'util/util.dart' show Link, Setlet; | 80 import 'util/util.dart' show Link, Setlet; |
| 81 import 'world.dart' show ClosedWorld, ClosedWorldRefiner, OpenWorld, WorldImpl; | 81 import 'world.dart' show ClosedWorld, ClosedWorldRefiner, WorldImpl; |
| 82 | 82 |
| 83 typedef Backend MakeBackendFuncion(Compiler compiler); | 83 typedef Backend MakeBackendFuncion(Compiler compiler); |
| 84 | 84 |
| 85 typedef CompilerDiagnosticReporter MakeReporterFunction( | 85 typedef CompilerDiagnosticReporter MakeReporterFunction( |
| 86 Compiler compiler, CompilerOptions options); | 86 Compiler compiler, CompilerOptions options); |
| 87 | 87 |
| 88 abstract class Compiler implements LibraryLoaderListener { | 88 abstract class Compiler implements LibraryLoaderListener { |
| 89 Measurer get measurer; | 89 Measurer get measurer; |
| 90 | 90 |
| 91 final IdGenerator idGenerator = new IdGenerator(); | 91 final IdGenerator idGenerator = new IdGenerator(); |
| 92 WorldImpl get _world => resolverWorld.openWorld; | |
| 93 Types types; | 92 Types types; |
| 94 _CompilerCoreTypes _coreTypes; | 93 _CompilerCoreTypes _coreTypes; |
| 95 CompilerDiagnosticReporter _reporter; | 94 CompilerDiagnosticReporter _reporter; |
| 96 CompilerResolution _resolution; | 95 CompilerResolution _resolution; |
| 97 ParsingContext _parsingContext; | 96 ParsingContext _parsingContext; |
| 98 | 97 |
| 99 final CacheStrategy cacheStrategy; | 98 final CacheStrategy cacheStrategy; |
| 100 | 99 |
| 101 ImpactStrategy impactStrategy = const ImpactStrategy(); | 100 ImpactStrategy impactStrategy = const ImpactStrategy(); |
| 102 | 101 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 if (options.resolveOnly) { | 268 if (options.resolveOnly) { |
| 270 serialization.supportSerialization = true; | 269 serialization.supportSerialization = true; |
| 271 } | 270 } |
| 272 | 271 |
| 273 _parsingContext = | 272 _parsingContext = |
| 274 new ParsingContext(reporter, parser, patchParser, backend); | 273 new ParsingContext(reporter, parser, patchParser, backend); |
| 275 | 274 |
| 276 tasks.addAll(backend.tasks); | 275 tasks.addAll(backend.tasks); |
| 277 } | 276 } |
| 278 | 277 |
| 279 /// The closed world after resolution and inference. | |
| 280 ClosedWorld get closedWorld { | |
| 281 assert(invariant(CURRENT_ELEMENT_SPANNABLE, _world.isClosed, | |
| 282 message: "Closed world not computed yet.")); | |
| 283 return _world; | |
| 284 } | |
| 285 | |
| 286 /// Creates the backend. | 278 /// Creates the backend. |
| 287 /// | 279 /// |
| 288 /// Override this to mock the backend for testing. | 280 /// Override this to mock the backend for testing. |
| 289 Backend createBackend() { | 281 Backend createBackend() { |
| 290 return new js_backend.JavaScriptBackend(this, | 282 return new js_backend.JavaScriptBackend(this, |
| 291 generateSourceMap: options.generateSourceMap, | 283 generateSourceMap: options.generateSourceMap, |
| 292 useStartupEmitter: options.useStartupEmitter, | 284 useStartupEmitter: options.useStartupEmitter, |
| 293 useNewSourceInfo: options.useNewSourceInfo, | 285 useNewSourceInfo: options.useNewSourceInfo, |
| 294 useKernel: options.useKernel); | 286 useKernel: options.useKernel); |
| 295 } | 287 } |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 // compiler from analyzing all the code. | 689 // compiler from analyzing all the code. |
| 698 // TODO(johnniwinther): Reenable this when the reporting is more | 690 // TODO(johnniwinther): Reenable this when the reporting is more |
| 699 // precise. | 691 // precise. |
| 700 //reportUnusedCode(); | 692 //reportUnusedCode(); |
| 701 } | 693 } |
| 702 return; | 694 return; |
| 703 } | 695 } |
| 704 assert(mainFunction != null); | 696 assert(mainFunction != null); |
| 705 | 697 |
| 706 ClosedWorldRefiner closedWorldRefiner = closeResolution(); | 698 ClosedWorldRefiner closedWorldRefiner = closeResolution(); |
| 699 // TODO(johnniwinther): Make [ClosedWorld] a property of |
| 700 // [ClosedWorldRefiner]. |
| 701 ClosedWorld closedWorld = resolverWorld.closedWorldForTesting; |
| 707 | 702 |
| 708 reporter.log('Inferring types...'); | 703 reporter.log('Inferring types...'); |
| 709 globalInference.runGlobalTypeInference( | 704 globalInference.runGlobalTypeInference( |
| 710 mainFunction, closedWorld, closedWorldRefiner); | 705 mainFunction, closedWorld, closedWorldRefiner); |
| 711 | 706 |
| 712 if (stopAfterTypeInference) return; | 707 if (stopAfterTypeInference) return; |
| 713 | 708 |
| 714 backend.onTypeInferenceComplete(); | 709 backend.onTypeInferenceComplete(); |
| 715 | 710 |
| 716 reporter.log('Compiling...'); | 711 reporter.log('Compiling...'); |
| (...skipping 1508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2225 _ElementScanner(this.scanner); | 2220 _ElementScanner(this.scanner); |
| 2226 void scanLibrary(LibraryElement library) => scanner.scanLibrary(library); | 2221 void scanLibrary(LibraryElement library) => scanner.scanLibrary(library); |
| 2227 void scanUnit(CompilationUnitElement unit) => scanner.scan(unit); | 2222 void scanUnit(CompilationUnitElement unit) => scanner.scan(unit); |
| 2228 } | 2223 } |
| 2229 | 2224 |
| 2230 class _EmptyEnvironment implements Environment { | 2225 class _EmptyEnvironment implements Environment { |
| 2231 const _EmptyEnvironment(); | 2226 const _EmptyEnvironment(); |
| 2232 | 2227 |
| 2233 String valueOf(String key) => null; | 2228 String valueOf(String key) => null; |
| 2234 } | 2229 } |
| OLD | NEW |