本文整理汇总了C++中ecma_is_value_undefined函数的典型用法代码示例。如果您正苦于以下问题:C++ ecma_is_value_undefined函数的具体用法?C++ ecma_is_value_undefined怎么用?C++ ecma_is_value_undefined使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ecma_is_value_undefined函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ecma_builtin_date_prototype_set_minutes
/**
* The Date.prototype object's 'setMinutes' routine
*
* See also:
* ECMA-262 v5, 15.9.5.32
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_date_prototype_set_minutes (ecma_value_t this_arg, /**< this argument */
const ecma_value_t args[], /**< arguments list */
ecma_length_t args_number) /**< number of arguments */
{
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
/* 1. */
ECMA_TRY_CATCH (this_time_value, ecma_builtin_date_prototype_get_time (this_arg), ret_value);
ecma_number_t t = ecma_date_local_time (*ecma_get_number_from_value (this_time_value));
/* 2. */
ecma_number_t m = ecma_number_make_nan ();
ecma_number_t s = ecma_date_sec_from_time (t);
ecma_number_t milli = ecma_date_ms_from_time (t);
if (args_number > 0 && !ecma_is_value_undefined (args[0]))
{
ECMA_OP_TO_NUMBER_TRY_CATCH (min, args[0], ret_value);
m = min;
/* 3. */
if (args_number > 1 && !ecma_is_value_undefined (args[1]))
{
ECMA_OP_TO_NUMBER_TRY_CATCH (sec, args[1], ret_value);
s = sec;
/* 4. */
if (args_number > 2 && !ecma_is_value_undefined (args[2]))
{
ECMA_OP_TO_NUMBER_TRY_CATCH (ms, args[2], ret_value);
milli = ms;
ECMA_OP_TO_NUMBER_FINALIZE (ms);
}
ECMA_OP_TO_NUMBER_FINALIZE (sec);
}
ECMA_OP_TO_NUMBER_FINALIZE (min);
}
if (ecma_is_value_empty (ret_value))
{
/* 5-8. */
ecma_number_t hour = ecma_date_hour_from_time (t);
ret_value = ecma_date_set_internal_property (this_arg,
ecma_date_day (t),
ecma_date_make_time (hour, m, s, milli),
ECMA_DATE_LOCAL);
}
ECMA_FINALIZE (this_time_value);
return ret_value;
} /* ecma_builtin_date_prototype_set_minutes */
示例2: 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 */
示例3: ecma_builtin_date_prototype_set_utc_seconds
/**
* The Date.prototype object's 'setUTCSeconds' routine
*
* See also:
* ECMA-262 v5, 15.9.5.31
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_date_prototype_set_utc_seconds (ecma_value_t this_arg, /**< this argument */
ecma_value_t sec, /**< second */
ecma_value_t ms) /**< millisecond */
{
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
/* 1. */
ECMA_TRY_CATCH (this_time_value, ecma_builtin_date_prototype_get_time (this_arg), ret_value);
ecma_number_t t = *ecma_get_number_from_value (this_time_value);
/* 2. */
ECMA_OP_TO_NUMBER_TRY_CATCH (s, sec, ret_value);
/* 3. */
ECMA_OP_TO_NUMBER_TRY_CATCH (milli, ms, ret_value);
if (ecma_is_value_undefined (ms))
{
milli = ecma_date_ms_from_time (t);
}
/* 4-7. */
ecma_number_t hour = ecma_date_hour_from_time (t);
ecma_number_t min = ecma_date_min_from_time (t);
ret_value = ecma_date_set_internal_property (this_arg,
ecma_date_day (t),
ecma_date_make_time (hour, min, s, milli),
ECMA_DATE_UTC);
ECMA_OP_TO_NUMBER_FINALIZE (milli);
ECMA_OP_TO_NUMBER_FINALIZE (s);
ECMA_FINALIZE (this_time_value);
return ret_value;
} /* ecma_builtin_date_prototype_set_utc_seconds */
示例4: opfunc_relation
/**
* Relation opcode handler.
*
* See also: ECMA-262 v5, 11.8.1, 11.8.2, 11.8.3, 11.8.4
*
* @return ecma value
* Returned value must be freed with ecma_free_value
*/
ecma_value_t
opfunc_relation (ecma_value_t left_value, /**< left value */
ecma_value_t right_value, /**< right value */
bool left_first, /**< 'LeftFirst' flag */
bool is_invert) /**< is invert */
{
JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (left_value)
&& !ECMA_IS_VALUE_ERROR (right_value));
ecma_value_t ret_value = ecma_op_abstract_relational_compare (left_value, right_value, left_first);
if (ECMA_IS_VALUE_ERROR (ret_value))
{
return ret_value;
}
if (ecma_is_value_undefined (ret_value))
{
ret_value = ECMA_VALUE_FALSE;
}
else
{
JERRY_ASSERT (ecma_is_value_boolean (ret_value));
if (is_invert)
{
ret_value = ecma_invert_boolean_value (ret_value);
}
}
return ret_value;
} /* opfunc_relation */
示例5: ecma_builtin_date_prototype_set_utc_month
/**
* The Date.prototype object's 'setUTCMonth' routine
*
* See also:
* ECMA-262 v5, 15.9.5.39
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_date_prototype_set_utc_month (ecma_value_t this_arg, /**< this argument */
ecma_value_t month, /**< month */
ecma_value_t date) /**< date */
{
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
/* 1. */
ECMA_TRY_CATCH (this_time_value, ecma_builtin_date_prototype_get_time (this_arg), ret_value);
ecma_number_t t = *ecma_get_number_from_value (this_time_value);
/* 2. */
ECMA_OP_TO_NUMBER_TRY_CATCH (m, month, ret_value);
/* 3. */
ECMA_OP_TO_NUMBER_TRY_CATCH (dt, date, ret_value);
if (ecma_is_value_undefined (date))
{
dt = ecma_date_date_from_time (t);
}
/* 4-7. */
ecma_number_t year = ecma_date_year_from_time (t);
ret_value = ecma_date_set_internal_property (this_arg,
ecma_date_make_day (year, m, dt),
ecma_date_time_within_day (t),
ECMA_DATE_UTC);
ECMA_OP_TO_NUMBER_FINALIZE (dt);
ECMA_OP_TO_NUMBER_FINALIZE (m);
ECMA_FINALIZE (this_time_value);
return ret_value;
} /* ecma_builtin_date_prototype_set_utc_month */
示例6: 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 */
示例7: opfunc_greater_than
/**
* 'Greater-than' opcode handler.
*
* See also: ECMA-262 v5, 11.8.2
*
* @return ecma value
* Returned value must be freed with ecma_free_value
*/
ecma_value_t
opfunc_greater_than (ecma_value_t left_value, /**< left value */
ecma_value_t right_value) /**< right value */
{
JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (left_value)
&& !ECMA_IS_VALUE_ERROR (right_value));
ecma_value_t ret_value = ecma_op_abstract_relational_compare (left_value, right_value, false);
if (ECMA_IS_VALUE_ERROR (ret_value))
{
return ret_value;
}
if (ecma_is_value_undefined (ret_value))
{
ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE);
}
else
{
JERRY_ASSERT (ecma_is_value_boolean (ret_value));
}
return ret_value;
} /* opfunc_greater_than */
示例8: ecma_op_to_object
/**
* ToObject operation.
*
* See also:
* ECMA-262 v5, 9.9
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_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_make_normal_completion_value (ecma_copy_value (value, true));
}
else
{
if (ecma_is_value_undefined (value)
|| ecma_is_value_null (value))
{
return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
}
else
{
JERRY_ASSERT (ecma_is_value_boolean (value));
return ecma_op_create_boolean_object (value);
}
}
} /* ecma_op_to_object */
示例9: ecma_builtin_syntax_error_dispatch_call
/**
* Handle calling [[Call]] of built-in SyntaxError object
*
* @return ecma value
*/
ecma_value_t
ecma_builtin_syntax_error_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);
if (arguments_list_len != 0
&& !ecma_is_value_undefined (arguments_list_p[0]))
{
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
ECMA_TRY_CATCH (msg_str_value,
ecma_op_to_string (arguments_list_p[0]),
ret_value);
ecma_string_t *message_string_p = ecma_get_string_from_value (msg_str_value);
ecma_object_t *new_error_object_p = ecma_new_standard_error_with_message (ECMA_ERROR_SYNTAX,
message_string_p);
ret_value = ecma_make_object_value (new_error_object_p);
ECMA_FINALIZE (msg_str_value);
return ret_value;
}
else
{
ecma_object_t *new_error_object_p = ecma_new_standard_error (ECMA_ERROR_SYNTAX);
return ecma_make_object_value (new_error_object_p);
}
} /* ecma_builtin_syntax_error_dispatch_call */
示例10: ecma_builtin_helper_error_dispatch_call
/**
* Handle calling [[Call]] of a built-in error object
*
* @return ecma value
*/
ecma_value_t
ecma_builtin_helper_error_dispatch_call (ecma_standard_error_t error_type, /**< native error type */
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 (arguments_list_len != 0
&& !ecma_is_value_undefined (arguments_list_p[0]))
{
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
ECMA_TRY_CATCH (msg_str_value,
ecma_op_to_string (arguments_list_p[0]),
ret_value);
ecma_string_t *message_string_p = ecma_get_string_from_value (msg_str_value);
ecma_object_t *new_error_object_p = ecma_new_standard_error_with_message (error_type,
message_string_p);
ret_value = ecma_make_object_value (new_error_object_p);
ECMA_FINALIZE (msg_str_value);
return ret_value;
}
else
{
ecma_object_t *new_error_object_p = ecma_new_standard_error (error_type);
return ecma_make_object_value (new_error_object_p);
}
} /* ecma_builtin_helper_error_dispatch_call */
示例11: ecma_op_to_string
/**
* ToString operation.
*
* See also:
* ECMA-262 v5, 9.8
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
ecma_op_to_string (ecma_value_t value) /**< ecma-value */
{
ecma_check_value_type_is_spec_defined (value);
if (unlikely (ecma_is_value_object (value)))
{
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
ECMA_TRY_CATCH (prim_value,
ecma_op_to_primitive (value, ECMA_PREFERRED_TYPE_STRING),
ret_value);
ret_value = ecma_op_to_string (prim_value);
ECMA_FINALIZE (prim_value);
return ret_value;
}
else
{
ecma_string_t *res_p = NULL;
if (ecma_is_value_string (value))
{
res_p = ecma_get_string_from_value (value);
res_p = ecma_copy_or_ref_ecma_string (res_p);
}
else if (ecma_is_value_number (value))
{
ecma_number_t *num_p = ecma_get_number_from_value (value);
res_p = ecma_new_ecma_string_from_number (*num_p);
}
else if (ecma_is_value_undefined (value))
{
res_p = ecma_get_magic_string (LIT_MAGIC_STRING_UNDEFINED);
}
else if (ecma_is_value_null (value))
{
res_p = ecma_get_magic_string (LIT_MAGIC_STRING_NULL);
}
else
{
JERRY_ASSERT (ecma_is_value_boolean (value));
if (ecma_is_value_true (value))
{
res_p = ecma_get_magic_string (LIT_MAGIC_STRING_TRUE);
}
else
{
res_p = ecma_get_magic_string (LIT_MAGIC_STRING_FALSE);
}
}
return ecma_make_normal_completion_value (ecma_make_string_value (res_p));
}
} /* ecma_op_to_string */
示例12: ecma_check_value_type_is_spec_defined
/**
* Debug assertion that specified value's type is one of ECMA-defined
* script-visible types, i.e.: undefined, null, boolean, number, string, object.
*/
void
ecma_check_value_type_is_spec_defined (ecma_value_t value) /**< ecma value */
{
JERRY_ASSERT (ecma_is_value_undefined (value)
|| ecma_is_value_null (value)
|| ecma_is_value_boolean (value)
|| ecma_is_value_number (value)
|| ecma_is_value_string (value)
|| ecma_is_value_object (value));
} /* ecma_check_value_type_is_spec_defined */
示例13: vm_run_global
/**
* Run global code
*/
jerry_completion_code_t
vm_run_global (void)
{
JERRY_ASSERT (__program != NULL);
JERRY_ASSERT (vm_top_context_p == NULL);
#ifdef MEM_STATS
interp_mem_stats_print_legend ();
#endif /* MEM_STATS */
bool is_strict = false;
vm_instr_counter_t start_pos = 0;
opcode_scope_code_flags_t scope_flags = vm_get_scope_flags (__program,
start_pos++);
if (scope_flags & OPCODE_SCOPE_CODE_FLAGS_STRICT)
{
is_strict = true;
}
ecma_object_t *glob_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_GLOBAL);
ecma_object_t *lex_env_p = ecma_get_global_environment ();
ecma_completion_value_t completion = vm_run_from_pos (__program,
start_pos,
ecma_make_object_value (glob_obj_p),
lex_env_p,
is_strict,
false);
jerry_completion_code_t ret_code;
if (ecma_is_completion_value_return (completion))
{
JERRY_ASSERT (ecma_is_value_undefined (ecma_get_completion_value_value (completion)));
ret_code = JERRY_COMPLETION_CODE_OK;
}
else
{
JERRY_ASSERT (ecma_is_completion_value_throw (completion));
ret_code = JERRY_COMPLETION_CODE_UNHANDLED_EXCEPTION;
}
ecma_free_completion_value (completion);
ecma_deref_object (glob_obj_p);
ecma_deref_object (lex_env_p);
JERRY_ASSERT (vm_top_context_p == NULL);
return ret_code;
} /* vm_run_global */
示例14: ecma_op_to_boolean
/**
* ToBoolean operation.
*
* See also:
* ECMA-262 v5, 9.2
*
* @return completion value
* Returned value is simple and so need not be freed.
* However, ecma_free_completion_value may be called for it, but it is a no-op.
*/
ecma_completion_value_t
ecma_op_to_boolean (ecma_value_t value) /**< ecma-value */
{
ecma_check_value_type_is_spec_defined (value);
ecma_simple_value_t ret_value;
if (ecma_is_value_boolean (value))
{
ret_value = (ecma_is_value_true (value) ?
ECMA_SIMPLE_VALUE_TRUE : ECMA_SIMPLE_VALUE_FALSE);
}
else if (ecma_is_value_undefined (value)
|| ecma_is_value_null (value))
{
ret_value = ECMA_SIMPLE_VALUE_FALSE;
}
else if (ecma_is_value_number (value))
{
ecma_number_t *num_p = ecma_get_number_from_value (value);
if (ecma_number_is_nan (*num_p)
|| ecma_number_is_zero (*num_p))
{
ret_value = ECMA_SIMPLE_VALUE_FALSE;
}
else
{
ret_value = ECMA_SIMPLE_VALUE_TRUE;
}
}
else if (ecma_is_value_string (value))
{
ecma_string_t *str_p = ecma_get_string_from_value (value);
if (ecma_string_get_length (str_p) == 0)
{
ret_value = ECMA_SIMPLE_VALUE_FALSE;
}
else
{
ret_value = ECMA_SIMPLE_VALUE_TRUE;
}
}
else
{
JERRY_ASSERT (ecma_is_value_object (value));
ret_value = ECMA_SIMPLE_VALUE_TRUE;
}
return ecma_make_simple_completion_value (ret_value);
} /* ecma_op_to_boolean */
示例15: ecma_op_check_object_coercible
/**
* CheckObjectCoercible operation.
*
* See also:
* ECMA-262 v5, 9.10
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
ecma_op_check_object_coercible (ecma_value_t value) /**< ecma-value */
{
ecma_check_value_type_is_spec_defined (value);
if (ecma_is_value_undefined (value)
|| ecma_is_value_null (value))
{
return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
}
else
{
return ecma_make_empty_completion_value ();
}
} /* ecma_op_check_object_coercible */