Implementing prototype of ToString (Number) routine - ecma_number_to_zt_string; adding unit tests for the routine.
This commit is contained in:
@@ -25,28 +25,41 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get specified magic string
|
||||
* Get specified magic string as zero-terminated string
|
||||
*
|
||||
* @return pointer to magic string contant
|
||||
* @return pointer to zero-terminated magic string
|
||||
*/
|
||||
ecma_string_t*
|
||||
ecma_get_magic_string (ecma_magic_string_id_t id) /**< magic string id */
|
||||
const ecma_char_t*
|
||||
ecma_get_magic_string_zt (ecma_magic_string_id_t id) /**< magic string id */
|
||||
{
|
||||
TODO(Support UTF-16);
|
||||
|
||||
switch (id)
|
||||
{
|
||||
case ECMA_MAGIC_STRING_ARGUMENTS: return ecma_new_ecma_string ((ecma_char_t*) "arguments");
|
||||
case ECMA_MAGIC_STRING_EVAL: return ecma_new_ecma_string ((ecma_char_t*) "eval");
|
||||
case ECMA_MAGIC_STRING_PROTOTYPE: return ecma_new_ecma_string ((ecma_char_t*) "prototype");
|
||||
case ECMA_MAGIC_STRING_CONSTRUCTOR: return ecma_new_ecma_string ((ecma_char_t*) "constructor");
|
||||
case ECMA_MAGIC_STRING_CALLER: return ecma_new_ecma_string ((ecma_char_t*) "caller");
|
||||
case ECMA_MAGIC_STRING_CALLEE: return ecma_new_ecma_string ((ecma_char_t*) "callee");
|
||||
case ECMA_MAGIC_STRING_UNDEFINED: return ecma_new_ecma_string ((ecma_char_t*) "undefined");
|
||||
case ECMA_MAGIC_STRING_LENGTH: return ecma_new_ecma_string ((ecma_char_t*) "length");
|
||||
case ECMA_MAGIC_STRING_ARGUMENTS: return (ecma_char_t*) "arguments";
|
||||
case ECMA_MAGIC_STRING_EVAL: return (ecma_char_t*) "eval";
|
||||
case ECMA_MAGIC_STRING_PROTOTYPE: return (ecma_char_t*) "prototype";
|
||||
case ECMA_MAGIC_STRING_CONSTRUCTOR: return (ecma_char_t*) "constructor";
|
||||
case ECMA_MAGIC_STRING_CALLER: return (ecma_char_t*) "caller";
|
||||
case ECMA_MAGIC_STRING_CALLEE: return (ecma_char_t*) "callee";
|
||||
case ECMA_MAGIC_STRING_UNDEFINED: return (ecma_char_t*) "undefined";
|
||||
case ECMA_MAGIC_STRING_LENGTH: return (ecma_char_t*) "length";
|
||||
case ECMA_MAGIC_STRING_NAN: return (ecma_char_t*) "NaN";
|
||||
case ECMA_MAGIC_STRING_INFINITY: return (ecma_char_t*) "Infinity";
|
||||
}
|
||||
|
||||
JERRY_UNREACHABLE();
|
||||
} /* ecma_get_magic_string_zt */
|
||||
|
||||
/**
|
||||
* Get specified magic string
|
||||
*
|
||||
* @return ecma-string containing specified magic string
|
||||
*/
|
||||
ecma_string_t*
|
||||
ecma_get_magic_string (ecma_magic_string_id_t id) /**< magic string id */
|
||||
{
|
||||
return ecma_new_ecma_string (ecma_get_magic_string_zt (id));
|
||||
} /* ecma_get_magic_string */
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,10 +36,13 @@ typedef enum
|
||||
ECMA_MAGIC_STRING_CONSTRUCTOR, /**< "constructor" */
|
||||
ECMA_MAGIC_STRING_CALLER, /**< "caller" */
|
||||
ECMA_MAGIC_STRING_CALLEE, /**< "callee" */
|
||||
ECMA_MAGIC_STRING_UNDEFINED,/**< undefined */
|
||||
ECMA_MAGIC_STRING_LENGTH /**< length */
|
||||
ECMA_MAGIC_STRING_UNDEFINED,/**< "undefined" */
|
||||
ECMA_MAGIC_STRING_LENGTH, /**< "length" */
|
||||
ECMA_MAGIC_STRING_NAN, /**< "NaN" */
|
||||
ECMA_MAGIC_STRING_INFINITY /**< "Infinity" */
|
||||
} ecma_magic_string_id_t;
|
||||
|
||||
extern const ecma_char_t* ecma_get_magic_string_zt (ecma_magic_string_id_t id);
|
||||
extern ecma_string_t* ecma_get_magic_string (ecma_magic_string_id_t id);
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user