| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library dart2js.serialization.constants; | 5 library dart2js.serialization.constants; |
| 6 | 6 |
| 7 import '../constants/constructors.dart'; | 7 import '../constants/constructors.dart'; |
| 8 import '../constants/expressions.dart'; | 8 import '../constants/expressions.dart'; |
| 9 import '../dart_types.dart'; | 9 import '../dart_types.dart'; |
| 10 import '../elements/elements.dart' show | 10 import '../elements/elements.dart' show |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 void visitRedirectingGenerative( | 351 void visitRedirectingGenerative( |
| 352 RedirectingGenerativeConstantConstructor constructor, | 352 RedirectingGenerativeConstantConstructor constructor, |
| 353 ObjectEncoder encoder) { | 353 ObjectEncoder encoder) { |
| 354 MapEncoder defaults = encoder.createMap(Key.DEFAULTS); | 354 MapEncoder defaults = encoder.createMap(Key.DEFAULTS); |
| 355 constructor.defaultValues.forEach((key, ConstantExpression e) { | 355 constructor.defaultValues.forEach((key, ConstantExpression e) { |
| 356 defaults.setConstant('$key', e); | 356 defaults.setConstant('$key', e); |
| 357 }); | 357 }); |
| 358 encoder.setConstant(Key.CONSTRUCTOR, | 358 encoder.setConstant(Key.CONSTRUCTOR, |
| 359 constructor.thisConstructorInvocation); | 359 constructor.thisConstructorInvocation); |
| 360 } | 360 } |
| 361 |
| 362 @override |
| 363 visitErroneous(ErroneousConstantConstructor constructor, ObjectEncoder arg) { |
| 364 // Nothing to add; the kind has been serialized. |
| 365 } |
| 361 } | 366 } |
| 362 /// Utility class for deserializing [ConstantConstructor]s. | 367 /// Utility class for deserializing [ConstantConstructor]s. |
| 363 /// | 368 /// |
| 364 /// This is used by the [ConstructorElementZ]. | 369 /// This is used by the [ConstructorElementZ]. |
| 365 class ConstantConstructorDeserializer { | 370 class ConstantConstructorDeserializer { |
| 366 /// Deserializes a [ConstantConstructor] from an [ObjectDecoder]. | 371 /// Deserializes a [ConstantConstructor] from an [ObjectDecoder]. |
| 367 /// | 372 /// |
| 368 /// The class is called from the [Deserializer] when a constant constructor | 373 /// The class is called from the [Deserializer] when a constant constructor |
| 369 /// needs deserialization. The [ObjectDecoder] ensures that any [Element], | 374 /// needs deserialization. The [ObjectDecoder] ensures that any [Element], |
| 370 /// [DartType], and [ConstantExpression] that the deserialized | 375 /// [DartType], and [ConstantExpression] that the deserialized |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 readDefaults(), | 426 readDefaults(), |
| 422 readFields(), | 427 readFields(), |
| 423 readConstructorInvocation()); | 428 readConstructorInvocation()); |
| 424 case ConstantConstructorKind.REDIRECTING_GENERATIVE: | 429 case ConstantConstructorKind.REDIRECTING_GENERATIVE: |
| 425 return new RedirectingGenerativeConstantConstructor( | 430 return new RedirectingGenerativeConstantConstructor( |
| 426 readDefaults(), | 431 readDefaults(), |
| 427 readConstructorInvocation()); | 432 readConstructorInvocation()); |
| 428 case ConstantConstructorKind.REDIRECTING_FACTORY: | 433 case ConstantConstructorKind.REDIRECTING_FACTORY: |
| 429 return new RedirectingFactoryConstantConstructor( | 434 return new RedirectingFactoryConstantConstructor( |
| 430 readConstructorInvocation()); | 435 readConstructorInvocation()); |
| 436 case ConstantConstructorKind.ERRONEOUS: |
| 437 return const ErroneousConstantConstructor(); |
| 431 } | 438 } |
| 432 } | 439 } |
| 433 } | 440 } |
| OLD | NEW |