Commit 239a58de authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

Refactor !foo.IsJust to foo.IsNothing()

BUG=v8:6921

Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_chromium_rel_ng
Change-Id: Id29a5562b1551e78f60129216fdc2c209e585e43
Reviewed-on: https://chromium-review.googlesource.com/452381Reviewed-by: 's avatarAlexei Filippov <alph@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Mathias Bynens <mathias@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48848}
parent 4a24ab21
......@@ -2798,7 +2798,7 @@ MaybeLocal<Value> v8::TryCatch::StackTrace(Local<Context> context) const {
i::Handle<i::JSObject> obj(i::JSObject::cast(raw_obj), isolate_);
i::Handle<i::String> name = isolate->factory()->stack_string();
Maybe<bool> maybe = i::JSReceiver::HasProperty(obj, name);
has_pending_exception = !maybe.IsJust();
has_pending_exception = maybe.IsNothing();
RETURN_ON_FAILED_EXECUTION(Value);
if (!maybe.FromJust()) return v8::Local<Value>();
Local<Value> result;
......
......@@ -773,7 +773,7 @@ bool IterateElementsSlow(Isolate* isolate, Handle<JSReceiver> receiver,
uint32_t length, ArrayConcatVisitor* visitor) {
FOR_WITH_HANDLE_SCOPE(isolate, uint32_t, i = 0, i, i < length, ++i, {
Maybe<bool> maybe = JSReceiver::HasElement(receiver, i);
if (!maybe.IsJust()) return false;
if (maybe.IsNothing()) return false;
if (maybe.FromJust()) {
Handle<Object> element_value;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
......@@ -836,7 +836,7 @@ bool IterateElements(Isolate* isolate, Handle<JSReceiver> receiver,
if (!visitor->visit(j, element_value)) return false;
} else {
Maybe<bool> maybe = JSReceiver::HasElement(array, j);
if (!maybe.IsJust()) return false;
if (maybe.IsNothing()) return false;
if (maybe.FromJust()) {
// Call GetElement on array, not its prototype, or getters won't
// have the correct receiver.
......@@ -871,7 +871,7 @@ bool IterateElements(Isolate* isolate, Handle<JSReceiver> receiver,
if (!visitor->visit(j, element_value)) return false;
} else {
Maybe<bool> maybe = JSReceiver::HasElement(array, j);
if (!maybe.IsJust()) return false;
if (maybe.IsNothing()) return false;
if (maybe.FromJust()) {
// Call GetElement on array, not its prototype, or getters won't
// have the correct receiver.
......
......@@ -234,7 +234,7 @@ Object* DoFunctionBind(Isolate* isolate, BuiltinArguments args) {
Handle<Object> length(Smi::kZero, isolate);
Maybe<PropertyAttributes> attributes =
JSReceiver::GetPropertyAttributes(&length_lookup);
if (!attributes.IsJust()) return isolate->heap()->exception();
if (attributes.IsNothing()) return isolate->heap()->exception();
if (attributes.FromJust() != ABSENT) {
Handle<Object> target_length;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, target_length,
......
......@@ -52,7 +52,7 @@ BUILTIN(ObjectPrototypePropertyIsEnumerable) {
isolate, object, JSReceiver::ToObject(isolate, args.receiver()));
Maybe<PropertyAttributes> maybe =
JSReceiver::GetOwnPropertyAttributes(object, name);
if (!maybe.IsJust()) return isolate->heap()->exception();
if (maybe.IsNothing()) return isolate->heap()->exception();
if (maybe.FromJust() == ABSENT) return isolate->heap()->false_value();
return isolate->heap()->ToBoolean((maybe.FromJust() & DONT_ENUM) == 0);
}
......
......@@ -174,7 +174,7 @@ static Maybe<bool> UnscopableLookup(LookupIterator* it) {
Isolate* isolate = it->isolate();
Maybe<bool> found = JSReceiver::HasProperty(it);
if (!found.IsJust() || !found.FromJust()) return found;
if (found.IsNothing() || !found.FromJust()) return found;
Handle<Object> unscopables;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
......@@ -295,7 +295,7 @@ Handle<Object> Context::Lookup(Handle<String> name, ContextLookupFlags flags,
maybe = JSReceiver::GetPropertyAttributes(object, name);
}
if (!maybe.IsJust()) return Handle<Object>();
if (maybe.IsNothing()) return Handle<Object>();
DCHECK(!isolate->has_pending_exception());
*attributes = maybe.FromJust();
......
......@@ -76,7 +76,8 @@ protocol::Response toProtocolValue(v8::Local<v8::Context> context,
if (name->IsString()) {
v8::Maybe<bool> hasRealNamedProperty = object->HasRealNamedProperty(
context, v8::Local<v8::String>::Cast(name));
if (!hasRealNamedProperty.IsJust() || !hasRealNamedProperty.FromJust())
if (hasRealNamedProperty.IsNothing() ||
!hasRealNamedProperty.FromJust())
continue;
}
v8::Local<v8::String> propertyName;
......
......@@ -4776,7 +4776,7 @@ Maybe<bool> Object::SetPropertyInternal(LookupIterator* it,
} else {
Maybe<PropertyAttributes> maybe_attributes =
JSObject::GetPropertyAttributesWithInterceptor(it);
if (!maybe_attributes.IsJust()) return Nothing<bool>();
if (maybe_attributes.IsNothing()) return Nothing<bool>();
if ((maybe_attributes.FromJust() & READ_ONLY) != 0) {
return WriteToReadOnlyProperty(it, value, should_throw);
}
......@@ -6106,7 +6106,7 @@ Maybe<PropertyAttributes> JSReceiver::GetPropertyAttributes(
case LookupIterator::INTERCEPTOR: {
Maybe<PropertyAttributes> result =
JSObject::GetPropertyAttributesWithInterceptor(it);
if (!result.IsJust()) return result;
if (result.IsNothing()) return result;
if (result.FromJust() != ABSENT) return result;
break;
}
......@@ -6768,7 +6768,7 @@ MaybeHandle<Object> JSReceiver::DefineProperties(Isolate* isolate,
isolate, props, next_key, &success, LookupIterator::OWN);
DCHECK(success);
Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
if (!maybe.IsJust()) return MaybeHandle<Object>();
if (maybe.IsNothing()) return MaybeHandle<Object>();
PropertyAttributes attrs = maybe.FromJust();
// 7c. If propDesc is not undefined and propDesc.[[Enumerable]] is true:
if (attrs == ABSENT) continue;
......@@ -6798,7 +6798,7 @@ MaybeHandle<Object> JSReceiver::DefineProperties(Isolate* isolate,
DefineOwnProperty(isolate, Handle<JSReceiver>::cast(object),
desc->name(), desc, THROW_ON_ERROR);
// 8d. ReturnIfAbrupt(status).
if (!status.IsJust()) return MaybeHandle<Object>();
if (status.IsNothing()) return MaybeHandle<Object>();
CHECK(status.FromJust());
}
// 9. Return o.
......
......@@ -294,7 +294,7 @@ RUNTIME_FUNCTION(Runtime_ObjectHasOwnProperty) {
Maybe<bool> result =
JSReceiver::HasOwnProperty(Handle<JSProxy>::cast(object), key);
if (!result.IsJust()) return isolate->heap()->exception();
if (result.IsNothing()) return isolate->heap()->exception();
return isolate->heap()->ToBoolean(result.FromJust());
} else if (object->IsString()) {
......@@ -467,7 +467,7 @@ RUNTIME_FUNCTION(Runtime_AddNamedProperty) {
DCHECK(!name->ToArrayIndex(&index));
LookupIterator it(object, name, object, LookupIterator::OWN_SKIP_INTERCEPTOR);
Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
if (!maybe.IsJust()) return isolate->heap()->exception();
if (maybe.IsNothing()) return isolate->heap()->exception();
DCHECK(!it.IsFound());
#endif
......@@ -493,7 +493,7 @@ RUNTIME_FUNCTION(Runtime_AddElement) {
LookupIterator it(isolate, object, index, object,
LookupIterator::OWN_SKIP_INTERCEPTOR);
Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
if (!maybe.IsJust()) return isolate->heap()->exception();
if (maybe.IsNothing()) return isolate->heap()->exception();
DCHECK(!it.IsFound());
if (object->IsJSArray()) {
......@@ -598,7 +598,7 @@ RUNTIME_FUNCTION(Runtime_HasProperty) {
// Lookup the {name} on {receiver}.
Maybe<bool> maybe = JSReceiver::HasProperty(receiver, name);
if (!maybe.IsJust()) return isolate->heap()->exception();
if (maybe.IsNothing()) return isolate->heap()->exception();
return isolate->heap()->ToBoolean(maybe.FromJust());
}
......
......@@ -114,7 +114,7 @@ RUNTIME_FUNCTION(Runtime_Equal) {
CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, y, 1);
Maybe<bool> result = Object::Equals(x, y);
if (!result.IsJust()) return isolate->heap()->exception();
if (result.IsNothing()) return isolate->heap()->exception();
return isolate->heap()->ToBoolean(result.FromJust());
}
......@@ -124,7 +124,7 @@ RUNTIME_FUNCTION(Runtime_NotEqual) {
CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, y, 1);
Maybe<bool> result = Object::Equals(x, y);
if (!result.IsJust()) return isolate->heap()->exception();
if (result.IsNothing()) return isolate->heap()->exception();
return isolate->heap()->ToBoolean(!result.FromJust());
}
......@@ -150,7 +150,7 @@ RUNTIME_FUNCTION(Runtime_LessThan) {
CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, y, 1);
Maybe<bool> result = Object::LessThan(x, y);
if (!result.IsJust()) return isolate->heap()->exception();
if (result.IsNothing()) return isolate->heap()->exception();
return isolate->heap()->ToBoolean(result.FromJust());
}
......@@ -160,7 +160,7 @@ RUNTIME_FUNCTION(Runtime_GreaterThan) {
CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, y, 1);
Maybe<bool> result = Object::GreaterThan(x, y);
if (!result.IsJust()) return isolate->heap()->exception();
if (result.IsNothing()) return isolate->heap()->exception();
return isolate->heap()->ToBoolean(result.FromJust());
}
......@@ -170,7 +170,7 @@ RUNTIME_FUNCTION(Runtime_LessThanOrEqual) {
CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, y, 1);
Maybe<bool> result = Object::LessThanOrEqual(x, y);
if (!result.IsJust()) return isolate->heap()->exception();
if (result.IsNothing()) return isolate->heap()->exception();
return isolate->heap()->ToBoolean(result.FromJust());
}
......@@ -180,7 +180,7 @@ RUNTIME_FUNCTION(Runtime_GreaterThanOrEqual) {
CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, y, 1);
Maybe<bool> result = Object::GreaterThanOrEqual(x, y);
if (!result.IsJust()) return isolate->heap()->exception();
if (result.IsNothing()) return isolate->heap()->exception();
return isolate->heap()->ToBoolean(result.FromJust());
}
......
......@@ -69,7 +69,7 @@ Object* DeclareGlobal(
}
LookupIterator it(global, name, global, lookup_config);
Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
if (!maybe.IsJust()) return isolate->heap()->exception();
if (maybe.IsNothing()) return isolate->heap()->exception();
if (it.IsFound()) {
PropertyAttributes old_attributes = maybe.FromJust();
......@@ -684,7 +684,7 @@ static Object* FindNameClash(Handle<ScopeInfo> scope_info,
LookupIterator it(global_object, name, global_object,
LookupIterator::OWN_SKIP_INTERCEPTOR);
Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
if (!maybe.IsJust()) return isolate->heap()->exception();
if (maybe.IsNothing()) return isolate->heap()->exception();
if ((maybe.FromJust() & DONT_DELETE) != 0) {
// ES#sec-globaldeclarationinstantiation 5.a:
// If envRec.HasVarDeclaration(name) is true, throw a SyntaxError
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment