| 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 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 if (constants == null) return; | 1010 if (constants == null) return; |
| 1011 bool isMainBuffer = buffer == mainBuffer; | 1011 bool isMainBuffer = buffer == mainBuffer; |
| 1012 if (compiler.hasIncrementalSupport && isMainBuffer) { | 1012 if (compiler.hasIncrementalSupport && isMainBuffer) { |
| 1013 buffer = cachedEmittedConstantsBuffer; | 1013 buffer = cachedEmittedConstantsBuffer; |
| 1014 } | 1014 } |
| 1015 for (ConstantValue constant in constants) { | 1015 for (ConstantValue constant in constants) { |
| 1016 if (compiler.hasIncrementalSupport && isMainBuffer) { | 1016 if (compiler.hasIncrementalSupport && isMainBuffer) { |
| 1017 if (cachedEmittedConstants.contains(constant)) continue; | 1017 if (cachedEmittedConstants.contains(constant)) continue; |
| 1018 cachedEmittedConstants.add(constant); | 1018 cachedEmittedConstants.add(constant); |
| 1019 } | 1019 } |
| 1020 String name = namer.constantName(constant); | 1020 jsAst.Expression init = buildConstantInitializer(constant); |
| 1021 jsAst.Expression init = js('#.# = #', | |
| 1022 [namer.globalObjectForConstant(constant), name, | |
| 1023 constantInitializerExpression(constant)]); | |
| 1024 buffer.write(jsAst.prettyPrint(init, compiler, | 1021 buffer.write(jsAst.prettyPrint(init, compiler, |
| 1025 monitor: compiler.dumpInfoTask)); | 1022 monitor: compiler.dumpInfoTask)); |
| 1026 buffer.write('$N'); | 1023 buffer.write('$N'); |
| 1027 } | 1024 } |
| 1028 if (compiler.hasIncrementalSupport && isMainBuffer) { | 1025 if (compiler.hasIncrementalSupport && isMainBuffer) { |
| 1029 mainBuffer.add(cachedEmittedConstantsBuffer); | 1026 mainBuffer.add(cachedEmittedConstantsBuffer); |
| 1030 } | 1027 } |
| 1031 } | 1028 } |
| 1032 | 1029 |
| 1030 jsAst.Expression buildConstantInitializer(ConstantValue constant) { |
| 1031 String name = namer.constantName(constant); |
| 1032 return js('#.# = #', |
| 1033 [namer.globalObjectForConstant(constant), name, |
| 1034 constantInitializerExpression(constant)]); |
| 1035 } |
| 1036 |
| 1033 jsAst.Template get makeConstantListTemplate { | 1037 jsAst.Template get makeConstantListTemplate { |
| 1034 // TODO(floitsch): there is no harm in caching the template. | 1038 // TODO(floitsch): there is no harm in caching the template. |
| 1035 return jsAst.js.uncachedExpressionTemplate( | 1039 return jsAst.js.uncachedExpressionTemplate( |
| 1036 '${namer.isolateName}.$makeConstListProperty(#)'); | 1040 '${namer.isolateName}.$makeConstListProperty(#)'); |
| 1037 } | 1041 } |
| 1038 | 1042 |
| 1039 void emitMakeConstantList(CodeBuffer buffer) { | 1043 void emitMakeConstantList(CodeBuffer buffer) { |
| 1040 buffer.write( | 1044 buffer.write( |
| 1041 jsAst.prettyPrint( | 1045 jsAst.prettyPrint( |
| 1042 // Functions are stored in the hidden class and not as properties in | 1046 // Functions are stored in the hidden class and not as properties in |
| (...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2110 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { | 2114 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { |
| 2111 if (element.isInstanceMember) { | 2115 if (element.isInstanceMember) { |
| 2112 cachedClassBuilders.remove(element.enclosingClass); | 2116 cachedClassBuilders.remove(element.enclosingClass); |
| 2113 | 2117 |
| 2114 nativeEmitter.cachedBuilders.remove(element.enclosingClass); | 2118 nativeEmitter.cachedBuilders.remove(element.enclosingClass); |
| 2115 | 2119 |
| 2116 } | 2120 } |
| 2117 } | 2121 } |
| 2118 } | 2122 } |
| 2119 } | 2123 } |
| OLD | NEW |