1/* Copyright JS Foundation and other contributors, http://js.foundation
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef ECMA_CONVERSION_H
17#define ECMA_CONVERSION_H
18
19#include "ecma-globals.h"
20#include "ecma-helpers.h"
21
22/** \addtogroup ecma ECMA
23 * @{
24 *
25 * \addtogroup ecmaconversion ECMA conversion routines
26 * @{
27 */
28
29/**
30 * Second argument of 'ToPrimitive' operation that is a hint,
31 * specifying the preferred type of conversion result.
32 */
33typedef enum
34{
35  ECMA_PREFERRED_TYPE_NO = 0, /**< no preferred type is specified */
36  ECMA_PREFERRED_TYPE_NUMBER, /**< Number */
37  ECMA_PREFERRED_TYPE_STRING /**< String */
38} ecma_preferred_type_hint_t;
39
40ecma_value_t ecma_op_check_object_coercible (ecma_value_t value);
41bool ecma_op_same_value (ecma_value_t x, ecma_value_t y);
42#if ENABLED (JERRY_ES2015_BUILTIN_MAP)
43bool ecma_op_same_value_zero (ecma_value_t x, ecma_value_t y);
44#endif /* ENABLED (JERRY_ES2015_BUILTIN_MAP) */
45ecma_value_t ecma_op_to_primitive (ecma_value_t value, ecma_preferred_type_hint_t preferred_type);
46bool ecma_op_to_boolean (ecma_value_t value);
47ecma_value_t ecma_op_to_number (ecma_value_t value);
48ecma_value_t ecma_get_number (ecma_value_t value, ecma_number_t *number_p);
49ecma_string_t *ecma_op_to_string (ecma_value_t value);
50ecma_string_t *ecma_op_to_prop_name (ecma_value_t value);
51ecma_value_t ecma_op_to_object (ecma_value_t value);
52ecma_value_t ecma_op_to_integer (ecma_value_t value, ecma_number_t *number_p);
53ecma_value_t ecma_op_to_length (ecma_value_t value, uint32_t *length);
54#if ENABLED (JERRY_ES2015)
55ecma_collection_t *ecma_op_create_list_from_array_like (ecma_value_t arr, bool prop_names_only);
56#endif /* ENABLED (JERRY_ES2015) */
57
58ecma_object_t *ecma_op_from_property_descriptor (const ecma_property_descriptor_t *src_prop_desc_p);
59ecma_value_t ecma_op_to_property_descriptor (ecma_value_t obj_value, ecma_property_descriptor_t *out_prop_desc_p);
60
61/**
62 * @}
63 * @}
64 */
65
66#endif /* !ECMA_CONVERSION_H */
67