Add fileEndOffset to Class.
R=ahe@google.com, kmillikin@google.com, paulberry@google.com, sigmund@google.com
BUG=
Review-Url: https://codereview.chromium.org/2971903006 .
diff --git a/pkg/kernel/binary.md b/pkg/kernel/binary.md
index 30c4801..df21664 100644
--- a/pkg/kernel/binary.md
+++ b/pkg/kernel/binary.md
@@ -223,6 +223,7 @@
Byte tag = 2;
CanonicalNameReference canonicalName;
FileOffset fileOffset;
+ FileOffset fileEndOffset;
Byte flags (isAbstract, xx); // Where xx is index into ClassLevel
StringReference name;
// An absolute path URI to the .dart file from which the class was created.
diff --git a/pkg/kernel/lib/ast.dart b/pkg/kernel/lib/ast.dart
index d477cdd..97326fc 100644
--- a/pkg/kernel/lib/ast.dart
+++ b/pkg/kernel/lib/ast.dart
@@ -585,6 +585,11 @@
/// rule directly, as doing so can obstruct transformations. It is possible to
/// transform a mixin application to become a regular class, and vice versa.
class Class extends NamedNode {
+ /// End offset in the source file it comes from. Valid values are from 0 and
+ /// up, or -1 ([TreeNode.noOffset]) if the file end offset is not available
+ /// (this is the default if none is specifically set).
+ int fileEndOffset = TreeNode.noOffset;
+
/// Offset of the declaration, set and used when writing the binary.
int binaryOffset = -1;
diff --git a/pkg/kernel/lib/binary/ast_from_binary.dart b/pkg/kernel/lib/binary/ast_from_binary.dart
index 9923be8..3542370 100644
--- a/pkg/kernel/lib/binary/ast_from_binary.dart
+++ b/pkg/kernel/lib/binary/ast_from_binary.dart
@@ -445,6 +445,7 @@
node = new Class(reference: reference)..level = ClassLevel.Temporary;
}
node.fileOffset = readOffset();
+ node.fileEndOffset = readOffset();
int flags = readByte();
node.isAbstract = flags & 0x1 != 0;
int levelIndex = (flags >> 1) & 0x3;
diff --git a/pkg/kernel/lib/binary/ast_to_binary.dart b/pkg/kernel/lib/binary/ast_to_binary.dart
index 7e09228..bf53b15 100644
--- a/pkg/kernel/lib/binary/ast_to_binary.dart
+++ b/pkg/kernel/lib/binary/ast_to_binary.dart
@@ -378,6 +378,7 @@
writeByte(Tag.Class);
writeCanonicalNameReference(getCanonicalNameOfClass(node));
writeOffset(node.fileOffset);
+ writeOffset(node.fileEndOffset);
writeByte(flags);
writeStringReference(node.name ?? '');
writeUriReference(node.fileUri ?? '');
diff --git a/runtime/vm/kernel_binary_flowgraph.h b/runtime/vm/kernel_binary_flowgraph.h
index c645744..9d7f15c 100644
--- a/runtime/vm/kernel_binary_flowgraph.h
+++ b/runtime/vm/kernel_binary_flowgraph.h
@@ -1198,6 +1198,7 @@
kStart, // tag.
kCanonicalName,
kPosition,
+ kEndPosition,
kIsAbstract,
kNameIndex,
kSourceUriIndex,
@@ -1238,6 +1239,9 @@
case kPosition:
position_ = builder_->ReadPosition(false); // read position.
if (++next_read_ == field) return;
+ case kEndPosition:
+ end_position_ = builder_->ReadPosition(); // read end position.
+ if (++next_read_ == field) return;
case kIsAbstract:
is_abstract_ = builder_->ReadBool(); // read is_abstract.
if (++next_read_ == field) return;
@@ -1314,6 +1318,7 @@
NameIndex canonical_name_;
TokenPosition position_;
+ TokenPosition end_position_;
bool is_abstract_;
StringIndex name_index_;
intptr_t source_uri_index_;