Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/v8_py_frontend/object_manipulator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ auto ObjectManipulator::GetIdentityHash(v8::Isolate* isolate,
const v8::Context::Scope context_scope(local_context);

const v8::Local<v8::Value> local_obj_val = obj_ptr->ToValue(local_context);
if (!local_obj_val->IsObject() && !local_obj_val->IsSymbol()) {
return bv_factory_->New("Not an object", type_execute_exception);
}

const v8::Local<v8::Object> local_obj = local_obj_val.As<v8::Object>();

return bv_factory_->New(static_cast<int64_t>(local_obj->GetIdentityHash()),
Expand All @@ -46,6 +50,10 @@ auto ObjectManipulator::GetOwnPropertyNames(v8::Isolate* isolate,
const v8::Context::Scope context_scope(local_context);

const v8::Local<v8::Value> local_obj_val = obj_ptr->ToValue(local_context);
if (!local_obj_val->IsObject() && !local_obj_val->IsSymbol()) {
return bv_factory_->New("Not an object", type_execute_exception);
}

const v8::Local<v8::Object> local_obj = local_obj_val.As<v8::Object>();

const v8::Local<v8::Array> names =
Expand All @@ -63,6 +71,10 @@ auto ObjectManipulator::Get(v8::Isolate* isolate,
const v8::Context::Scope context_scope(local_context);

const v8::Local<v8::Value> local_obj_val = obj_ptr->ToValue(local_context);
if (!local_obj_val->IsObject() && !local_obj_val->IsSymbol()) {
return bv_factory_->New("Not an object", type_execute_exception);
}

const v8::Local<v8::Object> local_obj = local_obj_val.As<v8::Object>();
const v8::Local<v8::Value> local_key = key_ptr->ToValue(local_context);

Expand All @@ -86,6 +98,10 @@ auto ObjectManipulator::Set(v8::Isolate* isolate,
const v8::Context::Scope context_scope(local_context);

const v8::Local<v8::Value> local_obj_val = obj_ptr->ToValue(local_context);
if (!local_obj_val->IsObject() && !local_obj_val->IsSymbol()) {
return bv_factory_->New("Not an object", type_execute_exception);
}

const v8::Local<v8::Object> local_obj = local_obj_val.As<v8::Object>();
const v8::Local<v8::Value> local_key = key_ptr->ToValue(local_context);
const v8::Local<v8::Value> local_value = val_ptr->ToValue(local_context);
Expand All @@ -104,6 +120,10 @@ auto ObjectManipulator::Del(v8::Isolate* isolate,
const v8::Context::Scope context_scope(local_context);

const v8::Local<v8::Value> local_obj_val = obj_ptr->ToValue(local_context);
if (!local_obj_val->IsObject() && !local_obj_val->IsSymbol()) {
return bv_factory_->New("Not an object", type_execute_exception);
}

const v8::Local<v8::Object> local_obj = local_obj_val.As<v8::Object>();
const v8::Local<v8::Value> local_key = key_ptr->ToValue(local_context);

Expand All @@ -126,6 +146,10 @@ auto ObjectManipulator::Splice(v8::Isolate* isolate,
const v8::Context::Scope context_scope(local_context);

const v8::Local<v8::Value> local_obj_val = obj_ptr->ToValue(local_context);
if (!local_obj_val->IsObject()) {
return bv_factory_->New("Not an object", type_execute_exception);
}

const v8::Local<v8::Object> local_obj = local_obj_val.As<v8::Object>();

// Array.prototype.splice doesn't exist in C++ in V8. We have to find the JS
Expand Down
4 changes: 4 additions & 0 deletions src/v8_py_frontend/promise_attacher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ auto PromiseAttacher::AttachPromiseThen(v8::Isolate* isolate,

const v8::Local<v8::Value> local_promise_val =
promise_ptr->ToValue(local_context);
if (!local_promise_val->IsPromise()) {
return bv_factory_->New("Not a promise", type_execute_exception);
}

const v8::Local<v8::Promise> local_promise =
local_promise_val.As<v8::Promise>();

Expand Down