Refactoring function call operations to return 'normal' completion values instead of 'return' completion values. Removing ECMA_FUNCTION_CALL macro.

This commit is contained in:
Ruben Ayrapetyan
2014-09-24 14:21:03 +04:00
parent 3a31bf6eb1
commit 25ec2bea17
9 changed files with 58 additions and 89 deletions
+8 -10
View File
@@ -532,11 +532,9 @@ ecma_op_function_call (ecma_object_t *func_obj_p, /**< Function object */
local_env_p,
is_strict,
false);
if (ecma_is_completion_value_normal (completion))
if (ecma_is_completion_value_return (completion))
{
JERRY_ASSERT(ecma_is_completion_value_empty (completion));
ret_value = ecma_make_return_completion_value (ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED));
ret_value = ecma_make_normal_completion_value (completion.u.value);
}
else
{
@@ -622,12 +620,12 @@ ecma_op_function_construct (ecma_object_t *func_obj_p, /**< Function object */
ecma_deref_object (prototype_p);
// 8.
ECMA_FUNCTION_CALL (call_completion,
ecma_op_function_call (func_obj_p,
ecma_make_object_value (obj_p),
arguments_list_p,
arguments_list_len),
ret_value);
ECMA_TRY_CATCH (call_completion,
ecma_op_function_call (func_obj_p,
ecma_make_object_value (obj_p),
arguments_list_p,
arguments_list_len),
ret_value);
ecma_value_t obj_value;
+3 -3
View File
@@ -240,9 +240,9 @@ ecma_op_put_value (ecma_reference_t ref, /**< ECMA-reference */
ecma_object_t *setter_p = ECMA_GET_POINTER(prop_p->u.named_accessor_property.set_p);
JERRY_ASSERT (setter_p != NULL);
ECMA_FUNCTION_CALL (call_completion,
ecma_op_function_call (setter_p, base, &value, 1),
ret_value);
ECMA_TRY_CATCH (call_completion,
ecma_op_function_call (setter_p, base, &value, 1),
ret_value);
ret_value = ecma_make_empty_completion_value ();
+12 -12
View File
@@ -159,12 +159,12 @@ ecma_op_general_object_get (ecma_object_t *obj_p, /**< the object */
{
ecma_completion_value_t ret_value;
ECMA_FUNCTION_CALL (call_completion,
ecma_op_function_call (getter_p,
ecma_make_object_value (obj_p),
NULL,
0),
ret_value);
ECMA_TRY_CATCH (call_completion,
ecma_op_function_call (getter_p,
ecma_make_object_value (obj_p),
NULL,
0),
ret_value);
ret_value = ecma_make_normal_completion_value (ecma_copy_value (call_completion.u.value, true));
@@ -308,12 +308,12 @@ ecma_op_general_object_put (ecma_object_t *obj_p, /**< the object */
ecma_completion_value_t ret_value;
ECMA_FUNCTION_CALL (call_completion,
ecma_op_function_call (setter_p,
ecma_make_object_value (obj_p),
&value,
1),
ret_value);
ECMA_TRY_CATCH (call_completion,
ecma_op_function_call (setter_p,
ecma_make_object_value (obj_p),
&value,
1),
ret_value);
ret_value = ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
+3 -32
View File
@@ -39,42 +39,13 @@
{ \
JERRY_ASSERT(ecma_is_completion_value_normal (var))
/**
* The macro defines function call block that executes function call 'op',
* assigns call's completion value to 'var', and checks for exceptions
* that might be thrown during initialization.
*
* If no return values is not return completion value,
* then code after the function call block is executed.
* Otherwise, completion value is just copied to return_value.
*
* Note:
* Each ECMA_FUNCTION_CALL should have it's own corresponding ECMA_FINALIZE
* statement with same argument as corresponding ECMA_FUNCTION_CALL's first argument.
*/
#define ECMA_FUNCTION_CALL(var, op, return_value) \
ecma_completion_value_t var = op; \
if (unlikely (!ecma_is_completion_value_return (var))) \
{ \
return_value = ecma_copy_completion_value (var); \
} \
else \
{ \
JERRY_ASSERT(!ecma_is_completion_value_normal (var))
/**
* The define is not used. It is just for vera++ style checker that wants to find closing pair for all opening braces
*/
#define ECMA_FUNCTION_CALL_CLOSING_BRACKET_FOR_VERA_STYLE_CHECKER }
/**
* The macro marks end of code block that is defined by corresponding
* ECMA_TRY_CATCH / ECMA_FUNCTION_CALL and frees variable, initialized
* by the ECMA_TRY_CATCH / ECMA_FUNCTION_CALL.
* ECMA_TRY_CATCH and frees variable, initialized by the ECMA_TRY_CATCH.
*
* Note:
* Each ECMA_TRY_CATCH / ECMA_FUNCTION_CALL should be followed by ECMA_FINALIZE with same argument
* as corresponding ECMA_TRY_CATCH's / ECMA_FUNCTION_CALL's first argument.
* Each ECMA_TRY_CATCH should be followed by ECMA_FINALIZE with same argument
* as corresponding ECMA_TRY_CATCH's first argument.
*/
#define ECMA_FINALIZE(var) } \
ecma_free_completion_value (var)