| 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 typedef jsAst.Expression _ConstantReferenceGenerator(ConstantValue constant); | 7 typedef jsAst.Expression _ConstantReferenceGenerator(ConstantValue constant); |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * Generates the JavaScript expressions for constants. | 10 * Generates the JavaScript expressions for constants. |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 } | 257 } |
| 258 | 258 |
| 259 @override | 259 @override |
| 260 jsAst.Expression visitInterceptor(InterceptorConstantValue constant, [_]) { | 260 jsAst.Expression visitInterceptor(InterceptorConstantValue constant, [_]) { |
| 261 ClassElement interceptorClass = constant.dispatchedType.element; | 261 ClassElement interceptorClass = constant.dispatchedType.element; |
| 262 return backend.emitter.interceptorPrototypeAccess(interceptorClass); | 262 return backend.emitter.interceptorPrototypeAccess(interceptorClass); |
| 263 } | 263 } |
| 264 | 264 |
| 265 @override | 265 @override |
| 266 jsAst.Expression visitDummy(DummyConstantValue constant, [_]) { | 266 jsAst.Expression visitDummy(DummyConstantValue constant, [_]) { |
| 267 return new jsAst.LiteralNumber('0'); | 267 switch (constant.kind) { |
| 268 case DummyConstantKinds.dummyReceiver: |
| 269 case DummyConstantKinds.emptyValue: |
| 270 return new jsAst.LiteralNumber('0'); |
| 271 case DummyConstantKinds.typeVariableReference: |
| 272 return constant.payload; |
| 273 default: |
| 274 compiler.internalError(NO_LOCATION_SPANNABLE, |
| 275 "Unexpected DummyConstantKind ${constant.kind}"); |
| 276 return null; |
| 277 } |
| 268 } | 278 } |
| 269 | 279 |
| 270 @override | 280 @override |
| 271 jsAst.Expression visitConstructed(ConstructedConstantValue constant, [_]) { | 281 jsAst.Expression visitConstructed(ConstructedConstantValue constant, [_]) { |
| 272 Element element = constant.type.element; | 282 Element element = constant.type.element; |
| 273 if (element.isForeign(backend) | 283 if (element.isForeign(backend) |
| 274 && element.name == 'JS_CONST') { | 284 && element.name == 'JS_CONST') { |
| 275 StringConstantValue str = constant.fields.values.single; | 285 StringConstantValue str = constant.fields.values.single; |
| 276 String value = str.primitiveValue.slowToString(); | 286 String value = str.primitiveValue.slowToString(); |
| 277 return new jsAst.LiteralExpression(stripComments(value)); | 287 return new jsAst.LiteralExpression(stripComments(value)); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 305 [value, argumentList]); | 315 [value, argumentList]); |
| 306 } | 316 } |
| 307 return value; | 317 return value; |
| 308 } | 318 } |
| 309 | 319 |
| 310 @override | 320 @override |
| 311 jsAst.Expression visitDeferred(DeferredConstantValue constant, [_]) { | 321 jsAst.Expression visitDeferred(DeferredConstantValue constant, [_]) { |
| 312 return constantReferenceGenerator(constant.referenced); | 322 return constantReferenceGenerator(constant.referenced); |
| 313 } | 323 } |
| 314 } | 324 } |
| OLD | NEW |