| 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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 | 202 |
| 203 // Initialized when dart:mirrors is loaded. | 203 // Initialized when dart:mirrors is loaded. |
| 204 ClassElement deferredLibraryClass; | 204 ClassElement deferredLibraryClass; |
| 205 | 205 |
| 206 /// Document class from dart:mirrors. | 206 /// Document class from dart:mirrors. |
| 207 ClassElement documentClass; | 207 ClassElement documentClass; |
| 208 Element identicalFunction; | 208 Element identicalFunction; |
| 209 Element loadLibraryFunction; | 209 Element loadLibraryFunction; |
| 210 Element functionApplyMethod; | 210 Element functionApplyMethod; |
| 211 | 211 |
| 212 /// The [int.fromEnvironment] constructor. | |
| 213 ConstructorElement intEnvironment; | |
| 214 | |
| 215 /// The [bool.fromEnvironment] constructor. | |
| 216 ConstructorElement boolEnvironment; | |
| 217 | |
| 218 /// The [String.fromEnvironment] constructor. | |
| 219 ConstructorElement stringEnvironment; | |
| 220 | |
| 221 // TODO(zarah): Remove this map and incorporate compile-time errors | 212 // TODO(zarah): Remove this map and incorporate compile-time errors |
| 222 // in the model. | 213 // in the model. |
| 223 /// Tracks elements with compile-time errors. | 214 /// Tracks elements with compile-time errors. |
| 224 final Map<Element, List<DiagnosticMessage>> elementsWithCompileTimeErrors = | 215 final Map<Element, List<DiagnosticMessage>> elementsWithCompileTimeErrors = |
| 225 new Map<Element, List<DiagnosticMessage>>(); | 216 new Map<Element, List<DiagnosticMessage>>(); |
| 226 | 217 |
| 227 final Environment environment; | 218 final Environment environment; |
| 228 // TODO(sigmund): delete once we migrate the rest of the compiler to use | 219 // TODO(sigmund): delete once we migrate the rest of the compiler to use |
| 229 // `environment` directly. | 220 // `environment` directly. |
| 230 @deprecated | 221 @deprecated |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 // [JavaScriptBackend]. Currently needed for testing. | 607 // [JavaScriptBackend]. Currently needed for testing. |
| 617 String get patchVersion => backend.patchVersion; | 608 String get patchVersion => backend.patchVersion; |
| 618 | 609 |
| 619 // TODO(johnniwinther): Remove this. All elements should be looked up on | 610 // TODO(johnniwinther): Remove this. All elements should be looked up on |
| 620 // demand. | 611 // demand. |
| 621 void onClassResolved(ClassElement cls) { | 612 void onClassResolved(ClassElement cls) { |
| 622 if (mirrorSystemClass == cls) { | 613 if (mirrorSystemClass == cls) { |
| 623 mirrorSystemGetNameFunction = cls.lookupLocalMember('getName'); | 614 mirrorSystemGetNameFunction = cls.lookupLocalMember('getName'); |
| 624 } else if (mirrorsUsedClass == cls) { | 615 } else if (mirrorsUsedClass == cls) { |
| 625 mirrorsUsedConstructor = cls.constructors.head; | 616 mirrorsUsedConstructor = cls.constructors.head; |
| 626 } else if (coreClasses.intClass == cls) { | |
| 627 intEnvironment = cls.lookupConstructor(Identifiers.fromEnvironment); | |
| 628 } else if (coreClasses.stringClass == cls) { | |
| 629 stringEnvironment = cls.lookupConstructor(Identifiers.fromEnvironment); | |
| 630 } else if (coreClasses.boolClass == cls) { | |
| 631 boolEnvironment = cls.lookupConstructor(Identifiers.fromEnvironment); | |
| 632 } | 617 } |
| 633 } | 618 } |
| 634 | 619 |
| 635 void initializeCoreClasses() { | 620 void initializeCoreClasses() { |
| 636 final List missingCoreClasses = []; | 621 final List missingCoreClasses = []; |
| 637 ClassElement lookupCoreClass(String name) { | 622 ClassElement lookupCoreClass(String name) { |
| 638 ClassElement result = coreLibrary.find(name); | 623 ClassElement result = coreLibrary.find(name); |
| 639 if (result == null) { | 624 if (result == null) { |
| 640 missingCoreClasses.add(name); | 625 missingCoreClasses.add(name); |
| 641 } | 626 } |
| (...skipping 1474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2116 _ElementScanner(this.scanner); | 2101 _ElementScanner(this.scanner); |
| 2117 void scanLibrary(LibraryElement library) => scanner.scanLibrary(library); | 2102 void scanLibrary(LibraryElement library) => scanner.scanLibrary(library); |
| 2118 void scanUnit(CompilationUnitElement unit) => scanner.scan(unit); | 2103 void scanUnit(CompilationUnitElement unit) => scanner.scan(unit); |
| 2119 } | 2104 } |
| 2120 | 2105 |
| 2121 class _EmptyEnvironment implements Environment { | 2106 class _EmptyEnvironment implements Environment { |
| 2122 const _EmptyEnvironment(); | 2107 const _EmptyEnvironment(); |
| 2123 | 2108 |
| 2124 String valueOf(String key) => null; | 2109 String valueOf(String key) => null; |
| 2125 } | 2110 } |
| OLD | NEW |