Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Side by Side Diff: src/objects-inl.h

Issue 967243002: Polish Maybe API a bit, removing useless creativity and fixing some signatures. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Simplified friendship. Added check in FromJust. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // Review notes: 5 // Review notes:
6 // 6 //
7 // - The use of macros in these inline functions may seem superfluous 7 // - The use of macros in these inline functions may seem superfluous
8 // but it is absolutely needed to make sure gcc generates optimal 8 // but it is absolutely needed to make sure gcc generates optimal
9 // code. gcc is not happy when attempting to inline too deep. 9 // code. gcc is not happy when attempting to inline too deep.
10 // 10 //
(...skipping 6943 matching lines...) Expand 10 before | Expand all | Expand 10 after
6954 } 6954 }
6955 6955
6956 6956
6957 Maybe<bool> JSReceiver::HasProperty(Handle<JSReceiver> object, 6957 Maybe<bool> JSReceiver::HasProperty(Handle<JSReceiver> object,
6958 Handle<Name> name) { 6958 Handle<Name> name) {
6959 if (object->IsJSProxy()) { 6959 if (object->IsJSProxy()) {
6960 Handle<JSProxy> proxy = Handle<JSProxy>::cast(object); 6960 Handle<JSProxy> proxy = Handle<JSProxy>::cast(object);
6961 return JSProxy::HasPropertyWithHandler(proxy, name); 6961 return JSProxy::HasPropertyWithHandler(proxy, name);
6962 } 6962 }
6963 Maybe<PropertyAttributes> result = GetPropertyAttributes(object, name); 6963 Maybe<PropertyAttributes> result = GetPropertyAttributes(object, name);
6964 if (!result.has_value) return Maybe<bool>(); 6964 return result.has_value ? Just(result.value != ABSENT) : Nothing<bool>();
6965 return maybe(result.value != ABSENT);
6966 } 6965 }
6967 6966
6968 6967
6969 Maybe<bool> JSReceiver::HasOwnProperty(Handle<JSReceiver> object, 6968 Maybe<bool> JSReceiver::HasOwnProperty(Handle<JSReceiver> object,
6970 Handle<Name> name) { 6969 Handle<Name> name) {
6971 if (object->IsJSProxy()) { 6970 if (object->IsJSProxy()) {
6972 Handle<JSProxy> proxy = Handle<JSProxy>::cast(object); 6971 Handle<JSProxy> proxy = Handle<JSProxy>::cast(object);
6973 return JSProxy::HasPropertyWithHandler(proxy, name); 6972 return JSProxy::HasPropertyWithHandler(proxy, name);
6974 } 6973 }
6975 Maybe<PropertyAttributes> result = GetOwnPropertyAttributes(object, name); 6974 Maybe<PropertyAttributes> result = GetOwnPropertyAttributes(object, name);
6976 if (!result.has_value) return Maybe<bool>(); 6975 return result.has_value ? Just(result.value != ABSENT) : Nothing<bool>();
6977 return maybe(result.value != ABSENT);
6978 } 6976 }
6979 6977
6980 6978
6981 Maybe<PropertyAttributes> JSReceiver::GetPropertyAttributes( 6979 Maybe<PropertyAttributes> JSReceiver::GetPropertyAttributes(
6982 Handle<JSReceiver> object, Handle<Name> key) { 6980 Handle<JSReceiver> object, Handle<Name> key) {
6983 uint32_t index; 6981 uint32_t index;
6984 if (object->IsJSObject() && key->AsArrayIndex(&index)) { 6982 if (object->IsJSObject() && key->AsArrayIndex(&index)) {
6985 return GetElementAttribute(object, index); 6983 return GetElementAttribute(object, index);
6986 } 6984 }
6987 LookupIterator it(object, key); 6985 LookupIterator it(object, key);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
7026 } 7024 }
7027 7025
7028 7026
7029 Maybe<bool> JSReceiver::HasElement(Handle<JSReceiver> object, uint32_t index) { 7027 Maybe<bool> JSReceiver::HasElement(Handle<JSReceiver> object, uint32_t index) {
7030 if (object->IsJSProxy()) { 7028 if (object->IsJSProxy()) {
7031 Handle<JSProxy> proxy = Handle<JSProxy>::cast(object); 7029 Handle<JSProxy> proxy = Handle<JSProxy>::cast(object);
7032 return JSProxy::HasElementWithHandler(proxy, index); 7030 return JSProxy::HasElementWithHandler(proxy, index);
7033 } 7031 }
7034 Maybe<PropertyAttributes> result = JSObject::GetElementAttributeWithReceiver( 7032 Maybe<PropertyAttributes> result = JSObject::GetElementAttributeWithReceiver(
7035 Handle<JSObject>::cast(object), object, index, true); 7033 Handle<JSObject>::cast(object), object, index, true);
7036 if (!result.has_value) return Maybe<bool>(); 7034 return result.has_value ? Just(result.value != ABSENT) : Nothing<bool>();
7037 return maybe(result.value != ABSENT);
7038 } 7035 }
7039 7036
7040 7037
7041 Maybe<bool> JSReceiver::HasOwnElement(Handle<JSReceiver> object, 7038 Maybe<bool> JSReceiver::HasOwnElement(Handle<JSReceiver> object,
7042 uint32_t index) { 7039 uint32_t index) {
7043 if (object->IsJSProxy()) { 7040 if (object->IsJSProxy()) {
7044 Handle<JSProxy> proxy = Handle<JSProxy>::cast(object); 7041 Handle<JSProxy> proxy = Handle<JSProxy>::cast(object);
7045 return JSProxy::HasElementWithHandler(proxy, index); 7042 return JSProxy::HasElementWithHandler(proxy, index);
7046 } 7043 }
7047 Maybe<PropertyAttributes> result = JSObject::GetElementAttributeWithReceiver( 7044 Maybe<PropertyAttributes> result = JSObject::GetElementAttributeWithReceiver(
7048 Handle<JSObject>::cast(object), object, index, false); 7045 Handle<JSObject>::cast(object), object, index, false);
7049 if (!result.has_value) return Maybe<bool>(); 7046 return result.has_value ? Just(result.value != ABSENT) : Nothing<bool>();
7050 return maybe(result.value != ABSENT);
7051 } 7047 }
7052 7048
7053 7049
7054 Maybe<PropertyAttributes> JSReceiver::GetOwnElementAttribute( 7050 Maybe<PropertyAttributes> JSReceiver::GetOwnElementAttribute(
7055 Handle<JSReceiver> object, uint32_t index) { 7051 Handle<JSReceiver> object, uint32_t index) {
7056 if (object->IsJSProxy()) { 7052 if (object->IsJSProxy()) {
7057 return JSProxy::GetElementAttributeWithHandler( 7053 return JSProxy::GetElementAttributeWithHandler(
7058 Handle<JSProxy>::cast(object), object, index); 7054 Handle<JSProxy>::cast(object), object, index);
7059 } 7055 }
7060 return JSObject::GetElementAttributeWithReceiver( 7056 return JSObject::GetElementAttributeWithReceiver(
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
7634 #undef READ_SHORT_FIELD 7630 #undef READ_SHORT_FIELD
7635 #undef WRITE_SHORT_FIELD 7631 #undef WRITE_SHORT_FIELD
7636 #undef READ_BYTE_FIELD 7632 #undef READ_BYTE_FIELD
7637 #undef WRITE_BYTE_FIELD 7633 #undef WRITE_BYTE_FIELD
7638 #undef NOBARRIER_READ_BYTE_FIELD 7634 #undef NOBARRIER_READ_BYTE_FIELD
7639 #undef NOBARRIER_WRITE_BYTE_FIELD 7635 #undef NOBARRIER_WRITE_BYTE_FIELD
7640 7636
7641 } } // namespace v8::internal 7637 } } // namespace v8::internal
7642 7638
7643 #endif // V8_OBJECTS_INL_H_ 7639 #endif // V8_OBJECTS_INL_H_
OLDNEW
« include/v8.h ('K') | « src/objects.cc ('k') | src/runtime/runtime-object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698