mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 08:24:39 +00:00
[vm] Initial vm-service support for records
TEST=ci Issue: https://github.com/dart-lang/sdk/issues/49724 Change-Id: I8012390db004d3b9dd52a460a04bce79af3df365 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/259881 Reviewed-by: Ben Konyi <bkonyi@google.com> Commit-Queue: Alexander Markov <alexmarkov@google.com>
This commit is contained in:
parent
fb29df7fdc
commit
d6b3b8a6be
|
@ -1243,7 +1243,7 @@ void FunctionType::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
|||
void RecordType::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
||||
JSONObject jsobj(stream);
|
||||
PrintSharedInstanceJSON(&jsobj, ref);
|
||||
jsobj.AddProperty("kind", "RecordType");
|
||||
jsobj.AddProperty("kind", "_RecordType");
|
||||
|
||||
{
|
||||
JSONArray arr(&jsobj, "fields");
|
||||
|
@ -1258,6 +1258,8 @@ void RecordType::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
|||
if (i >= num_positional_fields) {
|
||||
name = FieldNameAt(i - num_positional_fields);
|
||||
field.AddProperty("name", name.ToCString());
|
||||
} else {
|
||||
field.AddProperty("pos", i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1643,8 +1645,43 @@ void Closure::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
|||
}
|
||||
|
||||
void Record::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
||||
Instance::PrintJSONImpl(stream, ref);
|
||||
// TODO(dartbug.com/49724)
|
||||
JSONObject jsobj(stream);
|
||||
PrintSharedInstanceJSON(&jsobj, ref);
|
||||
jsobj.AddProperty("kind", "_Record");
|
||||
jsobj.AddProperty("numFields", num_fields());
|
||||
jsobj.AddServiceId(*this);
|
||||
if (ref) {
|
||||
return;
|
||||
}
|
||||
intptr_t offset;
|
||||
intptr_t count;
|
||||
stream->ComputeOffsetAndCount(num_fields(), &offset, &count);
|
||||
if (offset > 0) {
|
||||
jsobj.AddProperty("offset", offset);
|
||||
}
|
||||
if (count < num_fields()) {
|
||||
jsobj.AddProperty("count", count);
|
||||
}
|
||||
intptr_t limit = offset + count;
|
||||
ASSERT(limit <= num_fields());
|
||||
{
|
||||
JSONArray jsarr(&jsobj, "fields");
|
||||
Object& obj = Object::Handle();
|
||||
String& name = String::Handle();
|
||||
const intptr_t num_positional_fields = NumPositionalFields();
|
||||
const Array& field_names = Array::Handle(this->field_names());
|
||||
for (intptr_t index = offset; index < limit; ++index) {
|
||||
JSONObject field(&jsarr);
|
||||
obj = FieldAt(index);
|
||||
field.AddProperty("value", obj);
|
||||
if (index >= num_positional_fields) {
|
||||
name ^= field_names.At(index - num_positional_fields);
|
||||
field.AddProperty("name", name);
|
||||
} else {
|
||||
field.AddProperty("pos", index);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StackTrace::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
||||
|
|
Loading…
Reference in a new issue