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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart

Issue 787233006: dart2js: more uses of the model in the old emitter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 part of dart2js.js_emitter; 5 part of dart2js.js_emitter;
6 6
7 7
8 class OldEmitter implements Emitter { 8 class OldEmitter implements Emitter {
9 final Compiler compiler; 9 final Compiler compiler;
10 final CodeEmitterTask task; 10 final CodeEmitterTask task;
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 function dart_precompiled(\$collectedClasses) { 725 function dart_precompiled(\$collectedClasses) {
726 var \$desc; 726 var \$desc;
727 #; 727 #;
728 return #; 728 return #;
729 }''', 729 }''',
730 [cspPrecompiledFunctionFor(outputUnit), 730 [cspPrecompiledFunctionFor(outputUnit),
731 new jsAst.ArrayInitializer( 731 new jsAst.ArrayInitializer(
732 cspPrecompiledConstructorNamesFor(outputUnit))]); 732 cspPrecompiledConstructorNamesFor(outputUnit))]);
733 } 733 }
734 734
735 void generateClass(ClassElement classElement, ClassBuilder properties) { 735 void emitClass(Class cls, ClassBuilder enclosingBuilder) {
736 ClassElement classElement = cls.element;
736 compiler.withCurrentElement(classElement, () { 737 compiler.withCurrentElement(classElement, () {
737 if (compiler.hasIncrementalSupport) { 738 if (compiler.hasIncrementalSupport) {
738 ClassBuilder builder = 739 ClassBuilder cachedBuilder =
739 cachedClassBuilders.putIfAbsent(classElement, () { 740 cachedClassBuilders.putIfAbsent(classElement, () {
740 ClassBuilder builder = new ClassBuilder(classElement, namer); 741 ClassBuilder builder = new ClassBuilder(classElement, namer);
741 classEmitter.generateClass( 742 classEmitter.emitClass(
742 classElement, builder, additionalProperties[classElement]); 743 cls, builder, additionalProperties[classElement]);
743 return builder; 744 return builder;
744 }); 745 });
745 invariant(classElement, builder.fields.isEmpty); 746 invariant(classElement, cachedBuilder.fields.isEmpty);
746 invariant(classElement, builder.superName == null); 747 invariant(classElement, cachedBuilder.superName == null);
747 invariant(classElement, builder.functionType == null); 748 invariant(classElement, cachedBuilder.functionType == null);
748 invariant(classElement, builder.fieldMetadata == null); 749 invariant(classElement, cachedBuilder.fieldMetadata == null);
749 properties.properties.addAll(builder.properties); 750 enclosingBuilder.properties.addAll(cachedBuilder.properties);
750 } else { 751 } else {
751 classEmitter.generateClass( 752 classEmitter.emitClass(
752 classElement, properties, additionalProperties[classElement]); 753 cls, enclosingBuilder, additionalProperties[classElement]);
753 } 754 }
754 }); 755 });
755 } 756 }
756 757
757 void emitStaticFunctions(Iterable<Method> staticFunctions) { 758 void emitStaticFunctions(Iterable<Method> staticFunctions) {
758 if (staticFunctions == null) return; 759 if (staticFunctions == null) return;
759 // We need to filter out null-elements for the interceptors. 760 // We need to filter out null-elements for the interceptors.
760 Iterable<Element> elements = staticFunctions 761 Iterable<Element> elements = staticFunctions
761 .where((Method method) => method.element != null) 762 .where((Method method) => method.element != null)
762 .map((Method method) => method.element); 763 .map((Method method) => method.element);
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
1356 element, MessageKind.GENERIC, {'text': 'Pending statics.'})); 1357 element, MessageKind.GENERIC, {'text': 'Pending statics.'}));
1357 } 1358 }
1358 1359
1359 if (pendingStatics != null && !pendingStatics.isEmpty) { 1360 if (pendingStatics != null && !pendingStatics.isEmpty) {
1360 compiler.internalError(pendingStatics.first, 1361 compiler.internalError(pendingStatics.first,
1361 'Pending statics (see above).'); 1362 'Pending statics (see above).');
1362 } 1363 }
1363 } 1364 }
1364 1365
1365 void emitLibrary(Library library) { 1366 void emitLibrary(Library library) {
1367 LibraryElement libraryElement = library.element;
1368
1366 emitStaticFunctions(library.statics); 1369 emitStaticFunctions(library.statics);
1367 1370
1368 Iterable<ClassElement> classes = 1371 ClassBuilder libraryBuilder = getElementDescriptor(libraryElement);
1369 library.classes.map((Class cls) => cls.element); 1372 for (Class cls in library.classes) {
1370 for (ClassElement element in classes) { 1373 emitClass(cls, libraryBuilder);
1371 generateClass(element, getElementDescriptor(element));
1372 } 1374 }
1373 1375
1374 LibraryElement libraryElement = library.element; 1376 classEmitter.emitFields(libraryElement, libraryBuilder, emitStatics: true);
1375 ClassBuilder builder = getElementDescriptor(libraryElement);
1376 classEmitter.emitFields(library.element, builder, emitStatics: true);
1377 } 1377 }
1378 1378
1379 void emitMainOutputUnit(Program program, 1379 void emitMainOutputUnit(Program program,
1380 Map<OutputUnit, String> deferredLoadHashes, 1380 Map<OutputUnit, String> deferredLoadHashes,
1381 CodeBuffer nativeBuffer) { 1381 CodeBuffer nativeBuffer) {
1382 Fragment mainFragment = program.fragments.first; 1382 Fragment mainFragment = program.fragments.first;
1383 OutputUnit mainOutputUnit = mainFragment.outputUnit; 1383 OutputUnit mainOutputUnit = mainFragment.outputUnit;
1384 1384
1385 LineColumnCollector lineColumnCollector; 1385 LineColumnCollector lineColumnCollector;
1386 List<CodeOutputListener> codeOutputListeners; 1386 List<CodeOutputListener> codeOutputListeners;
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
2089 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { 2089 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) {
2090 if (element.isInstanceMember) { 2090 if (element.isInstanceMember) {
2091 cachedClassBuilders.remove(element.enclosingClass); 2091 cachedClassBuilders.remove(element.enclosingClass);
2092 2092
2093 nativeEmitter.cachedBuilders.remove(element.enclosingClass); 2093 nativeEmitter.cachedBuilders.remove(element.enclosingClass);
2094 2094
2095 } 2095 }
2096 } 2096 }
2097 } 2097 }
2098 } 2098 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698