| Index: runtime/vm/object.h
|
| ===================================================================
|
| --- runtime/vm/object.h (revision 20947)
|
| +++ runtime/vm/object.h (working copy)
|
| @@ -3432,6 +3432,7 @@
|
| HEAP_OBJECT_IMPLEMENTATION(Instance, Object);
|
| friend class Class;
|
| friend class Closure;
|
| + friend class TypedDataView;
|
| };
|
|
|
|
|
| @@ -5092,6 +5093,12 @@
|
| intptr_t src_offset_in_bytes,
|
| intptr_t length_in_bytes);
|
|
|
| + static bool IsTypedData(const Instance& obj) {
|
| + ASSERT(!obj.IsNull());
|
| + intptr_t cid = obj.raw()->GetClassId();
|
| + return RawObject::IsTypedDataClassId(cid);
|
| + }
|
| +
|
| protected:
|
| void SetLength(intptr_t value) const {
|
| raw_ptr()->length_ = Smi::New(value);
|
| @@ -5103,6 +5110,7 @@
|
| FINAL_HEAP_OBJECT_IMPLEMENTATION(TypedData, Instance);
|
| friend class Class;
|
| friend class ExternalTypedData;
|
| + friend class TypedDataView;
|
| };
|
|
|
|
|
| @@ -5187,6 +5195,12 @@
|
| intptr_t src_offset_in_bytes,
|
| intptr_t length_in_bytes);
|
|
|
| + static bool IsExternalTypedData(const Instance& obj) {
|
| + ASSERT(!obj.IsNull());
|
| + intptr_t cid = obj.raw()->GetClassId();
|
| + return RawObject::IsExternalTypedDataClassId(cid);
|
| + }
|
| +
|
| protected:
|
| void SetLength(intptr_t value) const {
|
| raw_ptr()->length_ = Smi::New(value);
|
| @@ -5206,6 +5220,71 @@
|
| };
|
|
|
|
|
| +class TypedDataView : public AllStatic {
|
| + public:
|
| + static intptr_t ElementSizeInBytes(const Instance& view_obj) {
|
| + ASSERT(!view_obj.IsNull());
|
| + intptr_t cid = view_obj.raw()->GetClassId();
|
| + return ElementSizeInBytes(cid);
|
| + }
|
| +
|
| + static RawInstance* Data(const Instance& view_obj) {
|
| + ASSERT(!view_obj.IsNull());
|
| + return *reinterpret_cast<RawInstance**>(view_obj.raw_ptr() + kDataOffset);
|
| + }
|
| +
|
| + static RawSmi* OffsetInBytes(const Instance& view_obj) {
|
| + ASSERT(!view_obj.IsNull());
|
| + return *reinterpret_cast<RawSmi**>(
|
| + view_obj.raw_ptr() + kOffsetInBytesOffset);
|
| + }
|
| +
|
| + static RawSmi* Length(const Instance& view_obj) {
|
| + ASSERT(!view_obj.IsNull());
|
| + return *reinterpret_cast<RawSmi**>(view_obj.raw_ptr() + kLengthOffset);
|
| + }
|
| +
|
| + static bool IsExternalTypedDataView(const Instance& view_obj) {
|
| + const Instance& data = Instance::Handle(Data(view_obj));
|
| + intptr_t cid = data.raw()->GetClassId();
|
| + ASSERT(RawObject::IsTypedDataClassId(cid) ||
|
| + RawObject::IsExternalTypedDataClassId(cid));
|
| + return RawObject::IsExternalTypedDataClassId(cid);
|
| + }
|
| +
|
| + static intptr_t NumberOfFields() {
|
| + return (kLengthOffset - kTypeArguments);
|
| + }
|
| +
|
| + static intptr_t data_offset() {
|
| + return kWordSize * kDataOffset;
|
| + }
|
| +
|
| + static intptr_t offset_in_bytes_offset() {
|
| + return kWordSize * kOffsetInBytesOffset;
|
| + }
|
| +
|
| + static intptr_t length_offset() {
|
| + return kWordSize * kLengthOffset;
|
| + }
|
| +
|
| + static intptr_t ElementSizeInBytes(intptr_t class_id) {
|
| + ASSERT(RawObject::IsTypedDataViewClassId(class_id));
|
| + return (class_id == kByteDataViewCid) ?
|
| + TypedData::element_size[kTypedDataInt8ArrayCid] :
|
| + TypedData::element_size[class_id - kTypedDataInt8ArrayViewCid];
|
| + }
|
| +
|
| + private:
|
| + enum {
|
| + kTypeArguments = 1,
|
| + kDataOffset = 2,
|
| + kOffsetInBytesOffset = 3,
|
| + kLengthOffset = 4,
|
| + };
|
| +};
|
| +
|
| +
|
| // DartFunction represents the abstract Dart class 'Function'.
|
| class DartFunction : public Instance {
|
| private:
|
|
|