Introducing built-in routines dispatcher and stubs for the Global object's routines.

This commit is contained in:
Ruben Ayrapetyan
2014-09-18 16:20:20 +04:00
parent 30008f8dc5
commit 55d9b12176
3 changed files with 406 additions and 0 deletions
@@ -108,6 +108,235 @@ ecma_builtin_finalize_global_object (void)
ecma_global_object_p = NULL;
} /* ecma_builtin_finalize_global_object */
/**
* The Global object's 'eval' routine
*
* See also:
* ECMA-262 v5, 15.1.2.1
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_global_object_eval (ecma_value_t x) /**< routine's first argument */
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS (x);
} /* ecma_builtin_global_object_eval */
/**
* The Global object's 'parseInt' routine
*
* See also:
* ECMA-262 v5, 15.1.2.2
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_global_object_parse_int (ecma_value_t string, /**< routine's first argument */
ecma_value_t radix) /**< routine's second argument */
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS (string, radix);
} /* ecma_builtin_global_object_parse_int */
/**
* The Global object's 'parseFloat' routine
*
* See also:
* ECMA-262 v5, 15.1.2.3
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_global_object_parse_float (ecma_value_t string) /**< routine's first argument */
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS (string);
} /* ecma_builtin_global_object_parse_float */
/**
* The Global object's 'isNaN' routine
*
* See also:
* ECMA-262 v5, 15.1.2.4
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_global_object_is_nan (ecma_value_t number) /**< routine's first argument */
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS (number);
} /* ecma_builtin_global_object_is_nan */
/**
* The Global object's 'isFinite' routine
*
* See also:
* ECMA-262 v5, 15.1.2.5
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_global_object_is_finite (ecma_value_t number) /**< routine's first argument */
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS (number);
} /* ecma_builtin_global_object_is_finite */
/**
* The Global object's 'decodeURI' routine
*
* See also:
* ECMA-262 v5, 15.1.3.1
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_global_object_decode_uri (ecma_value_t encoded_uri) /**< routine's first argument */
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS (encoded_uri);
} /* ecma_builtin_global_object_decode_uri */
/**
* The Global object's 'decodeURIComponent' routine
*
* See also:
* ECMA-262 v5, 15.1.3.2
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_global_object_decode_uri_component (ecma_value_t encoded_uri_component) /**< routine's first argument */
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS (encoded_uri_component);
} /* ecma_builtin_global_object_decode_uri_component */
/**
* The Global object's 'encodeURI' routine
*
* See also:
* ECMA-262 v5, 15.1.3.3
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_global_object_encode_uri (ecma_value_t uri) /**< routine's first argument */
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS (uri);
} /* ecma_builtin_global_object_encode_uri */
/**
* The Global object's 'encodeURIComponent' routine
*
* See also:
* ECMA-262 v5, 15.1.3.4
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_global_object_encode_uri_component (ecma_value_t uri_component) /**< routine's first argument */
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS (uri_component);
} /* ecma_builtin_global_object_encode_uri_component */
/**
* Dispatcher of the Global object's built-in routines
*
* @return completion-value
* Returned value must be freed with ecma_free_completion_value.
*/
ecma_completion_value_t
ecma_builtin_global_dispatch_routine (ecma_builtin_global_property_id_t builtin_routine_id, /**< identifier of
the Global object's
initial property that
corresponds to
routine to be called */
ecma_value_t arguments_list [], /**< list of arguments passed to routine */
ecma_length_t arguments_number) /**< length of arguments' list */
{
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
const ecma_value_t value_undefined = ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED);
switch (builtin_routine_id)
{
case ECMA_BUILTIN_GLOBAL_PROPERTY_ID_EVAL:
{
ecma_value_t arg = (arguments_number >= 1 ? arguments_list[0] : value_undefined);
return ecma_builtin_global_object_eval (arg);
}
case ECMA_BUILTIN_GLOBAL_PROPERTY_ID_PARSE_INT:
{
ecma_value_t arg1 = (arguments_number >= 1 ? arguments_list[0] : value_undefined);
ecma_value_t arg2 = (arguments_number >= 2 ? arguments_list[1] : value_undefined);
return ecma_builtin_global_object_parse_int (arg1, arg2);
}
case ECMA_BUILTIN_GLOBAL_PROPERTY_ID_PARSE_FLOAT:
{
ecma_value_t arg = (arguments_number >= 1 ? arguments_list[0] : value_undefined);
return ecma_builtin_global_object_parse_float (arg);
}
case ECMA_BUILTIN_GLOBAL_PROPERTY_ID_IS_NAN:
{
ecma_value_t arg = (arguments_number >= 1 ? arguments_list[0] : value_undefined);
return ecma_builtin_global_object_is_nan (arg);
}
case ECMA_BUILTIN_GLOBAL_PROPERTY_ID_IS_FINITE:
{
ecma_value_t arg = (arguments_number >= 1 ? arguments_list[0] : value_undefined);
return ecma_builtin_global_object_is_finite (arg);
}
case ECMA_BUILTIN_GLOBAL_PROPERTY_ID_DECODE_URI:
{
ecma_value_t arg = (arguments_number >= 1 ? arguments_list[0] : value_undefined);
return ecma_builtin_global_object_decode_uri (arg);
}
case ECMA_BUILTIN_GLOBAL_PROPERTY_ID_DECODE_URI_COMPONENT:
{
ecma_value_t arg = (arguments_number >= 1 ? arguments_list[0] : value_undefined);
return ecma_builtin_global_object_decode_uri_component (arg);
}
case ECMA_BUILTIN_GLOBAL_PROPERTY_ID_ENCODE_URI:
{
ecma_value_t arg = (arguments_number >= 1 ? arguments_list[0] : value_undefined);
return ecma_builtin_global_object_encode_uri (arg);
}
case ECMA_BUILTIN_GLOBAL_PROPERTY_ID_ENCODE_URI_COMPONENT:
{
ecma_value_t arg = (arguments_number >= 1 ? arguments_list[0] : value_undefined);
return ecma_builtin_global_object_encode_uri_component (arg);
}
default:
{
JERRY_UNREACHABLE ();
}
}
JERRY_ASSERT (!ecma_is_completion_value_empty (ret_value));
} /* ecma_builtin_global_dispatch_routine */
/**
* @}
* @}