本文整理匯總了C++中ECMA_TRY_CATCH函數的典型用法代碼示例。如果您正苦於以下問題:C++ ECMA_TRY_CATCH函數的具體用法?C++ ECMA_TRY_CATCH怎麽用?C++ ECMA_TRY_CATCH使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了ECMA_TRY_CATCH函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: ecma_builtin_object_prototype_object_has_own_property
/**
* The Object.prototype object's 'hasOwnProperty' routine
*
* See also:
* ECMA-262 v5, 15.2.4.5
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_object_prototype_object_has_own_property (ecma_value_t this_arg, /**< this argument */
ecma_value_t arg) /**< first argument */
{
ecma_value_t return_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
/* 1. */
ECMA_TRY_CATCH (to_string_val,
ecma_op_to_string (arg),
return_value);
/* 2. */
ECMA_TRY_CATCH (obj_val,
ecma_op_to_object (this_arg),
return_value);
ecma_string_t *property_name_string_p = ecma_get_string_from_value (to_string_val);
ecma_object_t *obj_p = ecma_get_object_from_value (obj_val);
/* 3. */
return_value = ecma_make_boolean_value (ecma_op_object_has_own_property (obj_p, property_name_string_p));
ECMA_FINALIZE (obj_val);
ECMA_FINALIZE (to_string_val);
return return_value;
} /* ecma_builtin_object_prototype_object_has_own_property */
示例2: 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 */
示例3: 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 */
示例4: opfunc_not_equal_value
/**
* 'Does-not-equals' opcode handler.
*
* See also: ECMA-262 v5, 11.9.2
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_not_equal_value (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
const idx_t dst_var_idx = instr.data.not_equal_value.dst;
const idx_t left_var_idx = instr.data.not_equal_value.var_left;
const idx_t right_var_idx = instr.data.not_equal_value.var_right;
//ilyushin
printf("not_equal_value,");
//ilyushin
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
ECMA_TRY_CATCH (left_value, get_variable_value (frame_ctx_p, left_var_idx, false), ret_value);
ECMA_TRY_CATCH (right_value, get_variable_value (frame_ctx_p, right_var_idx, false), ret_value);
ECMA_TRY_CATCH (compare_result,
ecma_op_abstract_equality_compare (left_value, right_value),
ret_value);
JERRY_ASSERT (ecma_is_value_boolean (compare_result));
bool is_equal = ecma_is_value_true (compare_result);
ret_value = set_variable_value (frame_ctx_p, frame_ctx_p->pos, dst_var_idx,
ecma_make_simple_value (is_equal ? ECMA_SIMPLE_VALUE_FALSE
: ECMA_SIMPLE_VALUE_TRUE));
ECMA_FINALIZE (compare_result);
ECMA_FINALIZE (right_value);
ECMA_FINALIZE (left_value);
frame_ctx_p->pos++;
return ret_value;
} /* opfunc_not_equal_value */
示例5: ecma_builtin_object_prototype_object_is_prototype_of
/**
* The Object.prototype object's 'isPrototypeOf' routine
*
* See also:
* ECMA-262 v5, 15.2.4.6
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_object_prototype_object_is_prototype_of (ecma_value_t this_arg, /**< this argument */
ecma_value_t arg) /**< routine's first argument */
{
/* 1. Is the argument an object? */
if (!ecma_is_value_object (arg))
{
return ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE);
}
ecma_value_t return_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
/* 2. ToObject(this) */
ECMA_TRY_CATCH (obj_value,
ecma_op_to_object (this_arg),
return_value);
ecma_object_t *obj_p = ecma_get_object_from_value (obj_value);
/* 3. Compare prototype to object */
ECMA_TRY_CATCH (v_obj_value,
ecma_op_to_object (arg),
return_value);
ecma_object_t *v_obj_p = ecma_get_object_from_value (v_obj_value);
bool is_prototype_of = ecma_op_object_is_prototype_of (obj_p, v_obj_p);
return_value = ecma_make_simple_value (is_prototype_of ? ECMA_SIMPLE_VALUE_TRUE
: ECMA_SIMPLE_VALUE_FALSE);
ECMA_FINALIZE (v_obj_value);
ECMA_FINALIZE (obj_value);
return return_value;
} /* ecma_builtin_object_prototype_object_is_prototype_of */
示例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: ecma_builtin_string_prototype_object_char_code_at
/**
* The String.prototype object's 'charCodeAt' routine
*
* See also:
* ECMA-262 v5, 15.5.4.5
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_char_code_at (ecma_value_t this_arg, /**< this argument */
ecma_value_t arg) /**< routine's argument */
{
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
/* 1 */
ECMA_TRY_CATCH (check_coercible_val,
ecma_op_check_object_coercible (this_arg),
ret_value);
/* 2 */
ECMA_TRY_CATCH (to_string_val,
ecma_op_to_string (this_arg),
ret_value);
/* 3 */
ECMA_OP_TO_NUMBER_TRY_CATCH (index_num,
arg,
ret_value);
/* 4 */
ecma_string_t *original_string_p = ecma_get_string_from_value (to_string_val);
const ecma_length_t len = ecma_string_get_length (original_string_p);
ecma_number_t *ret_num_p = ecma_alloc_number ();
/* 5 */
// When index_num is NaN, then the first two comparisons are false
if (index_num < 0 || index_num >= len || (ecma_number_is_nan (index_num) && !len))
{
*ret_num_p = ecma_number_make_nan ();
}
else
{
/* 6 */
/*
* String length is currently uit32_t, but index_num may be bigger,
* ToInteger performs floor, while ToUInt32 performs modulo 2^32,
* hence after the check 0 <= index_num < len we assume to_uint32 can be used.
* We assume to_uint32 (NaN) is 0.
*/
JERRY_ASSERT (ecma_number_is_nan (index_num) || ecma_number_to_uint32 (index_num) == ecma_number_trunc (index_num));
ecma_char_t new_ecma_char = ecma_string_get_char_at_pos (original_string_p, ecma_number_to_uint32 (index_num));
*ret_num_p = ecma_uint32_to_number (new_ecma_char);
}
ecma_value_t new_value = ecma_make_number_value (ret_num_p);
ret_value = ecma_make_normal_completion_value (new_value);
ECMA_OP_TO_NUMBER_FINALIZE (index_num);
ECMA_FINALIZE (to_string_val);
ECMA_FINALIZE (check_coercible_val);
return ret_value;
} /* ecma_builtin_string_prototype_object_char_code_at */
示例8: ecma_builtin_string_prototype_object_concat
/**
* The String.prototype object's 'concat' routine
*
* See also:
* ECMA-262 v5, 15.5.4.6
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_concat (ecma_value_t this_arg, /**< this argument */
const ecma_value_t* argument_list_p, /**< arguments list */
ecma_length_t arguments_number) /**< number of arguments */
{
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
/* 1 */
ECMA_TRY_CATCH (check_coercible_val,
ecma_op_check_object_coercible (this_arg),
ret_value);
/* 2 */
ECMA_TRY_CATCH (to_string_val,
ecma_op_to_string (this_arg),
ret_value);
/* 3 */
// No copy performed
/* 4 */
ecma_string_t *string_to_return = ecma_copy_or_ref_ecma_string (ecma_get_string_from_value (to_string_val));
/* 5 */
for (uint32_t arg_index = 0;
arg_index < arguments_number && ecma_is_completion_value_empty (ret_value);
++arg_index)
{
/* 5a */
/* 5b */
ecma_string_t *string_temp = string_to_return;
ECMA_TRY_CATCH (get_arg_string,
ecma_op_to_string (argument_list_p[arg_index]),
ret_value);
string_to_return = ecma_concat_ecma_strings (string_to_return, ecma_get_string_from_value (get_arg_string));
ecma_deref_ecma_string (string_temp);
ECMA_FINALIZE (get_arg_string);
}
/* 6 */
if (ecma_is_completion_value_empty (ret_value))
{
ret_value = ecma_make_normal_completion_value (ecma_make_string_value (string_to_return));
}
else
{
ecma_deref_ecma_string (string_to_return);
}
ECMA_FINALIZE (to_string_val);
ECMA_FINALIZE (check_coercible_val);
return ret_value;
} /* ecma_builtin_string_prototype_object_concat */
示例9: ecma_builtin_helper_string_prototype_object_index_of
/**
* Helper function for string indexOf and lastIndexOf functions
*
* This function implements string indexOf and lastIndexOf with required checks and conversions.
*
* See also:
* ECMA-262 v5, 15.5.4.7
* ECMA-262 v5, 15.5.4.8
*
* Used by:
* - The String.prototype.indexOf routine.
* - The String.prototype.lastIndexOf routine.
*
* @return uint32_t - (last) index of search string
*/
ecma_value_t
ecma_builtin_helper_string_prototype_object_index_of (ecma_value_t this_arg, /**< this argument */
ecma_value_t arg1, /**< routine's first argument */
ecma_value_t arg2, /**< routine's second argument */
bool first_index) /**< routine's third argument */
{
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
/* 1 */
ECMA_TRY_CATCH (check_coercible_val,
ecma_op_check_object_coercible (this_arg),
ret_value);
/* 2 */
ECMA_TRY_CATCH (to_str_val,
ecma_op_to_string (this_arg),
ret_value);
/* 3 */
ECMA_TRY_CATCH (search_str_val,
ecma_op_to_string (arg1),
ret_value);
/* 4 */
ECMA_OP_TO_NUMBER_TRY_CATCH (pos_num,
arg2,
ret_value);
/* 5 (indexOf) -- 6 (lastIndexOf) */
ecma_string_t *original_str_p = ecma_get_string_from_value (to_str_val);
const ecma_length_t original_len = ecma_string_get_length (original_str_p);
/* 4b, 6 (indexOf) - 4b, 5, 7 (lastIndexOf) */
ecma_length_t start = ecma_builtin_helper_string_index_normalize (pos_num, original_len, first_index);
/* 7 (indexOf) -- 8 (lastIndexOf) */
ecma_string_t *search_str_p = ecma_get_string_from_value (search_str_val);
ecma_number_t ret_num = ECMA_NUMBER_MINUS_ONE;
/* 8 (indexOf) -- 9 (lastIndexOf) */
ecma_length_t index_of = 0;
if (ecma_builtin_helper_string_find_index (original_str_p, search_str_p, first_index, start, &index_of))
{
ret_num = ((ecma_number_t) index_of);
}
ret_value = ecma_make_number_value (ret_num);
ECMA_OP_TO_NUMBER_FINALIZE (pos_num);
ECMA_FINALIZE (search_str_val);
ECMA_FINALIZE (to_str_val);
ECMA_FINALIZE (check_coercible_val);
return ret_value;
} /* ecma_builtin_helper_string_prototype_object_index_of */
示例10: 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 ret_value = ECMA_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_VALUE_NULL;
}
}
if (ecma_is_value_empty (ret_value))
{
ecma_object_t *value_obj_p = ecma_get_object_from_value (obj);
/* 4. */
ECMA_TRY_CATCH (to_iso,
ecma_op_object_get_by_magic_id (value_obj_p, LIT_MAGIC_STRING_TO_ISO_STRING_UL),
ret_value);
/* 5. */
if (!ecma_op_is_callable (to_iso))
{
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("'toISOString' is missing or not a function."));
}
/* 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_FINALIZE (tv);
ECMA_FINALIZE (obj);
return ret_value;
} /* ecma_builtin_date_prototype_to_json */
示例11: ecma_builtin_string_prototype_object_trim
/**
* The String.prototype object's 'trim' routine
*
* See also:
* ECMA-262 v5, 15.5.4.20
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_trim (ecma_value_t this_arg) /**< this argument */
{
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
/* 1 */
ECMA_TRY_CATCH (check_coercible_val,
ecma_op_check_object_coercible (this_arg),
ret_value);
/* 2 */
ECMA_TRY_CATCH (to_string_val,
ecma_op_to_string (this_arg),
ret_value);
ecma_string_t *original_string_p = ecma_get_string_from_value (to_string_val);
/* 3 */
const lit_utf8_size_t size = ecma_string_get_size (original_string_p);
const ecma_length_t length = ecma_string_get_size (original_string_p);
/* Workaround: avoid repeated call of ecma_string_get_char_at_pos() because its overhead */
lit_utf8_byte_t *original_utf8_str_p = (lit_utf8_byte_t *) mem_heap_alloc_block (size + 1,
MEM_HEAP_ALLOC_SHORT_TERM);
ecma_string_to_utf8_string (original_string_p, original_utf8_str_p, (ssize_t) size);
uint32_t prefix = 0, postfix = 0;
uint32_t new_len = 0;
while (prefix < length && isspace (lit_utf8_string_code_unit_at (original_utf8_str_p, size, prefix)))
{
prefix++;
}
while (postfix < length - prefix && isspace (lit_utf8_string_code_unit_at (original_utf8_str_p,
size,
length - postfix - 1)))
{
postfix++;
}
new_len = prefix < size ? size - prefix - postfix : 0;
ecma_string_t *new_str_p = ecma_string_substr (original_string_p, prefix, prefix + new_len);
/* 4 */
ret_value = ecma_make_normal_completion_value (ecma_make_string_value (new_str_p));
mem_heap_free_block (original_utf8_str_p);
ECMA_FINALIZE (to_string_val);
ECMA_FINALIZE (check_coercible_val);
return ret_value;
} /* ecma_builtin_string_prototype_object_trim */
示例12: ecma_builtin_regexp_prototype_exec
/**
* The RegExp.prototype object's 'exec' routine
*
* See also:
* ECMA-262 v5, 15.10.6.2
*
* @return array object containing the results - if the matched
* null - otherwise
*
* May raise error, so returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_regexp_prototype_exec (ecma_value_t this_arg, /**< this argument */
ecma_value_t arg) /**< routine's argument */
{
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_REGEXP_UL)
{
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Incomplete RegExp type"));
}
else
{
ECMA_TRY_CATCH (obj_this, ecma_op_to_object (this_arg), ret_value);
ECMA_TRY_CATCH (input_str_value,
ecma_op_to_string (arg),
ret_value);
ecma_property_t *bytecode_prop_p;
ecma_object_t *obj_p = ecma_get_object_from_value (obj_this);
bytecode_prop_p = ecma_get_internal_property (obj_p, ECMA_INTERNAL_PROPERTY_REGEXP_BYTECODE);
void *bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (void, ecma_get_internal_property_value (bytecode_prop_p));
if (bytecode_p == NULL)
{
/* Missing bytecode means empty RegExp: '/(?:)/', so always return empty string. */
ecma_string_t *capture_str_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
ecma_value_t arguments_list[1];
arguments_list[0] = ecma_make_string_value (capture_str_p);
ret_value = ecma_op_create_array_object (arguments_list, 1, false);
ecma_deref_ecma_string (capture_str_p);
re_set_result_array_properties (ecma_get_object_from_value (ret_value),
ecma_get_string_from_value (input_str_value),
1,
0);
}
else
{
ret_value = ecma_regexp_exec_helper (obj_this, input_str_value, false);
}
ECMA_FINALIZE (input_str_value);
ECMA_FINALIZE (obj_this);
}
return ret_value;
} /* ecma_builtin_regexp_prototype_exec */
示例13: ecma_op_create_regexp_object
/**
* RegExp object creation operation.
*
* See also: ECMA-262 v5, 15.10.4.1
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
ecma_op_create_regexp_object (ecma_string_t *pattern_p, /**< input pattern */
ecma_string_t *flags_str_p) /**< flags */
{
JERRY_ASSERT (pattern_p != NULL);
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
uint8_t flags = 0;
if (flags_str_p != NULL)
{
ECMA_TRY_CATCH (empty, re_parse_regexp_flags (flags_str_p, &flags), ret_value);
ECMA_FINALIZE (empty);
if (!ecma_is_completion_value_empty (ret_value))
{
return ret_value;
}
}
ecma_object_t *re_prototype_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_REGEXP_PROTOTYPE);
ecma_object_t *obj_p = ecma_create_object (re_prototype_obj_p, true, ECMA_OBJECT_TYPE_GENERAL);
ecma_deref_object (re_prototype_obj_p);
/* Set the internal [[Class]] property */
ecma_property_t *class_prop_p = ecma_create_internal_property (obj_p, ECMA_INTERNAL_PROPERTY_CLASS);
class_prop_p->u.internal_property.value = LIT_MAGIC_STRING_REGEXP_UL;
re_initialize_props (obj_p, pattern_p, flags);
/* Set bytecode internal property. */
ecma_property_t *bytecode_prop_p;
bytecode_prop_p = ecma_create_internal_property (obj_p, ECMA_INTERNAL_PROPERTY_REGEXP_BYTECODE);
/* Compile bytecode. */
re_bytecode_t *bc_p = NULL;
ECMA_TRY_CATCH (empty, re_compile_bytecode (&bc_p, pattern_p, flags), ret_value);
ECMA_SET_POINTER (bytecode_prop_p->u.internal_property.value, bc_p);
ret_value = ecma_make_normal_completion_value (ecma_make_object_value (obj_p));
ECMA_FINALIZE (empty);
if (ecma_is_completion_value_throw (ret_value))
{
ecma_deref_object (obj_p);
}
return ret_value;
} /* ecma_op_create_regexp_object */
示例14: opfunc_greater_or_equal_than
/**
* 'Greater-than-or-equal' opcode handler.
*
* See also: ECMA-262 v5, 11.8.4
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
opfunc_greater_or_equal_than (vm_instr_t instr, /**< instruction */
vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */
{
const idx_t dst_var_idx = instr.data.greater_or_equal_than.dst;
const idx_t left_var_idx = instr.data.greater_or_equal_than.var_left;
const idx_t right_var_idx = instr.data.greater_or_equal_than.var_right;
//ilyushin
printf("greater_or_equal_than,");
//ilyushin
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
ECMA_TRY_CATCH (left_value, get_variable_value (frame_ctx_p, left_var_idx, false), ret_value);
ECMA_TRY_CATCH (right_value, get_variable_value (frame_ctx_p, right_var_idx, false), ret_value);
ECMA_TRY_CATCH (compare_result,
ecma_op_abstract_relational_compare (left_value, right_value, true),
ret_value);
ecma_simple_value_t res;
if (ecma_is_value_undefined (compare_result))
{
res = ECMA_SIMPLE_VALUE_FALSE;
}
else
{
JERRY_ASSERT (ecma_is_value_boolean (compare_result));
if (ecma_is_value_true (compare_result))
{
res = ECMA_SIMPLE_VALUE_FALSE;
}
else
{
res = ECMA_SIMPLE_VALUE_TRUE;
}
}
ret_value = set_variable_value (frame_ctx_p, frame_ctx_p->pos, dst_var_idx, ecma_make_simple_value (res));
ECMA_FINALIZE (compare_result);
ECMA_FINALIZE (right_value);
ECMA_FINALIZE (left_value);
frame_ctx_p->pos++;
return ret_value;
} /* opfunc_greater_or_equal_than */
示例15: ecma_builtin_date_prototype_set_milliseconds
/**
* The Date.prototype object's 'setMilliseconds' routine
*
* See also:
* ECMA-262 v5, 15.9.5.28
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_date_prototype_set_milliseconds (ecma_value_t this_arg, /**< this argument */
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_date_local_time (*ecma_get_number_from_value (this_time_value));
/* 2. */
ECMA_OP_TO_NUMBER_TRY_CATCH (milli, ms, ret_value);
/* 3-5. */
ecma_number_t hour = ecma_date_hour_from_time (t);
ecma_number_t min = ecma_date_min_from_time (t);
ecma_number_t sec = ecma_date_sec_from_time (t);
ret_value = ecma_date_set_internal_property (this_arg,
ecma_date_day (t),
ecma_date_make_time (hour, min, sec, milli),
ECMA_DATE_LOCAL);
ECMA_OP_TO_NUMBER_FINALIZE (milli);
ECMA_FINALIZE (this_time_value);
return ret_value;
} /* ecma_builtin_date_prototype_set_milliseconds */