| 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; |
| 11 | 11 |
| 12 final ContainerBuilder containerBuilder = new ContainerBuilder(); | 12 final ContainerBuilder containerBuilder = new ContainerBuilder(); |
| 13 final ClassEmitter classEmitter = new ClassEmitter(); | 13 final ClassEmitter classEmitter = new ClassEmitter(); |
| 14 final NsmEmitter nsmEmitter = new NsmEmitter(); | 14 final NsmEmitter nsmEmitter = new NsmEmitter(); |
| 15 TypeTestEmitter get typeTestEmitter => task.typeTestEmitter; | 15 final TypeTestEmitter typeTestEmitter = new TypeTestEmitter(); |
| 16 final InterceptorEmitter interceptorEmitter = new InterceptorEmitter(); | 16 final InterceptorEmitter interceptorEmitter = new InterceptorEmitter(); |
| 17 final MetadataEmitter metadataEmitter = new MetadataEmitter(); | 17 final MetadataEmitter metadataEmitter = new MetadataEmitter(); |
| 18 | 18 |
| 19 final Set<ConstantValue> cachedEmittedConstants; | 19 final Set<ConstantValue> cachedEmittedConstants; |
| 20 final CodeBuffer cachedEmittedConstantsBuffer = new CodeBuffer(); | 20 final CodeBuffer cachedEmittedConstantsBuffer = new CodeBuffer(); |
| 21 final Map<Element, ClassBuilder> cachedClassBuilders; | 21 final Map<Element, ClassBuilder> cachedClassBuilders; |
| 22 final Set<Element> cachedElements; | 22 final Set<Element> cachedElements; |
| 23 | 23 |
| 24 bool needsDefineClass = false; | 24 bool needsDefineClass = false; |
| 25 bool needsMixinSupport = false; | 25 bool needsMixinSupport = false; |
| 26 bool needsLazyInitializer = false; | 26 bool needsLazyInitializer = false; |
| 27 final Namer namer; | 27 final Namer namer; |
| 28 ConstantEmitter constantEmitter; | 28 ConstantEmitter constantEmitter; |
| 29 NativeEmitter get nativeEmitter => task.nativeEmitter; | 29 NativeEmitter get nativeEmitter => task.nativeEmitter; |
| 30 TypeTestRegistry get typeTestRegistry => task.typeTestRegistry; |
| 30 | 31 |
| 31 // The full code that is written to each hunk part-file. | 32 // The full code that is written to each hunk part-file. |
| 32 Map<OutputUnit, CodeBuffer> outputBuffers = new Map<OutputUnit, CodeBuffer>(); | 33 Map<OutputUnit, CodeBuffer> outputBuffers = new Map<OutputUnit, CodeBuffer>(); |
| 33 final CodeBuffer deferredConstants = new CodeBuffer(); | 34 final CodeBuffer deferredConstants = new CodeBuffer(); |
| 34 | 35 |
| 35 /** Shorter access to [isolatePropertiesName]. Both here in the code, as | 36 /** Shorter access to [isolatePropertiesName]. Both here in the code, as |
| 36 well as in the generated code. */ | 37 well as in the generated code. */ |
| 37 String isolateProperties; | 38 String isolateProperties; |
| 38 String classesCollector; | 39 String classesCollector; |
| 39 Set<ClassElement> get neededClasses => task.neededClasses; | 40 Set<ClassElement> get neededClasses => task.neededClasses; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 : this.compiler = compiler, | 102 : this.compiler = compiler, |
| 102 this.namer = namer, | 103 this.namer = namer, |
| 103 cachedEmittedConstants = compiler.cacheStrategy.newSet(), | 104 cachedEmittedConstants = compiler.cacheStrategy.newSet(), |
| 104 cachedClassBuilders = compiler.cacheStrategy.newMap(), | 105 cachedClassBuilders = compiler.cacheStrategy.newMap(), |
| 105 cachedElements = compiler.cacheStrategy.newSet() { | 106 cachedElements = compiler.cacheStrategy.newSet() { |
| 106 constantEmitter = | 107 constantEmitter = |
| 107 new ConstantEmitter(compiler, namer, makeConstantListTemplate); | 108 new ConstantEmitter(compiler, namer, makeConstantListTemplate); |
| 108 containerBuilder.emitter = this; | 109 containerBuilder.emitter = this; |
| 109 classEmitter.emitter = this; | 110 classEmitter.emitter = this; |
| 110 nsmEmitter.emitter = this; | 111 nsmEmitter.emitter = this; |
| 112 typeTestEmitter.emitter = this; |
| 111 interceptorEmitter.emitter = this; | 113 interceptorEmitter.emitter = this; |
| 112 metadataEmitter.emitter = this; | 114 metadataEmitter.emitter = this; |
| 113 } | 115 } |
| 114 | 116 |
| 115 List<jsAst.Node> cspPrecompiledFunctionFor(OutputUnit outputUnit) { | 117 List<jsAst.Node> cspPrecompiledFunctionFor(OutputUnit outputUnit) { |
| 116 return _cspPrecompiledFunctions.putIfAbsent( | 118 return _cspPrecompiledFunctions.putIfAbsent( |
| 117 outputUnit, | 119 outputUnit, |
| 118 () => new List<jsAst.Node>()); | 120 () => new List<jsAst.Node>()); |
| 119 } | 121 } |
| 120 | 122 |
| (...skipping 1889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2010 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { | 2012 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { |
| 2011 if (element.isInstanceMember) { | 2013 if (element.isInstanceMember) { |
| 2012 cachedClassBuilders.remove(element.enclosingClass); | 2014 cachedClassBuilders.remove(element.enclosingClass); |
| 2013 | 2015 |
| 2014 nativeEmitter.cachedBuilders.remove(element.enclosingClass); | 2016 nativeEmitter.cachedBuilders.remove(element.enclosingClass); |
| 2015 | 2017 |
| 2016 } | 2018 } |
| 2017 } | 2019 } |
| 2018 } | 2020 } |
| 2019 } | 2021 } |
| OLD | NEW |