Index: src/objects-inl.h |
diff --git a/src/objects-inl.h b/src/objects-inl.h |
index e3b47427e38251435c4d4ab36f7498d7ec34029b..ece40a5e38b12e20d0ce83f655cf97cea046533c 100644 |
--- a/src/objects-inl.h |
+++ b/src/objects-inl.h |
@@ -1102,6 +1102,13 @@ MaybeHandle<Name> Object::ToName(Isolate* isolate, Handle<Object> input) { |
} |
// static |
+MaybeHandle<Object> Object::ToPropertyKey(Isolate* isolate, |
+ Handle<Object> value) { |
+ if (value->IsSmi() || HeapObject::cast(*value)->IsName()) return value; |
+ return ConvertToPropertyKey(isolate, value); |
+} |
+ |
+// static |
MaybeHandle<Object> Object::ToPrimitive(Handle<Object> input, |
ToPrimitiveHint hint) { |
if (input->IsPrimitive()) return input; |
@@ -1138,6 +1145,22 @@ MaybeHandle<String> Object::ToString(Isolate* isolate, Handle<Object> input) { |
return ConvertToString(isolate, input); |
} |
+// static |
+MaybeHandle<Object> Object::ToLength(Isolate* isolate, Handle<Object> input) { |
+ if (input->IsSmi()) { |
+ int value = std::max(Smi::cast(*input)->value(), 0); |
+ return handle(Smi::FromInt(value), isolate); |
+ } |
+ return ConvertToLength(isolate, input); |
+} |
+ |
+// static |
+MaybeHandle<Object> Object::ToIndex(Isolate* isolate, Handle<Object> input, |
+ MessageTemplate::Template error_index) { |
+ if (input->IsSmi() && Smi::cast(*input)->value() >= 0) return input; |
+ return ConvertToIndex(isolate, input, error_index); |
+} |
+ |
bool Object::HasSpecificClassOf(String* name) { |
return this->IsJSObject() && (JSObject::cast(this)->class_name() == name); |
} |