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.elements; | 5 library dart2js.serialization.elements; |
6 | 6 |
7 import '../common.dart'; | 7 import '../common.dart'; |
8 import '../constants/constructors.dart'; | 8 import '../constants/constructors.dart'; |
9 import '../constants/expressions.dart'; | 9 import '../constants/expressions.dart'; |
10 import '../dart_types.dart'; | 10 import '../dart_types.dart'; |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 return SerializedElementKind.FACTORY_CONSTRUCTOR; | 416 return SerializedElementKind.FACTORY_CONSTRUCTOR; |
417 } | 417 } |
418 } | 418 } |
419 return null; | 419 return null; |
420 } | 420 } |
421 | 421 |
422 void serialize(ConstructorElement element, ObjectEncoder encoder, | 422 void serialize(ConstructorElement element, ObjectEncoder encoder, |
423 SerializedElementKind kind) { | 423 SerializedElementKind kind) { |
424 SerializerUtil.serializeParentRelation(element, encoder); | 424 SerializerUtil.serializeParentRelation(element, encoder); |
425 if (kind == SerializedElementKind.FORWARDING_CONSTRUCTOR) { | 425 if (kind == SerializedElementKind.FORWARDING_CONSTRUCTOR) { |
426 encoder.setElement(Key.ELEMENT, element.definingConstructor); | 426 serializeElementReference(element.enclosingClass, Key.ELEMENT, Key.NAME, |
| 427 encoder, element.definingConstructor); |
427 } else { | 428 } else { |
428 SerializerUtil.serializeMetadata(element, encoder); | 429 SerializerUtil.serializeMetadata(element, encoder); |
429 encoder.setType(Key.TYPE, element.type); | 430 encoder.setType(Key.TYPE, element.type); |
430 encoder.setString(Key.NAME, element.name); | 431 encoder.setString(Key.NAME, element.name); |
431 SerializerUtil.serializePosition(element, encoder); | 432 SerializerUtil.serializePosition(element, encoder); |
432 SerializerUtil.serializeParameters(element, encoder); | 433 SerializerUtil.serializeParameters(element, encoder); |
433 encoder.setBool(Key.IS_CONST, element.isConst); | 434 encoder.setBool(Key.IS_CONST, element.isConst); |
434 encoder.setBool(Key.IS_EXTERNAL, element.isExternal); | 435 encoder.setBool(Key.IS_EXTERNAL, element.isExternal); |
435 encoder.setBool(Key.IS_INJECTED, element.isInjected); | 436 encoder.setBool(Key.IS_INJECTED, element.isInjected); |
436 if (element.isConst && !element.isFromEnvironmentConstructor) { | 437 if (element.isConst && !element.isFromEnvironmentConstructor) { |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 return new InstanceFieldElementZ(decoder); | 767 return new InstanceFieldElementZ(decoder); |
767 case SerializedElementKind.GENERATIVE_CONSTRUCTOR: | 768 case SerializedElementKind.GENERATIVE_CONSTRUCTOR: |
768 return new GenerativeConstructorElementZ(decoder); | 769 return new GenerativeConstructorElementZ(decoder); |
769 case SerializedElementKind.DEFAULT_CONSTRUCTOR: | 770 case SerializedElementKind.DEFAULT_CONSTRUCTOR: |
770 return new DefaultConstructorElementZ(decoder); | 771 return new DefaultConstructorElementZ(decoder); |
771 case SerializedElementKind.FACTORY_CONSTRUCTOR: | 772 case SerializedElementKind.FACTORY_CONSTRUCTOR: |
772 return new FactoryConstructorElementZ(decoder); | 773 return new FactoryConstructorElementZ(decoder); |
773 case SerializedElementKind.REDIRECTING_FACTORY_CONSTRUCTOR: | 774 case SerializedElementKind.REDIRECTING_FACTORY_CONSTRUCTOR: |
774 return new RedirectingFactoryConstructorElementZ(decoder); | 775 return new RedirectingFactoryConstructorElementZ(decoder); |
775 case SerializedElementKind.FORWARDING_CONSTRUCTOR: | 776 case SerializedElementKind.FORWARDING_CONSTRUCTOR: |
776 return new ForwardingConstructorElementZ( | 777 ClassElement cls = decoder.getElement(Key.CLASS); |
777 decoder.getElement(Key.CLASS), decoder.getElement(Key.ELEMENT)); | 778 Element definingConstructor = |
| 779 deserializeElementReference(cls, Key.ELEMENT, Key.NAME, decoder); |
| 780 return new ForwardingConstructorElementZ(cls, definingConstructor); |
778 case SerializedElementKind.TOPLEVEL_FUNCTION: | 781 case SerializedElementKind.TOPLEVEL_FUNCTION: |
779 return new TopLevelFunctionElementZ(decoder); | 782 return new TopLevelFunctionElementZ(decoder); |
780 case SerializedElementKind.STATIC_FUNCTION: | 783 case SerializedElementKind.STATIC_FUNCTION: |
781 return new StaticFunctionElementZ(decoder); | 784 return new StaticFunctionElementZ(decoder); |
782 case SerializedElementKind.INSTANCE_FUNCTION: | 785 case SerializedElementKind.INSTANCE_FUNCTION: |
783 return new InstanceFunctionElementZ(decoder); | 786 return new InstanceFunctionElementZ(decoder); |
784 case SerializedElementKind.LOCAL_FUNCTION: | 787 case SerializedElementKind.LOCAL_FUNCTION: |
785 return new LocalFunctionElementZ(decoder); | 788 return new LocalFunctionElementZ(decoder); |
786 case SerializedElementKind.TOPLEVEL_GETTER: | 789 case SerializedElementKind.TOPLEVEL_GETTER: |
787 return new TopLevelGetterElementZ(decoder); | 790 return new TopLevelGetterElementZ(decoder); |
(...skipping 25 matching lines...) Expand all Loading... |
813 return new LocalVariableElementZ(decoder); | 816 return new LocalVariableElementZ(decoder); |
814 case SerializedElementKind.EXTERNAL_LIBRARY: | 817 case SerializedElementKind.EXTERNAL_LIBRARY: |
815 case SerializedElementKind.EXTERNAL_LIBRARY_MEMBER: | 818 case SerializedElementKind.EXTERNAL_LIBRARY_MEMBER: |
816 case SerializedElementKind.EXTERNAL_CLASS_MEMBER: | 819 case SerializedElementKind.EXTERNAL_CLASS_MEMBER: |
817 case SerializedElementKind.EXTERNAL_CONSTRUCTOR: | 820 case SerializedElementKind.EXTERNAL_CONSTRUCTOR: |
818 break; | 821 break; |
819 } | 822 } |
820 throw new UnsupportedError("Unexpected element kind '${elementKind}."); | 823 throw new UnsupportedError("Unexpected element kind '${elementKind}."); |
821 } | 824 } |
822 } | 825 } |
OLD | NEW |