本文整理匯總了C++中ECMA_ERR_MSG函數的典型用法代碼示例。如果您正苦於以下問題:C++ ECMA_ERR_MSG函數的具體用法?C++ ECMA_ERR_MSG怎麽用?C++ ECMA_ERR_MSG使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了ECMA_ERR_MSG函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: ecma_builtin_typedarray_from
/**
* The %TypedArray%.from routine
*
* See also:
* ES2015 22.2.2.1
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_typedarray_from (ecma_value_t this_arg, /**< 'this' argument */
const 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 (!ecma_is_constructor (this_arg))
{
return ecma_raise_type_error (ECMA_ERR_MSG ("'this' is not a constructor."));
}
ecma_value_t source;
ecma_value_t map_fn = ECMA_VALUE_UNDEFINED;
ecma_value_t this_in_fn = ECMA_VALUE_UNDEFINED;
if (arguments_list_len == 0)
{
return ecma_raise_type_error (ECMA_ERR_MSG ("no source argument"));
}
source = arguments_list_p[0];
if (arguments_list_len > 1)
{
map_fn = arguments_list_p[1];
if (!ecma_op_is_callable (map_fn))
{
return ecma_raise_type_error (ECMA_ERR_MSG ("mapfn argument is not callable"));
}
if (arguments_list_len > 2)
{
this_in_fn = arguments_list_p[2];
}
}
ecma_object_t *obj_p = ecma_get_object_from_value (this_arg);
const uint8_t builtin_id = ecma_get_object_builtin_id (obj_p);
if (!ecma_typedarray_helper_is_typedarray (builtin_id))
{
return ecma_raise_type_error (ECMA_ERR_MSG ("'this' is not a typedarray constructor"));
}
ecma_object_t *proto_p = ecma_builtin_get (ecma_typedarray_helper_get_prototype_id (builtin_id));
const uint8_t element_size_shift = ecma_typedarray_helper_get_shift_size (builtin_id);
const lit_magic_string_id_t class_id = ecma_typedarray_helper_get_magic_string (builtin_id);
return ecma_op_typedarray_from (source,
map_fn,
this_in_fn,
proto_p,
element_size_shift,
class_id);
} /* ecma_builtin_typedarray_from */
示例2: ecma_op_resolve_reference_value
/**
* Resolve value corresponding to reference.
*
* @return value of the reference
*/
ecma_value_t
ecma_op_resolve_reference_value (ecma_object_t *lex_env_p, /**< starting lexical environment */
ecma_string_t *name_p, /**< identifier's name */
bool is_strict) /**< strict mode */
{
JERRY_ASSERT (lex_env_p != NULL);
while (lex_env_p != NULL)
{
if (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE)
{
ecma_property_t *property_p = ecma_find_named_property (lex_env_p, name_p);
if (property_p != NULL)
{
ecma_value_t prop_value = ecma_get_named_data_property_value (property_p);
/* is the binding mutable? */
if (unlikely (!ecma_is_property_writable (property_p)
&& ecma_is_value_empty (prop_value)))
{
/* unitialized mutable binding */
if (is_strict)
{
return ecma_raise_reference_error (ECMA_ERR_MSG (""));
}
else
{
return ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED);
}
}
return ecma_fast_copy_value (prop_value);
}
}
else
{
JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_OBJECT_BOUND
|| ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);
ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);
ecma_property_t *property_p = ecma_op_object_get_property (binding_obj_p, name_p);
if (property_p != NULL)
{
return ecma_op_object_get (binding_obj_p, name_p);
}
}
lex_env_p = ecma_get_lex_env_outer_reference (lex_env_p);
}
return ecma_raise_reference_error (ECMA_ERR_MSG (""));
} /* ecma_op_resolve_reference_value */
示例3: ecma_builtin_object_prototype_object_to_locale_string
/**
* The Object.prototype object's 'toLocaleString' routine
*
* See also:
* ECMA-262 v5, 15.2.4.3
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_object_prototype_object_to_locale_string (ecma_value_t this_arg) /**< this argument */
{
ecma_value_t return_value = ECMA_VALUE_EMPTY;
/* 1. */
ECMA_TRY_CATCH (obj_val,
ecma_op_to_object (this_arg),
return_value);
ecma_object_t *obj_p = ecma_get_object_from_value (obj_val);
/* 2. */
ECMA_TRY_CATCH (to_string_val,
ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_TO_STRING_UL),
return_value);
/* 3. */
if (!ecma_op_is_callable (to_string_val))
{
return_value = ecma_raise_type_error (ECMA_ERR_MSG ("'toString is missing or not a function.'"));
}
else
{
/* 4. */
ecma_object_t *to_string_func_obj_p = ecma_get_object_from_value (to_string_val);
return_value = ecma_op_function_call (to_string_func_obj_p, this_arg, NULL, 0);
}
ECMA_FINALIZE (to_string_val);
ECMA_FINALIZE (obj_val);
return return_value;
} /* ecma_builtin_object_prototype_object_to_locale_string */
示例4: ecma_builtin_number_prototype_object_value_of
/**
* The Number.prototype object's 'valueOf' routine
*
* See also:
* ECMA-262 v5, 15.7.4.4
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_number_prototype_object_value_of (ecma_value_t this_arg) /**< this argument */
{
if (ecma_is_value_number (this_arg))
{
return ecma_copy_value (this_arg);
}
else if (ecma_is_value_object (this_arg))
{
ecma_object_t *obj_p = ecma_get_object_from_value (this_arg);
if (ecma_object_get_class_name (obj_p) == LIT_MAGIC_STRING_NUMBER_UL)
{
ecma_property_t *prim_value_prop_p = ecma_get_internal_property (obj_p,
ECMA_INTERNAL_PROPERTY_PRIMITIVE_NUMBER_VALUE);
ecma_number_t *prim_value_num_p;
prim_value_num_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_number_t,
ecma_get_internal_property_value (prim_value_prop_p));
ecma_number_t *ret_num_p = ecma_alloc_number ();
*ret_num_p = *prim_value_num_p;
return ecma_make_number_value (ret_num_p);
}
}
return ecma_raise_type_error (ECMA_ERR_MSG (""));
} /* ecma_builtin_number_prototype_object_value_of */
示例5: ecma_builtin_date_prototype_to_json
/**
* The Date.prototype object's 'toJSON' routine
*
* See also:
* ECMA-262 v5, 15.9.5.44
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_date_prototype_to_json (ecma_value_t this_arg, /**< this argument */
ecma_value_t arg) /**< key */
{
JERRY_UNUSED (arg);
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
/* 1. */
ECMA_TRY_CATCH (obj,
ecma_op_to_object (this_arg),
ret_value);
/* 2. */
ECMA_TRY_CATCH (tv,
ecma_op_to_primitive (obj, ECMA_PREFERRED_TYPE_NUMBER),
ret_value);
/* 3. */
if (ecma_is_value_number (tv))
{
ecma_number_t num_value = ecma_get_number_from_value (tv);
if (ecma_number_is_nan (num_value) || ecma_number_is_infinity (num_value))
{
ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_NULL);
}
}
if (ecma_is_value_empty (ret_value))
{
ecma_string_t *to_iso_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_TO_ISO_STRING_UL);
ecma_object_t *value_obj_p = ecma_get_object_from_value (obj);
/* 4. */
ECMA_TRY_CATCH (to_iso,
ecma_op_object_get (value_obj_p, to_iso_str_p),
ret_value);
/* 5. */
if (!ecma_op_is_callable (to_iso))
{
ret_value = ecma_raise_type_error (ECMA_ERR_MSG (""));
}
/* 6. */
else
{
ecma_object_t *to_iso_obj_p = ecma_get_object_from_value (to_iso);
ret_value = ecma_op_function_call (to_iso_obj_p, this_arg, NULL, 0);
}
ECMA_FINALIZE (to_iso);
ecma_deref_ecma_string (to_iso_str_p);
}
ECMA_FINALIZE (tv);
ECMA_FINALIZE (obj);
return ret_value;
} /* ecma_builtin_date_prototype_to_json */
示例6: opfunc_in
/**
* 'in' opcode handler.
*
* See also: ECMA-262 v5, 11.8.7
*
* @return ecma value
* returned value must be freed with ecma_free_value.
*/
ecma_value_t
opfunc_in (ecma_value_t left_value, /**< left value */
ecma_value_t right_value) /**< right value */
{
if (!ecma_is_value_object (right_value))
{
return ecma_raise_type_error (ECMA_ERR_MSG ("Expected an object in 'in' check."));
}
bool to_string = !ecma_is_value_string (left_value);
if (to_string)
{
left_value = ecma_op_to_string (left_value);
if (ECMA_IS_VALUE_ERROR (left_value))
{
return left_value;
}
}
ecma_string_t *left_value_prop_name_p = ecma_get_string_from_value (left_value);
ecma_object_t *right_value_obj_p = ecma_get_object_from_value (right_value);
ecma_value_t result = ecma_make_boolean_value (ecma_op_object_has_property (right_value_obj_p,
left_value_prop_name_p));
if (to_string)
{
ecma_free_value (left_value);
}
return result;
} /* opfunc_in */
示例7: opfunc_in
/**
* 'in' opcode handler.
*
* See also: ECMA-262 v5, 11.8.7
*
* @return ecma value
* returned value must be freed with ecma_free_value.
*/
ecma_value_t
opfunc_in (ecma_value_t left_value, /**< left value */
ecma_value_t right_value) /**< right value */
{
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
if (!ecma_is_value_object (right_value))
{
ret_value = ecma_raise_type_error (ECMA_ERR_MSG (""));
}
else
{
ECMA_TRY_CATCH (str_left_value, ecma_op_to_string (left_value), ret_value);
ecma_string_t *left_value_prop_name_p = ecma_get_string_from_value (str_left_value);
ecma_object_t *right_value_obj_p = ecma_get_object_from_value (right_value);
if (ecma_op_object_get_property (right_value_obj_p, left_value_prop_name_p) != NULL)
{
ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_TRUE);
}
else
{
ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE);
}
ECMA_FINALIZE (str_left_value);
}
return ret_value;
} /* opfunc_in */
示例8: ecma_op_to_object
/**
* ToObject operation.
*
* See also:
* ECMA-262 v5, 9.9
*
* @return ecma value
* Returned value must be freed with ecma_free_value
*/
ecma_value_t
ecma_op_to_object (ecma_value_t value) /**< ecma value */
{
ecma_check_value_type_is_spec_defined (value);
if (ecma_is_value_number (value))
{
return ecma_op_create_number_object (value);
}
else if (ecma_is_value_string (value))
{
return ecma_op_create_string_object (&value, 1);
}
else if (ecma_is_value_object (value))
{
return ecma_copy_value (value);
}
else
{
if (ecma_is_value_undefined (value)
|| ecma_is_value_null (value))
{
return ecma_raise_type_error (ECMA_ERR_MSG (""));
}
else
{
JERRY_ASSERT (ecma_is_value_boolean (value));
return ecma_op_create_boolean_object (value);
}
}
} /* ecma_op_to_object */
示例9: opfunc_instanceof
/**
* 'instanceof' opcode handler.
*
* See also: ECMA-262 v5, 11.8.6
*
* @return ecma value
* returned value must be freed with ecma_free_value.
*/
ecma_value_t
opfunc_instanceof (ecma_value_t left_value, /**< left value */
ecma_value_t right_value) /**< right value */
{
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
if (!ecma_is_value_object (right_value))
{
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Expected an object in 'instanceof' check."));
}
else
{
ecma_object_t *right_value_obj_p = ecma_get_object_from_value (right_value);
ECMA_TRY_CATCH (is_instance_of,
ecma_op_object_has_instance (right_value_obj_p, left_value),
ret_value);
ret_value = is_instance_of;
ECMA_FINALIZE (is_instance_of);
}
return ret_value;
} /* opfunc_instanceof */
示例10: ecma_builtin_helper_get_to_locale_string_at_index
/**
* The Array.prototype's 'toLocaleString' single element operation routine
*
* See also:
* ECMA-262 v5, 15.4.4.3 steps 6-8 and 10.b-d
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
ecma_value_t
ecma_builtin_helper_get_to_locale_string_at_index (ecma_object_t *obj_p, /**< this object */
uint32_t index) /**< array index */
{
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
ecma_string_t *index_string_p = ecma_new_ecma_string_from_uint32 (index);
ECMA_TRY_CATCH (index_value,
ecma_op_object_get (obj_p, index_string_p),
ret_value);
if (ecma_is_value_undefined (index_value) || ecma_is_value_null (index_value))
{
ecma_string_t *return_string_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
ret_value = ecma_make_string_value (return_string_p);
}
else
{
ECMA_TRY_CATCH (index_obj_value,
ecma_op_to_object (index_value),
ret_value);
ecma_object_t *index_obj_p = ecma_get_object_from_value (index_obj_value);
ecma_string_t *locale_string_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_TO_LOCALE_STRING_UL);
ECMA_TRY_CATCH (to_locale_value,
ecma_op_object_get (index_obj_p, locale_string_magic_string_p),
ret_value);
if (ecma_op_is_callable (to_locale_value))
{
ecma_object_t *locale_func_obj_p = ecma_get_object_from_value (to_locale_value);
ECMA_TRY_CATCH (call_value,
ecma_op_function_call (locale_func_obj_p,
ecma_make_object_value (index_obj_p),
NULL,
0),
ret_value);
ret_value = ecma_op_to_string (call_value);
ECMA_FINALIZE (call_value);
}
else
{
ret_value = ecma_raise_type_error (ECMA_ERR_MSG (""));
}
ECMA_FINALIZE (to_locale_value);
ecma_deref_ecma_string (locale_string_magic_string_p);
ECMA_FINALIZE (index_obj_value);
}
ECMA_FINALIZE (index_value);
ecma_deref_ecma_string (index_string_p);
return ret_value;
} /* ecma_builtin_helper_get_to_locale_string_at_index */
示例11: ecma_builtin_date_prototype_set_time
/**
* The Date.prototype object's 'setTime' routine
*
* See also:
* ECMA-262 v5, 15.9.5.27
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_date_prototype_set_time (ecma_value_t this_arg, /**< this argument */
ecma_value_t time) /**< time */
{
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
if (!ecma_is_value_object (this_arg)
|| ecma_object_get_class_name (ecma_get_object_from_value (this_arg)) != LIT_MAGIC_STRING_DATE_UL)
{
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Incompatible type"));
}
else
{
/* 1. */
ECMA_OP_TO_NUMBER_TRY_CATCH (t, time, ret_value);
ecma_number_t *value_p = ecma_alloc_number ();
*value_p = ecma_date_time_clip (t);
/* 2. */
ecma_object_t *obj_p = ecma_get_object_from_value (this_arg);
ecma_property_t *prim_prop_p = ecma_get_internal_property (obj_p,
ECMA_INTERNAL_PROPERTY_PRIMITIVE_NUMBER_VALUE);
ecma_number_t *prim_value_num_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_number_t,
ecma_get_internal_property_value (prim_prop_p));
*prim_value_num_p = *value_p;
/* 3. */
ret_value = ecma_make_number_value (value_p);
ECMA_OP_TO_NUMBER_FINALIZE (t);
}
return ret_value;
} /* ecma_builtin_date_prototype_set_time */
示例12: ecma_builtin_function_prototype_object_call
/**
* The Function.prototype object's 'call' routine
*
* See also:
* ECMA-262 v5, 15.3.4.4
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_function_prototype_object_call (ecma_value_t this_arg, /**< this argument */
const ecma_value_t *arguments_list_p, /**< list of arguments */
ecma_length_t arguments_number) /**< number of arguments */
{
if (!ecma_op_is_callable (this_arg))
{
return ecma_raise_type_error (ECMA_ERR_MSG (""));
}
else
{
ecma_object_t *func_obj_p = ecma_get_object_from_value (this_arg);
if (arguments_number == 0)
{
/* Even a 'this' argument is missing. */
return ecma_op_function_call (func_obj_p,
ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED),
NULL,
0);
}
else
{
return ecma_op_function_call (func_obj_p,
arguments_list_p[0],
arguments_list_p + 1,
(ecma_length_t) (arguments_number - 1u));
}
}
} /* ecma_builtin_function_prototype_object_call */
示例13: ecma_builtin_uint16array_dispatch_call
/**
* Handle calling [[Call]] of Uint16Array
*
* @return ecma value
*/
ecma_value_t
ecma_builtin_uint16array_dispatch_call (const 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);
return ecma_raise_type_error (ECMA_ERR_MSG ("Uint16Array cannot be directly called"));
} /* ecma_builtin_uint16array_dispatch_call */
示例14: ecma_builtin_typedarray_dispatch_construct
/**
* Handle calling [[Construct]] of built-in %TypedArray% object
*
* ES2015 22.2.1 If %TypedArray% is directly called or
* called as part of a new expression an exception is thrown
*
* @return ecma value
*/
ecma_value_t
ecma_builtin_typedarray_dispatch_construct (const 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);
return ecma_raise_type_error (ECMA_ERR_MSG ("TypedArray intrinstic cannot be called by a 'new' expression"));
} /* ecma_builtin_typedarray_dispatch_construct */
示例15: ecma_builtin_arraybuffer_dispatch_call
/**
* Handle calling [[Call]] of built-in ArrayBuffer object
*
* ES2015 24.1.2 ArrayBuffer is not intended to be called as
* a function and will throw an exception when called in
* that manner.
*
* @return ecma value
*/
ecma_value_t
ecma_builtin_arraybuffer_dispatch_call (const 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);
return ecma_raise_type_error (ECMA_ERR_MSG ("Constructor ArrayBuffer requires 'new'"));
} /* ecma_builtin_arraybuffer_dispatch_call */