class Int32;
class Integer;
class Isolate;
+template <class T>
+class Maybe;
class Name;
class Number;
class NumberObject;
};
-/**
- * A simple Maybe type, representing an object which may or may not have a
- * value.
- */
-template <class T>
-class Maybe {
- public:
- Maybe() : has_value(false) {}
- explicit Maybe(const T& t) : has_value(true), value(t) {}
- // TODO(dcarney): remove this constructor, it makes no sense.
- Maybe(bool has, const T& t) : has_value(has), value(t) {}
-
- V8_INLINE bool HasValue() const { return has_value; }
-
- V8_WARN_UNUSED_RESULT V8_INLINE bool ToValue(T* out) const {
- *out = has_value ? value : T();
- return has_value;
- }
-
- V8_INLINE T ToValueChecked() const {
- // TODO(dcarney): add DCHECK.
- return value;
- }
-
- V8_INLINE T From(const T& default_value) const {
- return has_value ? value : default_value;
- }
-
- // TODO(dcarney): make private.
- bool has_value;
- T value;
-};
-
-
-// Convenience wrapper.
-template <class T>
-inline Maybe<T> maybe(T t) {
- return Maybe<T>(t);
-}
-
-
// --- Special objects ---
int* index);
static Local<Value> GetEternal(Isolate* isolate, int index);
+ static void CheckIsJust(bool is_just);
+
template <class T> friend class Handle;
template <class T> friend class Local;
+ template <class T>
+ friend class Maybe;
template <class T> friend class Eternal;
template <class T> friend class PersistentBase;
template <class T, class M> friend class Persistent;
};
+/**
+ * A simple Maybe type, representing an object which may or may not have a
+ * value.
+ */
+template <class T>
+class Maybe {
+ public:
+ // TODO(dcarney): remove this constructor, it makes no sense.
+ Maybe(bool has, const T& t) : has_value(has), value(t) {}
+
+ V8_INLINE bool IsJust() const { return has_value; }
+
+ V8_INLINE T FromJust() const {
+#ifdef V8_ENABLE_CHECKS
+ V8::CheckIsJust(IsJust());
+#endif
+ return value;
+ }
+
+ V8_INLINE T FromMaybe(const T& default_value) const {
+ return has_value ? value : default_value;
+ }
+
+ // TODO(dcarney): make private.
+ bool has_value;
+ T value;
+
+ private:
+ template <class U>
+ friend Maybe<U> Nothing();
+ template <class U>
+ friend Maybe<U> Just(const U& u);
+
+ Maybe() : has_value(false) {}
+ explicit Maybe(const T& t) : has_value(true), value(t) {}
+};
+
+
+template <class T>
+inline Maybe<T> Nothing() {
+ return Maybe<T>();
+}
+
+
+template <class T>
+inline Maybe<T> Just(const T& t) {
+ return Maybe<T>(t);
+}
+
+
/**
* An external exception handler.
*/
}
+void V8::CheckIsJust(bool is_just) {
+ Utils::ApiCheck(is_just, "v8::FromJust", "Maybe value is Nothing.");
+}
+
+
// --- H a n d l e s ---
Maybe<bool> Value::BooleanValue(Local<Context> context) const {
- return maybe(Utils::OpenHandle(this)->BooleanValue());
+ return Just(Utils::OpenHandle(this)->BooleanValue());
}
Maybe<double> Value::NumberValue(Local<Context> context) const {
auto obj = Utils::OpenHandle(this);
- if (obj->IsNumber()) return maybe(obj->Number());
+ if (obj->IsNumber()) return Just(obj->Number());
CONTEXT_SCOPE_GET_ISOLATE(context, "NumberValue");
EXCEPTION_PREAMBLE(isolate);
i::Handle<i::Object> num;
has_pending_exception = !i::Execution::ToNumber(isolate, obj).ToHandle(&num);
- EXCEPTION_BAILOUT_CHECK(isolate, Maybe<double>());
- return maybe(num->Number());
+ EXCEPTION_BAILOUT_CHECK(isolate, Nothing<double>());
+ return Just(num->Number());
}
auto obj = Utils::OpenHandle(this);
if (obj->IsNumber()) return obj->Number();
return NumberValue(ContextFromHeapObject(obj))
- .From(std::numeric_limits<double>::quiet_NaN());
+ .FromMaybe(std::numeric_limits<double>::quiet_NaN());
}
EXCEPTION_PREAMBLE(isolate);
has_pending_exception =
!i::Execution::ToInteger(isolate, obj).ToHandle(&num);
- EXCEPTION_BAILOUT_CHECK(isolate, Maybe<int64_t>());
- }
- if (num->IsSmi()) {
- return maybe(static_cast<int64_t>(i::Smi::cast(*num)->value()));
- } else {
- return maybe(static_cast<int64_t>(num->Number()));
+ EXCEPTION_BAILOUT_CHECK(isolate, Nothing<int64_t>());
}
+ return Just(num->IsSmi() ? static_cast<int64_t>(i::Smi::cast(*num)->value())
+ : static_cast<int64_t>(num->Number()));
}
return static_cast<int64_t>(obj->Number());
}
}
- return IntegerValue(ContextFromHeapObject(obj)).From(0);
+ return IntegerValue(ContextFromHeapObject(obj)).FromMaybe(0);
}
Maybe<int32_t> Value::Int32Value(Local<Context> context) const {
auto obj = Utils::OpenHandle(this);
- if (obj->IsNumber()) return maybe(NumberToInt32(*obj));
+ if (obj->IsNumber()) return Just(NumberToInt32(*obj));
CONTEXT_SCOPE_GET_ISOLATE(context, "Int32Value");
EXCEPTION_PREAMBLE(isolate);
i::Handle<i::Object> num;
has_pending_exception = !i::Execution::ToInt32(isolate, obj).ToHandle(&num);
- EXCEPTION_BAILOUT_CHECK(isolate, Maybe<int32_t>());
- if (num->IsSmi()) {
- return maybe(i::Smi::cast(*num)->value());
- } else {
- return maybe(static_cast<int32_t>(num->Number()));
- }
+ EXCEPTION_BAILOUT_CHECK(isolate, Nothing<int32_t>());
+ return Just(num->IsSmi() ? i::Smi::cast(*num)->value()
+ : static_cast<int32_t>(num->Number()));
}
int32_t Value::Int32Value() const {
auto obj = Utils::OpenHandle(this);
if (obj->IsNumber()) return NumberToInt32(*obj);
- return Int32Value(ContextFromHeapObject(obj)).From(0);
+ return Int32Value(ContextFromHeapObject(obj)).FromMaybe(0);
}
Maybe<uint32_t> Value::Uint32Value(Local<Context> context) const {
auto obj = Utils::OpenHandle(this);
- if (obj->IsNumber()) return maybe(NumberToUint32(*obj));
+ if (obj->IsNumber()) return Just(NumberToUint32(*obj));
CONTEXT_SCOPE_GET_ISOLATE(context, "Uint32Value");
EXCEPTION_PREAMBLE(isolate);
i::Handle<i::Object> num;
has_pending_exception = !i::Execution::ToUint32(isolate, obj).ToHandle(&num);
- EXCEPTION_BAILOUT_CHECK(isolate, Maybe<uint32_t>());
- if (num->IsSmi()) {
- return maybe(static_cast<uint32_t>(i::Smi::cast(*num)->value()));
- } else {
- return maybe(static_cast<uint32_t>(num->Number()));
- }
+ EXCEPTION_BAILOUT_CHECK(isolate, Nothing<uint32_t>());
+ return Just(num->IsSmi() ? static_cast<uint32_t>(i::Smi::cast(*num)->value())
+ : static_cast<uint32_t>(num->Number()));
}
uint32_t Value::Uint32Value() const {
auto obj = Utils::OpenHandle(this);
if (obj->IsNumber()) return NumberToUint32(*obj);
- return Uint32Value(ContextFromHeapObject(obj)).From(0);
+ return Uint32Value(ContextFromHeapObject(obj)).FromMaybe(0);
}
i::Handle<i::JSReceiver> self = Utils::OpenHandle(this);
i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
EXCEPTION_PREAMBLE(isolate);
- Maybe<bool> maybe;
+ Maybe<bool> maybe = Nothing<bool>();
// Check if the given key is an array index.
uint32_t index;
if (key_obj->ToArrayIndex(&index)) {
static Maybe<PropertyAttribute> GetPropertyAttributesByLookup(
i::LookupIterator* it) {
Maybe<PropertyAttributes> attr = i::JSReceiver::GetPropertyAttributes(it);
- if (!it->IsFound()) return Maybe<PropertyAttribute>();
- return Maybe<PropertyAttribute>(static_cast<PropertyAttribute>(attr.value));
+ return it->IsFound() ? Just<PropertyAttribute>(
+ static_cast<PropertyAttribute>(attr.value))
+ : Nothing<PropertyAttribute>();
}
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
ON_BAILOUT(isolate,
"v8::Object::GetRealNamedPropertyAttributesInPrototypeChain()",
- return Maybe<PropertyAttribute>());
+ return Nothing<PropertyAttribute>());
ENTER_V8(isolate);
i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this);
i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
i::PrototypeIterator iter(isolate, self_obj);
- if (iter.IsAtEnd()) return Maybe<PropertyAttribute>();
+ if (iter.IsAtEnd()) return Nothing<PropertyAttribute>();
i::Handle<i::Object> proto = i::PrototypeIterator::GetCurrent(iter);
i::LookupIterator it(self_obj, key_obj, i::Handle<i::JSReceiver>::cast(proto),
i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
Handle<String> key) {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
ON_BAILOUT(isolate, "v8::Object::GetRealNamedPropertyAttributes()",
- return Maybe<PropertyAttribute>());
+ return Nothing<PropertyAttribute>());
ENTER_V8(isolate);
i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this);
i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
return TypeFeedbackId(local_id(1));
}
Maybe<int> fixed_right_arg() const {
- return has_fixed_right_arg_ ? Maybe<int>(fixed_right_arg_value_)
- : Maybe<int>();
+ return has_fixed_right_arg_ ? Just(fixed_right_arg_value_) : Nothing<int>();
}
void set_fixed_right_arg(Maybe<int> arg) {
has_fixed_right_arg_ = arg.has_value;
MaybeHandle<Object> maybe_unscopables =
Object::GetProperty(receiver, unscopables_symbol);
if (!maybe_unscopables.ToHandle(&unscopables)) {
- return Maybe<PropertyAttributes>();
+ return Nothing<PropertyAttributes>();
}
if (!unscopables->IsSpecObject()) return attrs;
Handle<Object> blacklist;
Object::GetProperty(unscopables, it->name());
if (!maybe_blacklist.ToHandle(&blacklist)) {
DCHECK(isolate->has_pending_exception());
- return Maybe<PropertyAttributes>();
+ return Nothing<PropertyAttributes>();
}
- if (!blacklist->IsUndefined()) return maybe(ABSENT);
- return attrs;
+ return blacklist->IsUndefined() ? attrs : Just(ABSENT);
}
static void GetAttributesAndBindingFlags(VariableMode mode,
// Context extension objects needs to behave as if they have no
// prototype. So even if we want to follow prototype chains, we need
// to only do a local lookup for context extension objects.
- Maybe<PropertyAttributes> maybe;
+ Maybe<PropertyAttributes> maybe = Nothing<PropertyAttributes>();
if ((flags & FOLLOW_PROTOTYPE_CHAIN) == 0 ||
object->IsJSContextExtensionObject()) {
maybe = JSReceiver::GetOwnPropertyAttributes(object, name);
BinaryOpICState::BinaryOpICState(Isolate* isolate, ExtraICState extra_ic_state)
- : isolate_(isolate) {
+ : fixed_right_arg_(Nothing<int>()), isolate_(isolate) {
op_ =
static_cast<Token::Value>(FIRST_TOKEN + OpField::decode(extra_ic_state));
fixed_right_arg_ =
left_kind_(NONE),
right_kind_(NONE),
result_kind_(NONE),
+ fixed_right_arg_(Nothing<int>()),
isolate_(isolate) {
DCHECK_LE(FIRST_TOKEN, op);
DCHECK_LE(op, LAST_TOKEN);
return JSProxy::HasPropertyWithHandler(proxy, name);
}
Maybe<PropertyAttributes> result = GetPropertyAttributes(object, name);
- if (!result.has_value) return Maybe<bool>();
- return maybe(result.value != ABSENT);
+ return result.has_value ? Just(result.value != ABSENT) : Nothing<bool>();
}
return JSProxy::HasPropertyWithHandler(proxy, name);
}
Maybe<PropertyAttributes> result = GetOwnPropertyAttributes(object, name);
- if (!result.has_value) return Maybe<bool>();
- return maybe(result.value != ABSENT);
+ return result.has_value ? Just(result.value != ABSENT) : Nothing<bool>();
}
}
Maybe<PropertyAttributes> result = JSObject::GetElementAttributeWithReceiver(
Handle<JSObject>::cast(object), object, index, true);
- if (!result.has_value) return Maybe<bool>();
- return maybe(result.value != ABSENT);
+ return result.has_value ? Just(result.value != ABSENT) : Nothing<bool>();
}
}
Maybe<PropertyAttributes> result = JSObject::GetElementAttributeWithReceiver(
Handle<JSObject>::cast(object), object, index, false);
- if (!result.has_value) return Maybe<bool>();
- return maybe(result.value != ABSENT);
+ return result.has_value ? Just(result.value != ABSENT) : Nothing<bool>();
}
Handle<JSObject> checked = it->GetHolder<JSObject>();
while (FindAllCanReadHolder(it)) {
if (it->state() == LookupIterator::ACCESSOR) {
- return maybe(it->property_details().attributes());
+ return Just(it->property_details().attributes());
}
DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state());
auto result = GetPropertyAttributesWithInterceptor(
}
it->isolate()->ReportFailedAccessCheck(checked);
RETURN_VALUE_IF_SCHEDULED_EXCEPTION(it->isolate(),
- Maybe<PropertyAttributes>());
- return maybe(ABSENT);
+ Nothing<PropertyAttributes>());
+ return Just(ABSENT);
}
where_to_start = PrototypeIterator::START_AT_PROTOTYPE;
}
isolate->ReportFailedAccessCheck(object);
- RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Maybe<PropertyAttributes>());
- return maybe(ABSENT);
+ RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Nothing<PropertyAttributes>());
+ return Just(ABSENT);
}
Isolate* isolate = proxy->GetIsolate();
// TODO(rossberg): adjust once there is a story for symbols vs proxies.
- if (name->IsSymbol()) return maybe(false);
+ if (name->IsSymbol()) return Just(false);
Handle<Object> args[] = { name };
Handle<Object> result;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, result, CallTrap(proxy, "has", isolate->derived_has_trap(),
arraysize(args), args),
- Maybe<bool>());
+ Nothing<bool>());
- return maybe(result->BooleanValue());
+ return Just(result->BooleanValue());
}
HandleScope scope(isolate);
// TODO(rossberg): adjust once there is a story for symbols vs proxies.
- if (name->IsSymbol()) return maybe(ABSENT);
+ if (name->IsSymbol()) return Just(ABSENT);
Handle<Object> args[] = { name };
Handle<Object> result;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
- isolate, result,
- proxy->CallTrap(proxy, "getPropertyDescriptor", Handle<Object>(),
- arraysize(args), args),
- Maybe<PropertyAttributes>());
+ isolate, result, proxy->CallTrap(proxy, "getPropertyDescriptor",
+ Handle<Object>(), arraysize(args), args),
+ Nothing<PropertyAttributes>());
- if (result->IsUndefined()) return maybe(ABSENT);
+ if (result->IsUndefined()) return Just(ABSENT);
Handle<Object> argv[] = { result };
Handle<Object> desc;
isolate, desc,
Execution::Call(isolate, isolate->to_complete_property_descriptor(),
result, arraysize(argv), argv),
- Maybe<PropertyAttributes>());
+ Nothing<PropertyAttributes>());
// Convert result to PropertyAttributes.
Handle<String> enum_n = isolate->factory()->InternalizeOneByteString(
Handle<Object> enumerable;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, enumerable,
Object::GetProperty(desc, enum_n),
- Maybe<PropertyAttributes>());
+ Nothing<PropertyAttributes>());
Handle<String> conf_n = isolate->factory()->InternalizeOneByteString(
STATIC_CHAR_VECTOR("configurable_"));
Handle<Object> configurable;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, configurable,
Object::GetProperty(desc, conf_n),
- Maybe<PropertyAttributes>());
+ Nothing<PropertyAttributes>());
Handle<String> writ_n = isolate->factory()->InternalizeOneByteString(
STATIC_CHAR_VECTOR("writable_"));
Handle<Object> writable;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, writable,
Object::GetProperty(desc, writ_n),
- Maybe<PropertyAttributes>());
+ Nothing<PropertyAttributes>());
if (!writable->BooleanValue()) {
Handle<String> set_n = isolate->factory()->InternalizeOneByteString(
STATIC_CHAR_VECTOR("set_"));
Handle<Object> setter;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, setter,
Object::GetProperty(desc, set_n),
- Maybe<PropertyAttributes>());
+ Nothing<PropertyAttributes>());
writable = isolate->factory()->ToBoolean(!setter->IsUndefined());
}
Handle<Object> error = isolate->factory()->NewTypeError(
"proxy_prop_not_configurable", HandleVector(args, arraysize(args)));
isolate->Throw(*error);
- return maybe(NONE);
+ return Just(NONE);
}
int attributes = NONE;
if (!enumerable->BooleanValue()) attributes |= DONT_ENUM;
if (!configurable->BooleanValue()) attributes |= DONT_DELETE;
if (!writable->BooleanValue()) attributes |= READ_ONLY;
- return maybe(static_cast<PropertyAttributes>(attributes));
+ return Just(static_cast<PropertyAttributes>(attributes));
}
Handle<InterceptorInfo> interceptor(holder->GetNamedInterceptor());
if (name->IsSymbol() && !interceptor->can_intercept_symbols()) {
- return maybe(ABSENT);
+ return Just(ABSENT);
}
PropertyCallbackArguments args(
isolate, interceptor->data(), *receiver, *holder);
v8::Handle<v8::Integer> result = args.Call(query, v8::Utils::ToLocal(name));
if (!result.IsEmpty()) {
DCHECK(result->IsInt32());
- return maybe(static_cast<PropertyAttributes>(result->Int32Value()));
+ return Just(static_cast<PropertyAttributes>(result->Int32Value()));
}
} else if (!interceptor->getter()->IsUndefined()) {
v8::GenericNamedPropertyGetterCallback getter =
LOG(isolate,
ApiNamedPropertyAccess("interceptor-named-get-has", *holder, *name));
v8::Handle<v8::Value> result = args.Call(getter, v8::Utils::ToLocal(name));
- if (!result.IsEmpty()) return maybe(DONT_ENUM);
+ if (!result.IsEmpty()) return Just(DONT_ENUM);
}
- RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Maybe<PropertyAttributes>());
- return maybe(ABSENT);
+ RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Nothing<PropertyAttributes>());
+ return Just(ABSENT);
}
return JSObject::GetPropertyAttributesWithFailedAccessCheck(it);
case LookupIterator::ACCESSOR:
case LookupIterator::DATA:
- return maybe(it->property_details().attributes());
+ return Just(it->property_details().attributes());
}
}
- return maybe(ABSENT);
+ return Just(ABSENT);
}
if (object->IsJSGlobalProxy()) {
PrototypeIterator iter(isolate, object);
- if (iter.IsAtEnd()) return maybe(ABSENT);
+ if (iter.IsAtEnd()) return Just(ABSENT);
DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject());
return JSObject::GetElementAttributeWithReceiver(
Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)), receiver,
Maybe<PropertyAttributes> from_interceptor =
GetElementAttributeFromInterceptor(object, receiver, index);
- if (!from_interceptor.has_value) return Maybe<PropertyAttributes>();
- if (from_interceptor.value != ABSENT) return maybe(from_interceptor.value);
+ if (!from_interceptor.has_value) return Nothing<PropertyAttributes>();
+ if (from_interceptor.value != ABSENT) return Just(from_interceptor.value);
return GetElementAttributeWithoutInterceptor(object, receiver, index,
check_prototype);
ApiIndexedPropertyAccess("interceptor-indexed-has", *object, index));
v8::Handle<v8::Integer> result = args.Call(query, index);
if (!result.IsEmpty())
- return maybe(static_cast<PropertyAttributes>(result->Int32Value()));
+ return Just(static_cast<PropertyAttributes>(result->Int32Value()));
} else if (!interceptor->getter()->IsUndefined()) {
v8::IndexedPropertyGetterCallback getter =
v8::ToCData<v8::IndexedPropertyGetterCallback>(interceptor->getter());
ApiIndexedPropertyAccess(
"interceptor-indexed-get-has", *object, index));
v8::Handle<v8::Value> result = args.Call(getter, index);
- if (!result.IsEmpty()) return maybe(NONE);
+ if (!result.IsEmpty()) return Just(NONE);
}
- RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Maybe<PropertyAttributes>());
- return maybe(ABSENT);
+ RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Nothing<PropertyAttributes>());
+ return Just(ABSENT);
}
bool check_prototype) {
PropertyAttributes attr =
object->GetElementsAccessor()->GetAttributes(object, index);
- if (attr != ABSENT) return maybe(attr);
+ if (attr != ABSENT) return Just(attr);
// Handle [] on String objects.
if (object->IsStringObjectWithCharacterAt(index)) {
- return maybe(static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE));
+ return Just(static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE));
}
- if (!check_prototype) return maybe(ABSENT);
+ if (!check_prototype) return Just(ABSENT);
PrototypeIterator iter(object->GetIsolate(), object);
if (PrototypeIterator::GetCurrent(iter)->IsJSProxy()) {
Handle<JSProxy>::cast(PrototypeIterator::GetCurrent(iter)), receiver,
index);
}
- if (iter.IsAtEnd()) return maybe(ABSENT);
+ if (iter.IsAtEnd()) return Just(ABSENT);
return GetElementAttributeWithReceiver(
Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)), receiver,
index, true);
Handle<Name> key) {
LookupIterator it(object, key, LookupIterator::OWN_SKIP_INTERCEPTOR);
Maybe<PropertyAttributes> maybe_result = GetPropertyAttributes(&it);
- if (!maybe_result.has_value) return Maybe<bool>();
- return maybe(it.IsFound());
+ if (!maybe_result.has_value) return Nothing<bool>();
+ return Just(it.IsFound());
}
if (object->IsAccessCheckNeeded()) {
if (!isolate->MayAccess(object)) {
isolate->ReportFailedAccessCheck(object);
- RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Maybe<bool>());
- return maybe(false);
+ RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Nothing<bool>());
+ return Just(false);
}
}
if (object->IsJSGlobalProxy()) {
HandleScope scope(isolate);
PrototypeIterator iter(isolate, object);
- if (iter.IsAtEnd()) return maybe(false);
+ if (iter.IsAtEnd()) return Just(false);
DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject());
return HasRealElementProperty(
Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)), index);
Maybe<PropertyAttributes> result =
GetElementAttributeWithoutInterceptor(object, object, index, false);
- if (!result.has_value) return Maybe<bool>();
- return maybe(result.value != ABSENT);
+ return result.has_value ? Just(result.value != ABSENT) : Nothing<bool>();
}
Handle<Name> key) {
LookupIterator it(object, key, LookupIterator::OWN_SKIP_INTERCEPTOR);
Maybe<PropertyAttributes> maybe_result = GetPropertyAttributes(&it);
- if (!maybe_result.has_value) return Maybe<bool>();
- return maybe(it.state() == LookupIterator::ACCESSOR);
+ return maybe_result.has_value ? Just(it.state() == LookupIterator::ACCESSOR)
+ : Nothing<bool>();
}
// Fast case: either the key is a real named property or it is not
// an array index and there are no interceptors or hidden
// prototypes.
- Maybe<bool> maybe;
+ Maybe<bool> maybe = Nothing<bool>();
if (key_is_array_index) {
maybe = JSObject::HasOwnElement(js_obj, index);
} else {
DCHECK(op < BinaryOpICState::FIRST_TOKEN ||
op > BinaryOpICState::LAST_TOKEN);
*left = *right = *result = Type::None(zone());
- *fixed_right_arg = Maybe<int>();
+ *fixed_right_arg = Nothing<int>();
*allocation_site = Handle<AllocationSite>::null();
return;
}
Type* type;
Type* left_type;
Type* right_type;
- Maybe<int> fixed_right_arg;
+ Maybe<int> fixed_right_arg = Nothing<int>();
Handle<AllocationSite> allocation_site;
oracle()->BinaryType(expr->BinaryOperationFeedbackId(),
&left_type, &right_type, &type, &fixed_right_arg,