| OLD | NEW |
| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 String classesCollector; | 44 String classesCollector; |
| 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 final Map<String, String> mangledFieldNames = <String, String>{}; | 50 final Map<String, String> mangledFieldNames = <String, String>{}; |
| 51 final Map<String, String> mangledGlobalFieldNames = <String, String>{}; | 51 final Map<String, String> mangledGlobalFieldNames = <String, String>{}; |
| 52 final Set<String> recordedMangledNames = new Set<String>(); | 52 final Set<String> recordedMangledNames = new Set<String>(); |
| 53 | 53 |
| 54 Map<Class, Map<String, jsAst.Expression>> additionalProperties; | |
| 55 | |
| 56 List<TypedefElement> get typedefsNeededForReflection => | 54 List<TypedefElement> get typedefsNeededForReflection => |
| 57 task.typedefsNeededForReflection; | 55 task.typedefsNeededForReflection; |
| 58 | 56 |
| 59 JavaScriptBackend get backend => compiler.backend; | 57 JavaScriptBackend get backend => compiler.backend; |
| 60 TypeVariableHandler get typeVariableHandler => backend.typeVariableHandler; | 58 TypeVariableHandler get typeVariableHandler => backend.typeVariableHandler; |
| 61 | 59 |
| 62 String get _ => space; | 60 String get _ => space; |
| 63 String get space => compiler.enableMinification ? "" : " "; | 61 String get space => compiler.enableMinification ? "" : " "; |
| 64 String get n => compiler.enableMinification ? "" : "\n"; | 62 String get n => compiler.enableMinification ? "" : "\n"; |
| 65 String get N => compiler.enableMinification ? "\n" : ";\n"; | 63 String get N => compiler.enableMinification ? "\n" : ";\n"; |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 cspPrecompiledConstructorNamesFor(outputUnit))]); | 711 cspPrecompiledConstructorNamesFor(outputUnit))]); |
| 714 } | 712 } |
| 715 | 713 |
| 716 void emitClass(Class cls, ClassBuilder enclosingBuilder) { | 714 void emitClass(Class cls, ClassBuilder enclosingBuilder) { |
| 717 ClassElement classElement = cls.element; | 715 ClassElement classElement = cls.element; |
| 718 compiler.withCurrentElement(classElement, () { | 716 compiler.withCurrentElement(classElement, () { |
| 719 if (compiler.hasIncrementalSupport) { | 717 if (compiler.hasIncrementalSupport) { |
| 720 ClassBuilder cachedBuilder = | 718 ClassBuilder cachedBuilder = |
| 721 cachedClassBuilders.putIfAbsent(classElement, () { | 719 cachedClassBuilders.putIfAbsent(classElement, () { |
| 722 ClassBuilder builder = new ClassBuilder(classElement, namer); | 720 ClassBuilder builder = new ClassBuilder(classElement, namer); |
| 723 classEmitter.emitClass( | 721 classEmitter.emitClass(cls, builder); |
| 724 cls, builder, additionalProperties[cls]); | |
| 725 return builder; | 722 return builder; |
| 726 }); | 723 }); |
| 727 invariant(classElement, cachedBuilder.fields.isEmpty); | 724 invariant(classElement, cachedBuilder.fields.isEmpty); |
| 728 invariant(classElement, cachedBuilder.superName == null); | 725 invariant(classElement, cachedBuilder.superName == null); |
| 729 invariant(classElement, cachedBuilder.functionType == null); | 726 invariant(classElement, cachedBuilder.functionType == null); |
| 730 invariant(classElement, cachedBuilder.fieldMetadata == null); | 727 invariant(classElement, cachedBuilder.fieldMetadata == null); |
| 731 enclosingBuilder.properties.addAll(cachedBuilder.properties); | 728 enclosingBuilder.properties.addAll(cachedBuilder.properties); |
| 732 } else { | 729 } else { |
| 733 classEmitter.emitClass( | 730 classEmitter.emitClass(cls, enclosingBuilder); |
| 734 cls, enclosingBuilder, additionalProperties[cls]); | |
| 735 } | 731 } |
| 736 }); | 732 }); |
| 737 } | 733 } |
| 738 | 734 |
| 739 void emitStaticFunctions(Iterable<Method> staticFunctions) { | 735 void emitStaticFunctions(Iterable<Method> staticFunctions) { |
| 740 if (staticFunctions == null) return; | 736 if (staticFunctions == null) return; |
| 741 // We need to filter out null-elements for the interceptors. | 737 // We need to filter out null-elements for the interceptors. |
| 742 Iterable<Element> elements = staticFunctions | 738 Iterable<Element> elements = staticFunctions |
| 743 .where((Method method) => method.element != null) | 739 .where((Method method) => method.element != null) |
| 744 .map((Method method) => method.element); | 740 .map((Method method) => method.element); |
| (...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1759 } | 1755 } |
| 1760 } | 1756 } |
| 1761 | 1757 |
| 1762 return emitDeferredCode(program, outputBuffers); | 1758 return emitDeferredCode(program, outputBuffers); |
| 1763 } | 1759 } |
| 1764 | 1760 |
| 1765 int emitProgram(ProgramBuilder programBuilder) { | 1761 int emitProgram(ProgramBuilder programBuilder) { |
| 1766 Program program = programBuilder.buildProgram( | 1762 Program program = programBuilder.buildProgram( |
| 1767 storeFunctionTypesInMetadata: true); | 1763 storeFunctionTypesInMetadata: true); |
| 1768 | 1764 |
| 1769 additionalProperties = program.additionalProperties; | |
| 1770 | |
| 1771 // Shorten the code by using [namer.currentIsolate] as temporary. | 1765 // Shorten the code by using [namer.currentIsolate] as temporary. |
| 1772 isolateProperties = namer.currentIsolate; | 1766 isolateProperties = namer.currentIsolate; |
| 1773 | 1767 |
| 1774 // Emit deferred units first, so we have their hashes. | 1768 // Emit deferred units first, so we have their hashes. |
| 1775 // Map from OutputUnit to a hash of its content. The hash uniquely | 1769 // Map from OutputUnit to a hash of its content. The hash uniquely |
| 1776 // identifies the code of the output-unit. It does not include | 1770 // identifies the code of the output-unit. It does not include |
| 1777 // boilerplate JS code, like the sourcemap directives or the hash | 1771 // boilerplate JS code, like the sourcemap directives or the hash |
| 1778 // itself. | 1772 // itself. |
| 1779 Map<OutputUnit, String> deferredLoadHashes = | 1773 Map<OutputUnit, String> deferredLoadHashes = |
| 1780 emitDeferredOutputUnits(program); | 1774 emitDeferredOutputUnits(program); |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2071 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { | 2065 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { |
| 2072 if (element.isInstanceMember) { | 2066 if (element.isInstanceMember) { |
| 2073 cachedClassBuilders.remove(element.enclosingClass); | 2067 cachedClassBuilders.remove(element.enclosingClass); |
| 2074 | 2068 |
| 2075 nativeEmitter.cachedBuilders.remove(element.enclosingClass); | 2069 nativeEmitter.cachedBuilders.remove(element.enclosingClass); |
| 2076 | 2070 |
| 2077 } | 2071 } |
| 2078 } | 2072 } |
| 2079 } | 2073 } |
| 2080 } | 2074 } |
| OLD | NEW |