| Index: src/objects.cc
|
| diff --git a/src/objects.cc b/src/objects.cc
|
| index aaa03203ae444987ec954edb1d4e19012e0791c5..6f3dc6939c426b2f5e5208eb7ef8dc7874577087 100644
|
| --- a/src/objects.cc
|
| +++ b/src/objects.cc
|
| @@ -60,56 +60,27 @@
|
| namespace v8 {
|
| namespace internal {
|
|
|
| -
|
| -MUST_USE_RESULT static MaybeObject* CreateJSValue(JSFunction* constructor,
|
| - Object* value) {
|
| - Object* result;
|
| - { MaybeObject* maybe_result =
|
| - constructor->GetHeap()->AllocateJSObject(constructor);
|
| - if (!maybe_result->ToObject(&result)) return maybe_result;
|
| +Handle<JSReceiver> Object::ToObject(Isolate* isolate,
|
| + Handle<Object> object,
|
| + Handle<Context> native_context) {
|
| + if (object->IsJSReceiver()) return Handle<JSReceiver>::cast(object);
|
| + Handle<JSFunction> constructor;
|
| + if (object->IsNumber()) {
|
| + constructor = handle(native_context->number_function(), isolate);
|
| + } else if (object->IsBoolean()) {
|
| + constructor = handle(native_context->boolean_function(), isolate);
|
| + } else if (object->IsString()) {
|
| + constructor = handle(native_context->string_function(), isolate);
|
| + } else {
|
| + ASSERT(object->IsSymbol());
|
| + constructor = handle(native_context->symbol_function(), isolate);
|
| }
|
| - JSValue::cast(result)->set_value(value);
|
| + Handle<JSObject> result = isolate->factory()->NewJSObject(constructor);
|
| + Handle<JSValue>::cast(result)->set_value(*object);
|
| return result;
|
| }
|
|
|
|
|
| -MaybeObject* Object::ToObject(Context* native_context) {
|
| - if (IsNumber()) {
|
| - return CreateJSValue(native_context->number_function(), this);
|
| - } else if (IsBoolean()) {
|
| - return CreateJSValue(native_context->boolean_function(), this);
|
| - } else if (IsString()) {
|
| - return CreateJSValue(native_context->string_function(), this);
|
| - } else if (IsSymbol()) {
|
| - return CreateJSValue(native_context->symbol_function(), this);
|
| - }
|
| - ASSERT(IsJSObject());
|
| - return this;
|
| -}
|
| -
|
| -
|
| -MaybeObject* Object::ToObject(Isolate* isolate) {
|
| - if (IsJSReceiver()) {
|
| - return this;
|
| - } else if (IsNumber()) {
|
| - Context* native_context = isolate->context()->native_context();
|
| - return CreateJSValue(native_context->number_function(), this);
|
| - } else if (IsBoolean()) {
|
| - Context* native_context = isolate->context()->native_context();
|
| - return CreateJSValue(native_context->boolean_function(), this);
|
| - } else if (IsString()) {
|
| - Context* native_context = isolate->context()->native_context();
|
| - return CreateJSValue(native_context->string_function(), this);
|
| - } else if (IsSymbol()) {
|
| - Context* native_context = isolate->context()->native_context();
|
| - return CreateJSValue(native_context->symbol_function(), this);
|
| - }
|
| -
|
| - // Throw a type error.
|
| - return Failure::InternalError();
|
| -}
|
| -
|
| -
|
| bool Object::BooleanValue() {
|
| if (IsBoolean()) return IsTrue();
|
| if (IsSmi()) return Smi::cast(this)->value() != 0;
|
|
|