Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: pkg/compiler/lib/src/serialization/element_serialization.dart

Issue 2603263002: Prefix resolution_types with Resolution. (Closed)
Patch Set: Rebased Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 '../elements/resolution_types.dart'; 10 import '../elements/resolution_types.dart';
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 EXTERNAL_LIBRARY, 64 EXTERNAL_LIBRARY,
65 EXTERNAL_LIBRARY_MEMBER, 65 EXTERNAL_LIBRARY_MEMBER,
66 EXTERNAL_CLASS_MEMBER, 66 EXTERNAL_CLASS_MEMBER,
67 EXTERNAL_CONSTRUCTOR, 67 EXTERNAL_CONSTRUCTOR,
68 } 68 }
69 69
70 /// Set of serializers used to serialize different kinds of elements by 70 /// Set of serializers used to serialize different kinds of elements by
71 /// encoding into them into [ObjectEncoder]s. 71 /// encoding into them into [ObjectEncoder]s.
72 /// 72 ///
73 /// This class is called from the [Serializer] when an [Element] needs 73 /// This class is called from the [Serializer] when an [Element] needs
74 /// serialization. The [ObjectEncoder] ensures that any [Element], [DartType], 74 /// serialization. The [ObjectEncoder] ensures that any [Element],
75 /// and [ConstantExpression] that the serialized [Element] depends upon are also 75 /// [ResolutionDartType], and [ConstantExpression] that the serialized [Element]
76 /// serialized. 76 /// depends upon are also serialized.
77 const List<ElementSerializer> ELEMENT_SERIALIZERS = const [ 77 const List<ElementSerializer> ELEMENT_SERIALIZERS = const [
78 const ErrorSerializer(), 78 const ErrorSerializer(),
79 const LibrarySerializer(), 79 const LibrarySerializer(),
80 const CompilationUnitSerializer(), 80 const CompilationUnitSerializer(),
81 const PrefixSerializer(), 81 const PrefixSerializer(),
82 const DeferredLoadLibrarySerializer(), 82 const DeferredLoadLibrarySerializer(),
83 const ClassSerializer(), 83 const ClassSerializer(),
84 const ConstructorSerializer(), 84 const ConstructorSerializer(),
85 const FieldSerializer(), 85 const FieldSerializer(),
86 const FunctionSerializer(), 86 const FunctionSerializer(),
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 } 172 }
173 } else { 173 } else {
174 encoder.setElement(Key.LIBRARY, element.library); 174 encoder.setElement(Key.LIBRARY, element.library);
175 encoder.setElement(Key.COMPILATION_UNIT, element.compilationUnit); 175 encoder.setElement(Key.COMPILATION_UNIT, element.compilationUnit);
176 } 176 }
177 } 177 }
178 178
179 /// Serialize the parameters of [element] into [encoder]. 179 /// Serialize the parameters of [element] into [encoder].
180 static void serializeParameters( 180 static void serializeParameters(
181 FunctionElement element, ObjectEncoder encoder) { 181 FunctionElement element, ObjectEncoder encoder) {
182 FunctionType type = element.type; 182 ResolutionFunctionType type = element.type;
183 encoder.setType(Key.RETURN_TYPE, type.returnType); 183 encoder.setType(Key.RETURN_TYPE, type.returnType);
184 encoder.setElements(Key.PARAMETERS, element.parameters); 184 encoder.setElements(Key.PARAMETERS, element.parameters);
185 } 185 }
186 186
187 /// Returns a function that adds the underlying declared elements for a 187 /// Returns a function that adds the underlying declared elements for a
188 /// particular element into [set]. 188 /// particular element into [set].
189 /// 189 ///
190 /// For instance, for an [AbstractFieldElement] the getter and setter elements 190 /// For instance, for an [AbstractFieldElement] the getter and setter elements
191 /// are added, if available. 191 /// are added, if available.
192 static flattenElements(Set<Element> set) { 192 static flattenElements(Set<Element> set) {
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 encoder.setBool(Key.IS_ABSTRACT, element.isAbstract); 413 encoder.setBool(Key.IS_ABSTRACT, element.isAbstract);
414 SerializerUtil.serializeMembers(getMembers(element), encoder); 414 SerializerUtil.serializeMembers(getMembers(element), encoder);
415 encoder.setBool(Key.IS_PROXY, element.isProxy); 415 encoder.setBool(Key.IS_PROXY, element.isProxy);
416 encoder.setBool(Key.IS_INJECTED, element.isInjected); 416 encoder.setBool(Key.IS_INJECTED, element.isInjected);
417 if (kind == SerializedElementKind.ENUM) { 417 if (kind == SerializedElementKind.ENUM) {
418 EnumClassElement enumClass = element; 418 EnumClassElement enumClass = element;
419 encoder.setElements(Key.FIELDS, enumClass.enumValues); 419 encoder.setElements(Key.FIELDS, enumClass.enumValues);
420 } 420 }
421 if (element.isObject) return; 421 if (element.isObject) return;
422 422
423 List<InterfaceType> mixins = <InterfaceType>[]; 423 List<ResolutionInterfaceType> mixins = <ResolutionInterfaceType>[];
424 ClassElement superclass = element.superclass; 424 ClassElement superclass = element.superclass;
425 while (superclass.isUnnamedMixinApplication) { 425 while (superclass.isUnnamedMixinApplication) {
426 MixinApplicationElement mixinElement = superclass; 426 MixinApplicationElement mixinElement = superclass;
427 mixins.add(element.thisType.asInstanceOf(mixinElement.mixin)); 427 mixins.add(element.thisType.asInstanceOf(mixinElement.mixin));
428 superclass = mixinElement.superclass; 428 superclass = mixinElement.superclass;
429 } 429 }
430 mixins = mixins.reversed.toList(); 430 mixins = mixins.reversed.toList();
431 InterfaceType supertype = element.thisType.asInstanceOf(superclass); 431 ResolutionInterfaceType supertype =
432 element.thisType.asInstanceOf(superclass);
432 433
433 encoder.setType(Key.SUPERTYPE, supertype); 434 encoder.setType(Key.SUPERTYPE, supertype);
434 encoder.setTypes(Key.MIXINS, mixins); 435 encoder.setTypes(Key.MIXINS, mixins);
435 encoder.setTypes(Key.INTERFACES, element.interfaces.toList()); 436 encoder.setTypes(Key.INTERFACES, element.interfaces.toList());
436 FunctionType callType = element.declaration.callType; 437 ResolutionFunctionType callType = element.declaration.callType;
437 if (callType != null) { 438 if (callType != null) {
438 encoder.setType(Key.CALL_TYPE, element.callType); 439 encoder.setType(Key.CALL_TYPE, element.callType);
439 } 440 }
440 441
441 if (element.isMixinApplication) { 442 if (element.isMixinApplication) {
442 MixinApplicationElement mixinElement = element; 443 MixinApplicationElement mixinElement = element;
443 encoder.setType(Key.MIXIN, mixinElement.mixinType); 444 encoder.setType(Key.MIXIN, mixinElement.mixinType);
444 } 445 }
445 } 446 }
446 } 447 }
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 } 842 }
842 843
843 /// Utility class for deserializing [Element]s. 844 /// Utility class for deserializing [Element]s.
844 /// 845 ///
845 /// This is used by the [Deserializer]. 846 /// This is used by the [Deserializer].
846 class ElementDeserializer { 847 class ElementDeserializer {
847 /// Deserializes an [Element] from an [ObjectDecoder]. 848 /// Deserializes an [Element] from an [ObjectDecoder].
848 /// 849 ///
849 /// The class is called from the [Deserializer] when an [Element] 850 /// The class is called from the [Deserializer] when an [Element]
850 /// needs deserialization. The [ObjectDecoder] ensures that any [Element], 851 /// needs deserialization. The [ObjectDecoder] ensures that any [Element],
851 /// [DartType], and [ConstantExpression] that the deserialized [Element] 852 /// [ResolutionDartType], and [ConstantExpression] that the deserialized
852 /// depends upon are available. 853 /// [Element] depends upon are available.
853 static Element deserialize( 854 static Element deserialize(
854 ObjectDecoder decoder, SerializedElementKind elementKind) { 855 ObjectDecoder decoder, SerializedElementKind elementKind) {
855 switch (elementKind) { 856 switch (elementKind) {
856 case SerializedElementKind.ERROR: 857 case SerializedElementKind.ERROR:
857 Element enclosing = decoder.getElement(Key.ENCLOSING); 858 Element enclosing = decoder.getElement(Key.ENCLOSING);
858 String name = decoder.getString(Key.NAME); 859 String name = decoder.getString(Key.NAME);
859 MessageKind messageKind = 860 MessageKind messageKind =
860 decoder.getEnum(Key.MESSAGE_KIND, MessageKind.values); 861 decoder.getEnum(Key.MESSAGE_KIND, MessageKind.values);
861 Map<String, String> arguments = 862 Map<String, String> arguments =
862 deserializeMessageArguments(decoder, Key.ARGUMENTS); 863 deserializeMessageArguments(decoder, Key.ARGUMENTS);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 enclosingElement, existingElement, newElement); 950 enclosingElement, existingElement, newElement);
950 case SerializedElementKind.EXTERNAL_LIBRARY: 951 case SerializedElementKind.EXTERNAL_LIBRARY:
951 case SerializedElementKind.EXTERNAL_LIBRARY_MEMBER: 952 case SerializedElementKind.EXTERNAL_LIBRARY_MEMBER:
952 case SerializedElementKind.EXTERNAL_CLASS_MEMBER: 953 case SerializedElementKind.EXTERNAL_CLASS_MEMBER:
953 case SerializedElementKind.EXTERNAL_CONSTRUCTOR: 954 case SerializedElementKind.EXTERNAL_CONSTRUCTOR:
954 break; 955 break;
955 } 956 }
956 throw new UnsupportedError("Unexpected element kind '${elementKind}."); 957 throw new UnsupportedError("Unexpected element kind '${elementKind}.");
957 } 958 }
958 } 959 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/serialization/constant_serialization.dart ('k') | pkg/compiler/lib/src/serialization/equivalence.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698