| 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 import '../common.dart'; | 5 import '../common.dart'; |
| 6 import '../compiler.dart' show Compiler; | 6 import '../compiler.dart' show Compiler; |
| 7 import '../constants/values.dart'; | 7 import '../constants/values.dart'; |
| 8 import '../dart_types.dart'; | 8 import '../dart_types.dart'; |
| 9 import '../elements/elements.dart'; | 9 import '../elements/elements.dart'; |
| 10 import '../io/code_output.dart'; | 10 import '../io/code_output.dart'; |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 | 313 |
| 314 String stripComments(String rawJavaScript) { | 314 String stripComments(String rawJavaScript) { |
| 315 return rawJavaScript.replaceAll(COMMENT_RE, ''); | 315 return rawJavaScript.replaceAll(COMMENT_RE, ''); |
| 316 } | 316 } |
| 317 | 317 |
| 318 jsAst.Expression maybeAddTypeArguments( | 318 jsAst.Expression maybeAddTypeArguments( |
| 319 InterfaceType type, jsAst.Expression value) { | 319 InterfaceType type, jsAst.Expression value) { |
| 320 if (type is InterfaceType && | 320 if (type is InterfaceType && |
| 321 !type.treatAsRaw && | 321 !type.treatAsRaw && |
| 322 backend.classNeedsRti(type.element)) { | 322 backend.classNeedsRti(type.element)) { |
| 323 InterfaceType interface = type; | |
| 324 RuntimeTypesEncoder rtiEncoder = backend.rtiEncoder; | |
| 325 Iterable<jsAst.Expression> arguments = interface.typeArguments.map( | |
| 326 (DartType type) => | |
| 327 rtiEncoder.getTypeRepresentationWithPlaceholders(type, (_) {})); | |
| 328 jsAst.Expression argumentList = | |
| 329 new jsAst.ArrayInitializer(arguments.toList()); | |
| 330 return new jsAst.Call( | 323 return new jsAst.Call( |
| 331 getHelperProperty(backend.helpers.setRuntimeTypeInfo), | 324 getHelperProperty(backend.helpers.setRuntimeTypeInfo), |
| 332 [value, argumentList]); | 325 [value, _reifiedTypeArguments(type)]); |
| 333 } | 326 } |
| 334 return value; | 327 return value; |
| 335 } | 328 } |
| 336 | 329 |
| 330 jsAst.Expression _reifiedTypeArguments(InterfaceType type) { |
| 331 jsAst.Expression unexpected(TypeVariableType variable) { |
| 332 reporter.internalError( |
| 333 NO_LOCATION_SPANNABLE, |
| 334 "Unexpected type variable '${variable.getStringAsDeclared(null)}'" |
| 335 " in constant type '${type.getStringAsDeclared(null)}'"); |
| 336 return null; |
| 337 } |
| 338 List<jsAst.Expression> arguments = <jsAst.Expression>[]; |
| 339 RuntimeTypesEncoder rtiEncoder = backend.rtiEncoder; |
| 340 for (DartType argument in type.typeArguments) { |
| 341 arguments.add(rtiEncoder.getTypeRepresentation(argument, unexpected)); |
| 342 } |
| 343 return new jsAst.ArrayInitializer(arguments); |
| 344 } |
| 345 |
| 337 @override | 346 @override |
| 338 jsAst.Expression visitDeferred(DeferredConstantValue constant, [_]) { | 347 jsAst.Expression visitDeferred(DeferredConstantValue constant, [_]) { |
| 339 return constantReferenceGenerator(constant.referenced); | 348 return constantReferenceGenerator(constant.referenced); |
| 340 } | 349 } |
| 341 } | 350 } |
| OLD | NEW |