Skip to content

Commit 060d948

Browse files
Dmitry Stefantsovcommit-bot@chromium.org
authored andcommitted
[cfe] Add support for classes to round-trip text serialization
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 <[email protected]> Commit-Queue: Dmitry Stefantsov <[email protected]>
1 parent b6d14a9 commit 060d948

File tree

4 files changed

+239
-245
lines changed

4 files changed

+239
-245
lines changed

pkg/kernel/lib/text/serializer_combinators.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ class UriSerializer extends TextSerializer<Uri> {
230230
// They require a function mapping serializables to a tag string. This is
231231
// implemented by Tagger visitors.
232232
// A tagged union of serializer/deserializers.
233-
class Case<T extends Node> extends TextSerializer<T> {
233+
class Case<T> extends TextSerializer<T> {
234234
final Tagger<T> tagger;
235235
final List<String> _tags;
236236
final List<TextSerializer<T>> _serializers;

pkg/kernel/lib/text/text_serialization_verifier.dart

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -325,19 +325,13 @@ class VerificationState {
325325
static bool isSupported(Node node) => !isNotSupported(node);
326326

327327
static bool isNotSupported(Node node) =>
328-
node is FunctionNode && node.body == null ||
329-
node is Procedure &&
330-
(!node.isStatic || node.kind != ProcedureKind.Method) ||
331-
node is Class ||
332328
node is Component ||
333-
node is Constructor ||
334329
node is Extension ||
335330
node is Library ||
336331
node is LibraryPart ||
337332
node is MapEntry ||
338333
node is Name && node.isPrivate ||
339334
node is RedirectingFactoryConstructor ||
340-
node is Supertype ||
341335
node is Typedef;
342336
}
343337

@@ -485,6 +479,10 @@ class TextSerializationVerifier extends RecursiveVisitor<void> {
485479
makeRoundTrip<SwitchCase>(node, switchCaseSerializer);
486480
} else if (node is Initializer) {
487481
makeRoundTrip<Initializer>(node, initializerSerializer);
482+
} else if (node is Supertype) {
483+
makeRoundTrip<Supertype>(node, supertypeSerializer);
484+
} else if (node is Class) {
485+
makeRoundTrip<Class>(node, classSerializer);
488486
} else {
489487
throw new StateError(
490488
"Don't know how to make a round trip for a supported node "

0 commit comments

Comments
 (0)