mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 01:13:04 +00:00
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 .
This commit is contained in:
parent
2c33abdca9
commit
09a5d31ec4
|
@ -223,6 +223,7 @@ abstract type Class extends Node {
|
|||
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.
|
||||
|
|
|
@ -585,6 +585,11 @@ enum ClassLevel {
|
|||
/// 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;
|
||||
|
||||
|
|
|
@ -445,6 +445,7 @@ class BinaryBuilder {
|
|||
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;
|
||||
|
|
|
@ -378,6 +378,7 @@ class BinaryPrinter extends Visitor {
|
|||
writeByte(Tag.Class);
|
||||
writeCanonicalNameReference(getCanonicalNameOfClass(node));
|
||||
writeOffset(node.fileOffset);
|
||||
writeOffset(node.fileEndOffset);
|
||||
writeByte(flags);
|
||||
writeStringReference(node.name ?? '');
|
||||
writeUriReference(node.fileUri ?? '');
|
||||
|
|
|
@ -1198,6 +1198,7 @@ class ClassHelper {
|
|||
kStart, // tag.
|
||||
kCanonicalName,
|
||||
kPosition,
|
||||
kEndPosition,
|
||||
kIsAbstract,
|
||||
kNameIndex,
|
||||
kSourceUriIndex,
|
||||
|
@ -1238,6 +1239,9 @@ class ClassHelper {
|
|||
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 @@ class ClassHelper {
|
|||
|
||||
NameIndex canonical_name_;
|
||||
TokenPosition position_;
|
||||
TokenPosition end_position_;
|
||||
bool is_abstract_;
|
||||
StringIndex name_index_;
|
||||
intptr_t source_uri_index_;
|
||||
|
|
Loading…
Reference in a new issue