| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | 147 |
| 148 jsAst.Expression visitDummyReceiver(DummyReceiverConstant constant) { | 148 jsAst.Expression visitDummy(DummyConstant constant) { |
| 149 return new jsAst.LiteralNumber('0'); | 149 return new jsAst.LiteralNumber('0'); |
| 150 } | 150 } |
| 151 } | 151 } |
| 152 | 152 |
| 153 /** | 153 /** |
| 154 * Visitor for generating JavaScript expressions to initialize [Constant]s. | 154 * Visitor for generating JavaScript expressions to initialize [Constant]s. |
| 155 * Do not use directly; use methods from [ConstantEmitter]. | 155 * Do not use directly; use methods from [ConstantEmitter]. |
| 156 */ | 156 */ |
| 157 class ConstantInitializerEmitter implements ConstantVisitor<jsAst.Expression> { | 157 class ConstantInitializerEmitter implements ConstantVisitor<jsAst.Expression> { |
| 158 final Compiler compiler; | 158 final Compiler compiler; |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 [typeName]); | 311 [typeName]); |
| 312 } | 312 } |
| 313 | 313 |
| 314 jsAst.Expression visitInterceptor(InterceptorConstant constant) { | 314 jsAst.Expression visitInterceptor(InterceptorConstant constant) { |
| 315 return new jsAst.PropertyAccess.field( | 315 return new jsAst.PropertyAccess.field( |
| 316 new jsAst.VariableUse( | 316 new jsAst.VariableUse( |
| 317 getJsConstructor(constant.dispatchedType.element)), | 317 getJsConstructor(constant.dispatchedType.element)), |
| 318 'prototype'); | 318 'prototype'); |
| 319 } | 319 } |
| 320 | 320 |
| 321 jsAst.Expression visitDummyReceiver(DummyReceiverConstant constant) { | 321 jsAst.Expression visitDummy(DummyConstant constant) { |
| 322 return _reference(constant); | 322 return _reference(constant); |
| 323 } | 323 } |
| 324 | 324 |
| 325 jsAst.Expression visitConstructed(ConstructedConstant constant) { | 325 jsAst.Expression visitConstructed(ConstructedConstant constant) { |
| 326 Element element = constant.type.element; | 326 Element element = constant.type.element; |
| 327 if (element.isForeign(compiler) | 327 if (element.isForeign(compiler) |
| 328 && element.name == 'JS_CONST') { | 328 && element.name == 'JS_CONST') { |
| 329 StringConstant str = constant.fields[0]; | 329 StringConstant str = constant.fields[0]; |
| 330 String value = str.value.slowToString(); | 330 String value = str.value.slowToString(); |
| 331 return new jsAst.LiteralExpression(stripComments(value)); | 331 return new jsAst.LiteralExpression(stripComments(value)); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 360 .map((DartType type) => | 360 .map((DartType type) => |
| 361 rti.getTypeRepresentationWithHashes(type, (_){})); | 361 rti.getTypeRepresentationWithHashes(type, (_){})); |
| 362 jsAst.Expression argumentList = | 362 jsAst.Expression argumentList = |
| 363 new jsAst.LiteralString('[${arguments.join(', ')}]'); | 363 new jsAst.LiteralString('[${arguments.join(', ')}]'); |
| 364 return new jsAst.Call(getHelperProperty(backend.getSetRuntimeTypeInfo()), | 364 return new jsAst.Call(getHelperProperty(backend.getSetRuntimeTypeInfo()), |
| 365 [value, argumentList]); | 365 [value, argumentList]); |
| 366 } | 366 } |
| 367 return value; | 367 return value; |
| 368 } | 368 } |
| 369 } | 369 } |
| OLD | NEW |