Skip to content

Commit

Permalink
[cfe] Add support for classes to round-trip text serialization
Browse files Browse the repository at this point in the history
Supplementary changes for handling Classes done in this CL are the
following:

  * handling Supertypes
  * handling Constructors
  * handling remaining kinds of Procedure
  * serializing AsyncMarker the same way as flags
  * eliminating the need to wrap flags into IntLiteral

Change-Id: Id69c6e37f093cf80206f4657b649f79c75484775
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154000
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
  • Loading branch information
Dmitry Stefantsov authored and commit-bot@chromium.org committed Jul 10, 2020
1 parent b6d14a9 commit 060d948
Show file tree
Hide file tree
Showing 4 changed files with 239 additions and 245 deletions.
2 changes: 1 addition & 1 deletion pkg/kernel/lib/text/serializer_combinators.dart
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class UriSerializer extends TextSerializer<Uri> {
// They require a function mapping serializables to a tag string. This is
// implemented by Tagger visitors.
// A tagged union of serializer/deserializers.
class Case<T extends Node> extends TextSerializer<T> {
class Case<T> extends TextSerializer<T> {
final Tagger<T> tagger;
final List<String> _tags;
final List<TextSerializer<T>> _serializers;
Expand Down
10 changes: 4 additions & 6 deletions pkg/kernel/lib/text/text_serialization_verifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -325,19 +325,13 @@ class VerificationState {
static bool isSupported(Node node) => !isNotSupported(node);

static bool isNotSupported(Node node) =>
node is FunctionNode && node.body == null ||
node is Procedure &&
(!node.isStatic || node.kind != ProcedureKind.Method) ||
node is Class ||
node is Component ||
node is Constructor ||
node is Extension ||
node is Library ||
node is LibraryPart ||
node is MapEntry ||
node is Name && node.isPrivate ||
node is RedirectingFactoryConstructor ||
node is Supertype ||
node is Typedef;
}

Expand Down Expand Up @@ -485,6 +479,10 @@ class TextSerializationVerifier extends RecursiveVisitor<void> {
makeRoundTrip<SwitchCase>(node, switchCaseSerializer);
} else if (node is Initializer) {
makeRoundTrip<Initializer>(node, initializerSerializer);
} else if (node is Supertype) {
makeRoundTrip<Supertype>(node, supertypeSerializer);
} else if (node is Class) {
makeRoundTrip<Class>(node, classSerializer);
} else {
throw new StateError(
"Don't know how to make a round trip for a supported node "
Expand Down
Loading

0 comments on commit 060d948

Please sign in to comment.