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

Code before:
  }
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
  else
  {
    if (ecma_is_value_undefined (value)
        || ecma_is_value_null (value))
    {
      return ecma_raise_type_error (ECMA_ERR_MSG ("Argument cannot be converted to an object."));
    }
    else
    {
      JERRY_ASSERT (ecma_is_value_boolean (value));
#if ENABLED (JERRY_BUILTIN_BOOLEAN)
      proto_id = ECMA_BUILTIN_ID_BOOLEAN_PROTOTYPE;
#endif /* ENABLED (JERRY_BUILTIN_BOOLEAN) */
      lit_id = LIT_MAGIC_STRING_BOOLEAN_UL;
    }
  }

  return ecma_op_create_class_object (proto_id, value, lit_id);
} /* ecma_op_to_object */

/**
 * create class object operation.
 *
 *
 * @return ecma value
 *         Returned value must be freed with ecma_free_value
 */
ecma_value_t
ecma_op_create_class_object (ecma_builtin_id_t proto_id, /**< prototype id */
                             ecma_value_t value, /**< ecma value */
                             uint16_t lit_id) /**< magic string id */
{
  ecma_object_t *object_p = ecma_create_object (ecma_builtin_get (proto_id),
                                                sizeof (ecma_extended_object_t),
                                                ECMA_OBJECT_TYPE_CLASS);

  ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
  ext_object_p->u.class_prop.class_id = lit_id;
  ext_object_p->u.class_prop.u.value = ecma_copy_value_if_not_object (value);

  return ecma_make_object_value (object_p);
} /* ecma_op_create_class_object */

/**
 * FromPropertyDescriptor operation.
 *
 * See also:
 *          ECMA-262 v5, 8.10.4
 *

Review comment (suggestion):
```c
/**
 * Create a ECMA_OBJECT_TYPE_CLASS object from the given arguments.
 *
 * @return ecma_value - constructed object
 */
```

Code after:
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
  else
  {
    if (ecma_is_value_undefined (value)
        || ecma_is_value_null (value))
    {
      return ecma_raise_type_error (ECMA_ERR_MSG ("Argument cannot be converted to an object."));
    }
    else
    {
      JERRY_ASSERT (ecma_is_value_boolean (value));
#if ENABLED (JERRY_BUILTIN_BOOLEAN)
      proto_id = ECMA_BUILTIN_ID_BOOLEAN_PROTOTYPE;
#endif /* ENABLED (JERRY_BUILTIN_BOOLEAN) */
      lit_id = LIT_MAGIC_STRING_BOOLEAN_UL;
    }
  }

  return ecma_op_create_class_object (proto_id, value, lit_id);
} /* ecma_op_to_object */

/**
 * Create a ECMA_OBJECT_TYPE_CLASS object from the given arguments.
 *
 * @return ecma_value - constructed object
 */
ecma_value_t
ecma_op_create_class_object (ecma_builtin_id_t proto_id, /**< prototype id */
                             ecma_value_t value, /**< ecma value */
                             uint16_t class_id) /**< magic string id */
{
  ecma_object_t *object_p = ecma_create_object (ecma_builtin_get (proto_id),
                                                sizeof (ecma_extended_object_t),
                                                ECMA_OBJECT_TYPE_CLASS);

  ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
  ext_object_p->u.class_prop.class_id = class_id;
  ext_object_p->u.class_prop.u.value = ecma_copy_value_if_not_object (value);

  return ecma_make_object_value (object_p);
} /* ecma_op_create_class_object */

/**
 * FromPropertyDescriptor operation.
 *
 * See also:
 *          ECMA-262 v5, 8.10.4
 *
 * @return constructed object
 */
ecma_object_t *