Skip to content

Commit 69bfcea

Browse files
Zsolt Borbélydbatyai
authored andcommitted
Move of built-in implementation helpers to jerry-core/ecma/builtin-objects
Related issue: #145 JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély [email protected]
1 parent 3c4c545 commit 69bfcea

File tree

3 files changed

+61
-140
lines changed

3 files changed

+61
-140
lines changed

jerry-core/ecma/builtin-objects/ecma-builtin-array-prototype.cpp

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
#include "ecma-alloc.h"
1818
#include "ecma-array-object.h"
19-
#include "ecma-array-prototype.h"
2019
#include "ecma-builtin-helpers.h"
2120
#include "ecma-builtins.h"
2221
#include "ecma-comparison.h"
@@ -314,6 +313,67 @@ ecma_builtin_array_prototype_object_for_each (ecma_value_t this_arg, /**< this a
314313
return ret_value;
315314
} /* ecma_builtin_array_prototype_object_for_each */
316315

316+
/**
317+
* The Array.prototype.toString's separator creation routine
318+
*
319+
* See also:
320+
* ECMA-262 v5.1, 15.4.4.2 4th step
321+
*
322+
* @return completion value
323+
* Returned value must be freed with ecma_free_completion_value.
324+
*/
325+
static ecma_completion_value_t
326+
ecma_op_array_get_separator_string (ecma_value_t separator) /** < possible separator */
327+
{
328+
if (ecma_is_value_undefined (separator))
329+
{
330+
ecma_string_t *comma_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_COMMA_CHAR);
331+
return ecma_make_normal_completion_value (ecma_make_string_value (comma_string_p));
332+
}
333+
else
334+
{
335+
return ecma_op_to_string (separator);
336+
}
337+
} /* ecma_op_array_get_separator_string */
338+
339+
/**
340+
* The Array.prototype's 'toString' single element operation routine
341+
*
342+
* See also:
343+
* ECMA-262 v5.1, 15.4.4.2
344+
*
345+
* @return ecma_completion_value_t value
346+
* Returned value must be freed with ecma_free_completion_value.
347+
*/
348+
static ecma_completion_value_t
349+
ecma_op_array_get_to_string_at_index (ecma_object_t *obj_p, /** < this object */
350+
uint32_t index) /** < array index */
351+
{
352+
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
353+
ecma_string_t *index_string_p = ecma_new_ecma_string_from_uint32 (index);
354+
355+
ECMA_TRY_CATCH (index_value,
356+
ecma_op_object_get (obj_p, index_string_p),
357+
ret_value);
358+
359+
if (ecma_is_value_undefined (index_value)
360+
|| ecma_is_value_null (index_value))
361+
{
362+
ecma_string_t *empty_string_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
363+
ret_value = ecma_make_normal_completion_value (ecma_make_string_value (empty_string_p));
364+
}
365+
else
366+
{
367+
ret_value = ecma_op_to_string (index_value);
368+
}
369+
370+
ECMA_FINALIZE (index_value);
371+
372+
ecma_deref_ecma_string (index_string_p);
373+
374+
return ret_value;
375+
} /* ecma_op_array_get_to_string_at_index */
376+
317377
/**
318378
* The Array.prototype object's 'join' routine
319379
*

jerry-core/ecma/operations/ecma-array-prototype.cpp

Lines changed: 0 additions & 102 deletions
This file was deleted.

jerry-core/ecma/operations/ecma-array-prototype.h

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)