| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 import 'resolved_uri_translator.dart'; | 68 import 'resolved_uri_translator.dart'; |
| 69 import 'scanner/scanner_task.dart' show ScannerTask; | 69 import 'scanner/scanner_task.dart' show ScannerTask; |
| 70 import 'script.dart' show Script; | 70 import 'script.dart' show Script; |
| 71 import 'serialization/task.dart' show SerializationTask; | 71 import 'serialization/task.dart' show SerializationTask; |
| 72 import 'ssa/nodes.dart' show HInstruction; | 72 import 'ssa/nodes.dart' show HInstruction; |
| 73 import 'tokens/token.dart' show StringToken, Token, TokenPair; | 73 import 'tokens/token.dart' show StringToken, Token, TokenPair; |
| 74 import 'tokens/token_map.dart' show TokenMap; | 74 import 'tokens/token_map.dart' show TokenMap; |
| 75 import 'tracer.dart' show Tracer; | 75 import 'tracer.dart' show Tracer; |
| 76 import 'tree/tree.dart' show Node, TypeAnnotation; | 76 import 'tree/tree.dart' show Node, TypeAnnotation; |
| 77 import 'typechecker.dart' show TypeCheckerTask; | 77 import 'typechecker.dart' show TypeCheckerTask; |
| 78 import 'types/types.dart' as ti; | 78 import 'types/types.dart' show GlobalTypeInferenceTask; |
| 79 import 'types/masks.dart' show CommonMasks; |
| 79 import 'universe/selector.dart' show Selector; | 80 import 'universe/selector.dart' show Selector; |
| 80 import 'universe/universe.dart' show Universe; | 81 import 'universe/universe.dart' show Universe; |
| 81 import 'universe/use.dart' show StaticUse; | 82 import 'universe/use.dart' show StaticUse; |
| 82 import 'universe/world_impact.dart' show ImpactStrategy, WorldImpact; | 83 import 'universe/world_impact.dart' show ImpactStrategy, WorldImpact; |
| 83 import 'util/util.dart' show Link, Setlet; | 84 import 'util/util.dart' show Link, Setlet; |
| 84 import 'world.dart' show World; | 85 import 'world.dart' show World; |
| 85 | 86 |
| 86 typedef Backend MakeBackendFuncion(Compiler compiler); | 87 typedef Backend MakeBackendFuncion(Compiler compiler); |
| 87 | 88 |
| 88 typedef CompilerDiagnosticReporter MakeReporterFunction( | 89 typedef CompilerDiagnosticReporter MakeReporterFunction( |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 | 146 |
| 146 Tracer tracer; | 147 Tracer tracer; |
| 147 | 148 |
| 148 LibraryElement mainApp; | 149 LibraryElement mainApp; |
| 149 FunctionElement mainFunction; | 150 FunctionElement mainFunction; |
| 150 | 151 |
| 151 DiagnosticReporter get reporter => _reporter; | 152 DiagnosticReporter get reporter => _reporter; |
| 152 CommonElements get commonElements => _coreTypes; | 153 CommonElements get commonElements => _coreTypes; |
| 153 CoreClasses get coreClasses => _coreTypes; | 154 CoreClasses get coreClasses => _coreTypes; |
| 154 CoreTypes get coreTypes => _coreTypes; | 155 CoreTypes get coreTypes => _coreTypes; |
| 156 CommonMasks get commonMasks => globalInference.masks; |
| 155 Resolution get resolution => _resolution; | 157 Resolution get resolution => _resolution; |
| 156 ParsingContext get parsingContext => _parsingContext; | 158 ParsingContext get parsingContext => _parsingContext; |
| 157 | 159 |
| 158 // TODO(zarah): Remove this map and incorporate compile-time errors | 160 // TODO(zarah): Remove this map and incorporate compile-time errors |
| 159 // in the model. | 161 // in the model. |
| 160 /// Tracks elements with compile-time errors. | 162 /// Tracks elements with compile-time errors. |
| 161 final Map<Element, List<DiagnosticMessage>> elementsWithCompileTimeErrors = | 163 final Map<Element, List<DiagnosticMessage>> elementsWithCompileTimeErrors = |
| 162 new Map<Element, List<DiagnosticMessage>>(); | 164 new Map<Element, List<DiagnosticMessage>>(); |
| 163 | 165 |
| 164 final Environment environment; | 166 final Environment environment; |
| 165 // TODO(sigmund): delete once we migrate the rest of the compiler to use | 167 // TODO(sigmund): delete once we migrate the rest of the compiler to use |
| 166 // `environment` directly. | 168 // `environment` directly. |
| 167 @deprecated | 169 @deprecated |
| 168 fromEnvironment(String name) => environment.valueOf(name); | 170 fromEnvironment(String name) => environment.valueOf(name); |
| 169 | 171 |
| 170 Element get currentElement => _reporter.currentElement; | 172 Element get currentElement => _reporter.currentElement; |
| 171 | 173 |
| 172 List<CompilerTask> tasks; | 174 List<CompilerTask> tasks; |
| 173 ScannerTask scanner; | 175 ScannerTask scanner; |
| 174 DietParserTask dietParser; | 176 DietParserTask dietParser; |
| 175 ParserTask parser; | 177 ParserTask parser; |
| 176 PatchParserTask patchParser; | 178 PatchParserTask patchParser; |
| 177 LibraryLoaderTask libraryLoader; | 179 LibraryLoaderTask libraryLoader; |
| 178 SerializationTask serialization; | 180 SerializationTask serialization; |
| 179 ResolverTask resolver; | 181 ResolverTask resolver; |
| 180 closureMapping.ClosureTask closureToClassMapper; | 182 closureMapping.ClosureTask closureToClassMapper; |
| 181 TypeCheckerTask checker; | 183 TypeCheckerTask checker; |
| 182 ti.TypesTask typesTask; | 184 GlobalTypeInferenceTask globalInference; |
| 183 Backend backend; | 185 Backend backend; |
| 184 | 186 |
| 185 GenericTask selfTask; | 187 GenericTask selfTask; |
| 186 | 188 |
| 187 /// The constant environment for the frontend interpretation of compile-time | 189 /// The constant environment for the frontend interpretation of compile-time |
| 188 /// constants. | 190 /// constants. |
| 189 ConstantEnvironment constants; | 191 ConstantEnvironment constants; |
| 190 | 192 |
| 191 EnqueueTask enqueuer; | 193 EnqueueTask enqueuer; |
| 192 DeferredLoadTask deferredLoadTask; | 194 DeferredLoadTask deferredLoadTask; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 serialization, | 282 serialization, |
| 281 this, | 283 this, |
| 282 environment, | 284 environment, |
| 283 reporter, | 285 reporter, |
| 284 measurer), | 286 measurer), |
| 285 parser = new ParserTask(this, options), | 287 parser = new ParserTask(this, options), |
| 286 patchParser = new PatchParserTask(this, options), | 288 patchParser = new PatchParserTask(this, options), |
| 287 resolver = createResolverTask(), | 289 resolver = createResolverTask(), |
| 288 closureToClassMapper = new closureMapping.ClosureTask(this), | 290 closureToClassMapper = new closureMapping.ClosureTask(this), |
| 289 checker = new TypeCheckerTask(this), | 291 checker = new TypeCheckerTask(this), |
| 290 typesTask = new ti.TypesTask(this), | 292 globalInference = new GlobalTypeInferenceTask(this), |
| 291 constants = backend.constantCompilerTask, | 293 constants = backend.constantCompilerTask, |
| 292 deferredLoadTask = new DeferredLoadTask(this), | 294 deferredLoadTask = new DeferredLoadTask(this), |
| 293 mirrorUsageAnalyzerTask = new MirrorUsageAnalyzerTask(this), | 295 mirrorUsageAnalyzerTask = new MirrorUsageAnalyzerTask(this), |
| 294 enqueuer = backend.makeEnqueuer(), | 296 enqueuer = backend.makeEnqueuer(), |
| 295 dumpInfoTask = new DumpInfoTask(this), | 297 dumpInfoTask = new DumpInfoTask(this), |
| 296 selfTask = new GenericTask('self', measurer), | 298 selfTask = new GenericTask('self', measurer), |
| 297 ]; | 299 ]; |
| 298 if (options.resolveOnly) { | 300 if (options.resolveOnly) { |
| 299 serialization.supportSerialization = true; | 301 serialization.supportSerialization = true; |
| 300 } | 302 } |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 phase = PHASE_DONE_RESOLVING; | 715 phase = PHASE_DONE_RESOLVING; |
| 714 | 716 |
| 715 world.populate(); | 717 world.populate(); |
| 716 // Compute whole-program-knowledge that the backend needs. (This might | 718 // Compute whole-program-knowledge that the backend needs. (This might |
| 717 // require the information computed in [world.populate].) | 719 // require the information computed in [world.populate].) |
| 718 backend.onResolutionComplete(); | 720 backend.onResolutionComplete(); |
| 719 | 721 |
| 720 deferredLoadTask.onResolutionComplete(mainFunction); | 722 deferredLoadTask.onResolutionComplete(mainFunction); |
| 721 | 723 |
| 722 reporter.log('Inferring types...'); | 724 reporter.log('Inferring types...'); |
| 723 typesTask.onResolutionComplete(mainFunction); | 725 globalInference.runGlobalTypeInference(mainFunction); |
| 724 | 726 |
| 725 if (stopAfterTypeInference) return; | 727 if (stopAfterTypeInference) return; |
| 726 | 728 |
| 727 backend.onTypeInferenceComplete(); | 729 backend.onTypeInferenceComplete(); |
| 728 | 730 |
| 729 reporter.log('Compiling...'); | 731 reporter.log('Compiling...'); |
| 730 phase = PHASE_COMPILING; | 732 phase = PHASE_COMPILING; |
| 731 backend.onCodegenStart(); | 733 backend.onCodegenStart(); |
| 732 // TODO(johnniwinther): Move these to [CodegenEnqueuer]. | 734 // TODO(johnniwinther): Move these to [CodegenEnqueuer]. |
| 733 if (hasIsolateSupport) { | 735 if (hasIsolateSupport) { |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1215 if (_functionApplyMethod == null) { | 1217 if (_functionApplyMethod == null) { |
| 1216 functionClass.ensureResolved(resolution); | 1218 functionClass.ensureResolved(resolution); |
| 1217 _functionApplyMethod = functionClass.lookupLocalMember('apply'); | 1219 _functionApplyMethod = functionClass.lookupLocalMember('apply'); |
| 1218 assert(invariant(functionClass, _functionApplyMethod != null, | 1220 assert(invariant(functionClass, _functionApplyMethod != null, |
| 1219 message: "Member `apply` not found in ${functionClass}.")); | 1221 message: "Member `apply` not found in ${functionClass}.")); |
| 1220 } | 1222 } |
| 1221 return _functionApplyMethod; | 1223 return _functionApplyMethod; |
| 1222 } | 1224 } |
| 1223 | 1225 |
| 1224 bool isFunctionApplyMethod(Element element) => | 1226 bool isFunctionApplyMethod(Element element) => |
| 1225 element.name == 'apply' && element.enclosingClass == functionClass; | 1227 element.name == 'apply' && element.enclosingClass == functionClass; |
| 1226 | 1228 |
| 1227 ClassElement _nullClass; | 1229 ClassElement _nullClass; |
| 1228 ClassElement get nullClass => | 1230 ClassElement get nullClass => |
| 1229 _nullClass ??= _findRequired(coreLibrary, 'Null'); | 1231 _nullClass ??= _findRequired(coreLibrary, 'Null'); |
| 1230 | 1232 |
| 1231 ClassElement _listClass; | 1233 ClassElement _listClass; |
| 1232 ClassElement get listClass => | 1234 ClassElement get listClass => |
| 1233 _listClass ??= _findRequired(coreLibrary, 'List'); | 1235 _listClass ??= _findRequired(coreLibrary, 'List'); |
| 1234 | 1236 |
| 1235 ClassElement _typeClass; | 1237 ClassElement _typeClass; |
| (...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2234 _ElementScanner(this.scanner); | 2236 _ElementScanner(this.scanner); |
| 2235 void scanLibrary(LibraryElement library) => scanner.scanLibrary(library); | 2237 void scanLibrary(LibraryElement library) => scanner.scanLibrary(library); |
| 2236 void scanUnit(CompilationUnitElement unit) => scanner.scan(unit); | 2238 void scanUnit(CompilationUnitElement unit) => scanner.scan(unit); |
| 2237 } | 2239 } |
| 2238 | 2240 |
| 2239 class _EmptyEnvironment implements Environment { | 2241 class _EmptyEnvironment implements Environment { |
| 2240 const _EmptyEnvironment(); | 2242 const _EmptyEnvironment(); |
| 2241 | 2243 |
| 2242 String valueOf(String key) => null; | 2244 String valueOf(String key) => null; |
| 2243 } | 2245 } |
| OLD | NEW |