@@ -1599,13 +1599,26 @@ void FlowGraphSerializer::WriteObjectImpl(const Object& x,
1599
1599
break ;
1600
1600
}
1601
1601
case kRecordCid : {
1602
- // TODO(dartbug.com/49719)
1603
- UNIMPLEMENTED ();
1602
+ ASSERT (x.IsCanonical ());
1603
+ const auto & record = Record::Cast (x);
1604
+ const intptr_t num_fields = record.num_fields ();
1605
+ Write<intptr_t >(num_fields);
1606
+ Write<const Array&>(Array::Handle (Z, record.field_names ()));
1607
+ auto & field = Object::Handle (Z);
1608
+ for (intptr_t i = 0 ; i < num_fields; ++i) {
1609
+ field = record.FieldAt (i);
1610
+ Write<const Object&>(field);
1611
+ }
1604
1612
break ;
1605
1613
}
1606
1614
case kRecordTypeCid : {
1607
- // TODO(dartbug.com/49719)
1608
- UNIMPLEMENTED ();
1615
+ const auto & rec = RecordType::Cast (x);
1616
+ ASSERT (rec.IsFinalized ());
1617
+ TypeScope type_scope (this , rec.IsRecursive ());
1618
+ Write<int8_t >(static_cast <int8_t >(rec.nullability ()));
1619
+ Write<const Array&>(Array::Handle (Z, rec.field_names ()));
1620
+ Write<const Array&>(Array::Handle (Z, rec.field_types ()));
1621
+ Write<bool >(type_scope.CanBeCanonicalized ());
1609
1622
break ;
1610
1623
}
1611
1624
case kSentinelCid :
@@ -1869,14 +1882,25 @@ const Object& FlowGraphDeserializer::ReadObjectImpl(intptr_t cid,
1869
1882
Symbols::FromLatin1 (thread (), latin1, length));
1870
1883
}
1871
1884
case kRecordCid : {
1872
- // TODO(dartbug.com/49719)
1873
- UNIMPLEMENTED ();
1874
- break ;
1885
+ const intptr_t num_fields = Read<intptr_t >();
1886
+ const auto & field_names = Read<const Array&>();
1887
+ auto & record =
1888
+ Record::ZoneHandle (Z, Record::New (num_fields, field_names));
1889
+ for (intptr_t i = 0 ; i < num_fields; ++i) {
1890
+ record.SetFieldAt (i, Read<const Object&>());
1891
+ }
1892
+ record ^= record.Canonicalize (thread ());
1893
+ return record;
1875
1894
}
1876
1895
case kRecordTypeCid : {
1877
- // TODO(dartbug.com/49719)
1878
- UNIMPLEMENTED ();
1879
- break ;
1896
+ const Nullability nullability = static_cast <Nullability>(Read<int8_t >());
1897
+ const Array& field_names = Read<const Array&>();
1898
+ const Array& field_types = Read<const Array&>();
1899
+ RecordType& rec = RecordType::ZoneHandle (
1900
+ Z, RecordType::New (field_types, field_names, nullability));
1901
+ rec.SetIsFinalized ();
1902
+ rec ^= MaybeCanonicalize (rec, object_index, Read<bool >());
1903
+ return rec;
1880
1904
}
1881
1905
case kSentinelCid :
1882
1906
return Read<bool >() ? Object::sentinel () : Object::transition_sentinel ();
0 commit comments