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

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

Issue 868473003: dart2js: Run prepareNativeClasses in the program builder. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comment. 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 Set<ClassElement> get neededClasses => task.neededClasses; 45 Set<ClassElement> get neededClasses => task.neededClasses;
46 Map<OutputUnit, List<ClassElement>> get outputClassLists 46 Map<OutputUnit, List<ClassElement>> get outputClassLists
47 => task.outputClassLists; 47 => task.outputClassLists;
48 Map<OutputUnit, List<ConstantValue>> get outputConstantLists 48 Map<OutputUnit, List<ConstantValue>> get outputConstantLists
49 => task.outputConstantLists; 49 => task.outputConstantLists;
50 List<ClassElement> get nativeClasses => task.nativeClasses; 50 List<ClassElement> get nativeClasses => task.nativeClasses;
51 final Map<String, String> mangledFieldNames = <String, String>{}; 51 final Map<String, String> mangledFieldNames = <String, String>{};
52 final Map<String, String> mangledGlobalFieldNames = <String, String>{}; 52 final Map<String, String> mangledGlobalFieldNames = <String, String>{};
53 final Set<String> recordedMangledNames = new Set<String>(); 53 final Set<String> recordedMangledNames = new Set<String>();
54 54
55 final Map<Class, Map<String, jsAst.Expression>> additionalProperties = 55 Map<Class, Map<String, jsAst.Expression>> additionalProperties;
56 new Map<Class, Map<String, jsAst.Expression>>();
57 56
58 List<TypedefElement> get typedefsNeededForReflection => 57 List<TypedefElement> get typedefsNeededForReflection =>
59 task.typedefsNeededForReflection; 58 task.typedefsNeededForReflection;
60 59
61 JavaScriptBackend get backend => compiler.backend; 60 JavaScriptBackend get backend => compiler.backend;
62 TypeVariableHandler get typeVariableHandler => backend.typeVariableHandler; 61 TypeVariableHandler get typeVariableHandler => backend.typeVariableHandler;
63 62
64 String get _ => space; 63 String get _ => space;
65 String get space => compiler.enableMinification ? "" : " "; 64 String get space => compiler.enableMinification ? "" : " ";
66 String get n => compiler.enableMinification ? "" : "\n"; 65 String get n => compiler.enableMinification ? "" : "\n";
(...skipping 1701 matching lines...) Expand 10 before | Expand all | Expand 10 after
1768 CodeBuffer buildNativesBuffer(Program program) { 1767 CodeBuffer buildNativesBuffer(Program program) {
1769 // Emit native classes on [nativeBuffer]. 1768 // Emit native classes on [nativeBuffer].
1770 // TODO(johnniwinther): Avoid creating a [CodeBuffer]. 1769 // TODO(johnniwinther): Avoid creating a [CodeBuffer].
1771 final CodeBuffer nativeBuffer = new CodeBuffer(); 1770 final CodeBuffer nativeBuffer = new CodeBuffer();
1772 1771
1773 if (program.nativeClasses.isEmpty) return nativeBuffer; 1772 if (program.nativeClasses.isEmpty) return nativeBuffer;
1774 1773
1775 1774
1776 addComment('Native classes', nativeBuffer); 1775 addComment('Native classes', nativeBuffer);
1777 1776
1778 List<Class> neededClasses = 1777 for (Class cls in program.nativeClasses) {
1779 nativeEmitter.prepareNativeClasses(program.nativeClasses,
1780 additionalProperties);
1781
1782 for (Class cls in neededClasses) {
1783 assert(cls.isNative); 1778 assert(cls.isNative);
1784 ClassBuilder enclosingBuilder = getElementDescriptor(cls.element); 1779 ClassBuilder enclosingBuilder = getElementDescriptor(cls.element);
1785 emitClass(cls, enclosingBuilder); 1780 emitClass(cls, enclosingBuilder);
1786 } 1781 }
1787 1782
1788 nativeEmitter.finishGenerateNativeClasses(); 1783 nativeEmitter.finishGenerateNativeClasses();
1789 nativeEmitter.assembleCode(nativeBuffer); 1784 nativeEmitter.assembleCode(nativeBuffer);
1790 1785
1791 return nativeBuffer; 1786 return nativeBuffer;
1792 } 1787 }
1793 1788
1794 int emitProgram(ProgramBuilder programBuilder) { 1789 int emitProgram(ProgramBuilder programBuilder) {
1795 Program program = programBuilder.buildProgram( 1790 Program program = programBuilder.buildProgram(
1796 storeFunctionTypesInMetadata: true); 1791 storeFunctionTypesInMetadata: true);
1797 1792
1793 additionalProperties = program.additionalProperties;
1794
1798 // Shorten the code by using [namer.currentIsolate] as temporary. 1795 // Shorten the code by using [namer.currentIsolate] as temporary.
1799 isolateProperties = namer.currentIsolate; 1796 isolateProperties = namer.currentIsolate;
1800 1797
1801 // Emit deferred units first, so we have their hashes. 1798 // Emit deferred units first, so we have their hashes.
1802 // Map from OutputUnit to a hash of its content. The hash uniquely 1799 // Map from OutputUnit to a hash of its content. The hash uniquely
1803 // identifies the code of the output-unit. It does not include 1800 // identifies the code of the output-unit. It does not include
1804 // boilerplate JS code, like the sourcemap directives or the hash 1801 // boilerplate JS code, like the sourcemap directives or the hash
1805 // itself. 1802 // itself.
1806 Map<OutputUnit, String> deferredLoadHashes = 1803 Map<OutputUnit, String> deferredLoadHashes =
1807 emitDeferredOutputUnits(program); 1804 emitDeferredOutputUnits(program);
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
2099 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { 2096 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) {
2100 if (element.isInstanceMember) { 2097 if (element.isInstanceMember) {
2101 cachedClassBuilders.remove(element.enclosingClass); 2098 cachedClassBuilders.remove(element.enclosingClass);
2102 2099
2103 nativeEmitter.cachedBuilders.remove(element.enclosingClass); 2100 nativeEmitter.cachedBuilders.remove(element.enclosingClass);
2104 2101
2105 } 2102 }
2106 } 2103 }
2107 } 2104 }
2108 } 2105 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/model.dart ('k') | pkg/compiler/lib/src/js_emitter/program_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698