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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 if ((className == JavaScriptMapConstant.DART_STRING_CLASS && | 244 if ((className == JavaScriptMapConstant.DART_STRING_CLASS && |
245 emittedArgumentCount != 3) || | 245 emittedArgumentCount != 3) || |
246 (className == JavaScriptMapConstant.DART_PROTO_CLASS && | 246 (className == JavaScriptMapConstant.DART_PROTO_CLASS && |
247 emittedArgumentCount != 4) || | 247 emittedArgumentCount != 4) || |
248 (className == JavaScriptMapConstant.DART_GENERAL_CLASS && | 248 (className == JavaScriptMapConstant.DART_GENERAL_CLASS && |
249 emittedArgumentCount != 1)) { | 249 emittedArgumentCount != 1)) { |
250 reporter.internalError(classElement, | 250 reporter.internalError(classElement, |
251 "Compiler and ${className} disagree on number of fields."); | 251 "Compiler and ${className} disagree on number of fields."); |
252 } | 252 } |
253 | 253 |
| 254 if (backend.classNeedsRtiField(classElement)) { |
| 255 arguments.add(_reifiedTypeArguments(constant.type)); |
| 256 } |
| 257 |
254 jsAst.Expression constructor = | 258 jsAst.Expression constructor = |
255 backend.emitter.constructorAccess(classElement); | 259 backend.emitter.constructorAccess(classElement); |
256 jsAst.Expression value = new jsAst.New(constructor, arguments); | 260 jsAst.Expression value = new jsAst.New(constructor, arguments); |
257 return maybeAddTypeArguments(constant.type, value); | 261 return value; |
258 } | 262 } |
259 | 263 |
260 JavaScriptBackend get backend => compiler.backend; | 264 JavaScriptBackend get backend => compiler.backend; |
261 | 265 |
262 jsAst.PropertyAccess getHelperProperty(Element helper) { | 266 jsAst.PropertyAccess getHelperProperty(Element helper) { |
263 return backend.emitter.staticFunctionAccess(helper); | 267 return backend.emitter.staticFunctionAccess(helper); |
264 } | 268 } |
265 | 269 |
266 @override | 270 @override |
267 jsAst.Expression visitType(TypeConstantValue constant, [_]) { | 271 jsAst.Expression visitType(TypeConstantValue constant, [_]) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 StringConstantValue str = constant.fields.values.single; | 304 StringConstantValue str = constant.fields.values.single; |
301 String value = str.primitiveValue.slowToString(); | 305 String value = str.primitiveValue.slowToString(); |
302 return new jsAst.LiteralExpression(stripComments(value)); | 306 return new jsAst.LiteralExpression(stripComments(value)); |
303 } | 307 } |
304 jsAst.Expression constructor = | 308 jsAst.Expression constructor = |
305 backend.emitter.constructorAccess(constant.type.element); | 309 backend.emitter.constructorAccess(constant.type.element); |
306 List<jsAst.Expression> fields = <jsAst.Expression>[]; | 310 List<jsAst.Expression> fields = <jsAst.Expression>[]; |
307 element.forEachInstanceField((_, FieldElement field) { | 311 element.forEachInstanceField((_, FieldElement field) { |
308 fields.add(constantReferenceGenerator(constant.fields[field])); | 312 fields.add(constantReferenceGenerator(constant.fields[field])); |
309 }, includeSuperAndInjectedMembers: true); | 313 }, includeSuperAndInjectedMembers: true); |
| 314 if (backend.classNeedsRtiField(constant.type.element)) { |
| 315 fields.add(_reifiedTypeArguments(constant.type)); |
| 316 } |
310 jsAst.New instantiation = new jsAst.New(constructor, fields); | 317 jsAst.New instantiation = new jsAst.New(constructor, fields); |
311 return maybeAddTypeArguments(constant.type, instantiation); | 318 return maybeAddTypeArguments(constant.type, instantiation); |
312 } | 319 } |
313 | 320 |
314 String stripComments(String rawJavaScript) { | 321 String stripComments(String rawJavaScript) { |
315 return rawJavaScript.replaceAll(COMMENT_RE, ''); | 322 return rawJavaScript.replaceAll(COMMENT_RE, ''); |
316 } | 323 } |
317 | 324 |
318 jsAst.Expression maybeAddTypeArguments( | 325 jsAst.Expression maybeAddTypeArguments( |
319 InterfaceType type, jsAst.Expression value) { | 326 InterfaceType type, jsAst.Expression value) { |
(...skipping 22 matching lines...) Expand all Loading... |
342 arguments.add(rtiEncoder.getTypeRepresentation(argument, unexpected)); | 349 arguments.add(rtiEncoder.getTypeRepresentation(argument, unexpected)); |
343 } | 350 } |
344 return new jsAst.ArrayInitializer(arguments); | 351 return new jsAst.ArrayInitializer(arguments); |
345 } | 352 } |
346 | 353 |
347 @override | 354 @override |
348 jsAst.Expression visitDeferred(DeferredConstantValue constant, [_]) { | 355 jsAst.Expression visitDeferred(DeferredConstantValue constant, [_]) { |
349 return constantReferenceGenerator(constant.referenced); | 356 return constantReferenceGenerator(constant.referenced); |
350 } | 357 } |
351 } | 358 } |
OLD | NEW |