| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 js_backend; | 5 part of js_backend; |
| 6 | 6 |
| 7 class ConstantEmitter { | 7 class ConstantEmitter { |
| 8 ConstantReferenceEmitter _referenceEmitter; | 8 ConstantReferenceEmitter _referenceEmitter; |
| 9 ConstantInitializerEmitter _initializerEmitter; | 9 ConstantInitializerEmitter _initializerEmitter; |
| 10 | 10 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 // then it should be assigned to a name. We don't have reference counts (or | 124 // then it should be assigned to a name. We don't have reference counts (or |
| 125 // profile information) here, so this is the wrong place. | 125 // profile information) here, so this is the wrong place. |
| 126 StringBuffer sb = new StringBuffer(); | 126 StringBuffer sb = new StringBuffer(); |
| 127 writeJsonEscapedCharsOn(constant.value.slowToString(), sb); | 127 writeJsonEscapedCharsOn(constant.value.slowToString(), sb); |
| 128 return new js.LiteralString('"$sb"'); | 128 return new js.LiteralString('"$sb"'); |
| 129 } | 129 } |
| 130 | 130 |
| 131 js.Expression emitCanonicalVersion(Constant constant) { | 131 js.Expression emitCanonicalVersion(Constant constant) { |
| 132 String name = namer.constantName(constant); | 132 String name = namer.constantName(constant); |
| 133 if (inIsolateInitializationContext) { | 133 if (inIsolateInitializationContext) { |
| 134 // $ISOLATE.$ISOLATE_PROPERTIES.$name | 134 // $isolateName.$isolatePropertiesName.$name |
| 135 return new js.PropertyAccess.field( | 135 return new js.PropertyAccess.field( |
| 136 new js.PropertyAccess.field( | 136 new js.PropertyAccess.field( |
| 137 new js.VariableUse(namer.ISOLATE), | 137 new js.VariableUse(namer.isolateName), |
| 138 namer.ISOLATE_PROPERTIES), | 138 namer.isolatePropertiesName), |
| 139 name); | 139 name); |
| 140 } else { | 140 } else { |
| 141 return new js.PropertyAccess.field( | 141 return new js.PropertyAccess.field( |
| 142 new js.VariableUse(namer.CURRENT_ISOLATE), | 142 new js.VariableUse(namer.CURRENT_ISOLATE), |
| 143 name); | 143 name); |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 | 146 |
| 147 js.Expression visitList(ListConstant constant) { | 147 js.Expression visitList(ListConstant constant) { |
| 148 return emitCanonicalVersion(constant); | 148 return emitCanonicalVersion(constant); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 } | 215 } |
| 216 | 216 |
| 217 js.Expression visitString(StringConstant constant) { | 217 js.Expression visitString(StringConstant constant) { |
| 218 // TODO(sra): Some larger strings are worth sharing. | 218 // TODO(sra): Some larger strings are worth sharing. |
| 219 return _reference(constant); | 219 return _reference(constant); |
| 220 } | 220 } |
| 221 | 221 |
| 222 js.Expression visitList(ListConstant constant) { | 222 js.Expression visitList(ListConstant constant) { |
| 223 return new js.Call( | 223 return new js.Call( |
| 224 new js.PropertyAccess.field( | 224 new js.PropertyAccess.field( |
| 225 new js.VariableUse(namer.ISOLATE), | 225 new js.VariableUse(namer.isolateName), |
| 226 'makeConstantList'), | 226 'makeConstantList'), |
| 227 [new js.ArrayInitializer.from(_array(constant.entries))]); | 227 [new js.ArrayInitializer.from(_array(constant.entries))]); |
| 228 } | 228 } |
| 229 | 229 |
| 230 String getJsConstructor(ClassElement element) { | 230 String getJsConstructor(ClassElement element) { |
| 231 return namer.isolatePropertiesAccess(element); | 231 return namer.isolatePropertiesAccess(element); |
| 232 } | 232 } |
| 233 | 233 |
| 234 js.Expression visitMap(MapConstant constant) { | 234 js.Expression visitMap(MapConstant constant) { |
| 235 js.Expression jsMap() { | 235 js.Expression jsMap() { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 } | 316 } |
| 317 | 317 |
| 318 List<js.Expression> _array(List<Constant> values) { | 318 List<js.Expression> _array(List<Constant> values) { |
| 319 List<js.Expression> valueList = <js.Expression>[]; | 319 List<js.Expression> valueList = <js.Expression>[]; |
| 320 for (int i = 0; i < values.length; i++) { | 320 for (int i = 0; i < values.length; i++) { |
| 321 valueList.add(_reference(values[i])); | 321 valueList.add(_reference(values[i])); |
| 322 } | 322 } |
| 323 return valueList; | 323 return valueList; |
| 324 } | 324 } |
| 325 } | 325 } |
| OLD | NEW |