Skip to content

Commit 9f750ca

Browse files
Dmitry Stefantsovcommit-bot@chromium.org
Dmitry Stefantsov
authored andcommitted
[cfe] Add flags field to Extension and use it for 'extension type'
TEST=Checked by existing tests. Change-Id: I436c0322124165f52195ebef402d7ab9104bbb30 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/198763 Commit-Queue: Dmitry Stefantsov <[email protected]> Reviewed-by: Jens Johansen <[email protected]>
1 parent c9cb86e commit 9f750ca

File tree

8 files changed

+27
-4
lines changed

8 files changed

+27
-4
lines changed

pkg/kernel/binary.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ type CanonicalName {
147147

148148
type ComponentFile {
149149
UInt32 magic = 0x90ABCDEF;
150-
UInt32 formatVersion = 64;
150+
UInt32 formatVersion = 65;
151151
Byte[10] shortSdkHash;
152152
List<String> problemsAsJson; // Described in problems.md.
153153
Library[] libraries;
@@ -343,6 +343,7 @@ type Extension extends Node {
343343
List<Expression> annotations;
344344
UriReference fileUri;
345345
FileOffset fileOffset;
346+
Byte flags (isExtensionTypeDeclaration);
346347
List<TypeParameter> typeParameters;
347348
DartType onType;
348349
List<ExtensionMemberDescriptor> members;

pkg/kernel/lib/ast.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,6 +1522,11 @@ class Extension extends NamedNode implements Annotatable, FileUriNode {
15221522
@override
15231523
List<Expression> annotations = const <Expression>[];
15241524

1525+
// Must match serialized bit positions.
1526+
static const int FlagExtensionTypeDeclaration = 1 << 0;
1527+
1528+
int flags = 0;
1529+
15251530
@override
15261531
void addAnnotation(Expression node) {
15271532
if (annotations.isEmpty) {
@@ -1553,6 +1558,16 @@ class Extension extends NamedNode implements Annotatable, FileUriNode {
15531558

15541559
Library get enclosingLibrary => parent as Library;
15551560

1561+
bool get isExtensionTypeDeclaration {
1562+
return flags & FlagExtensionTypeDeclaration != 0;
1563+
}
1564+
1565+
void set isExtensionTypeDeclaration(bool value) {
1566+
flags = value
1567+
? (flags | FlagExtensionTypeDeclaration)
1568+
: (flags & ~FlagExtensionTypeDeclaration);
1569+
}
1570+
15561571
@override
15571572
R accept<R>(TreeVisitor<R> v) => v.visitExtension(this);
15581573

pkg/kernel/lib/binary/ast_from_binary.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,6 +1416,8 @@ class BinaryBuilder {
14161416

14171417
node.fileOffset = readOffset();
14181418

1419+
node.flags = readByte();
1420+
14191421
readAndPushTypeParameterList(node.typeParameters, node);
14201422
DartType onType = readDartType();
14211423
typeParameterStack.length = 0;

pkg/kernel/lib/binary/ast_to_binary.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2436,6 +2436,7 @@ class BinaryPrinter implements Visitor<void>, BinarySink {
24362436
writeAnnotationList(node.annotations);
24372437
writeUriReference(node.fileUri);
24382438
writeOffset(node.fileOffset);
2439+
writeByte(node.flags);
24392440

24402441
enterScope(typeParameters: node.typeParameters);
24412442
writeNodeList(node.typeParameters);

pkg/kernel/lib/binary/tag.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ class Tag {
174174
/// Internal version of kernel binary format.
175175
/// Bump it when making incompatible changes in kernel binaries.
176176
/// Keep in sync with runtime/vm/kernel_binary.h, pkg/kernel/binary.md.
177-
static const int BinaryFormatVersion = 64;
177+
static const int BinaryFormatVersion = 65;
178178
}
179179

180180
abstract class ConstantTag {

pkg/kernel/lib/text/ast_to_text.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,6 +1337,9 @@ class Printer extends Visitor<void> with VisitorVoidMixin {
13371337
writeAnnotationList(node.annotations);
13381338
writeIndentation();
13391339
writeWord('extension');
1340+
if (node.isExtensionTypeDeclaration) {
1341+
writeWord('type');
1342+
}
13401343
writeWord(getExtensionName(node));
13411344
writeTypeParameterList(node.typeParameters);
13421345
writeSpaced('on');

runtime/vm/kernel_binary.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ namespace kernel {
2020
static const uint32_t kMagicProgramFile = 0x90ABCDEFu;
2121

2222
// Both version numbers are inclusive.
23-
static const uint32_t kMinSupportedKernelFormatVersion = 64;
24-
static const uint32_t kMaxSupportedKernelFormatVersion = 64;
23+
static const uint32_t kMinSupportedKernelFormatVersion = 65;
24+
static const uint32_t kMaxSupportedKernelFormatVersion = 65;
2525

2626
// Keep in sync with package:kernel/lib/binary/tag.dart
2727
#define KERNEL_TAG_LIST(V) \

runtime/vm/kernel_loader.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,6 +1187,7 @@ void KernelLoader::FinishTopLevelClassLoading(
11871187
helper_.SkipListOfExpressions(); // skip annotations.
11881188
helper_.ReadUInt(); // read source uri index.
11891189
helper_.ReadPosition(); // read file offset.
1190+
helper_.ReadByte(); // skip flags.
11901191
helper_.SkipTypeParametersList(); // skip type parameter list.
11911192
helper_.SkipDartType(); // skip on-type.
11921193

0 commit comments

Comments
 (0)