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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 // then it should be assigned to a name. We don't have reference counts (or | 115 // then it should be assigned to a name. We don't have reference counts (or |
116 // profile information) here, so this is the wrong place. | 116 // profile information) here, so this is the wrong place. |
117 StringBuffer sb = new StringBuffer(); | 117 StringBuffer sb = new StringBuffer(); |
118 writeJsonEscapedCharsOn(constant.value.slowToString(), sb); | 118 writeJsonEscapedCharsOn(constant.value.slowToString(), sb); |
119 return new jsAst.LiteralString('"$sb"'); | 119 return new jsAst.LiteralString('"$sb"'); |
120 } | 120 } |
121 | 121 |
122 jsAst.Expression emitCanonicalVersion(Constant constant) { | 122 jsAst.Expression emitCanonicalVersion(Constant constant) { |
123 String name = namer.constantName(constant); | 123 String name = namer.constantName(constant); |
124 return new jsAst.PropertyAccess.field( | 124 return new jsAst.PropertyAccess.field( |
125 new jsAst.VariableUse(namer.CURRENT_ISOLATE), name); | 125 new jsAst.VariableUse(namer.globalObjectForConstant(constant)), name); |
126 } | 126 } |
127 | 127 |
128 jsAst.Expression visitList(ListConstant constant) { | 128 jsAst.Expression visitList(ListConstant constant) { |
129 return emitCanonicalVersion(constant); | 129 return emitCanonicalVersion(constant); |
130 } | 130 } |
131 | 131 |
132 jsAst.Expression visitMap(MapConstant constant) { | 132 jsAst.Expression visitMap(MapConstant constant) { |
133 return emitCanonicalVersion(constant); | 133 return emitCanonicalVersion(constant); |
134 } | 134 } |
135 | 135 |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 .toList(growable: false) | 324 .toList(growable: false) |
325 .map((DartType type) => rti.getTypeRepresentation(type, (_){})); | 325 .map((DartType type) => rti.getTypeRepresentation(type, (_){})); |
326 jsAst.Expression argumentList = | 326 jsAst.Expression argumentList = |
327 new jsAst.LiteralString('[${arguments.join(', ')}]'); | 327 new jsAst.LiteralString('[${arguments.join(', ')}]'); |
328 return new jsAst.Call(getHelperProperty(backend.getSetRuntimeTypeInfo()), | 328 return new jsAst.Call(getHelperProperty(backend.getSetRuntimeTypeInfo()), |
329 [value, argumentList]); | 329 [value, argumentList]); |
330 } | 330 } |
331 return value; | 331 return value; |
332 } | 332 } |
333 } | 333 } |
OLD | NEW |