| Index: runtime/vm/object.cc
|
| diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
|
| index d4bdb64ca90fc5fb24f7852c93542044173621bd..8fcd9c0198b7c0f4af13597aa22aa6cbeeeeb219 100644
|
| --- a/runtime/vm/object.cc
|
| +++ b/runtime/vm/object.cc
|
| @@ -397,6 +397,9 @@ void Object::Init(Isolate* isolate) {
|
| cls = Class::New<Bool>();
|
| object_store->set_bool_class(cls);
|
|
|
| + cls = Class::New<ByteBuffer>();
|
| + object_store->set_byte_buffer_class(cls);
|
| +
|
| cls = Class::New<UnhandledException>();
|
| object_store->set_unhandled_exception_class(cls);
|
|
|
| @@ -527,6 +530,12 @@ void Object::Init(Isolate* isolate) {
|
| cls.set_script(script);
|
| core_lib.AddClass(cls);
|
|
|
| + name = String::NewSymbol("ByteBuffer");
|
| + cls = object_store->byte_buffer_class();
|
| + cls.set_name(name);
|
| + cls.set_script(script);
|
| + core_lib.AddClass(cls);
|
| +
|
| name = String::NewSymbol("Function");
|
| cls = Class::NewInterface(name, script);
|
| core_lib.AddClass(cls);
|
| @@ -625,6 +634,9 @@ void Object::InitFromSnapshot(Isolate* isolate) {
|
| cls = Class::New<ImmutableArray>();
|
| object_store->set_immutable_array_class(cls);
|
|
|
| + cls = Class::New<ByteBuffer>();
|
| + object_store->set_byte_buffer_class(cls);
|
| +
|
| cls = Class::New<Instance>();
|
| object_store->set_object_class(cls);
|
|
|
| @@ -1109,6 +1121,9 @@ RawClass* Class::GetClass(ObjectKind kind) {
|
| case kImmutableArray:
|
| ASSERT(object_store->immutable_array_class() != Class::null());
|
| return object_store->immutable_array_class();
|
| + case kByteBuffer:
|
| + ASSERT(object_store->byte_buffer_class() != Class::null());
|
| + return object_store->byte_buffer_class();
|
| case kStacktrace:
|
| ASSERT(object_store->stacktrace_class() != Class::null());
|
| return object_store->stacktrace_class();
|
| @@ -6642,6 +6657,53 @@ const char* ImmutableArray::ToCString() const {
|
| }
|
|
|
|
|
| +RawByteBuffer* ByteBuffer::New(uint8_t* data,
|
| + intptr_t len,
|
| + Heap::Space space) {
|
| + Isolate* isolate = Isolate::Current();
|
| + const Class& byte_buffer_class =
|
| + Class::Handle(isolate->object_store()->byte_buffer_class());
|
| + ByteBuffer& result = ByteBuffer::Handle();
|
| + {
|
| + RawObject* raw = Object::Allocate(byte_buffer_class,
|
| + ByteBuffer::InstanceSize(),
|
| + space);
|
| + NoGCScope no_gc;
|
| + result ^= raw;
|
| + result.SetLength(len);
|
| + result.SetData(data);
|
| + }
|
| + return result.raw();
|
| +}
|
| +
|
| +
|
| +bool ByteBuffer::Equals(const Instance& other) const {
|
| + if (this->raw() == other.raw()) {
|
| + // Both handles point to the same raw instance.
|
| + return true;
|
| + }
|
| +
|
| + if (!other.IsByteBuffer() || other.IsNull()) {
|
| + return false;
|
| + }
|
| +
|
| + ByteBuffer& other_array = ByteBuffer::Handle();
|
| + other_array ^= other.raw();
|
| +
|
| + intptr_t len = this->Length();
|
| + if (len != other_array.Length()) {
|
| + return false;
|
| + }
|
| +
|
| + return !memcmp(this->Addr<uint8_t>(0), other_array.Addr<uint8_t>(0), len);
|
| +}
|
| +
|
| +
|
| +const char* ByteBuffer::ToCString() const {
|
| + return "ByteBuffer";
|
| +}
|
| +
|
| +
|
| RawClosure* Closure::New(const Function& function,
|
| const Context& context,
|
| Heap::Space space) {
|
|
|