Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: pkg/compiler/lib/src/compiler.dart

Issue 1888803002: Support serialization of all resolved asts from dart:core (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix unittests. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 /// The constant for the [proxy] variable defined in dart:core. 161 /// The constant for the [proxy] variable defined in dart:core.
162 ConstantValue proxyConstant; 162 ConstantValue proxyConstant;
163 163
164 // TODO(johnniwinther): Move this to the JavaScriptBackend. 164 // TODO(johnniwinther): Move this to the JavaScriptBackend.
165 /// The class for patch annotation defined in dart:_js_helper. 165 /// The class for patch annotation defined in dart:_js_helper.
166 ClassElement patchAnnotationClass; 166 ClassElement patchAnnotationClass;
167 167
168 // TODO(johnniwinther): Move this to the JavaScriptBackend. 168 // TODO(johnniwinther): Move this to the JavaScriptBackend.
169 ClassElement nativeAnnotationClass; 169 ClassElement nativeAnnotationClass;
170 170
171 // Initialized after symbolClass has been resolved. 171 ConstructorElement _symbolConstructor;
172 FunctionElement symbolConstructor; 172 ConstructorElement get symbolConstructor {
173 if (_symbolConstructor == null) {
174 ClassElement symbolClass = coreClasses.symbolClass;
175 symbolClass.ensureResolved(resolution);
176 _symbolConstructor = symbolClass.lookupConstructor('');
177 assert(invariant(symbolClass, _symbolConstructor != null,
178 message: "Default constructor not found ${symbolClass}."));
179 }
180 return _symbolConstructor;
181 }
173 182
174 // Initialized when dart:mirrors is loaded. 183 // Initialized when dart:mirrors is loaded.
175 ClassElement mirrorSystemClass; 184 ClassElement mirrorSystemClass;
176 185
177 // Initialized when dart:mirrors is loaded. 186 // Initialized when dart:mirrors is loaded.
178 ClassElement mirrorsUsedClass; 187 ClassElement mirrorsUsedClass;
179 188
180 // Initialized after mirrorSystemClass has been resolved. 189 // Initialized after mirrorSystemClass has been resolved.
181 FunctionElement mirrorSystemGetNameFunction; 190 FunctionElement mirrorSystemGetNameFunction;
182 191
183 // Initialized when dart:_internal is loaded.
184 ClassElement symbolImplementationClass;
185
186 // Initialized when symbolImplementationClass has been resolved.
187 // TODO(johnniwinther): Move this to [BackendHelpers].
188 FunctionElement symbolValidatedConstructor;
189
190 // Initialized when mirrorsUsedClass has been resolved. 192 // Initialized when mirrorsUsedClass has been resolved.
191 FunctionElement mirrorsUsedConstructor; 193 FunctionElement mirrorsUsedConstructor;
192 194
193 // Initialized when dart:mirrors is loaded. 195 // Initialized when dart:mirrors is loaded.
194 ClassElement deferredLibraryClass; 196 ClassElement deferredLibraryClass;
195 197
196 /// Document class from dart:mirrors. 198 /// Document class from dart:mirrors.
197 ClassElement documentClass; 199 ClassElement documentClass;
198 Element identicalFunction; 200 Element identicalFunction;
199 Element loadLibraryFunction; 201 Element loadLibraryFunction;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 ConstantEnvironment constants; 241 ConstantEnvironment constants;
240 242
241 EnqueueTask enqueuer; 243 EnqueueTask enqueuer;
242 DeferredLoadTask deferredLoadTask; 244 DeferredLoadTask deferredLoadTask;
243 MirrorUsageAnalyzerTask mirrorUsageAnalyzerTask; 245 MirrorUsageAnalyzerTask mirrorUsageAnalyzerTask;
244 DumpInfoTask dumpInfoTask; 246 DumpInfoTask dumpInfoTask;
245 247
246 /// A customizable filter that is applied to enqueued work items. 248 /// A customizable filter that is applied to enqueued work items.
247 QueueFilter enqueuerFilter = new QueueFilter(); 249 QueueFilter enqueuerFilter = new QueueFilter();
248 250
249 final Selector symbolValidatedConstructorSelector =
250 new Selector.call(const PublicName('validated'), CallStructure.ONE_ARG);
251
252 static const String CREATE_INVOCATION_MIRROR = 'createInvocationMirror'; 251 static const String CREATE_INVOCATION_MIRROR = 'createInvocationMirror';
253 252
254 bool enabledRuntimeType = false; 253 bool enabledRuntimeType = false;
255 bool enabledFunctionApply = false; 254 bool enabledFunctionApply = false;
256 bool enabledInvokeOn = false; 255 bool enabledInvokeOn = false;
257 bool hasIsolateSupport = false; 256 bool hasIsolateSupport = false;
258 257
259 bool get hasCrashed => _reporter.hasCrashed; 258 bool get hasCrashed => _reporter.hasCrashed;
260 259
261 Stopwatch progress; 260 Stopwatch progress;
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 /// in certain libraries. Note that [library] has not been patched yet, nor 426 /// in certain libraries. Note that [library] has not been patched yet, nor
428 /// has its imports/exports been resolved. 427 /// has its imports/exports been resolved.
429 /// 428 ///
430 /// Use [loader] to register the creation and scanning of a patch library 429 /// Use [loader] to register the creation and scanning of a patch library
431 /// for [library]. 430 /// for [library].
432 Future onLibraryScanned(LibraryElement library, LibraryLoader loader) { 431 Future onLibraryScanned(LibraryElement library, LibraryLoader loader) {
433 Uri uri = library.canonicalUri; 432 Uri uri = library.canonicalUri;
434 if (uri == Uris.dart_core) { 433 if (uri == Uris.dart_core) {
435 initializeCoreClasses(); 434 initializeCoreClasses();
436 identicalFunction = coreLibrary.find('identical'); 435 identicalFunction = coreLibrary.find('identical');
437 } else if (uri == Uris.dart__internal) {
438 symbolImplementationClass = findRequiredElement(library, 'Symbol');
439 } else if (uri == Uris.dart_mirrors) { 436 } else if (uri == Uris.dart_mirrors) {
440 mirrorSystemClass = findRequiredElement(library, 'MirrorSystem'); 437 mirrorSystemClass = findRequiredElement(library, 'MirrorSystem');
441 mirrorsUsedClass = findRequiredElement(library, 'MirrorsUsed'); 438 mirrorsUsedClass = findRequiredElement(library, 'MirrorsUsed');
442 } else if (uri == Uris.dart_async) { 439 } else if (uri == Uris.dart_async) {
443 asyncLibrary = library; 440 asyncLibrary = library;
444 deferredLibraryClass = findRequiredElement(library, 'DeferredLibrary'); 441 deferredLibraryClass = findRequiredElement(library, 'DeferredLibrary');
445 _coreTypes.futureClass = findRequiredElement(library, 'Future'); 442 _coreTypes.futureClass = findRequiredElement(library, 'Future');
446 _coreTypes.streamClass = findRequiredElement(library, 'Stream'); 443 _coreTypes.streamClass = findRequiredElement(library, 'Stream');
447 } else if (uri == Uris.dart__native_typed_data) { 444 } else if (uri == Uris.dart__native_typed_data) {
448 typedDataClass = findRequiredElement(library, 'NativeTypedData'); 445 typedDataClass = findRequiredElement(library, 'NativeTypedData');
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 "The library '${library.canonicalUri}' does not contain required " 587 "The library '${library.canonicalUri}' does not contain required "
591 "element: '$name'."); 588 "element: '$name'.");
592 } 589 }
593 return element; 590 return element;
594 } 591 }
595 592
596 // TODO(johnniwinther): Move this to [PatchParser] when it is moved to the 593 // TODO(johnniwinther): Move this to [PatchParser] when it is moved to the
597 // [JavaScriptBackend]. Currently needed for testing. 594 // [JavaScriptBackend]. Currently needed for testing.
598 String get patchVersion => backend.patchVersion; 595 String get patchVersion => backend.patchVersion;
599 596
597 // TODO(johnniwinther): Remove this. All elements should be looked up on
598 // demand.
600 void onClassResolved(ClassElement cls) { 599 void onClassResolved(ClassElement cls) {
601 if (mirrorSystemClass == cls) { 600 if (mirrorSystemClass == cls) {
602 mirrorSystemGetNameFunction = cls.lookupLocalMember('getName'); 601 mirrorSystemGetNameFunction = cls.lookupLocalMember('getName');
603 } else if (coreClasses.symbolClass == cls) {
604 symbolConstructor = cls.constructors.head;
605 } else if (symbolImplementationClass == cls) {
606 symbolValidatedConstructor =
607 cls.lookupConstructor(symbolValidatedConstructorSelector.name);
608 } else if (mirrorsUsedClass == cls) { 602 } else if (mirrorsUsedClass == cls) {
609 mirrorsUsedConstructor = cls.constructors.head; 603 mirrorsUsedConstructor = cls.constructors.head;
610 } else if (coreClasses.intClass == cls) { 604 } else if (coreClasses.intClass == cls) {
611 intEnvironment = cls.lookupConstructor(Identifiers.fromEnvironment); 605 intEnvironment = cls.lookupConstructor(Identifiers.fromEnvironment);
612 } else if (coreClasses.stringClass == cls) { 606 } else if (coreClasses.stringClass == cls) {
613 stringEnvironment = cls.lookupConstructor(Identifiers.fromEnvironment); 607 stringEnvironment = cls.lookupConstructor(Identifiers.fromEnvironment);
614 } else if (coreClasses.boolClass == cls) { 608 } else if (coreClasses.boolClass == cls) {
615 boolEnvironment = cls.lookupConstructor(Identifiers.fromEnvironment); 609 boolEnvironment = cls.lookupConstructor(Identifiers.fromEnvironment);
616 } 610 }
617 } 611 }
(...skipping 1416 matching lines...) Expand 10 before | Expand all | Expand 10 after
2034 _ElementScanner(this.scanner); 2028 _ElementScanner(this.scanner);
2035 void scanLibrary(LibraryElement library) => scanner.scanLibrary(library); 2029 void scanLibrary(LibraryElement library) => scanner.scanLibrary(library);
2036 void scanUnit(CompilationUnitElement unit) => scanner.scan(unit); 2030 void scanUnit(CompilationUnitElement unit) => scanner.scan(unit);
2037 } 2031 }
2038 2032
2039 class _EmptyEnvironment implements Environment { 2033 class _EmptyEnvironment implements Environment {
2040 const _EmptyEnvironment(); 2034 const _EmptyEnvironment();
2041 2035
2042 String valueOf(String key) => null; 2036 String valueOf(String key) => null;
2043 } 2037 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698