| 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 return emitCanonicalVersion(constant); | 137 return emitCanonicalVersion(constant); |
| 138 } | 138 } |
| 139 | 139 |
| 140 jsAst.Expression visitConstructed(ConstructedConstant constant) { | 140 jsAst.Expression visitConstructed(ConstructedConstant constant) { |
| 141 return emitCanonicalVersion(constant); | 141 return emitCanonicalVersion(constant); |
| 142 } | 142 } |
| 143 | 143 |
| 144 jsAst.Expression visitInterceptor(InterceptorConstant constant) { | 144 jsAst.Expression visitInterceptor(InterceptorConstant constant) { |
| 145 return emitCanonicalVersion(constant); | 145 return emitCanonicalVersion(constant); |
| 146 } | 146 } |
| 147 | |
| 148 jsAst.Expression visitDummyReceiver(DummyReceiverConstant constant) { | |
| 149 return new jsAst.LiteralNumber('0'); | |
| 150 } | |
| 151 } | 147 } |
| 152 | 148 |
| 153 /** | 149 /** |
| 154 * Visitor for generating JavaScript expressions to initialize [Constant]s. | 150 * Visitor for generating JavaScript expressions to initialize [Constant]s. |
| 155 * Do not use directly; use methods from [ConstantEmitter]. | 151 * Do not use directly; use methods from [ConstantEmitter]. |
| 156 */ | 152 */ |
| 157 class ConstantInitializerEmitter implements ConstantVisitor<jsAst.Expression> { | 153 class ConstantInitializerEmitter implements ConstantVisitor<jsAst.Expression> { |
| 158 final Compiler compiler; | 154 final Compiler compiler; |
| 159 final Namer namer; | 155 final Namer namer; |
| 160 final ConstantReferenceEmitter referenceEmitter; | 156 final ConstantReferenceEmitter referenceEmitter; |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 [typeName]); | 306 [typeName]); |
| 311 } | 307 } |
| 312 | 308 |
| 313 jsAst.Expression visitInterceptor(InterceptorConstant constant) { | 309 jsAst.Expression visitInterceptor(InterceptorConstant constant) { |
| 314 return new jsAst.PropertyAccess.field( | 310 return new jsAst.PropertyAccess.field( |
| 315 new jsAst.VariableUse( | 311 new jsAst.VariableUse( |
| 316 getJsConstructor(constant.dispatchedType.element)), | 312 getJsConstructor(constant.dispatchedType.element)), |
| 317 'prototype'); | 313 'prototype'); |
| 318 } | 314 } |
| 319 | 315 |
| 320 jsAst.Expression visitDummyReceiver(DummyReceiverConstant constant) { | |
| 321 return _reference(constant); | |
| 322 } | |
| 323 | |
| 324 jsAst.Expression visitConstructed(ConstructedConstant constant) { | 316 jsAst.Expression visitConstructed(ConstructedConstant constant) { |
| 325 Element element = constant.type.element; | 317 Element element = constant.type.element; |
| 326 if (element.isForeign(compiler) | 318 if (element.isForeign(compiler) |
| 327 && element.name == 'JS_CONST') { | 319 && element.name == 'JS_CONST') { |
| 328 StringConstant str = constant.fields[0]; | 320 StringConstant str = constant.fields[0]; |
| 329 String value = str.value.slowToString(); | 321 String value = str.value.slowToString(); |
| 330 return new jsAst.LiteralExpression(stripComments(value)); | 322 return new jsAst.LiteralExpression(stripComments(value)); |
| 331 } | 323 } |
| 332 jsAst.New instantiation = new jsAst.New( | 324 jsAst.New instantiation = new jsAst.New( |
| 333 new jsAst.VariableUse(getJsConstructor(constant.type.element)), | 325 new jsAst.VariableUse(getJsConstructor(constant.type.element)), |
| (...skipping 25 matching lines...) Expand all Loading... |
| 359 .map((DartType type) => | 351 .map((DartType type) => |
| 360 rti.getTypeRepresentationWithHashes(type, (_){})); | 352 rti.getTypeRepresentationWithHashes(type, (_){})); |
| 361 jsAst.Expression argumentList = | 353 jsAst.Expression argumentList = |
| 362 new jsAst.LiteralString('[${arguments.join(', ')}]'); | 354 new jsAst.LiteralString('[${arguments.join(', ')}]'); |
| 363 return new jsAst.Call(getHelperProperty(backend.getSetRuntimeTypeInfo()), | 355 return new jsAst.Call(getHelperProperty(backend.getSetRuntimeTypeInfo()), |
| 364 [value, argumentList]); | 356 [value, argumentList]); |
| 365 } | 357 } |
| 366 return value; | 358 return value; |
| 367 } | 359 } |
| 368 } | 360 } |
| OLD | NEW |