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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 return rawJavaScript.replaceAll(COMMENT_RE, ''); | 289 return rawJavaScript.replaceAll(COMMENT_RE, ''); |
290 } | 290 } |
291 | 291 |
292 jsAst.Expression maybeAddTypeArguments(InterfaceType type, | 292 jsAst.Expression maybeAddTypeArguments(InterfaceType type, |
293 jsAst.Expression value) { | 293 jsAst.Expression value) { |
294 if (type is InterfaceType && | 294 if (type is InterfaceType && |
295 !type.treatAsRaw && | 295 !type.treatAsRaw && |
296 backend.classNeedsRti(type.element)) { | 296 backend.classNeedsRti(type.element)) { |
297 InterfaceType interface = type; | 297 InterfaceType interface = type; |
298 RuntimeTypes rti = backend.rti; | 298 RuntimeTypes rti = backend.rti; |
299 Iterable<String> arguments = interface.typeArguments | 299 Iterable<jsAst.Expression> arguments = interface.typeArguments |
300 .map((DartType type) => | 300 .map((DartType type) => |
301 rti.getTypeRepresentationWithHashes(type, (_){})); | 301 rti.getTypeRepresentationWithPlaceholders(type, (_){})); |
302 jsAst.Expression argumentList = | 302 jsAst.Expression argumentList = |
303 new jsAst.LiteralString('[${arguments.join(', ')}]'); | 303 new jsAst.ArrayInitializer(arguments.toList()); |
304 return new jsAst.Call(getHelperProperty(backend.getSetRuntimeTypeInfo()), | 304 return new jsAst.Call(getHelperProperty(backend.getSetRuntimeTypeInfo()), |
305 [value, argumentList]); | 305 [value, argumentList]); |
306 } | 306 } |
307 return value; | 307 return value; |
308 } | 308 } |
309 | 309 |
310 @override | 310 @override |
311 jsAst.Expression visitDeferred(DeferredConstantValue constant, [_]) { | 311 jsAst.Expression visitDeferred(DeferredConstantValue constant, [_]) { |
312 return constantReferenceGenerator(constant.referenced); | 312 return constantReferenceGenerator(constant.referenced); |
313 } | 313 } |
314 } | 314 } |
OLD | NEW |