Implementing 'new Object(...)' built-in constructor.
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-objects-general.h"
|
||||
#include "ecma-try-catch-macro.h"
|
||||
#include "globals.h"
|
||||
|
||||
@@ -193,6 +194,70 @@ ecma_builtin_object_get_routine_parameters_number (ecma_magic_string_id_t builti
|
||||
}
|
||||
} /* ecma_builtin_object_get_routine_parameters_number */
|
||||
|
||||
/**
|
||||
* Handle calling [[Call]] of built-in Object object
|
||||
*
|
||||
* @return completion-value
|
||||
*/
|
||||
ecma_completion_value_t
|
||||
ecma_builtin_object_dispatch_call (ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
if (arguments_list_len == 0
|
||||
|| ecma_is_value_undefined (arguments_list_p[0])
|
||||
|| ecma_is_value_null (arguments_list_p [0]))
|
||||
{
|
||||
return ecma_builtin_object_dispatch_construct (arguments_list_p, arguments_list_len);
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_completion_value_t new_obj_value = ecma_op_to_object (arguments_list_p [0]);
|
||||
|
||||
if (!ecma_is_completion_value_normal (new_obj_value))
|
||||
{
|
||||
return new_obj_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ecma_make_return_completion_value (new_obj_value.u.value);
|
||||
}
|
||||
}
|
||||
} /* ecma_builtin_object_dispatch_call */
|
||||
|
||||
/**
|
||||
* Handle calling [[Construct]] of built-in Object object
|
||||
*
|
||||
* @return completion-value
|
||||
*/
|
||||
ecma_completion_value_t
|
||||
ecma_builtin_object_dispatch_construct (ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
if (arguments_list_len == 0)
|
||||
{
|
||||
ecma_object_t *obj_p = ecma_op_create_object_object_noarg ();
|
||||
|
||||
return ecma_make_return_completion_value (ecma_make_object_value (obj_p));
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_completion_value_t new_obj_value = ecma_op_create_object_object_arg (arguments_list_p [0]);
|
||||
|
||||
if (!ecma_is_completion_value_normal (new_obj_value))
|
||||
{
|
||||
return new_obj_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ecma_make_return_completion_value (new_obj_value.u.value);
|
||||
}
|
||||
}
|
||||
} /* ecma_builtin_object_dispatch_construct */
|
||||
|
||||
/**
|
||||
* The Object object's 'getPrototypeOf' routine
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user