Files
sdk/pkg/vm/lib/metadata/call_site_attributes.dart
T
Johnni Winther 7fce125300 [cfe,kernel] Add AstPrinter
This CL adds a Node.toText method together with an AstPrinter. These
facility and better toString implementation on AST nodes while allowing
for toString independent printing of AST to use in testing. This also
add support for an integrated toString of custom/internal nodes.

Some work is still needed in bringing the toString implementation on
all nodes to the old quality, and not all internal nodes have
customized textual representations yet. This work is left for future
CLs.

Change-Id: Ib0bf8a0bc02f489dfacdc8aa5f96da9c52f26058
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150923
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2020-06-16 17:15:10 +00:00

45 lines
1.4 KiB
Dart

// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library vm.metadata.call_site_attributes;
import 'package:kernel/ast.dart';
import 'package:kernel/src/printer.dart';
/// Metadata for annotating call sites with various attributes.
class CallSiteAttributesMetadata {
final DartType receiverType;
const CallSiteAttributesMetadata({this.receiverType});
@override
String toString() =>
"receiverType:${receiverType.toText(astTextStrategyForTesting)}";
}
/// Repository for [CallSiteAttributesMetadata].
class CallSiteAttributesMetadataRepository
extends MetadataRepository<CallSiteAttributesMetadata> {
static final repositoryTag = 'vm.call-site-attributes.metadata';
@override
final String tag = repositoryTag;
@override
final Map<TreeNode, CallSiteAttributesMetadata> mapping =
<TreeNode, CallSiteAttributesMetadata>{};
@override
void writeToBinary(
CallSiteAttributesMetadata metadata, Node node, BinarySink sink) {
sink.writeDartType(metadata.receiverType);
}
@override
CallSiteAttributesMetadata readFromBinary(Node node, BinarySource source) {
final type = source.readDartType();
return new CallSiteAttributesMetadata(receiverType: type);
}
}