Repository: jerryscript-project/jerryscript
File: jerry-core/ecma/operations/ecma-objects-general.c (C)

Code before:
  return ecma_op_create_object_object_noarg_and_set_prototype (object_prototype_p);
} /* ecma_op_create_object_object_noarg */

/**
 * 'Object' object creation operation with one argument.
 *
 * See also: ECMA-262 v5, 15.2.2.1
 *
 * @return pointer to newly created 'Object' object
 */
ecma_value_t
ecma_op_create_object_object_arg (ecma_value_t value) /**< argument of constructor */
{
  ecma_check_value_type_is_spec_defined (value);

  if (!ecma_is_value_undefined (value)
      && !ecma_is_value_null (value))
  {
    /* 1.b, 1.c, 1.d */
#if ENABLED (JERRY_ESNEXT)
    JERRY_ASSERT (ecma_is_value_object (value)
                  || ecma_is_value_number (value)
                  || ecma_is_value_prop_name (value)
                  || ecma_is_value_boolean (value)
                  || ecma_is_value_bigint (value));
#else
    JERRY_ASSERT (ecma_is_value_object (value)
                  || ecma_is_value_number (value)
                  || ecma_is_value_prop_name (value)
                  || ecma_is_value_boolean (value));
#endif /* ENABLED (JERRY_ESNEXT) */
    return ecma_op_to_object (value);
  }
  else
  {
    /* 2. */
    JERRY_ASSERT (ecma_is_value_undefined (value)
                  || ecma_is_value_null (value));

    ecma_object_t *obj_p = ecma_op_create_object_object_noarg ();

    return ecma_make_object_value (obj_p);
  }
} /* ecma_op_create_object_object_arg */

/**
 * Object creation operation with no arguments.
 * It sets the given prototype to the newly created object.
 *
 * See also: ECMA-262 v5, 15.2.2.1, 15.2.3.5
 *

Review comment (refactor):
Please use this macro:
https://github.com/jerryscript-project/jerryscript/blob/master/jerry-core/ecma/base/ecma-helpers.h#L211

The `#else` has no comment, but it should be removed anyway.

Code after:
  return ecma_op_create_object_object_noarg_and_set_prototype (object_prototype_p);
} /* ecma_op_create_object_object_noarg */

/**
 * 'Object' object creation operation with one argument.
 *
 * See also: ECMA-262 v5, 15.2.2.1
 *
 * @return pointer to newly created 'Object' object
 */
ecma_value_t
ecma_op_create_object_object_arg (ecma_value_t value) /**< argument of constructor */
{
  ecma_check_value_type_is_spec_defined (value);

  if (!ecma_is_value_undefined (value)
      && !ecma_is_value_null (value))
  {
    /* 1.b, 1.c, 1.d */
    JERRY_ASSERT (ecma_is_value_object (value)
                  || ecma_is_value_number (value)
                  || ecma_is_value_prop_name (value)
                  || ecma_is_value_boolean (value)
                  || ECMA_CHECK_BIGINT_IN_ASSERT (value));

    return ecma_op_to_object (value);
  }
  else
  {
    /* 2. */
    JERRY_ASSERT (ecma_is_value_undefined (value)
                  || ecma_is_value_null (value));

    ecma_object_t *obj_p = ecma_op_create_object_object_noarg ();

    return ecma_make_object_value (obj_p);
  }
} /* ecma_op_create_object_object_arg */

/**
 * Object creation operation with no arguments.
 * It sets the given prototype to the newly created object.
 *
 * See also: ECMA-262 v5, 15.2.2.1, 15.2.3.5
 *
 * @return pointer to newly created object
 */
ecma_object_t *
ecma_op_create_object_object_noarg_and_set_prototype (ecma_object_t *object_prototype_p) /**< pointer to prototype of
                                                                                              the object
                                                                                              (can be NULL) */