| 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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 } | 292 } |
| 293 | 293 |
| 294 jsAst.Expression visitInterceptor(InterceptorConstant constant) { | 294 jsAst.Expression visitInterceptor(InterceptorConstant constant) { |
| 295 return new jsAst.PropertyAccess.field( | 295 return new jsAst.PropertyAccess.field( |
| 296 new jsAst.VariableUse( | 296 new jsAst.VariableUse( |
| 297 getJsConstructor(constant.dispatchedType.element)), | 297 getJsConstructor(constant.dispatchedType.element)), |
| 298 'prototype'); | 298 'prototype'); |
| 299 } | 299 } |
| 300 | 300 |
| 301 jsAst.Expression visitConstructed(ConstructedConstant constant) { | 301 jsAst.Expression visitConstructed(ConstructedConstant constant) { |
| 302 Element element = constant.type.element; |
| 303 if (element.isForeign(compiler) |
| 304 && element.name == const SourceString('JS_CONST')) { |
| 305 StringConstant str = constant.fields[0]; |
| 306 return new jsAst.LiteralExpression(str.value.slowToString()); |
| 307 } |
| 302 jsAst.New instantiation = new jsAst.New( | 308 jsAst.New instantiation = new jsAst.New( |
| 303 new jsAst.VariableUse(getJsConstructor(constant.type.element)), | 309 new jsAst.VariableUse(getJsConstructor(constant.type.element)), |
| 304 _array(constant.fields)); | 310 _array(constant.fields)); |
| 305 return maybeAddTypeArguments(constant.type, instantiation); | 311 return maybeAddTypeArguments(constant.type, instantiation); |
| 306 } | 312 } |
| 307 | 313 |
| 308 List<jsAst.Expression> _array(List<Constant> values) { | 314 List<jsAst.Expression> _array(List<Constant> values) { |
| 309 List<jsAst.Expression> valueList = <jsAst.Expression>[]; | 315 List<jsAst.Expression> valueList = <jsAst.Expression>[]; |
| 310 for (int i = 0; i < values.length; i++) { | 316 for (int i = 0; i < values.length; i++) { |
| 311 valueList.add(_reference(values[i])); | 317 valueList.add(_reference(values[i])); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 324 .toList(growable: false) | 330 .toList(growable: false) |
| 325 .map((DartType type) => rti.getTypeRepresentation(type, (_){})); | 331 .map((DartType type) => rti.getTypeRepresentation(type, (_){})); |
| 326 jsAst.Expression argumentList = | 332 jsAst.Expression argumentList = |
| 327 new jsAst.LiteralString('[${arguments.join(', ')}]'); | 333 new jsAst.LiteralString('[${arguments.join(', ')}]'); |
| 328 return new jsAst.Call(getHelperProperty(backend.getSetRuntimeTypeInfo()), | 334 return new jsAst.Call(getHelperProperty(backend.getSetRuntimeTypeInfo()), |
| 329 [value, argumentList]); | 335 [value, argumentList]); |
| 330 } | 336 } |
| 331 return value; | 337 return value; |
| 332 } | 338 } |
| 333 } | 339 } |
| OLD | NEW |