Reverting changes related to on-stack GC-root introduction (except of passing ecma_value_t by const reference).
This reverts commits:
31e1405f39d72f8b885e92256b0dc29ecab1a99,
7cb43840b59c539d9b043990ed658ae15a9defc3,
1ab57a4493689806035a9853b0030cc6fea65590,
c24b511ca60587e0db12d46a7e7567c86c3649bc,
b2caf3e8b31b4b6b16499108ee3aabdcb94f0717,
44f9c307fb6204bfd2181b19a9d94cabddf04de9.
This commit is contained in:
+1
-5
@@ -37,11 +37,7 @@ typedef unsigned long mword_t;
|
||||
#define __noinline __attribute__((noinline))
|
||||
#define __used __attribute__((used))
|
||||
#ifndef __attribute_always_inline__
|
||||
# ifdef JERRY_NDEBUG
|
||||
# define __attribute_always_inline__ __attribute__((always_inline))
|
||||
# else /* !JERRY_NDEBUG */
|
||||
# define __attribute_always_inline__
|
||||
# endif /* !JERRY_NDEBUG */
|
||||
# define __attribute_always_inline__ __attribute__((always_inline))
|
||||
#endif /* !__attribute_always_inline__ */
|
||||
#ifndef __attribute_const__
|
||||
# define __attribute_const__ __attribute__((const))
|
||||
|
||||
@@ -367,33 +367,26 @@ run_int (void)
|
||||
|
||||
ecma_init ();
|
||||
|
||||
ecma_object_ptr_t glob_obj_p;
|
||||
ecma_builtin_get (glob_obj_p, ECMA_BUILTIN_ID_GLOBAL);
|
||||
ecma_object_t *glob_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_GLOBAL);
|
||||
|
||||
ecma_object_ptr_t lex_env_p;
|
||||
ecma_op_create_global_environment (lex_env_p, glob_obj_p);
|
||||
ecma_value_t this_binding_value (glob_obj_p);
|
||||
ecma_object_t *lex_env_p = ecma_op_create_global_environment (glob_obj_p);
|
||||
ecma_value_t this_binding_value = ecma_make_object_value (glob_obj_p);
|
||||
|
||||
ecma_completion_value_t run_completion;
|
||||
run_int_from_pos (run_completion,
|
||||
start_pos,
|
||||
this_binding_value,
|
||||
lex_env_p,
|
||||
is_strict,
|
||||
false);
|
||||
ecma_completion_value_t completion = run_int_from_pos (start_pos,
|
||||
this_binding_value,
|
||||
lex_env_p,
|
||||
is_strict,
|
||||
false);
|
||||
|
||||
if (ecma_is_completion_value_exit (run_completion))
|
||||
if (ecma_is_completion_value_exit (completion))
|
||||
{
|
||||
ecma_deref_object (glob_obj_p);
|
||||
ecma_deref_object (lex_env_p);
|
||||
ecma_finalize ();
|
||||
|
||||
ecma_value_t value_ret;
|
||||
ecma_get_completion_value_value (value_ret, run_completion);
|
||||
|
||||
return ecma_is_value_true (value_ret);
|
||||
return ecma_is_value_true (ecma_get_completion_value_value (completion));
|
||||
}
|
||||
else if (ecma_is_completion_value_throw (run_completion))
|
||||
else if (ecma_is_completion_value_throw (completion))
|
||||
{
|
||||
jerry_exit (ERR_UNHANDLED_EXCEPTION);
|
||||
}
|
||||
@@ -401,10 +394,11 @@ run_int (void)
|
||||
JERRY_UNREACHABLE ();
|
||||
}
|
||||
|
||||
void
|
||||
run_int_loop (ecma_completion_value_t &completion, /**< out: completion value */
|
||||
int_data_t *int_data /**< interpretation context */)
|
||||
ecma_completion_value_t
|
||||
run_int_loop (int_data_t *int_data)
|
||||
{
|
||||
ecma_completion_value_t completion;
|
||||
|
||||
#ifdef MEM_STATS
|
||||
mem_heap_stats_t heap_stats_before;
|
||||
mem_pools_stats_t pools_stats_before;
|
||||
@@ -427,7 +421,7 @@ run_int_loop (ecma_completion_value_t &completion, /**< out: completion value */
|
||||
&pools_stats_before);
|
||||
#endif /* MEM_STATS */
|
||||
|
||||
__opfuncs[curr->op_idx] (completion, *curr, int_data);
|
||||
completion = __opfuncs[curr->op_idx] (*curr, int_data);
|
||||
|
||||
#ifdef MEM_STATS
|
||||
interp_mem_stats_opcode_exit (int_data,
|
||||
@@ -441,23 +435,32 @@ run_int_loop (ecma_completion_value_t &completion, /**< out: completion value */
|
||||
}
|
||||
while (ecma_is_completion_value_normal (completion));
|
||||
|
||||
if (ecma_is_completion_value_meta (completion))
|
||||
if (ecma_is_completion_value_break (completion)
|
||||
|| ecma_is_completion_value_continue (completion))
|
||||
{
|
||||
ecma_make_empty_completion_value (completion);
|
||||
JERRY_UNIMPLEMENTED ("break and continue on labels are not supported.");
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
return;
|
||||
if (ecma_is_completion_value_meta (completion))
|
||||
{
|
||||
completion = ecma_make_empty_completion_value ();
|
||||
}
|
||||
|
||||
return completion;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
run_int_from_pos (ecma_completion_value_t &completion, /**< out: completion value */
|
||||
opcode_counter_t start_pos, /**< position to start interpretation at */
|
||||
const ecma_value_t& this_binding_value, /**< value of 'this' binding */
|
||||
const ecma_object_ptr_t& lex_env_p, /**< starting lexical environment */
|
||||
bool is_strict, /**< is execution mode strict? */
|
||||
bool is_eval_code) /**< is current code executed with eval? */
|
||||
ecma_completion_value_t
|
||||
run_int_from_pos (opcode_counter_t start_pos,
|
||||
const ecma_value_t& this_binding_value,
|
||||
ecma_object_t *lex_env_p,
|
||||
bool is_strict,
|
||||
bool is_eval_code)
|
||||
{
|
||||
ecma_completion_value_t completion;
|
||||
|
||||
const opcode_t *curr = &__program[start_pos];
|
||||
JERRY_ASSERT (curr->op_idx == __op__idx_reg_var_decl);
|
||||
|
||||
@@ -467,12 +470,12 @@ run_int_from_pos (ecma_completion_value_t &completion, /**< out: completion valu
|
||||
|
||||
const int32_t regs_num = max_reg_num - min_reg_num + 1;
|
||||
|
||||
MEM_DEFINE_LOCAL_ARRAY (regs, regs_num, ecma_value_packed_t);
|
||||
MEM_DEFINE_LOCAL_ARRAY (regs, regs_num, ecma_value_t);
|
||||
|
||||
int_data_t int_data;
|
||||
int_data.pos = (opcode_counter_t) (start_pos + 1);
|
||||
int_data.this_binding_p = &this_binding_value;
|
||||
int_data.lex_env_p = &lex_env_p;
|
||||
int_data.this_binding = this_binding_value;
|
||||
int_data.lex_env_p = lex_env_p;
|
||||
int_data.is_strict = is_strict;
|
||||
int_data.is_eval_code = is_eval_code;
|
||||
int_data.min_reg_num = min_reg_num;
|
||||
@@ -484,7 +487,7 @@ run_int_from_pos (ecma_completion_value_t &completion, /**< out: completion valu
|
||||
interp_mem_stats_context_enter (&int_data, start_pos);
|
||||
#endif /* MEM_STATS */
|
||||
|
||||
run_int_loop (completion, &int_data);
|
||||
completion = run_int_loop (&int_data);
|
||||
|
||||
JERRY_ASSERT (ecma_is_completion_value_normal (completion)
|
||||
|| ecma_is_completion_value_throw (completion)
|
||||
@@ -500,6 +503,8 @@ run_int_from_pos (ecma_completion_value_t &completion, /**< out: completion valu
|
||||
#endif /* MEM_STATS */
|
||||
|
||||
MEM_FINALIZE_LOCAL_ARRAY (regs);
|
||||
|
||||
return completion;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,20 +17,17 @@
|
||||
#define INTERPRETER_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-value.h"
|
||||
#include "globals.h"
|
||||
#include "opcodes.h"
|
||||
|
||||
void init_int (const opcode_t* program_p, bool dump_mem_stats);
|
||||
bool run_int (void);
|
||||
void run_int_loop (ecma_completion_value_t &ret_value,
|
||||
int_data_t *int_data);
|
||||
void run_int_from_pos (ecma_completion_value_t &ret_value,
|
||||
opcode_counter_t start_pos,
|
||||
const ecma_value_t& this_binding_value,
|
||||
const ecma_object_ptr_t& lex_env_p,
|
||||
bool is_strict,
|
||||
bool is_eval_code);
|
||||
ecma_completion_value_t run_int_loop (int_data_t *int_data);
|
||||
ecma_completion_value_t run_int_from_pos (opcode_counter_t start_pos,
|
||||
const ecma_value_t& this_binding_value,
|
||||
ecma_object_t *lex_env_p,
|
||||
bool is_strict,
|
||||
bool is_eval_code);
|
||||
|
||||
opcode_t read_opcode (opcode_counter_t counter);
|
||||
|
||||
|
||||
@@ -23,19 +23,19 @@
|
||||
* current opcode's position changes by adding specified offset
|
||||
* if argument evaluates to true.
|
||||
*/
|
||||
void
|
||||
opfunc_is_true_jmp_down (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
opcode_t opdata, /**< operation data */
|
||||
ecma_completion_value_t
|
||||
opfunc_is_true_jmp_down (opcode_t opdata, /**< operation data */
|
||||
int_data_t *int_data) /**< interpreter context */
|
||||
{
|
||||
const idx_t cond_var_idx = opdata.data.is_true_jmp_down.value;
|
||||
const opcode_counter_t offset = calc_opcode_counter_from_idx_idx (opdata.data.is_true_jmp_down.opcode_1,
|
||||
opdata.data.is_true_jmp_down.opcode_2);
|
||||
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, cond_value, int_data, cond_var_idx, false);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
ecma_completion_value_t to_bool_completion;
|
||||
ecma_op_to_boolean (to_bool_completion, cond_value);
|
||||
ECMA_TRY_CATCH (cond_value, get_variable_value (int_data, cond_var_idx, false), ret_value);
|
||||
|
||||
ecma_completion_value_t to_bool_completion = ecma_op_to_boolean (cond_value);
|
||||
JERRY_ASSERT (ecma_is_completion_value_normal (to_bool_completion));
|
||||
|
||||
if (ecma_is_completion_value_normal_true (to_bool_completion))
|
||||
@@ -48,25 +48,27 @@ opfunc_is_true_jmp_down (ecma_completion_value_t &ret_value, /**< out: completio
|
||||
int_data->pos++;
|
||||
}
|
||||
|
||||
ecma_make_empty_completion_value (ret_value);
|
||||
ret_value = ecma_make_empty_completion_value ();
|
||||
|
||||
ECMA_FINALIZE (cond_value);
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
/* Likewise to opfunc_is_true_jmp_down, but jumps up. */
|
||||
void
|
||||
opfunc_is_true_jmp_up (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
opcode_t opdata, /**< operation data */
|
||||
ecma_completion_value_t
|
||||
opfunc_is_true_jmp_up (opcode_t opdata, /**< operation data */
|
||||
int_data_t *int_data) /**< interpreter context */
|
||||
{
|
||||
const idx_t cond_var_idx = opdata.data.is_true_jmp_up.value;
|
||||
const opcode_counter_t offset = calc_opcode_counter_from_idx_idx (opdata.data.is_true_jmp_up.opcode_1,
|
||||
opdata.data.is_true_jmp_up.opcode_2);
|
||||
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, cond_value, int_data, cond_var_idx, false);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
ecma_completion_value_t to_bool_completion;
|
||||
ecma_op_to_boolean (to_bool_completion, cond_value);
|
||||
ECMA_TRY_CATCH (cond_value, get_variable_value (int_data, cond_var_idx, false), ret_value);
|
||||
|
||||
ecma_completion_value_t to_bool_completion = ecma_op_to_boolean (cond_value);
|
||||
JERRY_ASSERT (ecma_is_completion_value_normal (to_bool_completion));
|
||||
|
||||
if (ecma_is_completion_value_normal_true (to_bool_completion))
|
||||
@@ -79,9 +81,11 @@ opfunc_is_true_jmp_up (ecma_completion_value_t &ret_value, /**< out: completion
|
||||
int_data->pos++;
|
||||
}
|
||||
|
||||
ecma_make_empty_completion_value (ret_value);
|
||||
ret_value = ecma_make_empty_completion_value ();
|
||||
|
||||
ECMA_FINALIZE (cond_value);
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,19 +95,19 @@ opfunc_is_true_jmp_up (ecma_completion_value_t &ret_value, /**< out: completion
|
||||
* current opcode's position changes by adding specified offset
|
||||
* if argument evaluates to false.
|
||||
*/
|
||||
void
|
||||
opfunc_is_false_jmp_down (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
opcode_t opdata, /**< operation data */
|
||||
ecma_completion_value_t
|
||||
opfunc_is_false_jmp_down (opcode_t opdata, /**< operation data */
|
||||
int_data_t *int_data) /**< interpreter context */
|
||||
{
|
||||
const idx_t cond_var_idx = opdata.data.is_false_jmp_down.value;
|
||||
const opcode_counter_t offset = calc_opcode_counter_from_idx_idx (opdata.data.is_false_jmp_down.opcode_1,
|
||||
opdata.data.is_false_jmp_down.opcode_2);
|
||||
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, cond_value, int_data, cond_var_idx, false);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
ecma_completion_value_t to_bool_completion;
|
||||
ecma_op_to_boolean (to_bool_completion, cond_value);
|
||||
ECMA_TRY_CATCH (cond_value, get_variable_value (int_data, cond_var_idx, false), ret_value);
|
||||
|
||||
ecma_completion_value_t to_bool_completion = ecma_op_to_boolean (cond_value);
|
||||
JERRY_ASSERT (ecma_is_completion_value_normal (to_bool_completion));
|
||||
|
||||
if (!ecma_is_completion_value_normal_true (to_bool_completion))
|
||||
@@ -116,25 +120,27 @@ opfunc_is_false_jmp_down (ecma_completion_value_t &ret_value, /**< out: completi
|
||||
int_data->pos++;
|
||||
}
|
||||
|
||||
ecma_make_empty_completion_value (ret_value);
|
||||
ret_value = ecma_make_empty_completion_value ();
|
||||
|
||||
ECMA_FINALIZE (cond_value);
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
/* Likewise to opfunc_is_false_jmp_down, but jumps up. */
|
||||
void
|
||||
opfunc_is_false_jmp_up (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
opcode_t opdata, /**< operation data */
|
||||
ecma_completion_value_t
|
||||
opfunc_is_false_jmp_up (opcode_t opdata, /**< operation data */
|
||||
int_data_t *int_data) /**< interpreter context */
|
||||
{
|
||||
const idx_t cond_var_idx = opdata.data.is_false_jmp_up.value;
|
||||
const opcode_counter_t offset = calc_opcode_counter_from_idx_idx (opdata.data.is_false_jmp_up.opcode_1,
|
||||
opdata.data.is_false_jmp_up.opcode_2);
|
||||
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, cond_value, int_data, cond_var_idx, false);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
ecma_completion_value_t to_bool_completion;
|
||||
ecma_op_to_boolean (to_bool_completion, cond_value);
|
||||
ECMA_TRY_CATCH (cond_value, get_variable_value (int_data, cond_var_idx, false), ret_value);
|
||||
|
||||
ecma_completion_value_t to_bool_completion = ecma_op_to_boolean (cond_value);
|
||||
JERRY_ASSERT (ecma_is_completion_value_normal (to_bool_completion));
|
||||
|
||||
if (!ecma_is_completion_value_normal_true (to_bool_completion))
|
||||
@@ -147,9 +153,11 @@ opfunc_is_false_jmp_up (ecma_completion_value_t &ret_value, /**< out: completion
|
||||
int_data->pos++;
|
||||
}
|
||||
|
||||
ecma_make_empty_completion_value (ret_value);
|
||||
ret_value = ecma_make_empty_completion_value ();
|
||||
|
||||
ECMA_FINALIZE (cond_value);
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,9 +166,8 @@ opfunc_is_false_jmp_up (ecma_completion_value_t &ret_value, /**< out: completion
|
||||
* Note:
|
||||
* the opcode changes adds specified value to current opcode position
|
||||
*/
|
||||
void
|
||||
opfunc_jmp_down (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
opcode_t opdata, /**< operation data */
|
||||
ecma_completion_value_t
|
||||
opfunc_jmp_down (opcode_t opdata, /**< operation data */
|
||||
int_data_t *int_data) /**< interpreter context */
|
||||
{
|
||||
const opcode_counter_t offset = calc_opcode_counter_from_idx_idx (opdata.data.jmp_down.opcode_1,
|
||||
@@ -170,7 +177,7 @@ opfunc_jmp_down (ecma_completion_value_t &ret_value, /**< out: completion value
|
||||
|
||||
int_data->pos = (opcode_counter_t) (int_data->pos + offset);
|
||||
|
||||
ecma_make_empty_completion_value (ret_value);
|
||||
return ecma_make_empty_completion_value ();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -179,9 +186,8 @@ opfunc_jmp_down (ecma_completion_value_t &ret_value, /**< out: completion value
|
||||
* Note:
|
||||
* the opcode changes substracts specified value from current opcode position
|
||||
*/
|
||||
void
|
||||
opfunc_jmp_up (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
opcode_t opdata, /**< operation data */
|
||||
ecma_completion_value_t
|
||||
opfunc_jmp_up (opcode_t opdata, /**< operation data */
|
||||
int_data_t *int_data) /**< interpreter context */
|
||||
{
|
||||
const opcode_counter_t offset = calc_opcode_counter_from_idx_idx (opdata.data.jmp_up.opcode_1,
|
||||
@@ -190,5 +196,5 @@ opfunc_jmp_up (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
|
||||
int_data->pos = (opcode_counter_t) (int_data->pos - offset);
|
||||
|
||||
ecma_make_empty_completion_value (ret_value);
|
||||
return ecma_make_empty_completion_value ();
|
||||
}
|
||||
|
||||
@@ -41,14 +41,15 @@ typedef enum
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
static void
|
||||
do_number_arithmetic (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
int_data_t *int_data, /**< interpreter context */
|
||||
static ecma_completion_value_t
|
||||
do_number_arithmetic (int_data_t *int_data, /**< interpreter context */
|
||||
idx_t dst_var_idx, /**< destination variable identifier */
|
||||
number_arithmetic_op op, /**< number arithmetic operation */
|
||||
const ecma_value_t& left_value, /**< left value */
|
||||
const ecma_value_t& right_value) /** right value */
|
||||
{
|
||||
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
|
||||
|
||||
ECMA_OP_TO_NUMBER_TRY_CATCH (num_left, left_value, ret_value);
|
||||
ECMA_OP_TO_NUMBER_TRY_CATCH (num_right, right_value, ret_value);
|
||||
|
||||
@@ -83,13 +84,14 @@ do_number_arithmetic (ecma_completion_value_t &ret_value, /**< out: completion v
|
||||
}
|
||||
}
|
||||
|
||||
set_variable_value (ret_value,
|
||||
int_data, int_data->pos,
|
||||
dst_var_idx,
|
||||
ecma_value_t (res_p));
|
||||
ret_value = set_variable_value (int_data, int_data->pos,
|
||||
dst_var_idx,
|
||||
ecma_make_number_value (res_p));
|
||||
|
||||
ECMA_OP_TO_NUMBER_FINALIZE (num_right);
|
||||
ECMA_OP_TO_NUMBER_FINALIZE (num_left);
|
||||
|
||||
return ret_value;
|
||||
} /* do_number_arithmetic */
|
||||
|
||||
/**
|
||||
@@ -100,32 +102,39 @@ do_number_arithmetic (ecma_completion_value_t &ret_value, /**< out: completion v
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
opfunc_addition (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
opcode_t opdata, /**< operation data */
|
||||
ecma_completion_value_t
|
||||
opfunc_addition (opcode_t opdata, /**< operation data */
|
||||
int_data_t *int_data) /**< interpreter context */
|
||||
{
|
||||
const idx_t dst_var_idx = opdata.data.addition.dst;
|
||||
const idx_t left_var_idx = opdata.data.addition.var_left;
|
||||
const idx_t right_var_idx = opdata.data.addition.var_right;
|
||||
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, left_value, int_data, left_var_idx, false);
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, right_value, int_data, right_var_idx, false);
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_to_primitive, prim_left_value, left_value, ECMA_PREFERRED_TYPE_NO);
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_to_primitive, prim_right_value, right_value, ECMA_PREFERRED_TYPE_NO);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
ECMA_TRY_CATCH (left_value, get_variable_value (int_data, left_var_idx, false), ret_value);
|
||||
ECMA_TRY_CATCH (right_value, get_variable_value (int_data, right_var_idx, false), ret_value);
|
||||
ECMA_TRY_CATCH (prim_left_value,
|
||||
ecma_op_to_primitive (left_value,
|
||||
ECMA_PREFERRED_TYPE_NO),
|
||||
ret_value);
|
||||
ECMA_TRY_CATCH (prim_right_value,
|
||||
ecma_op_to_primitive (right_value,
|
||||
ECMA_PREFERRED_TYPE_NO),
|
||||
ret_value);
|
||||
|
||||
if (ecma_is_value_string (prim_left_value)
|
||||
|| ecma_is_value_string (prim_right_value))
|
||||
{
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_to_string, str_left_value, prim_left_value);
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_to_string, str_right_value, prim_right_value);
|
||||
ECMA_TRY_CATCH (str_left_value, ecma_op_to_string (prim_left_value), ret_value);
|
||||
ECMA_TRY_CATCH (str_right_value, ecma_op_to_string (prim_right_value), ret_value);
|
||||
|
||||
ecma_string_t *string1_p = ecma_get_string_from_value (str_left_value);
|
||||
ecma_string_t *string2_p = ecma_get_string_from_value (str_right_value);
|
||||
|
||||
ecma_string_t *concat_str_p = ecma_concat_ecma_strings (string1_p, string2_p);
|
||||
|
||||
set_variable_value (ret_value, int_data, int_data->pos, dst_var_idx, ecma_value_t (concat_str_p));
|
||||
ret_value = set_variable_value (int_data, int_data->pos, dst_var_idx, ecma_make_string_value (concat_str_p));
|
||||
|
||||
ecma_deref_ecma_string (concat_str_p);
|
||||
|
||||
@@ -134,12 +143,11 @@ opfunc_addition (ecma_completion_value_t &ret_value, /**< out: completion value
|
||||
}
|
||||
else
|
||||
{
|
||||
do_number_arithmetic (ret_value,
|
||||
int_data,
|
||||
dst_var_idx,
|
||||
number_arithmetic_addition,
|
||||
prim_left_value,
|
||||
prim_right_value);
|
||||
ret_value = do_number_arithmetic (int_data,
|
||||
dst_var_idx,
|
||||
number_arithmetic_addition,
|
||||
prim_left_value,
|
||||
prim_right_value);
|
||||
}
|
||||
|
||||
ECMA_FINALIZE (prim_right_value);
|
||||
@@ -148,6 +156,8 @@ opfunc_addition (ecma_completion_value_t &ret_value, /**< out: completion value
|
||||
ECMA_FINALIZE (left_value);
|
||||
|
||||
int_data->pos++;
|
||||
|
||||
return ret_value;
|
||||
} /* opfunc_addition */
|
||||
|
||||
/**
|
||||
@@ -158,29 +168,31 @@ opfunc_addition (ecma_completion_value_t &ret_value, /**< out: completion value
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
opfunc_substraction (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
opcode_t opdata, /**< operation data */
|
||||
ecma_completion_value_t
|
||||
opfunc_substraction (opcode_t opdata, /**< operation data */
|
||||
int_data_t *int_data) /**< interpreter context */
|
||||
{
|
||||
const idx_t dst_var_idx = opdata.data.substraction.dst;
|
||||
const idx_t left_var_idx = opdata.data.substraction.var_left;
|
||||
const idx_t right_var_idx = opdata.data.substraction.var_right;
|
||||
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, left_value, int_data, left_var_idx, false);
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, right_value, int_data, right_var_idx, false);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
do_number_arithmetic (ret_value,
|
||||
int_data,
|
||||
dst_var_idx,
|
||||
number_arithmetic_substraction,
|
||||
left_value,
|
||||
right_value);
|
||||
ECMA_TRY_CATCH (left_value, get_variable_value (int_data, left_var_idx, false), ret_value);
|
||||
ECMA_TRY_CATCH (right_value, get_variable_value (int_data, right_var_idx, false), ret_value);
|
||||
|
||||
ret_value = do_number_arithmetic (int_data,
|
||||
dst_var_idx,
|
||||
number_arithmetic_substraction,
|
||||
left_value,
|
||||
right_value);
|
||||
|
||||
ECMA_FINALIZE (right_value);
|
||||
ECMA_FINALIZE (left_value);
|
||||
|
||||
int_data->pos++;
|
||||
|
||||
return ret_value;
|
||||
} /* opfunc_substraction */
|
||||
|
||||
/**
|
||||
@@ -191,29 +203,31 @@ opfunc_substraction (ecma_completion_value_t &ret_value, /**< out: completion va
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
opfunc_multiplication (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
opcode_t opdata, /**< operation data */
|
||||
ecma_completion_value_t
|
||||
opfunc_multiplication (opcode_t opdata, /**< operation data */
|
||||
int_data_t *int_data) /**< interpreter context */
|
||||
{
|
||||
const idx_t dst_var_idx = opdata.data.multiplication.dst;
|
||||
const idx_t left_var_idx = opdata.data.multiplication.var_left;
|
||||
const idx_t right_var_idx = opdata.data.multiplication.var_right;
|
||||
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, left_value, int_data, left_var_idx, false);
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, right_value, int_data, right_var_idx, false);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
do_number_arithmetic (ret_value,
|
||||
int_data,
|
||||
dst_var_idx,
|
||||
number_arithmetic_multiplication,
|
||||
left_value,
|
||||
right_value);
|
||||
ECMA_TRY_CATCH (left_value, get_variable_value (int_data, left_var_idx, false), ret_value);
|
||||
ECMA_TRY_CATCH (right_value, get_variable_value (int_data, right_var_idx, false), ret_value);
|
||||
|
||||
ret_value = do_number_arithmetic (int_data,
|
||||
dst_var_idx,
|
||||
number_arithmetic_multiplication,
|
||||
left_value,
|
||||
right_value);
|
||||
|
||||
ECMA_FINALIZE (right_value);
|
||||
ECMA_FINALIZE (left_value);
|
||||
|
||||
int_data->pos++;
|
||||
|
||||
return ret_value;
|
||||
} /* opfunc_multiplication */
|
||||
|
||||
/**
|
||||
@@ -224,29 +238,31 @@ opfunc_multiplication (ecma_completion_value_t &ret_value, /**< out: completion
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
opfunc_division (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
opcode_t opdata, /**< operation data */
|
||||
ecma_completion_value_t
|
||||
opfunc_division (opcode_t opdata, /**< operation data */
|
||||
int_data_t *int_data) /**< interpreter context */
|
||||
{
|
||||
const idx_t dst_var_idx = opdata.data.division.dst;
|
||||
const idx_t left_var_idx = opdata.data.division.var_left;
|
||||
const idx_t right_var_idx = opdata.data.division.var_right;
|
||||
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, left_value, int_data, left_var_idx, false);
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, right_value, int_data, right_var_idx, false);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
do_number_arithmetic (ret_value,
|
||||
int_data,
|
||||
dst_var_idx,
|
||||
number_arithmetic_division,
|
||||
left_value,
|
||||
right_value);
|
||||
ECMA_TRY_CATCH (left_value, get_variable_value (int_data, left_var_idx, false), ret_value);
|
||||
ECMA_TRY_CATCH (right_value, get_variable_value (int_data, right_var_idx, false), ret_value);
|
||||
|
||||
ret_value = do_number_arithmetic (int_data,
|
||||
dst_var_idx,
|
||||
number_arithmetic_division,
|
||||
left_value,
|
||||
right_value);
|
||||
|
||||
ECMA_FINALIZE (right_value);
|
||||
ECMA_FINALIZE (left_value);
|
||||
|
||||
int_data->pos++;
|
||||
|
||||
return ret_value;
|
||||
} /* opfunc_division */
|
||||
|
||||
/**
|
||||
@@ -257,29 +273,31 @@ opfunc_division (ecma_completion_value_t &ret_value, /**< out: completion value
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
opfunc_remainder (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
opcode_t opdata, /**< operation data */
|
||||
ecma_completion_value_t
|
||||
opfunc_remainder (opcode_t opdata, /**< operation data */
|
||||
int_data_t *int_data) /**< interpreter context */
|
||||
{
|
||||
const idx_t dst_var_idx = opdata.data.remainder.dst;
|
||||
const idx_t left_var_idx = opdata.data.remainder.var_left;
|
||||
const idx_t right_var_idx = opdata.data.remainder.var_right;
|
||||
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, left_value, int_data, left_var_idx, false);
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, right_value, int_data, right_var_idx, false);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
do_number_arithmetic (ret_value,
|
||||
int_data,
|
||||
dst_var_idx,
|
||||
number_arithmetic_remainder,
|
||||
left_value,
|
||||
right_value);
|
||||
ECMA_TRY_CATCH (left_value, get_variable_value (int_data, left_var_idx, false), ret_value);
|
||||
ECMA_TRY_CATCH (right_value, get_variable_value (int_data, right_var_idx, false), ret_value);
|
||||
|
||||
ret_value = do_number_arithmetic (int_data,
|
||||
dst_var_idx,
|
||||
number_arithmetic_remainder,
|
||||
left_value,
|
||||
right_value);
|
||||
|
||||
ECMA_FINALIZE (right_value);
|
||||
ECMA_FINALIZE (left_value);
|
||||
|
||||
int_data->pos++;
|
||||
|
||||
return ret_value;
|
||||
} /* opfunc_remainder */
|
||||
|
||||
/**
|
||||
@@ -290,15 +308,16 @@ opfunc_remainder (ecma_completion_value_t &ret_value, /**< out: completion value
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
opfunc_unary_plus (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
opcode_t opdata, /**< operation data */
|
||||
ecma_completion_value_t
|
||||
opfunc_unary_plus (opcode_t opdata, /**< operation data */
|
||||
int_data_t *int_data) /**< interpreter context */
|
||||
{
|
||||
const idx_t dst_var_idx = opdata.data.remainder.dst;
|
||||
const idx_t var_idx = opdata.data.remainder.var_left;
|
||||
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, var_value, int_data, var_idx, false);
|
||||
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
|
||||
|
||||
ECMA_TRY_CATCH (var_value, get_variable_value (int_data, var_idx, false), ret_value);
|
||||
ECMA_OP_TO_NUMBER_TRY_CATCH (num_var_value,
|
||||
var_value,
|
||||
ret_value);
|
||||
@@ -306,12 +325,16 @@ opfunc_unary_plus (ecma_completion_value_t &ret_value, /**< out: completion valu
|
||||
ecma_number_t *tmp_p = int_data->tmp_num_p;
|
||||
|
||||
*tmp_p = num_var_value;
|
||||
set_variable_value (ret_value, int_data, int_data->pos, dst_var_idx, ecma_value_t (tmp_p));
|
||||
ret_value = set_variable_value (int_data, int_data->pos,
|
||||
dst_var_idx,
|
||||
ecma_make_number_value (tmp_p));
|
||||
|
||||
ECMA_OP_TO_NUMBER_FINALIZE (num_var_value);
|
||||
ECMA_FINALIZE (var_value);
|
||||
|
||||
int_data->pos++;
|
||||
|
||||
return ret_value;
|
||||
} /* opfunc_unary_plus */
|
||||
|
||||
/**
|
||||
@@ -322,15 +345,16 @@ opfunc_unary_plus (ecma_completion_value_t &ret_value, /**< out: completion valu
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
opfunc_unary_minus (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
opcode_t opdata, /**< operation data */
|
||||
ecma_completion_value_t
|
||||
opfunc_unary_minus (opcode_t opdata, /**< operation data */
|
||||
int_data_t *int_data) /**< interpreter context */
|
||||
{
|
||||
const idx_t dst_var_idx = opdata.data.remainder.dst;
|
||||
const idx_t var_idx = opdata.data.remainder.var_left;
|
||||
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, var_value, int_data, var_idx, false);
|
||||
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
|
||||
|
||||
ECMA_TRY_CATCH (var_value, get_variable_value (int_data, var_idx, false), ret_value);
|
||||
ECMA_OP_TO_NUMBER_TRY_CATCH (num_var_value,
|
||||
var_value,
|
||||
ret_value);
|
||||
@@ -338,10 +362,14 @@ opfunc_unary_minus (ecma_completion_value_t &ret_value, /**< out: completion val
|
||||
ecma_number_t *tmp_p = int_data->tmp_num_p;
|
||||
|
||||
*tmp_p = ecma_number_negate (num_var_value);
|
||||
set_variable_value (ret_value, int_data, int_data->pos, dst_var_idx, ecma_value_t (tmp_p));
|
||||
ret_value = set_variable_value (int_data, int_data->pos,
|
||||
dst_var_idx,
|
||||
ecma_make_number_value (tmp_p));
|
||||
|
||||
ECMA_OP_TO_NUMBER_FINALIZE (num_var_value);
|
||||
ECMA_FINALIZE (var_value);
|
||||
|
||||
int_data->pos++;
|
||||
|
||||
return ret_value;
|
||||
} /* opfunc_unary_minus */
|
||||
|
||||
@@ -41,14 +41,15 @@ typedef enum
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
static void
|
||||
do_number_bitwise_logic (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
int_data_t *int_data, /**< interpreter context */
|
||||
static ecma_completion_value_t
|
||||
do_number_bitwise_logic (int_data_t *int_data, /**< interpreter context */
|
||||
idx_t dst_var_idx, /**< destination variable identifier */
|
||||
number_bitwise_logic_op op, /**< number bitwise logic operation */
|
||||
const ecma_value_t& left_value, /**< left value */
|
||||
const ecma_value_t& right_value) /** right value */
|
||||
{
|
||||
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
|
||||
|
||||
ECMA_OP_TO_NUMBER_TRY_CATCH (num_left, left_value, ret_value);
|
||||
ECMA_OP_TO_NUMBER_TRY_CATCH (num_right, right_value, ret_value);
|
||||
|
||||
@@ -99,10 +100,14 @@ do_number_bitwise_logic (ecma_completion_value_t &ret_value, /**< out: completio
|
||||
}
|
||||
}
|
||||
|
||||
set_variable_value (ret_value, int_data, int_data->pos, dst_var_idx, ecma_value_t (res_p));
|
||||
ret_value = set_variable_value (int_data, int_data->pos,
|
||||
dst_var_idx,
|
||||
ecma_make_number_value (res_p));
|
||||
|
||||
ECMA_OP_TO_NUMBER_FINALIZE (num_right);
|
||||
ECMA_OP_TO_NUMBER_FINALIZE (num_left);
|
||||
|
||||
return ret_value;
|
||||
} /* do_number_bitwise_logic */
|
||||
|
||||
/**
|
||||
@@ -113,29 +118,31 @@ do_number_bitwise_logic (ecma_completion_value_t &ret_value, /**< out: completio
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
opfunc_b_and (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
opcode_t opdata, /**< operation data */
|
||||
ecma_completion_value_t
|
||||
opfunc_b_and (opcode_t opdata, /**< operation data */
|
||||
int_data_t *int_data) /**< interpreter context */
|
||||
{
|
||||
const idx_t dst_var_idx = opdata.data.b_and.dst;
|
||||
const idx_t left_var_idx = opdata.data.b_and.var_left;
|
||||
const idx_t right_var_idx = opdata.data.b_and.var_right;
|
||||
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, left_value, int_data, left_var_idx, false);
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, right_value, int_data, right_var_idx, false);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
do_number_bitwise_logic (ret_value,
|
||||
int_data,
|
||||
dst_var_idx,
|
||||
number_bitwise_logic_and,
|
||||
left_value,
|
||||
right_value);
|
||||
ECMA_TRY_CATCH (left_value, get_variable_value (int_data, left_var_idx, false), ret_value);
|
||||
ECMA_TRY_CATCH (right_value, get_variable_value (int_data, right_var_idx, false), ret_value);
|
||||
|
||||
ret_value = do_number_bitwise_logic (int_data,
|
||||
dst_var_idx,
|
||||
number_bitwise_logic_and,
|
||||
left_value,
|
||||
right_value);
|
||||
|
||||
ECMA_FINALIZE (right_value);
|
||||
ECMA_FINALIZE (left_value);
|
||||
|
||||
int_data->pos++;
|
||||
|
||||
return ret_value;
|
||||
} /* opfunc_b_and */
|
||||
|
||||
/**
|
||||
@@ -146,29 +153,31 @@ opfunc_b_and (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
opfunc_b_or (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
opcode_t opdata, /**< operation data */
|
||||
ecma_completion_value_t
|
||||
opfunc_b_or (opcode_t opdata, /**< operation data */
|
||||
int_data_t *int_data) /**< interpreter context */
|
||||
{
|
||||
const idx_t dst_var_idx = opdata.data.b_or.dst;
|
||||
const idx_t left_var_idx = opdata.data.b_or.var_left;
|
||||
const idx_t right_var_idx = opdata.data.b_or.var_right;
|
||||
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, left_value, int_data, left_var_idx, false);
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, right_value, int_data, right_var_idx, false);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
do_number_bitwise_logic (ret_value,
|
||||
int_data,
|
||||
dst_var_idx,
|
||||
number_bitwise_logic_or,
|
||||
left_value,
|
||||
right_value);
|
||||
ECMA_TRY_CATCH (left_value, get_variable_value (int_data, left_var_idx, false), ret_value);
|
||||
ECMA_TRY_CATCH (right_value, get_variable_value (int_data, right_var_idx, false), ret_value);
|
||||
|
||||
ret_value = do_number_bitwise_logic (int_data,
|
||||
dst_var_idx,
|
||||
number_bitwise_logic_or,
|
||||
left_value,
|
||||
right_value);
|
||||
|
||||
ECMA_FINALIZE (right_value);
|
||||
ECMA_FINALIZE (left_value);
|
||||
|
||||
int_data->pos++;
|
||||
|
||||
return ret_value;
|
||||
} /* opfunc_b_or */
|
||||
|
||||
/**
|
||||
@@ -179,29 +188,31 @@ opfunc_b_or (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
opfunc_b_xor (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
opcode_t opdata, /**< operation data */
|
||||
ecma_completion_value_t
|
||||
opfunc_b_xor (opcode_t opdata, /**< operation data */
|
||||
int_data_t *int_data) /**< interpreter context */
|
||||
{
|
||||
const idx_t dst_var_idx = opdata.data.b_xor.dst;
|
||||
const idx_t left_var_idx = opdata.data.b_xor.var_left;
|
||||
const idx_t right_var_idx = opdata.data.b_xor.var_right;
|
||||
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, left_value, int_data, left_var_idx, false);
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, right_value, int_data, right_var_idx, false);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
do_number_bitwise_logic (ret_value,
|
||||
int_data,
|
||||
dst_var_idx,
|
||||
number_bitwise_logic_xor,
|
||||
left_value,
|
||||
right_value);
|
||||
ECMA_TRY_CATCH (left_value, get_variable_value (int_data, left_var_idx, false), ret_value);
|
||||
ECMA_TRY_CATCH (right_value, get_variable_value (int_data, right_var_idx, false), ret_value);
|
||||
|
||||
ret_value = do_number_bitwise_logic (int_data,
|
||||
dst_var_idx,
|
||||
number_bitwise_logic_xor,
|
||||
left_value,
|
||||
right_value);
|
||||
|
||||
ECMA_FINALIZE (right_value);
|
||||
ECMA_FINALIZE (left_value);
|
||||
|
||||
int_data->pos++;
|
||||
|
||||
return ret_value;
|
||||
} /* opfunc_b_xor */
|
||||
|
||||
/**
|
||||
@@ -212,29 +223,31 @@ opfunc_b_xor (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
opfunc_b_shift_left (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
opcode_t opdata, /**< operation data */
|
||||
ecma_completion_value_t
|
||||
opfunc_b_shift_left (opcode_t opdata, /**< operation data */
|
||||
int_data_t *int_data) /**< interpreter context */
|
||||
{
|
||||
const idx_t dst_var_idx = opdata.data.b_shift_left.dst;
|
||||
const idx_t left_var_idx = opdata.data.b_shift_left.var_left;
|
||||
const idx_t right_var_idx = opdata.data.b_shift_left.var_right;
|
||||
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, left_value, int_data, left_var_idx, false);
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, right_value, int_data, right_var_idx, false);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
do_number_bitwise_logic (ret_value,
|
||||
int_data,
|
||||
dst_var_idx,
|
||||
number_bitwise_shift_left,
|
||||
left_value,
|
||||
right_value);
|
||||
ECMA_TRY_CATCH (left_value, get_variable_value (int_data, left_var_idx, false), ret_value);
|
||||
ECMA_TRY_CATCH (right_value, get_variable_value (int_data, right_var_idx, false), ret_value);
|
||||
|
||||
ret_value = do_number_bitwise_logic (int_data,
|
||||
dst_var_idx,
|
||||
number_bitwise_shift_left,
|
||||
left_value,
|
||||
right_value);
|
||||
|
||||
ECMA_FINALIZE (right_value);
|
||||
ECMA_FINALIZE (left_value);
|
||||
|
||||
int_data->pos++;
|
||||
|
||||
return ret_value;
|
||||
} /* opfunc_b_shift_left */
|
||||
|
||||
/**
|
||||
@@ -245,29 +258,31 @@ opfunc_b_shift_left (ecma_completion_value_t &ret_value, /**< out: completion va
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
opfunc_b_shift_right (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
opcode_t opdata, /**< operation data */
|
||||
ecma_completion_value_t
|
||||
opfunc_b_shift_right (opcode_t opdata, /**< operation data */
|
||||
int_data_t *int_data) /**< interpreter context */
|
||||
{
|
||||
const idx_t dst_var_idx = opdata.data.b_shift_right.dst;
|
||||
const idx_t left_var_idx = opdata.data.b_shift_right.var_left;
|
||||
const idx_t right_var_idx = opdata.data.b_shift_right.var_right;
|
||||
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, left_value, int_data, left_var_idx, false);
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, right_value, int_data, right_var_idx, false);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
do_number_bitwise_logic (ret_value,
|
||||
int_data,
|
||||
dst_var_idx,
|
||||
number_bitwise_shift_right,
|
||||
left_value,
|
||||
right_value);
|
||||
ECMA_TRY_CATCH (left_value, get_variable_value (int_data, left_var_idx, false), ret_value);
|
||||
ECMA_TRY_CATCH (right_value, get_variable_value (int_data, right_var_idx, false), ret_value);
|
||||
|
||||
ret_value = do_number_bitwise_logic (int_data,
|
||||
dst_var_idx,
|
||||
number_bitwise_shift_right,
|
||||
left_value,
|
||||
right_value);
|
||||
|
||||
ECMA_FINALIZE (right_value);
|
||||
ECMA_FINALIZE (left_value);
|
||||
|
||||
int_data->pos++;
|
||||
|
||||
return ret_value;
|
||||
} /* opfunc_b_shift_right */
|
||||
|
||||
/**
|
||||
@@ -278,29 +293,31 @@ opfunc_b_shift_right (ecma_completion_value_t &ret_value, /**< out: completion v
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
opfunc_b_shift_uright (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
opcode_t opdata, /**< operation data */
|
||||
int_data_t *int_data) /**< interpreter context */
|
||||
ecma_completion_value_t
|
||||
opfunc_b_shift_uright (opcode_t opdata, /**< operation data */
|
||||
int_data_t *int_data) /**< interpreter context */
|
||||
{
|
||||
const idx_t dst_var_idx = opdata.data.b_shift_uright.dst;
|
||||
const idx_t left_var_idx = opdata.data.b_shift_uright.var_left;
|
||||
const idx_t right_var_idx = opdata.data.b_shift_uright.var_right;
|
||||
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, left_value, int_data, left_var_idx, false);
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, right_value, int_data, right_var_idx, false);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
do_number_bitwise_logic (ret_value,
|
||||
int_data,
|
||||
dst_var_idx,
|
||||
number_bitwise_shift_uright,
|
||||
left_value,
|
||||
right_value);
|
||||
ECMA_TRY_CATCH (left_value, get_variable_value (int_data, left_var_idx, false), ret_value);
|
||||
ECMA_TRY_CATCH (right_value, get_variable_value (int_data, right_var_idx, false), ret_value);
|
||||
|
||||
ret_value = do_number_bitwise_logic (int_data,
|
||||
dst_var_idx,
|
||||
number_bitwise_shift_uright,
|
||||
left_value,
|
||||
right_value);
|
||||
|
||||
ECMA_FINALIZE (right_value);
|
||||
ECMA_FINALIZE (left_value);
|
||||
|
||||
int_data->pos++;
|
||||
|
||||
return ret_value;
|
||||
} /* opfunc_b_shift_uright */
|
||||
|
||||
/**
|
||||
@@ -311,24 +328,26 @@ opfunc_b_shift_uright (ecma_completion_value_t &ret_value, /**< out: completion
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
opfunc_b_not (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
opcode_t opdata, /**< operation data */
|
||||
ecma_completion_value_t
|
||||
opfunc_b_not (opcode_t opdata, /**< operation data */
|
||||
int_data_t *int_data) /**< interpreter context */
|
||||
{
|
||||
const idx_t dst_var_idx = opdata.data.b_not.dst;
|
||||
const idx_t right_var_idx = opdata.data.b_not.var_right;
|
||||
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, right_value, int_data, right_var_idx, false);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
do_number_bitwise_logic (ret_value,
|
||||
int_data,
|
||||
dst_var_idx,
|
||||
number_bitwise_not,
|
||||
right_value,
|
||||
right_value);
|
||||
ECMA_TRY_CATCH (right_value, get_variable_value (int_data, right_var_idx, false), ret_value);
|
||||
|
||||
ret_value = do_number_bitwise_logic (int_data,
|
||||
dst_var_idx,
|
||||
number_bitwise_not,
|
||||
right_value,
|
||||
right_value);
|
||||
|
||||
ECMA_FINALIZE (right_value);
|
||||
|
||||
int_data->pos++;
|
||||
|
||||
return ret_value;
|
||||
} /* opfunc_b_not */
|
||||
|
||||
@@ -24,28 +24,35 @@
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
opfunc_equal_value (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
opcode_t opdata, /**< operation data */
|
||||
ecma_completion_value_t
|
||||
opfunc_equal_value (opcode_t opdata, /**< operation data */
|
||||
int_data_t *int_data) /**< interpreter context */
|
||||
{
|
||||
const idx_t dst_var_idx = opdata.data.equal_value.dst;
|
||||
const idx_t left_var_idx = opdata.data.equal_value.var_left;
|
||||
const idx_t right_var_idx = opdata.data.equal_value.var_right;
|
||||
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, left_value, int_data, left_var_idx, false);
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, right_value, int_data, right_var_idx, false);
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_abstract_equality_compare, compare_result, left_value, right_value);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
ECMA_TRY_CATCH (left_value, get_variable_value (int_data, left_var_idx, false), ret_value);
|
||||
ECMA_TRY_CATCH (right_value, get_variable_value (int_data, 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));
|
||||
|
||||
set_variable_value (ret_value, int_data, int_data->pos, dst_var_idx, compare_result);
|
||||
ret_value = set_variable_value (int_data, int_data->pos, dst_var_idx,
|
||||
compare_result);
|
||||
|
||||
ECMA_FINALIZE (compare_result);
|
||||
ECMA_FINALIZE (right_value);
|
||||
ECMA_FINALIZE (left_value);
|
||||
|
||||
int_data->pos++;
|
||||
|
||||
return ret_value;
|
||||
} /* opfunc_equal_value */
|
||||
|
||||
/**
|
||||
@@ -56,32 +63,37 @@ opfunc_equal_value (ecma_completion_value_t &ret_value, /**< out: completion val
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
opfunc_not_equal_value (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
opcode_t opdata, /**< operation data */
|
||||
ecma_completion_value_t
|
||||
opfunc_not_equal_value (opcode_t opdata, /**< operation data */
|
||||
int_data_t *int_data) /**< interpreter context */
|
||||
{
|
||||
const idx_t dst_var_idx = opdata.data.not_equal_value.dst;
|
||||
const idx_t left_var_idx = opdata.data.not_equal_value.var_left;
|
||||
const idx_t right_var_idx = opdata.data.not_equal_value.var_right;
|
||||
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, left_value, int_data, left_var_idx, false);
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, right_value, int_data, right_var_idx, false);
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_abstract_equality_compare, compare_result, left_value, right_value);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
ECMA_TRY_CATCH (left_value, get_variable_value (int_data, left_var_idx, false), ret_value);
|
||||
ECMA_TRY_CATCH (right_value, get_variable_value (int_data, 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);
|
||||
|
||||
set_variable_value (ret_value, int_data, int_data->pos, dst_var_idx,
|
||||
ecma_value_t (is_equal ? ECMA_SIMPLE_VALUE_FALSE
|
||||
: ECMA_SIMPLE_VALUE_TRUE));
|
||||
ret_value = set_variable_value (int_data, int_data->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);
|
||||
|
||||
int_data->pos++;
|
||||
|
||||
return ret_value;
|
||||
} /* opfunc_not_equal_value */
|
||||
|
||||
/**
|
||||
@@ -92,28 +104,31 @@ opfunc_not_equal_value (ecma_completion_value_t &ret_value, /**< out: completion
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
opfunc_equal_value_type (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
opcode_t opdata, /**< operation data */
|
||||
ecma_completion_value_t
|
||||
opfunc_equal_value_type (opcode_t opdata, /**< operation data */
|
||||
int_data_t *int_data) /**< interpreter context */
|
||||
{
|
||||
const idx_t dst_var_idx = opdata.data.equal_value_type.dst;
|
||||
const idx_t left_var_idx = opdata.data.equal_value_type.var_left;
|
||||
const idx_t right_var_idx = opdata.data.equal_value_type.var_right;
|
||||
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, left_value, int_data, left_var_idx, false);
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, right_value, int_data, right_var_idx, false);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
ECMA_TRY_CATCH (left_value, get_variable_value (int_data, left_var_idx, false), ret_value);
|
||||
ECMA_TRY_CATCH (right_value, get_variable_value (int_data, right_var_idx, false), ret_value);
|
||||
|
||||
bool is_equal = ecma_op_strict_equality_compare (left_value, right_value);
|
||||
|
||||
set_variable_value (ret_value, int_data, int_data->pos, dst_var_idx,
|
||||
ecma_value_t (is_equal ? ECMA_SIMPLE_VALUE_TRUE
|
||||
: ECMA_SIMPLE_VALUE_FALSE));
|
||||
ret_value = set_variable_value (int_data, int_data->pos, dst_var_idx,
|
||||
ecma_make_simple_value (is_equal ? ECMA_SIMPLE_VALUE_TRUE
|
||||
: ECMA_SIMPLE_VALUE_FALSE));
|
||||
|
||||
ECMA_FINALIZE (right_value);
|
||||
ECMA_FINALIZE (left_value);
|
||||
|
||||
int_data->pos++;
|
||||
|
||||
return ret_value;
|
||||
} /* opfunc_equal_value_type */
|
||||
|
||||
/**
|
||||
@@ -124,27 +139,30 @@ opfunc_equal_value_type (ecma_completion_value_t &ret_value, /**< out: completio
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
opfunc_not_equal_value_type (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
opcode_t opdata, /**< operation data */
|
||||
ecma_completion_value_t
|
||||
opfunc_not_equal_value_type (opcode_t opdata, /**< operation data */
|
||||
int_data_t *int_data) /**< interpreter context */
|
||||
{
|
||||
const idx_t dst_var_idx = opdata.data.not_equal_value_type.dst;
|
||||
const idx_t left_var_idx = opdata.data.not_equal_value_type.var_left;
|
||||
const idx_t right_var_idx = opdata.data.not_equal_value_type.var_right;
|
||||
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, left_value, int_data, left_var_idx, false);
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, right_value, int_data, right_var_idx, false);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
ECMA_TRY_CATCH (left_value, get_variable_value (int_data, left_var_idx, false), ret_value);
|
||||
ECMA_TRY_CATCH (right_value, get_variable_value (int_data, right_var_idx, false), ret_value);
|
||||
|
||||
bool is_equal = ecma_op_strict_equality_compare (left_value, right_value);
|
||||
|
||||
set_variable_value (ret_value, int_data, int_data->pos, dst_var_idx,
|
||||
ecma_value_t (is_equal ? ECMA_SIMPLE_VALUE_FALSE
|
||||
: ECMA_SIMPLE_VALUE_TRUE));
|
||||
ret_value = set_variable_value (int_data, int_data->pos, dst_var_idx,
|
||||
ecma_make_simple_value (is_equal ? ECMA_SIMPLE_VALUE_FALSE
|
||||
: ECMA_SIMPLE_VALUE_TRUE));
|
||||
|
||||
|
||||
ECMA_FINALIZE (right_value);
|
||||
ECMA_FINALIZE (left_value);
|
||||
|
||||
int_data->pos++;
|
||||
|
||||
return ret_value;
|
||||
} /* opfunc_not_equal_value_type */
|
||||
|
||||
@@ -24,18 +24,21 @@
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
opfunc_less_than (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
opcode_t opdata, /**< operation data */
|
||||
ecma_completion_value_t
|
||||
opfunc_less_than (opcode_t opdata, /**< operation data */
|
||||
int_data_t *int_data) /**< interpreter context */
|
||||
{
|
||||
const idx_t dst_var_idx = opdata.data.less_than.dst;
|
||||
const idx_t left_var_idx = opdata.data.less_than.var_left;
|
||||
const idx_t right_var_idx = opdata.data.less_than.var_right;
|
||||
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, left_value, int_data, left_var_idx, false);
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, right_value, int_data, right_var_idx, false);
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_abstract_relational_compare, compare_result, left_value, right_value, true);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
ECMA_TRY_CATCH (left_value, get_variable_value (int_data, left_var_idx, false), ret_value);
|
||||
ECMA_TRY_CATCH (right_value, get_variable_value (int_data, 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;
|
||||
|
||||
@@ -50,13 +53,15 @@ opfunc_less_than (ecma_completion_value_t &ret_value, /**< out: completion value
|
||||
res = (ecma_is_value_true (compare_result) ? ECMA_SIMPLE_VALUE_TRUE : ECMA_SIMPLE_VALUE_FALSE);
|
||||
}
|
||||
|
||||
set_variable_value (ret_value, int_data, int_data->pos, dst_var_idx, ecma_value_t (res));
|
||||
ret_value = set_variable_value (int_data, int_data->pos, dst_var_idx, ecma_make_simple_value (res));
|
||||
|
||||
ECMA_FINALIZE (compare_result);
|
||||
ECMA_FINALIZE (right_value);
|
||||
ECMA_FINALIZE (left_value);
|
||||
|
||||
int_data->pos++;
|
||||
|
||||
return ret_value;
|
||||
} /* opfunc_less_than */
|
||||
|
||||
/**
|
||||
@@ -67,18 +72,21 @@ opfunc_less_than (ecma_completion_value_t &ret_value, /**< out: completion value
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
opfunc_greater_than (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
opcode_t opdata, /**< operation data */
|
||||
ecma_completion_value_t
|
||||
opfunc_greater_than (opcode_t opdata, /**< operation data */
|
||||
int_data_t *int_data) /**< interpreter context */
|
||||
{
|
||||
const idx_t dst_var_idx = opdata.data.greater_than.dst;
|
||||
const idx_t left_var_idx = opdata.data.greater_than.var_left;
|
||||
const idx_t right_var_idx = opdata.data.greater_than.var_right;
|
||||
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, left_value, int_data, left_var_idx, false);
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, right_value, int_data, right_var_idx, false);
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_abstract_relational_compare, compare_result, right_value, left_value, false);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
ECMA_TRY_CATCH (left_value, get_variable_value (int_data, left_var_idx, false), ret_value);
|
||||
ECMA_TRY_CATCH (right_value, get_variable_value (int_data, right_var_idx, false), ret_value);
|
||||
ECMA_TRY_CATCH (compare_result,
|
||||
ecma_op_abstract_relational_compare (right_value, left_value, false),
|
||||
ret_value);
|
||||
|
||||
ecma_simple_value_t res;
|
||||
|
||||
@@ -93,13 +101,15 @@ opfunc_greater_than (ecma_completion_value_t &ret_value, /**< out: completion va
|
||||
res = (ecma_is_value_true (compare_result) ? ECMA_SIMPLE_VALUE_TRUE : ECMA_SIMPLE_VALUE_FALSE);
|
||||
}
|
||||
|
||||
set_variable_value (ret_value, int_data, int_data->pos, dst_var_idx, ecma_value_t (res));
|
||||
ret_value = set_variable_value (int_data, int_data->pos, dst_var_idx, ecma_make_simple_value (res));
|
||||
|
||||
ECMA_FINALIZE (compare_result);
|
||||
ECMA_FINALIZE (right_value);
|
||||
ECMA_FINALIZE (left_value);
|
||||
|
||||
int_data->pos++;
|
||||
|
||||
return ret_value;
|
||||
} /* opfunc_greater_than */
|
||||
|
||||
/**
|
||||
@@ -110,18 +120,21 @@ opfunc_greater_than (ecma_completion_value_t &ret_value, /**< out: completion va
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
opfunc_less_or_equal_than (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
opcode_t opdata, /**< operation data */
|
||||
ecma_completion_value_t
|
||||
opfunc_less_or_equal_than (opcode_t opdata, /**< operation data */
|
||||
int_data_t *int_data) /**< interpreter context */
|
||||
{
|
||||
const idx_t dst_var_idx = opdata.data.less_or_equal_than.dst;
|
||||
const idx_t left_var_idx = opdata.data.less_or_equal_than.var_left;
|
||||
const idx_t right_var_idx = opdata.data.less_or_equal_than.var_right;
|
||||
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, left_value, int_data, left_var_idx, false);
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, right_value, int_data, right_var_idx, false);
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_abstract_relational_compare, compare_result, right_value, left_value, false);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
ECMA_TRY_CATCH (left_value, get_variable_value (int_data, left_var_idx, false), ret_value);
|
||||
ECMA_TRY_CATCH (right_value, get_variable_value (int_data, right_var_idx, false), ret_value);
|
||||
ECMA_TRY_CATCH (compare_result,
|
||||
ecma_op_abstract_relational_compare (right_value, left_value, false),
|
||||
ret_value);
|
||||
|
||||
ecma_simple_value_t res;
|
||||
|
||||
@@ -143,13 +156,15 @@ opfunc_less_or_equal_than (ecma_completion_value_t &ret_value, /**< out: complet
|
||||
}
|
||||
}
|
||||
|
||||
set_variable_value (ret_value, int_data, int_data->pos, dst_var_idx, ecma_value_t (res));
|
||||
ret_value = set_variable_value (int_data, int_data->pos, dst_var_idx, ecma_make_simple_value (res));
|
||||
|
||||
ECMA_FINALIZE (compare_result);
|
||||
ECMA_FINALIZE (right_value);
|
||||
ECMA_FINALIZE (left_value);
|
||||
|
||||
int_data->pos++;
|
||||
|
||||
return ret_value;
|
||||
} /* opfunc_less_or_equal_than */
|
||||
|
||||
/**
|
||||
@@ -160,18 +175,21 @@ opfunc_less_or_equal_than (ecma_completion_value_t &ret_value, /**< out: complet
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
opfunc_greater_or_equal_than (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
opcode_t opdata, /**< operation data */
|
||||
ecma_completion_value_t
|
||||
opfunc_greater_or_equal_than (opcode_t opdata, /**< operation data */
|
||||
int_data_t *int_data) /**< interpreter context */
|
||||
{
|
||||
const idx_t dst_var_idx = opdata.data.greater_or_equal_than.dst;
|
||||
const idx_t left_var_idx = opdata.data.greater_or_equal_than.var_left;
|
||||
const idx_t right_var_idx = opdata.data.greater_or_equal_than.var_right;
|
||||
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, left_value, int_data, left_var_idx, false);
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, right_value, int_data, right_var_idx, false);
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_abstract_relational_compare, compare_result, left_value, right_value, true);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
ECMA_TRY_CATCH (left_value, get_variable_value (int_data, left_var_idx, false), ret_value);
|
||||
ECMA_TRY_CATCH (right_value, get_variable_value (int_data, 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;
|
||||
|
||||
@@ -193,13 +211,15 @@ opfunc_greater_or_equal_than (ecma_completion_value_t &ret_value, /**< out: comp
|
||||
}
|
||||
}
|
||||
|
||||
set_variable_value (ret_value, int_data, int_data->pos, dst_var_idx, ecma_value_t (res));
|
||||
ret_value = set_variable_value (int_data, int_data->pos, dst_var_idx, ecma_make_simple_value (res));
|
||||
|
||||
ECMA_FINALIZE (compare_result);
|
||||
ECMA_FINALIZE (right_value);
|
||||
ECMA_FINALIZE (left_value);
|
||||
|
||||
int_data->pos++;
|
||||
|
||||
return ret_value;
|
||||
} /* opfunc_greater_or_equal_than */
|
||||
|
||||
/**
|
||||
@@ -210,32 +230,32 @@ opfunc_greater_or_equal_than (ecma_completion_value_t &ret_value, /**< out: comp
|
||||
* @return completion value
|
||||
* returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
void
|
||||
opfunc_instanceof (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
opcode_t opdata __unused, /**< operation data */
|
||||
ecma_completion_value_t
|
||||
opfunc_instanceof (opcode_t opdata __unused, /**< operation data */
|
||||
int_data_t *int_data __unused) /**< interpreter context */
|
||||
{
|
||||
const idx_t dst_idx = opdata.data.instanceof.dst;
|
||||
const idx_t left_var_idx = opdata.data.instanceof.var_left;
|
||||
const idx_t right_var_idx = opdata.data.instanceof.var_right;
|
||||
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, left_value, int_data, left_var_idx, false);
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, right_value, int_data, right_var_idx, false);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
ECMA_TRY_CATCH (left_value, get_variable_value (int_data, left_var_idx, false), ret_value);
|
||||
ECMA_TRY_CATCH (right_value, get_variable_value (int_data, right_var_idx, false), ret_value);
|
||||
|
||||
if (!ecma_is_value_object (right_value))
|
||||
{
|
||||
ecma_object_ptr_t exception_obj_p;
|
||||
ecma_new_standard_error (exception_obj_p, ECMA_ERROR_TYPE);
|
||||
ecma_make_throw_obj_completion_value (ret_value, exception_obj_p);
|
||||
ret_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_object_ptr_t right_value_obj_p;
|
||||
ecma_get_object_from_value (right_value_obj_p, right_value);
|
||||
ecma_object_t *right_value_obj_p = ecma_get_object_from_value (right_value);
|
||||
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_object_has_instance, is_instance_of, right_value_obj_p, left_value);
|
||||
ECMA_TRY_CATCH (is_instance_of,
|
||||
ecma_op_object_has_instance (right_value_obj_p, left_value),
|
||||
ret_value);
|
||||
|
||||
set_variable_value (ret_value, int_data, int_data->pos, dst_idx, is_instance_of);
|
||||
ret_value = set_variable_value (int_data, int_data->pos, dst_idx, is_instance_of);
|
||||
|
||||
ECMA_FINALIZE (is_instance_of);
|
||||
}
|
||||
@@ -244,6 +264,8 @@ opfunc_instanceof (ecma_completion_value_t &ret_value, /**< out: completion valu
|
||||
ECMA_FINALIZE (left_value);
|
||||
|
||||
int_data->pos++;
|
||||
|
||||
return ret_value;
|
||||
} /* opfunc_instanceof */
|
||||
|
||||
/**
|
||||
@@ -254,32 +276,30 @@ opfunc_instanceof (ecma_completion_value_t &ret_value, /**< out: completion valu
|
||||
* @return completion value
|
||||
* returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
void
|
||||
opfunc_in (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
opcode_t opdata __unused, /**< operation data */
|
||||
ecma_completion_value_t
|
||||
opfunc_in (opcode_t opdata __unused, /**< operation data */
|
||||
int_data_t *int_data __unused) /**< interpreter context */
|
||||
{
|
||||
const idx_t dst_idx = opdata.data.in.dst;
|
||||
const idx_t left_var_idx = opdata.data.in.var_left;
|
||||
const idx_t right_var_idx = opdata.data.in.var_right;
|
||||
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, left_value, int_data, left_var_idx, false);
|
||||
ECMA_TRY_CATCH (ret_value, get_variable_value, right_value, int_data, right_var_idx, false);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
ECMA_TRY_CATCH (left_value, get_variable_value (int_data, left_var_idx, false), ret_value);
|
||||
ECMA_TRY_CATCH (right_value, get_variable_value (int_data, right_var_idx, false), ret_value);
|
||||
|
||||
if (!ecma_is_value_object (right_value))
|
||||
{
|
||||
ecma_object_ptr_t exception_obj_p;
|
||||
ecma_new_standard_error (exception_obj_p, ECMA_ERROR_TYPE);
|
||||
ecma_make_throw_obj_completion_value (ret_value, exception_obj_p);
|
||||
ret_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||
}
|
||||
else
|
||||
{
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_to_string, str_left_value, left_value);
|
||||
ECMA_TRY_CATCH (str_left_value, ecma_op_to_string (left_value), ret_value);
|
||||
|
||||
ecma_simple_value_t is_in = ECMA_SIMPLE_VALUE_UNDEFINED;
|
||||
ecma_string_t *left_value_prop_name_p = ecma_get_string_from_value (str_left_value);
|
||||
ecma_object_ptr_t right_value_obj_p;
|
||||
ecma_get_object_from_value (right_value_obj_p, right_value);
|
||||
ecma_object_t *right_value_obj_p = ecma_get_object_from_value (right_value);
|
||||
|
||||
if (ecma_op_object_get_property (right_value_obj_p, left_value_prop_name_p) != NULL)
|
||||
{
|
||||
@@ -290,8 +310,9 @@ opfunc_in (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
is_in = ECMA_SIMPLE_VALUE_FALSE;
|
||||
}
|
||||
|
||||
set_variable_value (ret_value, int_data, int_data->pos,
|
||||
dst_idx, ecma_value_t (is_in));
|
||||
ret_value = set_variable_value (int_data, int_data->pos,
|
||||
dst_idx,
|
||||
ecma_make_simple_value (is_in));
|
||||
|
||||
ECMA_FINALIZE (str_left_value);
|
||||
}
|
||||
@@ -300,4 +321,6 @@ opfunc_in (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
ECMA_FINALIZE (left_value);
|
||||
|
||||
int_data->pos++;
|
||||
|
||||
return ret_value;
|
||||
} /* opfunc_in */
|
||||
|
||||
@@ -31,31 +31,16 @@
|
||||
#include "ecma-operations.h"
|
||||
#include "ecma-reference.h"
|
||||
#include "ecma-try-catch-macro.h"
|
||||
#include "ecma-value.h"
|
||||
#include "deserializer.h"
|
||||
|
||||
bool
|
||||
is_reg_variable (int_data_t *int_data,
|
||||
idx_t var_idx);
|
||||
void
|
||||
get_variable_value (ecma_completion_value_t &ret_value,
|
||||
int_data_t *,
|
||||
idx_t,
|
||||
bool);
|
||||
void
|
||||
set_variable_value (ecma_completion_value_t &ret_value,
|
||||
int_data_t *,
|
||||
opcode_counter_t,
|
||||
idx_t,
|
||||
const ecma_value_t&);
|
||||
void
|
||||
fill_varg_list (ecma_completion_value_t &ret_value,
|
||||
int_data_t *int_data,
|
||||
ecma_length_t args_number,
|
||||
ecma_value_t args_values[],
|
||||
ecma_length_t *out_arg_number_p);
|
||||
void
|
||||
fill_params_list (int_data_t *int_data,
|
||||
ecma_length_t params_number,
|
||||
ecma_string_t* params_names[]);
|
||||
bool is_reg_variable (int_data_t *int_data, idx_t var_idx);
|
||||
ecma_completion_value_t get_variable_value (int_data_t *, idx_t, bool);
|
||||
ecma_completion_value_t set_variable_value (int_data_t *, opcode_counter_t, idx_t, const ecma_value_t&);
|
||||
ecma_completion_value_t fill_varg_list (int_data_t *int_data,
|
||||
ecma_length_t args_number,
|
||||
ecma_value_t args_values[],
|
||||
ecma_length_t *out_arg_number_p);
|
||||
void fill_params_list (int_data_t *int_data,
|
||||
ecma_length_t params_number,
|
||||
ecma_string_t* params_names[]);
|
||||
#endif /* OPCODES_ECMA_SUPPORT_H */
|
||||
|
||||
@@ -26,9 +26,8 @@
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
opfunc_try_block (ecma_completion_value_t &try_completion, /**< out: completion value */
|
||||
opcode_t opdata, /**< operation data */
|
||||
ecma_completion_value_t
|
||||
opfunc_try_block (opcode_t opdata, /**< operation data */
|
||||
int_data_t *int_data) /**< interpreter context */
|
||||
{
|
||||
const idx_t block_end_oc_idx_1 = opdata.data.try_block.oc_idx_1;
|
||||
@@ -38,8 +37,7 @@ opfunc_try_block (ecma_completion_value_t &try_completion, /**< out: completion
|
||||
|
||||
int_data->pos++;
|
||||
|
||||
run_int_loop (try_completion, int_data);
|
||||
|
||||
ecma_completion_value_t try_completion = run_int_loop (int_data);
|
||||
JERRY_ASSERT ((!ecma_is_completion_value_empty (try_completion) && int_data->pos <= try_end_oc)
|
||||
|| (ecma_is_completion_value_empty (try_completion) && int_data->pos == try_end_oc));
|
||||
int_data->pos = try_end_oc;
|
||||
@@ -49,7 +47,7 @@ opfunc_try_block (ecma_completion_value_t &try_completion, /**< out: completion
|
||||
|
||||
if (ecma_is_completion_value_exit (try_completion))
|
||||
{
|
||||
return;
|
||||
return try_completion;
|
||||
}
|
||||
|
||||
if (next_opcode.data.meta.type == OPCODE_META_TYPE_CATCH)
|
||||
@@ -70,33 +68,25 @@ opfunc_try_block (ecma_completion_value_t &try_completion, /**< out: completion
|
||||
|
||||
ecma_string_t *catch_exc_var_name_str_p = ecma_new_ecma_string_from_lit_index (catch_exc_val_var_name_lit_idx);
|
||||
|
||||
const ecma_object_ptr_t* old_env_p = int_data->lex_env_p;
|
||||
ecma_object_ptr_t catch_env_p;
|
||||
ecma_create_decl_lex_env (catch_env_p, *old_env_p);
|
||||
|
||||
ecma_completion_value_t completion;
|
||||
ecma_op_create_mutable_binding (completion,
|
||||
catch_env_p,
|
||||
catch_exc_var_name_str_p,
|
||||
false);
|
||||
ecma_object_t *old_env_p = int_data->lex_env_p;
|
||||
ecma_object_t *catch_env_p = ecma_create_decl_lex_env (old_env_p);
|
||||
ecma_completion_value_t completion = ecma_op_create_mutable_binding (catch_env_p,
|
||||
catch_exc_var_name_str_p,
|
||||
false);
|
||||
JERRY_ASSERT (ecma_is_completion_value_empty (completion));
|
||||
|
||||
ecma_value_t catched_exc_value;
|
||||
ecma_get_completion_value_value (catched_exc_value, try_completion);
|
||||
|
||||
ecma_op_set_mutable_binding (completion,
|
||||
catch_env_p,
|
||||
catch_exc_var_name_str_p,
|
||||
catched_exc_value,
|
||||
false);
|
||||
completion = ecma_op_set_mutable_binding (catch_env_p,
|
||||
catch_exc_var_name_str_p,
|
||||
ecma_get_completion_value_value (try_completion),
|
||||
false);
|
||||
JERRY_ASSERT (ecma_is_completion_value_empty (completion));
|
||||
|
||||
ecma_deref_ecma_string (catch_exc_var_name_str_p);
|
||||
|
||||
int_data->lex_env_p = &catch_env_p;
|
||||
int_data->lex_env_p = catch_env_p;
|
||||
|
||||
ecma_free_completion_value (try_completion);
|
||||
run_int_loop (try_completion, int_data);
|
||||
try_completion = run_int_loop (int_data);
|
||||
|
||||
int_data->lex_env_p = old_env_p;
|
||||
|
||||
@@ -114,7 +104,7 @@ opfunc_try_block (ecma_completion_value_t &try_completion, /**< out: completion
|
||||
|
||||
if (ecma_is_completion_value_exit (try_completion))
|
||||
{
|
||||
return;
|
||||
return try_completion;
|
||||
}
|
||||
|
||||
if (next_opcode.data.meta.type == OPCODE_META_TYPE_FINALLY)
|
||||
@@ -123,8 +113,7 @@ opfunc_try_block (ecma_completion_value_t &try_completion, /**< out: completion
|
||||
read_meta_opcode_counter (OPCODE_META_TYPE_FINALLY, int_data) + int_data->pos);
|
||||
int_data->pos++;
|
||||
|
||||
ecma_completion_value_t finally_completion;
|
||||
run_int_loop (finally_completion, int_data);
|
||||
ecma_completion_value_t finally_completion = run_int_loop (int_data);
|
||||
JERRY_ASSERT ((!ecma_is_completion_value_empty (finally_completion) && int_data->pos <= finally_end_oc)
|
||||
|| (ecma_is_completion_value_empty (finally_completion) && int_data->pos == finally_end_oc));
|
||||
int_data->pos = finally_end_oc;
|
||||
@@ -139,4 +128,6 @@ opfunc_try_block (ecma_completion_value_t &try_completion, /**< out: completion
|
||||
next_opcode = read_opcode (int_data->pos++);
|
||||
JERRY_ASSERT (next_opcode.op_idx == __op__idx_meta);
|
||||
JERRY_ASSERT (next_opcode.data.meta.type == OPCODE_META_TYPE_END_TRY_CATCH_FINALLY);
|
||||
|
||||
return try_completion;
|
||||
} /* opfunc_try_block */
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
* but has no ECMA-defined name.
|
||||
*/
|
||||
static void
|
||||
do_strict_eval_arguments_check (const ecma_object_ptr_t &ref_base_lex_env_p, /**< base of ECMA-reference
|
||||
(lexical environment) */
|
||||
do_strict_eval_arguments_check (ecma_object_t *ref_base_lex_env_p, /**< base of ECMA-reference
|
||||
(lexical environment) */
|
||||
ecma_string_t *var_name_string_p, /**< variable name */
|
||||
bool is_strict) /**< flag indicating strict mode */
|
||||
{
|
||||
@@ -31,7 +31,7 @@ do_strict_eval_arguments_check (const ecma_object_ptr_t &ref_base_lex_env_p, /**
|
||||
|
||||
if (is_strict)
|
||||
{
|
||||
if (ref_base_lex_env_p.is_not_null ())
|
||||
if (ref_base_lex_env_p != NULL)
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_lexical_environment (ref_base_lex_env_p));
|
||||
|
||||
@@ -71,26 +71,22 @@ is_reg_variable (int_data_t *int_data, /**< interpreter context */
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
get_variable_value (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
int_data_t *int_data, /**< interpreter context */
|
||||
ecma_completion_value_t
|
||||
get_variable_value (int_data_t *int_data, /**< interpreter context */
|
||||
idx_t var_idx, /**< variable identifier */
|
||||
bool do_eval_or_arguments_check) /** run 'strict eval or arguments reference' check
|
||||
See also: do_strict_eval_arguments_check */
|
||||
{
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
if (is_reg_variable (int_data, var_idx))
|
||||
{
|
||||
ecma_value_t reg_value;
|
||||
ecma_stack_frame_get_reg_value (reg_value,
|
||||
&int_data->stack_frame,
|
||||
var_idx - int_data->min_reg_num);
|
||||
ecma_value_t reg_value = ecma_stack_frame_get_reg_value (&int_data->stack_frame,
|
||||
var_idx - int_data->min_reg_num);
|
||||
|
||||
JERRY_ASSERT (!ecma_is_value_empty (reg_value));
|
||||
|
||||
ecma_value_t value_copy;
|
||||
ecma_copy_value (value_copy, reg_value, true);
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, value_copy);
|
||||
ret_value = ecma_make_normal_completion_value (ecma_copy_value (reg_value, true));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -99,8 +95,8 @@ get_variable_value (ecma_completion_value_t &ret_value, /**< out: completion val
|
||||
JERRY_ASSERT (lit_id != INVALID_LITERAL);
|
||||
ecma_new_ecma_string_on_stack_from_lit_index (&var_name_string, lit_id);
|
||||
|
||||
ecma_object_ptr_t ref_base_lex_env_p;
|
||||
ecma_op_resolve_reference_base (ref_base_lex_env_p, *int_data->lex_env_p, &var_name_string);
|
||||
ecma_object_t *ref_base_lex_env_p = ecma_op_resolve_reference_base (int_data->lex_env_p,
|
||||
&var_name_string);
|
||||
|
||||
if (do_eval_or_arguments_check)
|
||||
{
|
||||
@@ -111,13 +107,14 @@ get_variable_value (ecma_completion_value_t &ret_value, /**< out: completion val
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
}
|
||||
|
||||
ecma_op_get_value_lex_env_base (ret_value,
|
||||
ref_base_lex_env_p,
|
||||
&var_name_string,
|
||||
int_data->is_strict);
|
||||
ret_value = ecma_op_get_value_lex_env_base (ref_base_lex_env_p,
|
||||
&var_name_string,
|
||||
int_data->is_strict);
|
||||
|
||||
ecma_check_that_ecma_string_need_not_be_freed (&var_name_string);
|
||||
}
|
||||
|
||||
return ret_value;
|
||||
} /* get_variable_value */
|
||||
|
||||
/**
|
||||
@@ -126,21 +123,20 @@ get_variable_value (ecma_completion_value_t &ret_value, /**< out: completion val
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
set_variable_value (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
int_data_t *int_data, /**< interpreter context */
|
||||
ecma_completion_value_t
|
||||
set_variable_value (int_data_t *int_data, /**< interpreter context */
|
||||
opcode_counter_t lit_oc, /**< opcode counter for literal */
|
||||
idx_t var_idx, /**< variable identifier */
|
||||
const ecma_value_t& value) /**< value to set */
|
||||
{
|
||||
ecma_make_empty_completion_value (ret_value);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
if (is_reg_variable (int_data, var_idx))
|
||||
{
|
||||
ecma_value_t reg_value;
|
||||
ecma_stack_frame_get_reg_value (reg_value,
|
||||
&int_data->stack_frame,
|
||||
var_idx - int_data->min_reg_num);
|
||||
ret_value = ecma_make_empty_completion_value ();
|
||||
|
||||
ecma_value_t reg_value = ecma_stack_frame_get_reg_value (&int_data->stack_frame,
|
||||
var_idx - int_data->min_reg_num);
|
||||
|
||||
if (ecma_is_value_number (reg_value)
|
||||
&& ecma_is_value_number (value))
|
||||
@@ -154,12 +150,9 @@ set_variable_value (ecma_completion_value_t &ret_value, /**< out: completion val
|
||||
ecma_free_value (reg_value, false);
|
||||
}
|
||||
|
||||
ecma_value_t value_copy;
|
||||
ecma_copy_value (value_copy, value, false);
|
||||
|
||||
ecma_stack_frame_set_reg_value (&int_data->stack_frame,
|
||||
var_idx - int_data->min_reg_num,
|
||||
value_copy);
|
||||
ecma_copy_value (value, false));
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -169,8 +162,8 @@ set_variable_value (ecma_completion_value_t &ret_value, /**< out: completion val
|
||||
JERRY_ASSERT (lit_id != INVALID_LITERAL);
|
||||
ecma_new_ecma_string_on_stack_from_lit_index (&var_name_string, lit_id);
|
||||
|
||||
ecma_object_ptr_t ref_base_lex_env_p;
|
||||
ecma_op_resolve_reference_base (ref_base_lex_env_p, *int_data->lex_env_p, &var_name_string);
|
||||
ecma_object_t *ref_base_lex_env_p = ecma_op_resolve_reference_base (int_data->lex_env_p,
|
||||
&var_name_string);
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
do_strict_eval_arguments_check (ref_base_lex_env_p,
|
||||
@@ -178,12 +171,13 @@ set_variable_value (ecma_completion_value_t &ret_value, /**< out: completion val
|
||||
int_data->is_strict);
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
|
||||
ecma_op_put_value_lex_env_base (ret_value,
|
||||
ref_base_lex_env_p,
|
||||
&var_name_string,
|
||||
int_data->is_strict,
|
||||
value);
|
||||
ret_value = ecma_op_put_value_lex_env_base (ref_base_lex_env_p,
|
||||
&var_name_string,
|
||||
int_data->is_strict,
|
||||
value);
|
||||
|
||||
ecma_check_that_ecma_string_need_not_be_freed (&var_name_string);
|
||||
}
|
||||
|
||||
return ret_value;
|
||||
} /* set_variable_value */
|
||||
|
||||
@@ -29,9 +29,8 @@
|
||||
/**
|
||||
* 'Native call' opcode handler.
|
||||
*/
|
||||
void
|
||||
opfunc_native_call (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
opcode_t opdata, /**< operation data */
|
||||
ecma_completion_value_t
|
||||
opfunc_native_call (opcode_t opdata, /**< operation data */
|
||||
int_data_t *int_data) /**< interpreter context */
|
||||
{
|
||||
// const idx_t dst_var_idx = opdata.data.native_call.lhs;
|
||||
@@ -44,15 +43,15 @@ opfunc_native_call (ecma_completion_value_t &ret_value, /**< out: completion val
|
||||
|
||||
JERRY_STATIC_ASSERT (OPCODE_NATIVE_CALL__COUNT < (1u << (sizeof (native_call_id_idx) * JERRY_BITSINBYTE)));
|
||||
|
||||
ecma_completion_value_t ret_value = 0;
|
||||
|
||||
MEM_DEFINE_LOCAL_ARRAY (arg_values, args_number, ecma_value_t);
|
||||
|
||||
ecma_length_t args_read;
|
||||
ecma_completion_value_t get_arg_completion;
|
||||
fill_varg_list (get_arg_completion,
|
||||
int_data,
|
||||
args_number,
|
||||
arg_values,
|
||||
&args_read);
|
||||
ecma_completion_value_t get_arg_completion = fill_varg_list (int_data,
|
||||
args_number,
|
||||
arg_values,
|
||||
&args_read);
|
||||
|
||||
if (ecma_is_completion_value_empty (get_arg_completion))
|
||||
{
|
||||
@@ -67,7 +66,7 @@ opfunc_native_call (ecma_completion_value_t &ret_value, /**< out: completion val
|
||||
uint32_t int_num = ecma_number_to_uint32 (*num_p);
|
||||
led_toggle (int_num);
|
||||
|
||||
ecma_make_empty_completion_value (ret_value);
|
||||
ret_value = ecma_make_empty_completion_value ();
|
||||
break;
|
||||
}
|
||||
case OPCODE_NATIVE_CALL_LED_ON:
|
||||
@@ -77,7 +76,7 @@ opfunc_native_call (ecma_completion_value_t &ret_value, /**< out: completion val
|
||||
uint32_t int_num = ecma_number_to_uint32 (*num_p);
|
||||
led_on (int_num);
|
||||
|
||||
ecma_make_empty_completion_value (ret_value);
|
||||
ret_value = ecma_make_empty_completion_value ();
|
||||
break;
|
||||
}
|
||||
case OPCODE_NATIVE_CALL_LED_OFF:
|
||||
@@ -87,7 +86,7 @@ opfunc_native_call (ecma_completion_value_t &ret_value, /**< out: completion val
|
||||
uint32_t int_num = ecma_number_to_uint32 (*num_p);
|
||||
led_off (int_num);
|
||||
|
||||
ecma_make_empty_completion_value (ret_value);
|
||||
ret_value = ecma_make_empty_completion_value ();
|
||||
break;
|
||||
}
|
||||
case OPCODE_NATIVE_CALL_LED_ONCE:
|
||||
@@ -97,7 +96,7 @@ opfunc_native_call (ecma_completion_value_t &ret_value, /**< out: completion val
|
||||
uint32_t int_num = ecma_number_to_uint32 (*num_p);
|
||||
led_blink_once (int_num);
|
||||
|
||||
ecma_make_empty_completion_value (ret_value);
|
||||
ret_value = ecma_make_empty_completion_value ();
|
||||
break;
|
||||
}
|
||||
case OPCODE_NATIVE_CALL_WAIT:
|
||||
@@ -107,7 +106,7 @@ opfunc_native_call (ecma_completion_value_t &ret_value, /**< out: completion val
|
||||
uint32_t int_num = ecma_number_to_uint32 (*num_p);
|
||||
wait_ms (int_num);
|
||||
|
||||
ecma_make_empty_completion_value (ret_value);
|
||||
ret_value = ecma_make_empty_completion_value ();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -115,7 +114,9 @@ opfunc_native_call (ecma_completion_value_t &ret_value, /**< out: completion val
|
||||
{
|
||||
JERRY_ASSERT (args_number == 1);
|
||||
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_to_string, str_value, arg_values[0]);
|
||||
ECMA_TRY_CATCH (str_value,
|
||||
ecma_op_to_string (arg_values[0]),
|
||||
ret_value);
|
||||
|
||||
ecma_string_t *str_p = ecma_get_string_from_value (str_value);
|
||||
|
||||
@@ -140,7 +141,7 @@ opfunc_native_call (ecma_completion_value_t &ret_value, /**< out: completion val
|
||||
|
||||
mem_heap_free_block (zt_str_p);
|
||||
|
||||
ecma_make_empty_completion_value (ret_value);
|
||||
ret_value = ecma_make_empty_completion_value ();
|
||||
|
||||
ECMA_FINALIZE (str_value);
|
||||
|
||||
@@ -168,4 +169,6 @@ opfunc_native_call (ecma_completion_value_t &ret_value, /**< out: completion val
|
||||
}
|
||||
|
||||
MEM_FINALIZE_LOCAL_ARRAY (arg_values);
|
||||
|
||||
return ret_value;
|
||||
} /* opfunc_native_call */
|
||||
|
||||
@@ -26,23 +26,21 @@
|
||||
* otherwise - not normal completion value indicating completion type
|
||||
* of last expression evaluated
|
||||
*/
|
||||
void
|
||||
fill_varg_list (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
int_data_t *int_data, /**< interpreter context */
|
||||
ecma_completion_value_t
|
||||
fill_varg_list (int_data_t *int_data, /**< interpreter context */
|
||||
ecma_length_t args_number, /**< number of arguments */
|
||||
ecma_value_t arg_values[], /**< out: arguments' values */
|
||||
ecma_length_t *out_arg_number_p) /**< out: number of arguments
|
||||
successfully read */
|
||||
{
|
||||
ecma_make_empty_completion_value (ret_value);
|
||||
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
|
||||
|
||||
ecma_length_t arg_index;
|
||||
for (arg_index = 0;
|
||||
arg_index < args_number;
|
||||
arg_index++)
|
||||
{
|
||||
ecma_completion_value_t evaluate_arg_completion;
|
||||
run_int_loop (evaluate_arg_completion, int_data);
|
||||
ecma_completion_value_t evaluate_arg_completion = run_int_loop (int_data);
|
||||
|
||||
if (ecma_is_completion_value_normal (evaluate_arg_completion))
|
||||
{
|
||||
@@ -52,12 +50,11 @@ fill_varg_list (ecma_completion_value_t &ret_value, /**< out: completion value *
|
||||
|
||||
const idx_t varg_var_idx = next_opcode.data.meta.data_1;
|
||||
|
||||
ecma_completion_value_t get_arg_completion;
|
||||
get_variable_value (get_arg_completion, int_data, varg_var_idx, false);
|
||||
ecma_completion_value_t get_arg_completion = get_variable_value (int_data, varg_var_idx, false);
|
||||
|
||||
if (ecma_is_completion_value_normal (get_arg_completion))
|
||||
{
|
||||
ecma_get_completion_value_value (arg_values[arg_index], get_arg_completion);
|
||||
arg_values[arg_index] = ecma_get_completion_value_value (get_arg_completion);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -78,6 +75,8 @@ fill_varg_list (ecma_completion_value_t &ret_value, /**< out: completion value *
|
||||
}
|
||||
|
||||
*out_arg_number_p = arg_index;
|
||||
|
||||
return ret_value;
|
||||
} /* fill_varg_list */
|
||||
|
||||
/**
|
||||
|
||||
+429
-343
File diff suppressed because it is too large
Load Diff
@@ -18,7 +18,6 @@
|
||||
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-stack.h"
|
||||
#include "ecma-value.h"
|
||||
#include "globals.h"
|
||||
|
||||
/* Maximum opcodes number in bytecode. */
|
||||
@@ -77,8 +76,8 @@ typedef enum
|
||||
typedef struct
|
||||
{
|
||||
opcode_counter_t pos; /**< current opcode to execute */
|
||||
const ecma_value_t* this_binding_p; /**< this binding for current context */
|
||||
const ecma_object_ptr_t *lex_env_p; /**< current lexical environment */
|
||||
ecma_value_t this_binding; /**< this binding for current context */
|
||||
ecma_object_t *lex_env_p; /**< current lexical environment */
|
||||
bool is_strict; /**< is current code execution mode strict? */
|
||||
bool is_eval_code; /**< is current code executed with eval */
|
||||
idx_t min_reg_num; /**< minimum idx used for register identification */
|
||||
@@ -242,11 +241,11 @@ enum __opcode_idx
|
||||
};
|
||||
#undef __OP_ENUM_FIELD
|
||||
|
||||
#define __OP_FUNC_DECL(name, arg1, arg2, arg3) void opfunc_##name (ecma_completion_value_t &, opcode_t, int_data_t*);
|
||||
#define __OP_FUNC_DECL(name, arg1, arg2, arg3) ecma_completion_value_t opfunc_##name (opcode_t, int_data_t*);
|
||||
OP_LIST (OP_FUNC_DECL)
|
||||
#undef __OP_FUNC_DECL
|
||||
|
||||
typedef void (*opfunc) (ecma_completion_value_t &, opcode_t, int_data_t *);
|
||||
typedef ecma_completion_value_t (*opfunc) (opcode_t, int_data_t *);
|
||||
|
||||
#define GETOP_DECL_0(a, name) \
|
||||
opcode_t getop_##name (void);
|
||||
|
||||
@@ -53,11 +53,10 @@
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_array_prototype_object_to_string (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg) /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_array_prototype_object_to_string (const ecma_value_t& this_arg) /**< this argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg);
|
||||
} /* ecma_builtin_array_prototype_object_to_string */
|
||||
|
||||
/**
|
||||
|
||||
@@ -41,7 +41,7 @@ OBJECT_ID (ECMA_BUILTIN_ID_ARRAY_PROTOTYPE)
|
||||
|
||||
// 15.4.4.1
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_CONSTRUCTOR,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_ARRAY),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_ARRAY),
|
||||
ECMA_PROPERTY_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_CONFIGURABLE)
|
||||
|
||||
@@ -53,17 +53,15 @@
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_array_object_is_array (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg __unused, /**< 'this' argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_array_object_is_array (const ecma_value_t& this_arg __unused, /**< 'this' argument */
|
||||
const ecma_value_t& arg) /**< first argument */
|
||||
{
|
||||
ecma_simple_value_t is_array = ECMA_SIMPLE_VALUE_FALSE;
|
||||
|
||||
if (ecma_is_value_object (arg))
|
||||
{
|
||||
ecma_object_ptr_t obj_p;
|
||||
ecma_get_object_from_value (obj_p, arg);
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (arg);
|
||||
|
||||
ecma_property_t *class_prop_p = ecma_get_internal_property (obj_p,
|
||||
ECMA_INTERNAL_PROPERTY_CLASS);
|
||||
@@ -74,7 +72,7 @@ ecma_builtin_array_object_is_array (ecma_completion_value_t &ret_value, /**< out
|
||||
}
|
||||
}
|
||||
|
||||
ecma_make_simple_completion_value (ret_value, is_array);
|
||||
return ecma_make_simple_completion_value (is_array);
|
||||
} /* ecma_builtin_array_object_is_array */
|
||||
|
||||
/**
|
||||
@@ -82,14 +80,13 @@ ecma_builtin_array_object_is_array (ecma_completion_value_t &ret_value, /**< out
|
||||
*
|
||||
* @return completion-value
|
||||
*/
|
||||
void
|
||||
ecma_builtin_array_dispatch_call (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_completion_value_t
|
||||
ecma_builtin_array_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
ecma_builtin_array_dispatch_construct (ret_value, arguments_list_p, arguments_list_len);
|
||||
return ecma_builtin_array_dispatch_construct (arguments_list_p, arguments_list_len);
|
||||
} /* ecma_builtin_array_dispatch_call */
|
||||
|
||||
/**
|
||||
@@ -97,14 +94,13 @@ ecma_builtin_array_dispatch_call (ecma_completion_value_t &ret_value, /**< out:
|
||||
*
|
||||
* @return completion-value
|
||||
*/
|
||||
void
|
||||
ecma_builtin_array_dispatch_construct (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_completion_value_t
|
||||
ecma_builtin_array_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
ecma_op_create_array_object (ret_value, arguments_list_p, arguments_list_len, true);
|
||||
return ecma_op_create_array_object (arguments_list_p, arguments_list_len, true);
|
||||
} /* ecma_builtin_array_dispatch_construct */
|
||||
|
||||
/**
|
||||
|
||||
@@ -41,7 +41,7 @@ OBJECT_ID (ECMA_BUILTIN_ID_ARRAY)
|
||||
|
||||
// 15.4.3.1
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_PROTOTYPE,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_ARRAY_PROTOTYPE),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_ARRAY_PROTOTYPE),
|
||||
ECMA_PROPERTY_NOT_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_NOT_CONFIGURABLE)
|
||||
|
||||
@@ -53,11 +53,14 @@
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_boolean_prototype_object_to_string (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg) /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_boolean_prototype_object_to_string (const ecma_value_t& this_arg) /**< this argument */
|
||||
{
|
||||
ECMA_TRY_CATCH (ret_value, ecma_builtin_boolean_prototype_object_value_of, value_of_ret, this_arg);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
ECMA_TRY_CATCH (value_of_ret,
|
||||
ecma_builtin_boolean_prototype_object_value_of (this_arg),
|
||||
ret_value);
|
||||
|
||||
ecma_string_t *ret_str_p;
|
||||
|
||||
@@ -72,9 +75,11 @@ ecma_builtin_boolean_prototype_object_to_string (ecma_completion_value_t &ret_va
|
||||
ret_str_p = ecma_get_magic_string (ECMA_MAGIC_STRING_FALSE);
|
||||
}
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (ret_str_p));
|
||||
ret_value = ecma_make_normal_completion_value (ecma_make_string_value (ret_str_p));
|
||||
|
||||
ECMA_FINALIZE (value_of_ret);
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_builtin_boolean_prototype_object_to_string */
|
||||
|
||||
/**
|
||||
@@ -86,19 +91,16 @@ ecma_builtin_boolean_prototype_object_to_string (ecma_completion_value_t &ret_va
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_boolean_prototype_object_value_of (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg) /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_boolean_prototype_object_value_of (const ecma_value_t& this_arg) /**< this argument */
|
||||
{
|
||||
if (ecma_is_value_boolean (this_arg))
|
||||
{
|
||||
ecma_make_normal_completion_value (ret_value, this_arg);
|
||||
return;
|
||||
return ecma_make_normal_completion_value (this_arg);
|
||||
}
|
||||
else if (ecma_is_value_object (this_arg))
|
||||
{
|
||||
ecma_object_ptr_t obj_p;
|
||||
ecma_get_object_from_value (obj_p, this_arg);
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (this_arg);
|
||||
|
||||
ecma_property_t *class_prop_p = ecma_get_internal_property (obj_p, ECMA_INTERNAL_PROPERTY_CLASS);
|
||||
|
||||
@@ -111,18 +113,15 @@ ecma_builtin_boolean_prototype_object_value_of (ecma_completion_value_t &ret_val
|
||||
|
||||
ecma_simple_value_t prim_simple_value = (ecma_simple_value_t) prim_value_prop_p->u.internal_property.value;
|
||||
|
||||
ecma_value_t ret_boolean_value (prim_simple_value);
|
||||
ecma_value_t ret_boolean_value = ecma_make_simple_value (prim_simple_value);
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_boolean (ret_boolean_value));
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, ret_boolean_value);
|
||||
return;
|
||||
return ecma_make_normal_completion_value (ret_boolean_value);
|
||||
}
|
||||
}
|
||||
|
||||
ecma_object_ptr_t exception_obj_p;
|
||||
ecma_new_standard_error (exception_obj_p, ECMA_ERROR_TYPE);
|
||||
ecma_make_throw_obj_completion_value (ret_value, exception_obj_p);
|
||||
return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||
} /* ecma_builtin_boolean_prototype_object_value_of */
|
||||
|
||||
/**
|
||||
|
||||
@@ -37,7 +37,7 @@ OBJECT_ID (ECMA_BUILTIN_ID_BOOLEAN_PROTOTYPE)
|
||||
|
||||
// 15.6.4.1
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_CONSTRUCTOR,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_BOOLEAN),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_BOOLEAN),
|
||||
ECMA_PROPERTY_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_CONFIGURABLE)
|
||||
|
||||
@@ -49,23 +49,24 @@
|
||||
*
|
||||
* @return completion-value
|
||||
*/
|
||||
void
|
||||
ecma_builtin_boolean_dispatch_call (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_completion_value_t
|
||||
ecma_builtin_boolean_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
ecma_value_t arg_value;
|
||||
|
||||
if (arguments_list_len == 0)
|
||||
{
|
||||
ecma_value_t value_undefined (ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||
|
||||
ecma_op_to_boolean (ret_value, value_undefined);
|
||||
arg_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_op_to_boolean (ret_value, arguments_list_p [0]);
|
||||
arg_value = arguments_list_p [0];
|
||||
}
|
||||
|
||||
return ecma_op_to_boolean (arg_value);
|
||||
} /* ecma_builtin_boolean_dispatch_call */
|
||||
|
||||
/**
|
||||
@@ -73,20 +74,19 @@ ecma_builtin_boolean_dispatch_call (ecma_completion_value_t &ret_value, /**< out
|
||||
*
|
||||
* @return completion-value
|
||||
*/
|
||||
void
|
||||
ecma_builtin_boolean_dispatch_construct (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_completion_value_t
|
||||
ecma_builtin_boolean_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
if (arguments_list_len == 0)
|
||||
{
|
||||
ecma_op_create_boolean_object (ret_value, ecma_value_t (ECMA_SIMPLE_VALUE_FALSE));
|
||||
return ecma_op_create_boolean_object (ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE));
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_op_create_boolean_object (ret_value, arguments_list_p[0]);
|
||||
return ecma_op_create_boolean_object (arguments_list_p[0]);
|
||||
}
|
||||
} /* ecma_builtin_boolean_dispatch_construct */
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ OBJECT_ID (ECMA_BUILTIN_ID_BOOLEAN)
|
||||
|
||||
// 15.6.3.1
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_PROTOTYPE,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_BOOLEAN_PROTOTYPE),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_BOOLEAN_PROTOTYPE),
|
||||
ECMA_PROPERTY_NOT_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_NOT_CONFIGURABLE)
|
||||
|
||||
@@ -48,16 +48,13 @@
|
||||
*
|
||||
* @return completion-value
|
||||
*/
|
||||
void
|
||||
ecma_builtin_compact_profile_error_dispatch_call (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_completion_value_t
|
||||
ecma_builtin_compact_profile_error_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
ecma_object_ptr_t cp_error_obj_p;
|
||||
ecma_builtin_get (cp_error_obj_p, ECMA_BUILTIN_ID_COMPACT_PROFILE_ERROR);
|
||||
ecma_make_throw_obj_completion_value (ret_value, cp_error_obj_p);
|
||||
return ecma_make_throw_obj_completion_value (ecma_builtin_get (ECMA_BUILTIN_ID_COMPACT_PROFILE_ERROR));
|
||||
} /* ecma_builtin_compact_profile_error_dispatch_call */
|
||||
|
||||
/**
|
||||
@@ -65,16 +62,13 @@ ecma_builtin_compact_profile_error_dispatch_call (ecma_completion_value_t &ret_v
|
||||
*
|
||||
* @return completion-value
|
||||
*/
|
||||
void
|
||||
ecma_builtin_compact_profile_error_dispatch_construct (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_completion_value_t
|
||||
ecma_builtin_compact_profile_error_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
ecma_object_ptr_t cp_error_obj_p;
|
||||
ecma_builtin_get (cp_error_obj_p, ECMA_BUILTIN_ID_COMPACT_PROFILE_ERROR);
|
||||
ecma_make_throw_obj_completion_value (ret_value, cp_error_obj_p);
|
||||
return ecma_make_throw_obj_completion_value (ecma_builtin_get (ECMA_BUILTIN_ID_COMPACT_PROFILE_ERROR));
|
||||
} /* ecma_builtin_compact_profile_error_dispatch_construct */
|
||||
|
||||
/**
|
||||
|
||||
@@ -53,24 +53,24 @@
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_error_prototype_object_to_string (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg) /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_error_prototype_object_to_string (const ecma_value_t& this_arg) /**< this argument */
|
||||
{
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
// 2.
|
||||
if (!ecma_is_value_object (this_arg))
|
||||
{
|
||||
ecma_object_ptr_t exception_obj_p;
|
||||
ecma_new_standard_error (exception_obj_p, ECMA_ERROR_TYPE);
|
||||
ecma_make_throw_obj_completion_value (ret_value, exception_obj_p);
|
||||
ret_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_object_ptr_t obj_p;
|
||||
ecma_get_object_from_value (obj_p, this_arg);
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (this_arg);
|
||||
ecma_string_t *name_magic_string_p = ecma_get_magic_string (ECMA_MAGIC_STRING_NAME);
|
||||
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_object_get, name_get_ret_value, obj_p, name_magic_string_p);
|
||||
ECMA_TRY_CATCH (name_get_ret_value,
|
||||
ecma_op_object_get (obj_p, name_magic_string_p),
|
||||
ret_value);
|
||||
|
||||
ecma_completion_value_t name_to_str_completion;
|
||||
|
||||
@@ -78,22 +78,24 @@ ecma_builtin_error_prototype_object_to_string (ecma_completion_value_t &ret_valu
|
||||
{
|
||||
ecma_string_t *error_magic_string_p = ecma_get_magic_string (ECMA_MAGIC_STRING_ERROR_UL);
|
||||
|
||||
ecma_make_normal_completion_value (name_to_str_completion, ecma_value_t (error_magic_string_p));
|
||||
name_to_str_completion = ecma_make_normal_completion_value (ecma_make_string_value (error_magic_string_p));
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_op_to_string (name_to_str_completion, name_get_ret_value);
|
||||
name_to_str_completion = ecma_op_to_string (name_get_ret_value);
|
||||
}
|
||||
|
||||
if (unlikely (!ecma_is_completion_value_normal (name_to_str_completion)))
|
||||
{
|
||||
ecma_copy_completion_value (ret_value, name_to_str_completion);
|
||||
ret_value = ecma_copy_completion_value (name_to_str_completion);
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_string_t *message_magic_string_p = ecma_get_magic_string (ECMA_MAGIC_STRING_MESSAGE);
|
||||
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_object_get, msg_get_ret_value, obj_p, message_magic_string_p);
|
||||
ECMA_TRY_CATCH (msg_get_ret_value,
|
||||
ecma_op_object_get (obj_p, message_magic_string_p),
|
||||
ret_value);
|
||||
|
||||
ecma_completion_value_t msg_to_str_completion;
|
||||
|
||||
@@ -101,26 +103,21 @@ ecma_builtin_error_prototype_object_to_string (ecma_completion_value_t &ret_valu
|
||||
{
|
||||
ecma_string_t *empty_magic_string_p = ecma_get_magic_string (ECMA_MAGIC_STRING__EMPTY);
|
||||
|
||||
ecma_make_normal_completion_value (msg_to_str_completion, ecma_value_t (empty_magic_string_p));
|
||||
msg_to_str_completion = ecma_make_normal_completion_value (ecma_make_string_value (empty_magic_string_p));
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_op_to_string (msg_to_str_completion, msg_get_ret_value);
|
||||
msg_to_str_completion = ecma_op_to_string (msg_get_ret_value);
|
||||
}
|
||||
|
||||
if (unlikely (!ecma_is_completion_value_normal (msg_to_str_completion)))
|
||||
{
|
||||
ecma_copy_completion_value (ret_value, msg_to_str_completion);
|
||||
ret_value = ecma_copy_completion_value (msg_to_str_completion);
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_value_t name_to_str_value, msg_to_str_value;
|
||||
|
||||
ecma_get_completion_value_value (name_to_str_value, name_to_str_completion);
|
||||
ecma_get_completion_value_value (msg_to_str_value, msg_to_str_completion);
|
||||
|
||||
ecma_string_t *name_string_p = ecma_get_string_from_value (name_to_str_value);
|
||||
ecma_string_t *msg_string_p = ecma_get_string_from_value (msg_to_str_value);
|
||||
ecma_string_t *name_string_p = ecma_get_string_from_completion_value (name_to_str_completion);
|
||||
ecma_string_t *msg_string_p = ecma_get_string_from_completion_value (msg_to_str_completion);
|
||||
|
||||
ecma_string_t *ret_str_p;
|
||||
|
||||
@@ -180,7 +177,7 @@ ecma_builtin_error_prototype_object_to_string (ecma_completion_value_t &ret_valu
|
||||
MEM_FINALIZE_LOCAL_ARRAY (ret_str_buffer);
|
||||
}
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (ret_str_p));
|
||||
ret_value = ecma_make_normal_completion_value (ecma_make_string_value (ret_str_p));
|
||||
}
|
||||
|
||||
ecma_free_completion_value (msg_to_str_completion);
|
||||
@@ -196,6 +193,8 @@ ecma_builtin_error_prototype_object_to_string (ecma_completion_value_t &ret_valu
|
||||
|
||||
ecma_deref_ecma_string (name_magic_string_p);
|
||||
}
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_builtin_error_prototype_object_to_string */
|
||||
|
||||
/**
|
||||
|
||||
@@ -41,7 +41,7 @@ OBJECT_ID (ECMA_BUILTIN_ID_ERROR_PROTOTYPE)
|
||||
|
||||
// 15.11.4.1
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_CONSTRUCTOR,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_ERROR),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_ERROR),
|
||||
ECMA_PROPERTY_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_CONFIGURABLE)
|
||||
|
||||
@@ -48,9 +48,8 @@
|
||||
*
|
||||
* @return completion-value
|
||||
*/
|
||||
void
|
||||
ecma_builtin_error_dispatch_call (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_completion_value_t
|
||||
ecma_builtin_error_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
@@ -58,21 +57,26 @@ ecma_builtin_error_dispatch_call (ecma_completion_value_t &ret_value, /**< out:
|
||||
if (arguments_list_len != 0
|
||||
&& !ecma_is_value_undefined (arguments_list_p [0]))
|
||||
{
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_to_string, msg_str_value, arguments_list_p[0]);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
ECMA_TRY_CATCH (msg_str_value,
|
||||
ecma_op_to_string (arguments_list_p[0]),
|
||||
ret_value);
|
||||
|
||||
ecma_string_t *message_string_p = ecma_get_string_from_value (msg_str_value);
|
||||
ecma_object_ptr_t new_error_object_p;
|
||||
ecma_new_standard_error_with_message (new_error_object_p, ECMA_ERROR_COMMON, message_string_p);
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (new_error_object_p));
|
||||
ecma_object_t *new_error_object_p = ecma_new_standard_error_with_message (ECMA_ERROR_COMMON,
|
||||
message_string_p);
|
||||
ret_value = ecma_make_normal_completion_value (ecma_make_object_value (new_error_object_p));
|
||||
|
||||
ECMA_FINALIZE (msg_str_value);
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_object_ptr_t new_error_object_p;
|
||||
ecma_new_standard_error (new_error_object_p, ECMA_ERROR_COMMON);
|
||||
ecma_object_t *new_error_object_p = ecma_new_standard_error (ECMA_ERROR_COMMON);
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (new_error_object_p));
|
||||
return ecma_make_normal_completion_value (ecma_make_object_value (new_error_object_p));
|
||||
}
|
||||
} /* ecma_builtin_error_dispatch_call */
|
||||
|
||||
@@ -81,12 +85,11 @@ ecma_builtin_error_dispatch_call (ecma_completion_value_t &ret_value, /**< out:
|
||||
*
|
||||
* @return completion-value
|
||||
*/
|
||||
void
|
||||
ecma_builtin_error_dispatch_construct (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_completion_value_t
|
||||
ecma_builtin_error_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
ecma_builtin_error_dispatch_call (ret_value, arguments_list_p, arguments_list_len);
|
||||
return ecma_builtin_error_dispatch_call (arguments_list_p, arguments_list_len);
|
||||
} /* ecma_builtin_error_dispatch_construct */
|
||||
|
||||
/**
|
||||
|
||||
@@ -51,7 +51,7 @@ NUMBER_VALUE (ECMA_MAGIC_STRING_LENGTH,
|
||||
|
||||
// 15.7.3.1
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_PROTOTYPE,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_ERROR_PROTOTYPE),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_ERROR_PROTOTYPE),
|
||||
ECMA_PROPERTY_NOT_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_NOT_CONFIGURABLE)
|
||||
|
||||
@@ -37,7 +37,7 @@ OBJECT_ID (ECMA_BUILTIN_ID_EVAL_ERROR_PROTOTYPE)
|
||||
|
||||
// 15.11.7.8
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_CONSTRUCTOR,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_EVAL_ERROR),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_EVAL_ERROR),
|
||||
ECMA_PROPERTY_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_CONFIGURABLE)
|
||||
|
||||
@@ -48,9 +48,8 @@
|
||||
*
|
||||
* @return completion-value
|
||||
*/
|
||||
void
|
||||
ecma_builtin_eval_error_dispatch_call (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_completion_value_t
|
||||
ecma_builtin_eval_error_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
@@ -58,21 +57,26 @@ ecma_builtin_eval_error_dispatch_call (ecma_completion_value_t &ret_value, /**<
|
||||
if (arguments_list_len != 0
|
||||
&& !ecma_is_value_undefined (arguments_list_p [0]))
|
||||
{
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_to_string, msg_str_value, arguments_list_p[0]);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
ECMA_TRY_CATCH (msg_str_value,
|
||||
ecma_op_to_string (arguments_list_p[0]),
|
||||
ret_value);
|
||||
|
||||
ecma_string_t *message_string_p = ecma_get_string_from_value (msg_str_value);
|
||||
ecma_object_ptr_t new_error_object_p;
|
||||
ecma_new_standard_error_with_message (new_error_object_p, ECMA_ERROR_EVAL, message_string_p);
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (new_error_object_p));
|
||||
ecma_object_t *new_error_object_p = ecma_new_standard_error_with_message (ECMA_ERROR_EVAL,
|
||||
message_string_p);
|
||||
ret_value = ecma_make_normal_completion_value (ecma_make_object_value (new_error_object_p));
|
||||
|
||||
ECMA_FINALIZE (msg_str_value);
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_object_ptr_t new_error_object_p;
|
||||
ecma_new_standard_error (new_error_object_p, ECMA_ERROR_EVAL);
|
||||
ecma_object_t *new_error_object_p = ecma_new_standard_error (ECMA_ERROR_EVAL);
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (new_error_object_p));
|
||||
return ecma_make_normal_completion_value (ecma_make_object_value (new_error_object_p));
|
||||
}
|
||||
} /* ecma_builtin_eval_error_dispatch_call */
|
||||
|
||||
@@ -81,12 +85,11 @@ ecma_builtin_eval_error_dispatch_call (ecma_completion_value_t &ret_value, /**<
|
||||
*
|
||||
* @return completion-value
|
||||
*/
|
||||
void
|
||||
ecma_builtin_eval_error_dispatch_construct (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_completion_value_t
|
||||
ecma_builtin_eval_error_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
ecma_builtin_eval_error_dispatch_call (ret_value, arguments_list_p, arguments_list_len);
|
||||
return ecma_builtin_eval_error_dispatch_call (arguments_list_p, arguments_list_len);
|
||||
} /* ecma_builtin_eval_error_dispatch_construct */
|
||||
|
||||
/**
|
||||
|
||||
@@ -51,7 +51,7 @@ NUMBER_VALUE (ECMA_MAGIC_STRING_LENGTH,
|
||||
|
||||
// 15.11.3.1
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_PROTOTYPE,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_EVAL_ERROR_PROTOTYPE),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_EVAL_ERROR_PROTOTYPE),
|
||||
ECMA_PROPERTY_NOT_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_NOT_CONFIGURABLE)
|
||||
|
||||
@@ -51,11 +51,10 @@
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_function_prototype_object_to_string (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg) /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_function_prototype_object_to_string (const ecma_value_t& this_arg) /**< this argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg);
|
||||
} /* ecma_builtin_function_prototype_object_to_string */
|
||||
|
||||
/**
|
||||
@@ -67,13 +66,12 @@ ecma_builtin_function_prototype_object_to_string (ecma_completion_value_t &ret_v
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_function_prototype_object_apply (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_function_prototype_object_apply (const ecma_value_t& this_arg, /**< this argument */
|
||||
const ecma_value_t& arg1, /**< first argument */
|
||||
const ecma_value_t& arg2) /**< second argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arg1, arg2);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg1, arg2);
|
||||
} /* ecma_builtin_function_prototype_object_apply */
|
||||
|
||||
/**
|
||||
@@ -85,13 +83,12 @@ ecma_builtin_function_prototype_object_apply (ecma_completion_value_t &ret_value
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_function_prototype_object_call (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_function_prototype_object_call (const ecma_value_t& this_arg, /**< this argument */
|
||||
const ecma_value_t* arguments_list_p, /**< list of arguments */
|
||||
ecma_length_t arguments_number) /**< number of arguments */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arguments_list_p, arguments_number);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arguments_list_p, arguments_number);
|
||||
} /* ecma_builtin_function_prototype_object_call */
|
||||
|
||||
/**
|
||||
@@ -103,13 +100,12 @@ ecma_builtin_function_prototype_object_call (ecma_completion_value_t &ret_value,
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_function_prototype_object_bind (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_function_prototype_object_bind (const ecma_value_t& this_arg, /**< this argument */
|
||||
const ecma_value_t* arguments_list_p, /**< list of arguments */
|
||||
ecma_length_t arguments_number) /**< number of arguments */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arguments_list_p, arguments_number);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arguments_list_p, arguments_number);
|
||||
} /* ecma_builtin_function_prototype_object_bind */
|
||||
|
||||
/**
|
||||
@@ -117,14 +113,13 @@ ecma_builtin_function_prototype_object_bind (ecma_completion_value_t &ret_value,
|
||||
*
|
||||
* @return completion-value
|
||||
*/
|
||||
void
|
||||
ecma_builtin_function_prototype_dispatch_call (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t* arguments_list_p, /**< arguments list */
|
||||
ecma_completion_value_t
|
||||
ecma_builtin_function_prototype_dispatch_call (const ecma_value_t* arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
ecma_make_simple_completion_value (ret_value, ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||
} /* ecma_builtin_function_prototype_dispatch_call */
|
||||
|
||||
/**
|
||||
@@ -132,16 +127,13 @@ ecma_builtin_function_prototype_dispatch_call (ecma_completion_value_t &ret_valu
|
||||
*
|
||||
* @return completion-value
|
||||
*/
|
||||
void
|
||||
ecma_builtin_function_prototype_dispatch_construct (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_completion_value_t
|
||||
ecma_builtin_function_prototype_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
ecma_object_ptr_t exception_obj_p;
|
||||
ecma_new_standard_error (exception_obj_p, ECMA_ERROR_TYPE);
|
||||
ecma_make_throw_obj_completion_value (ret_value, exception_obj_p);
|
||||
return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||
} /* ecma_builtin_function_prototype_dispatch_construct */
|
||||
|
||||
/**
|
||||
|
||||
@@ -41,7 +41,7 @@ OBJECT_ID (ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE)
|
||||
|
||||
// 15.3.4.1
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_CONSTRUCTOR,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_FUNCTION),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_FUNCTION),
|
||||
ECMA_PROPERTY_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_CONFIGURABLE)
|
||||
|
||||
@@ -47,14 +47,13 @@
|
||||
*
|
||||
* @return completion-value
|
||||
*/
|
||||
void
|
||||
ecma_builtin_function_dispatch_call (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_completion_value_t
|
||||
ecma_builtin_function_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
ecma_builtin_function_dispatch_construct (ret_value, arguments_list_p, arguments_list_len);
|
||||
return ecma_builtin_function_dispatch_construct (arguments_list_p, arguments_list_len);
|
||||
} /* ecma_builtin_function_dispatch_call */
|
||||
|
||||
/**
|
||||
@@ -62,14 +61,13 @@ ecma_builtin_function_dispatch_call (ecma_completion_value_t &ret_value, /**< ou
|
||||
*
|
||||
* @return completion-value
|
||||
*/
|
||||
void
|
||||
ecma_builtin_function_dispatch_construct (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_completion_value_t
|
||||
ecma_builtin_function_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, arguments_list_p, arguments_list_len);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (arguments_list_p, arguments_list_len);
|
||||
} /* ecma_builtin_function_dispatch_construct */
|
||||
|
||||
/**
|
||||
|
||||
@@ -41,7 +41,7 @@ OBJECT_ID (ECMA_BUILTIN_ID_FUNCTION)
|
||||
|
||||
// 15.3.3.1
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_PROTOTYPE,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE),
|
||||
ECMA_PROPERTY_NOT_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_NOT_CONFIGURABLE)
|
||||
|
||||
@@ -48,12 +48,11 @@
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_global_object_eval (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_global_object_eval (const ecma_value_t& this_arg, /**< this argument */
|
||||
const ecma_value_t& x) /**< routine's first argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, x);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, x);
|
||||
} /* ecma_builtin_global_object_eval */
|
||||
|
||||
/**
|
||||
@@ -65,13 +64,12 @@ ecma_builtin_global_object_eval (ecma_completion_value_t &ret_value, /**< out: c
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_global_object_parse_int (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_global_object_parse_int (const ecma_value_t& this_arg, /**< this argument */
|
||||
const ecma_value_t& string, /**< routine's first argument */
|
||||
const ecma_value_t& radix) /**< routine's second argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, string, radix);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, string, radix);
|
||||
} /* ecma_builtin_global_object_parse_int */
|
||||
|
||||
/**
|
||||
@@ -83,12 +81,11 @@ ecma_builtin_global_object_parse_int (ecma_completion_value_t &ret_value, /**< o
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_global_object_parse_float (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_global_object_parse_float (const ecma_value_t& this_arg, /**< this argument */
|
||||
const ecma_value_t& string) /**< routine's first argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, string);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, string);
|
||||
} /* ecma_builtin_global_object_parse_float */
|
||||
|
||||
/**
|
||||
@@ -100,21 +97,22 @@ ecma_builtin_global_object_parse_float (ecma_completion_value_t &ret_value, /**<
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_global_object_is_nan (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg __unused, /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_global_object_is_nan (const ecma_value_t& this_arg __unused, /**< this argument */
|
||||
const ecma_value_t& arg) /**< routine's first argument */
|
||||
{
|
||||
ecma_make_empty_completion_value (ret_value);
|
||||
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
|
||||
|
||||
ECMA_OP_TO_NUMBER_TRY_CATCH (arg_num, arg, ret_value);
|
||||
|
||||
bool is_nan = ecma_number_is_nan (arg_num);
|
||||
|
||||
ecma_make_simple_completion_value (ret_value,
|
||||
is_nan ? ECMA_SIMPLE_VALUE_TRUE : ECMA_SIMPLE_VALUE_FALSE);
|
||||
ret_value = ecma_make_simple_completion_value (is_nan ? ECMA_SIMPLE_VALUE_TRUE
|
||||
: ECMA_SIMPLE_VALUE_FALSE);
|
||||
|
||||
ECMA_OP_TO_NUMBER_FINALIZE (arg_num);
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_builtin_global_object_is_nan */
|
||||
|
||||
/**
|
||||
@@ -126,22 +124,23 @@ ecma_builtin_global_object_is_nan (ecma_completion_value_t &ret_value, /**< out:
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_global_object_is_finite (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg __unused, /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_global_object_is_finite (const ecma_value_t& this_arg __unused, /**< this argument */
|
||||
const ecma_value_t& arg) /**< routine's first argument */
|
||||
{
|
||||
ecma_make_empty_completion_value (ret_value);
|
||||
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
|
||||
|
||||
ECMA_OP_TO_NUMBER_TRY_CATCH (arg_num, arg, ret_value);
|
||||
|
||||
bool is_finite = !(ecma_number_is_nan (arg_num)
|
||||
|| ecma_number_is_infinity (arg_num));
|
||||
|
||||
ecma_make_simple_completion_value (ret_value,
|
||||
is_finite ? ECMA_SIMPLE_VALUE_TRUE : ECMA_SIMPLE_VALUE_FALSE);
|
||||
ret_value = ecma_make_simple_completion_value (is_finite ? ECMA_SIMPLE_VALUE_TRUE
|
||||
: ECMA_SIMPLE_VALUE_FALSE);
|
||||
|
||||
ECMA_OP_TO_NUMBER_FINALIZE (arg_num);
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_builtin_global_object_is_finite */
|
||||
|
||||
/**
|
||||
@@ -153,12 +152,11 @@ ecma_builtin_global_object_is_finite (ecma_completion_value_t &ret_value, /**< o
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_global_object_decode_uri (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_global_object_decode_uri (const ecma_value_t& this_arg, /**< this argument */
|
||||
const ecma_value_t& encoded_uri) /**< routine's first argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, encoded_uri);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, encoded_uri);
|
||||
} /* ecma_builtin_global_object_decode_uri */
|
||||
|
||||
/**
|
||||
@@ -170,13 +168,12 @@ ecma_builtin_global_object_decode_uri (ecma_completion_value_t &ret_value, /**<
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_global_object_decode_uri_component (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_global_object_decode_uri_component (const ecma_value_t& this_arg, /**< this argument */
|
||||
const ecma_value_t& encoded_uri_component) /**< routine's
|
||||
* first argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, encoded_uri_component);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, encoded_uri_component);
|
||||
} /* ecma_builtin_global_object_decode_uri_component */
|
||||
|
||||
/**
|
||||
@@ -188,12 +185,11 @@ ecma_builtin_global_object_decode_uri_component (ecma_completion_value_t &ret_va
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_global_object_encode_uri (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_global_object_encode_uri (const ecma_value_t& this_arg, /**< this argument */
|
||||
const ecma_value_t& uri) /**< routine's first argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, uri);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, uri);
|
||||
} /* ecma_builtin_global_object_encode_uri */
|
||||
|
||||
/**
|
||||
@@ -205,12 +201,11 @@ ecma_builtin_global_object_encode_uri (ecma_completion_value_t &ret_value, /**<
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_global_object_encode_uri_component (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_global_object_encode_uri_component (const ecma_value_t& this_arg, /**< this argument */
|
||||
const ecma_value_t& uri_component) /**< routine's first argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, uri_component);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, uri_component);
|
||||
} /* ecma_builtin_global_object_encode_uri_component */
|
||||
|
||||
/**
|
||||
|
||||
@@ -76,14 +76,14 @@ NUMBER_VALUE (ECMA_MAGIC_STRING_INFINITY_UL,
|
||||
|
||||
// ECMA-262 v5, 15.1.4.1
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_OBJECT_UL,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_OBJECT),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_OBJECT),
|
||||
ECMA_PROPERTY_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_CONFIGURABLE)
|
||||
|
||||
// ECMA-262 v5, 15.1.4.2
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_FUNCTION_UL,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_FUNCTION),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_FUNCTION),
|
||||
ECMA_PROPERTY_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_CONFIGURABLE)
|
||||
@@ -91,7 +91,7 @@ OBJECT_VALUE (ECMA_MAGIC_STRING_FUNCTION_UL,
|
||||
// ECMA-262 v5, 15.1.4.3
|
||||
#ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_ARRAY_BUILTIN
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_ARRAY_UL,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_ARRAY),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_ARRAY),
|
||||
ECMA_PROPERTY_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_CONFIGURABLE)
|
||||
@@ -100,7 +100,7 @@ OBJECT_VALUE (ECMA_MAGIC_STRING_ARRAY_UL,
|
||||
#ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_STRING_BUILTIN
|
||||
// ECMA-262 v5, 15.1.4.4
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_STRING_UL,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_STRING),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_STRING),
|
||||
ECMA_PROPERTY_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_CONFIGURABLE)
|
||||
@@ -109,7 +109,7 @@ OBJECT_VALUE (ECMA_MAGIC_STRING_STRING_UL,
|
||||
#ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_BOOLEAN_BUILTIN
|
||||
// ECMA-262 v5, 15.1.4.5
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_BOOLEAN_UL,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_BOOLEAN),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_BOOLEAN),
|
||||
ECMA_PROPERTY_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_CONFIGURABLE)
|
||||
@@ -118,7 +118,7 @@ OBJECT_VALUE (ECMA_MAGIC_STRING_BOOLEAN_UL,
|
||||
#ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_NUMBER_BUILTIN
|
||||
// ECMA-262 v5, 15.1.4.6
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_NUMBER_UL,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_NUMBER),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_NUMBER),
|
||||
ECMA_PROPERTY_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_CONFIGURABLE)
|
||||
@@ -126,14 +126,14 @@ OBJECT_VALUE (ECMA_MAGIC_STRING_NUMBER_UL,
|
||||
|
||||
// ECMA-262 v5, 15.1.4.7
|
||||
CP_UNIMPLEMENTED_VALUE (ECMA_MAGIC_STRING_DATE_UL,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_DATE),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_DATE),
|
||||
ECMA_PROPERTY_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_CONFIGURABLE)
|
||||
|
||||
// ECMA-262 v5, 15.1.4.8
|
||||
CP_UNIMPLEMENTED_VALUE (ECMA_MAGIC_STRING_REG_EXP_UL,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_REGEXP),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_REGEXP),
|
||||
ECMA_PROPERTY_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_CONFIGURABLE)
|
||||
@@ -141,49 +141,49 @@ CP_UNIMPLEMENTED_VALUE (ECMA_MAGIC_STRING_REG_EXP_UL,
|
||||
#ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_ERROR_BUILTINS
|
||||
// ECMA-262 v5, 15.1.4.9
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_ERROR_UL,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_ERROR),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_ERROR),
|
||||
ECMA_PROPERTY_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_CONFIGURABLE)
|
||||
|
||||
// ECMA-262 v5, 15.1.4.10
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_EVAL_ERROR_UL,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_EVAL_ERROR),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_EVAL_ERROR),
|
||||
ECMA_PROPERTY_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_CONFIGURABLE)
|
||||
|
||||
// ECMA-262 v5, 15.1.4.11
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_RANGE_ERROR_UL,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_RANGE_ERROR),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_RANGE_ERROR),
|
||||
ECMA_PROPERTY_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_CONFIGURABLE)
|
||||
|
||||
// ECMA-262 v5, 15.1.4.12
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_REFERENCE_ERROR_UL,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_REFERENCE_ERROR),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_REFERENCE_ERROR),
|
||||
ECMA_PROPERTY_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_CONFIGURABLE)
|
||||
|
||||
// ECMA-262 v5, 15.1.4.13
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_SYNTAX_ERROR_UL,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_SYNTAX_ERROR),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_SYNTAX_ERROR),
|
||||
ECMA_PROPERTY_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_CONFIGURABLE)
|
||||
|
||||
// ECMA-262 v5, 15.1.4.14
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_TYPE_ERROR_UL,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_TYPE_ERROR),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_TYPE_ERROR),
|
||||
ECMA_PROPERTY_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_CONFIGURABLE)
|
||||
|
||||
// ECMA-262 v5, 15.1.4.15
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_URI_ERROR_UL,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_URI_ERROR),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_URI_ERROR),
|
||||
ECMA_PROPERTY_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_CONFIGURABLE)
|
||||
@@ -192,7 +192,7 @@ OBJECT_VALUE (ECMA_MAGIC_STRING_URI_ERROR_UL,
|
||||
#ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_MATH_BUILTIN
|
||||
// ECMA-262 v5, 15.1.5.1
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_MATH_UL,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_MATH),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_MATH),
|
||||
ECMA_PROPERTY_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_CONFIGURABLE)
|
||||
@@ -200,14 +200,14 @@ OBJECT_VALUE (ECMA_MAGIC_STRING_MATH_UL,
|
||||
|
||||
// ECMA-262 v5, 15.1.5.2
|
||||
CP_UNIMPLEMENTED_VALUE (ECMA_MAGIC_STRING_JSON_U,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_JSON),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_JSON),
|
||||
ECMA_PROPERTY_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_CONFIGURABLE)
|
||||
|
||||
#ifdef CONFIG_ECMA_COMPACT_PROFILE
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_COMPACT_PROFILE_ERROR_UL,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_COMPACT_PROFILE_ERROR),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_COMPACT_PROFILE_ERROR),
|
||||
ECMA_PROPERTY_NOT_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_NOT_CONFIGURABLE)
|
||||
|
||||
@@ -40,8 +40,7 @@
|
||||
#define ROUTINE_ARG_LIST_NON_FIXED ROUTINE_ARG_LIST_0, \
|
||||
const ecma_value_t *arguments_list_p, ecma_length_t arguments_list_len
|
||||
#define ROUTINE(name, c_function_name, args_number, length_prop_value) \
|
||||
static void c_function_name (ecma_completion_value_t &ret_value, \
|
||||
ROUTINE_ARG_LIST_ ## args_number);
|
||||
static ecma_completion_value_t c_function_name (ROUTINE_ARG_LIST_ ## args_number);
|
||||
#include BUILTIN_INC_HEADER_NAME
|
||||
#undef ROUTINE_ARG_LIST_NON_FIXED
|
||||
#undef ROUTINE_ARG_LIST_3
|
||||
@@ -99,7 +98,7 @@ SORT_PROPERTY_NAMES_ROUTINE_NAME (BUILTIN_UNDERSCORED_ID) (void)
|
||||
* NULL - otherwise.
|
||||
*/
|
||||
ecma_property_t*
|
||||
TRY_TO_INSTANTIATE_PROPERTY_ROUTINE_NAME (BUILTIN_UNDERSCORED_ID) (const ecma_object_ptr_t& obj_p, /**< object */
|
||||
TRY_TO_INSTANTIATE_PROPERTY_ROUTINE_NAME (BUILTIN_UNDERSCORED_ID) (ecma_object_t *obj_p, /**< object */
|
||||
ecma_string_t *prop_name_p) /**< property's name */
|
||||
{
|
||||
#define OBJECT_ID(builtin_id) const ecma_builtin_id_t builtin_object_id = builtin_id;
|
||||
@@ -161,7 +160,7 @@ TRY_TO_INSTANTIATE_PROPERTY_ROUTINE_NAME (BUILTIN_UNDERSCORED_ID) (const ecma_ob
|
||||
|
||||
mask_prop_p->u.internal_property.value = bit_mask;
|
||||
|
||||
ecma_value_t value (ECMA_SIMPLE_VALUE_EMPTY);
|
||||
ecma_value_t value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
|
||||
ecma_property_writable_value_t writable;
|
||||
ecma_property_enumerable_value_t enumerable;
|
||||
ecma_property_configurable_value_t configurable;
|
||||
@@ -170,25 +169,21 @@ TRY_TO_INSTANTIATE_PROPERTY_ROUTINE_NAME (BUILTIN_UNDERSCORED_ID) (const ecma_ob
|
||||
{
|
||||
#define ROUTINE(name, c_function_name, args_number, length_prop_value) case name: \
|
||||
{ \
|
||||
ecma_object_ptr_t func_obj_p; \
|
||||
ecma_builtin_make_function_object_for_routine (func_obj_p, \
|
||||
builtin_object_id, \
|
||||
id, \
|
||||
length_prop_value); \
|
||||
ecma_object_t *func_obj_p = ecma_builtin_make_function_object_for_routine (builtin_object_id, \
|
||||
id, \
|
||||
length_prop_value); \
|
||||
\
|
||||
writable = ECMA_PROPERTY_WRITABLE; \
|
||||
enumerable = ECMA_PROPERTY_NOT_ENUMERABLE; \
|
||||
configurable = ECMA_PROPERTY_CONFIGURABLE; \
|
||||
\
|
||||
value = func_obj_p; \
|
||||
value = ecma_make_object_value (func_obj_p); \
|
||||
\
|
||||
break; \
|
||||
}
|
||||
#define OBJECT_VALUE(name, obj_getter, prop_writable, prop_enumerable, prop_configurable) case name: \
|
||||
{ \
|
||||
ecma_object_ptr_t object_out_p; \
|
||||
obj_getter; \
|
||||
value = object_out_p; \
|
||||
value = ecma_make_object_value (obj_getter); \
|
||||
writable = prop_writable; \
|
||||
enumerable = prop_enumerable; \
|
||||
configurable = prop_configurable; \
|
||||
@@ -196,7 +191,7 @@ TRY_TO_INSTANTIATE_PROPERTY_ROUTINE_NAME (BUILTIN_UNDERSCORED_ID) (const ecma_ob
|
||||
}
|
||||
#define SIMPLE_VALUE(name, simple_value, prop_writable, prop_enumerable, prop_configurable) case name: \
|
||||
{ \
|
||||
value = simple_value; \
|
||||
value = ecma_make_simple_value (simple_value); \
|
||||
\
|
||||
writable = prop_writable; \
|
||||
enumerable = prop_enumerable; \
|
||||
@@ -209,7 +204,7 @@ TRY_TO_INSTANTIATE_PROPERTY_ROUTINE_NAME (BUILTIN_UNDERSCORED_ID) (const ecma_ob
|
||||
ecma_number_t *num_p = ecma_alloc_number (); \
|
||||
*num_p = number_value; \
|
||||
\
|
||||
value = num_p; \
|
||||
value = ecma_make_number_value (num_p); \
|
||||
\
|
||||
writable = prop_writable; \
|
||||
enumerable = prop_enumerable; \
|
||||
@@ -221,7 +216,7 @@ TRY_TO_INSTANTIATE_PROPERTY_ROUTINE_NAME (BUILTIN_UNDERSCORED_ID) (const ecma_ob
|
||||
{ \
|
||||
ecma_string_t *magic_string_p = ecma_get_magic_string (magic_string_id); \
|
||||
\
|
||||
value = magic_string_p; \
|
||||
value = ecma_make_string_value (magic_string_p); \
|
||||
\
|
||||
writable = prop_writable; \
|
||||
enumerable = prop_enumerable; \
|
||||
@@ -233,8 +228,7 @@ TRY_TO_INSTANTIATE_PROPERTY_ROUTINE_NAME (BUILTIN_UNDERSCORED_ID) (const ecma_ob
|
||||
#define CP_UNIMPLEMENTED_VALUE(name, value, prop_writable, prop_enumerable, prop_configurable) case name: \
|
||||
{ \
|
||||
/* The object throws CompactProfileError upon invocation */ \
|
||||
ecma_object_ptr_t get_set_p; \
|
||||
ecma_builtin_get (get_set_p, ECMA_BUILTIN_ID_COMPACT_PROFILE_ERROR); \
|
||||
ecma_object_t *get_set_p = ecma_builtin_get (ECMA_BUILTIN_ID_COMPACT_PROFILE_ERROR); \
|
||||
ecma_property_t *compact_profile_thrower_property_p = ecma_create_named_accessor_property (obj_p, \
|
||||
prop_name_p, \
|
||||
get_set_p, \
|
||||
@@ -278,10 +272,8 @@ TRY_TO_INSTANTIATE_PROPERTY_ROUTINE_NAME (BUILTIN_UNDERSCORED_ID) (const ecma_ob
|
||||
* @return completion-value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
void
|
||||
DISPATCH_ROUTINE_ROUTINE_NAME (BUILTIN_UNDERSCORED_ID) (ecma_completion_value_t &ret_value, /**< out: completion
|
||||
* value */
|
||||
ecma_magic_string_id_t builtin_routine_id, /**< built-in's
|
||||
ecma_completion_value_t
|
||||
DISPATCH_ROUTINE_ROUTINE_NAME (BUILTIN_UNDERSCORED_ID) (ecma_magic_string_id_t builtin_routine_id, /**< built-in's
|
||||
routine's
|
||||
name */
|
||||
const ecma_value_t& this_arg_value, /**< 'this' argument
|
||||
@@ -296,13 +288,10 @@ DISPATCH_ROUTINE_ROUTINE_NAME (BUILTIN_UNDERSCORED_ID) (ecma_completion_value_t
|
||||
(void) arguments_list;
|
||||
(void) arguments_number;
|
||||
|
||||
ecma_make_empty_completion_value (ret_value);
|
||||
|
||||
ecma_value_t value_undefined (ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||
switch (builtin_routine_id)
|
||||
{
|
||||
#define ROUTINE_ARG(n) (arguments_number >= n ? arguments_list[n - 1] \
|
||||
: value_undefined)
|
||||
: ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED))
|
||||
#define ROUTINE_ARG_LIST_0
|
||||
#define ROUTINE_ARG_LIST_1 , ROUTINE_ARG(1)
|
||||
#define ROUTINE_ARG_LIST_2 ROUTINE_ARG_LIST_1, ROUTINE_ARG(2)
|
||||
@@ -311,8 +300,7 @@ DISPATCH_ROUTINE_ROUTINE_NAME (BUILTIN_UNDERSCORED_ID) (ecma_completion_value_t
|
||||
#define ROUTINE(name, c_function_name, args_number, length_prop_value) \
|
||||
case name: \
|
||||
{ \
|
||||
c_function_name (ret_value, this_arg_value ROUTINE_ARG_LIST_ ## args_number); \
|
||||
return; \
|
||||
return c_function_name (this_arg_value ROUTINE_ARG_LIST_ ## args_number); \
|
||||
}
|
||||
#include BUILTIN_INC_HEADER_NAME
|
||||
#undef ROUTINE_ARG_LIST_0
|
||||
|
||||
@@ -54,11 +54,12 @@
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_math_object_abs (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg __unused, /**< 'this' argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_math_object_abs (const ecma_value_t& this_arg __unused, /**< 'this' argument */
|
||||
const ecma_value_t& arg) /**< routine's argument */
|
||||
{
|
||||
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
|
||||
|
||||
ECMA_OP_TO_NUMBER_TRY_CATCH (arg_num, arg, ret_value);
|
||||
|
||||
ecma_number_t *num_p = ecma_alloc_number ();
|
||||
@@ -72,9 +73,11 @@ ecma_builtin_math_object_abs (ecma_completion_value_t &ret_value, /**< out: comp
|
||||
*num_p = ecma_number_abs (arg_num);
|
||||
}
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (num_p));
|
||||
ret_value = ecma_make_normal_completion_value (ecma_make_number_value (num_p));
|
||||
|
||||
ECMA_OP_TO_NUMBER_FINALIZE (arg_num);
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_builtin_math_object_abs */
|
||||
|
||||
/**
|
||||
@@ -86,12 +89,11 @@ ecma_builtin_math_object_abs (ecma_completion_value_t &ret_value, /**< out: comp
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_math_object_acos (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_math_object_acos (const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
const ecma_value_t& arg) /**< routine's argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arg);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg);
|
||||
} /* ecma_builtin_math_object_acos */
|
||||
|
||||
/**
|
||||
@@ -103,12 +105,11 @@ ecma_builtin_math_object_acos (ecma_completion_value_t &ret_value, /**< out: com
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_math_object_asin (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_math_object_asin (const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
const ecma_value_t& arg) /**< routine's argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arg);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg);
|
||||
} /* ecma_builtin_math_object_asin */
|
||||
|
||||
/**
|
||||
@@ -120,12 +121,11 @@ ecma_builtin_math_object_asin (ecma_completion_value_t &ret_value, /**< out: com
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_math_object_atan (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_math_object_atan (const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
const ecma_value_t& arg) /**< routine's argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arg);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg);
|
||||
} /* ecma_builtin_math_object_atan */
|
||||
|
||||
/**
|
||||
@@ -137,13 +137,12 @@ ecma_builtin_math_object_atan (ecma_completion_value_t &ret_value, /**< out: com
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_math_object_atan2 (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_math_object_atan2 (const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
const ecma_value_t& arg1, /**< first routine's argument */
|
||||
const ecma_value_t& arg2) /**< second routine's argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arg1, arg2);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg1, arg2);
|
||||
} /* ecma_builtin_math_object_atan2 */
|
||||
|
||||
/**
|
||||
@@ -155,12 +154,11 @@ ecma_builtin_math_object_atan2 (ecma_completion_value_t &ret_value, /**< out: co
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_math_object_ceil (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_math_object_ceil (const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
const ecma_value_t& arg) /**< routine's argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arg);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg);
|
||||
} /* ecma_builtin_math_object_ceil */
|
||||
|
||||
/**
|
||||
@@ -172,11 +170,12 @@ ecma_builtin_math_object_ceil (ecma_completion_value_t &ret_value, /**< out: com
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_math_object_cos (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg __unused, /**< 'this' argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_math_object_cos (const ecma_value_t& this_arg __unused, /**< 'this' argument */
|
||||
const ecma_value_t& arg) /**< routine's argument */
|
||||
{
|
||||
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
|
||||
|
||||
ECMA_OP_TO_NUMBER_TRY_CATCH (arg_num, arg, ret_value);
|
||||
|
||||
ecma_number_t *num_p = ecma_alloc_number ();
|
||||
@@ -223,9 +222,11 @@ ecma_builtin_math_object_cos (ecma_completion_value_t &ret_value, /**< out: comp
|
||||
*num_p = sum;
|
||||
}
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (num_p));
|
||||
ret_value = ecma_make_normal_completion_value (ecma_make_number_value (num_p));
|
||||
|
||||
ECMA_OP_TO_NUMBER_FINALIZE (arg_num);
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_builtin_math_object_cos */
|
||||
|
||||
/**
|
||||
@@ -237,11 +238,12 @@ ecma_builtin_math_object_cos (ecma_completion_value_t &ret_value, /**< out: comp
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_math_object_exp (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg __unused, /**< 'this' argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_math_object_exp (const ecma_value_t& this_arg __unused, /**< 'this' argument */
|
||||
const ecma_value_t& arg) /**< routine's argument */
|
||||
{
|
||||
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
|
||||
|
||||
ECMA_OP_TO_NUMBER_TRY_CATCH (arg_num, arg, ret_value);
|
||||
|
||||
ecma_number_t *num_p = ecma_alloc_number ();
|
||||
@@ -270,9 +272,11 @@ ecma_builtin_math_object_exp (ecma_completion_value_t &ret_value, /**< out: comp
|
||||
*num_p = ecma_number_exp (arg_num);
|
||||
}
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (num_p));
|
||||
ret_value = ecma_make_normal_completion_value (ecma_make_number_value (num_p));
|
||||
|
||||
ECMA_OP_TO_NUMBER_FINALIZE (arg_num);
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_builtin_math_object_exp */
|
||||
|
||||
/**
|
||||
@@ -284,12 +288,11 @@ ecma_builtin_math_object_exp (ecma_completion_value_t &ret_value, /**< out: comp
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_math_object_floor (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_math_object_floor (const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
const ecma_value_t& arg) /**< routine's argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arg);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg);
|
||||
} /* ecma_builtin_math_object_floor */
|
||||
|
||||
/**
|
||||
@@ -301,11 +304,12 @@ ecma_builtin_math_object_floor (ecma_completion_value_t &ret_value, /**< out: co
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_math_object_log (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg __unused, /**< 'this' argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_math_object_log (const ecma_value_t& this_arg __unused, /**< 'this' argument */
|
||||
const ecma_value_t& arg) /**< routine's argument */
|
||||
{
|
||||
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
|
||||
|
||||
ECMA_OP_TO_NUMBER_TRY_CATCH (arg_num, arg, ret_value);
|
||||
|
||||
ecma_number_t *num_p = ecma_alloc_number ();
|
||||
@@ -331,9 +335,11 @@ ecma_builtin_math_object_log (ecma_completion_value_t &ret_value, /**< out: comp
|
||||
*num_p = ecma_number_ln (arg_num);
|
||||
}
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (num_p));
|
||||
ret_value = ecma_make_normal_completion_value (ecma_make_number_value (num_p));
|
||||
|
||||
ECMA_OP_TO_NUMBER_FINALIZE (arg_num);
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_builtin_math_object_log */
|
||||
|
||||
/**
|
||||
@@ -345,12 +351,13 @@ ecma_builtin_math_object_log (ecma_completion_value_t &ret_value, /**< out: comp
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_math_object_max (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg __unused, /**< 'this' argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_math_object_max (const ecma_value_t& this_arg __unused, /**< 'this' argument */
|
||||
const ecma_value_t args[], /**< arguments list */
|
||||
ecma_length_t args_number) /**< number of arguments */
|
||||
{
|
||||
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
|
||||
|
||||
ecma_number_t ret_num = ecma_number_make_infinity (true);
|
||||
|
||||
bool is_just_convert = false;
|
||||
@@ -408,7 +415,7 @@ ecma_builtin_math_object_max (ecma_completion_value_t &ret_value, /**< out: comp
|
||||
|
||||
if (ecma_is_completion_value_throw (ret_value))
|
||||
{
|
||||
return;
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
JERRY_ASSERT (ecma_is_completion_value_empty (ret_value));
|
||||
@@ -419,7 +426,7 @@ ecma_builtin_math_object_max (ecma_completion_value_t &ret_value, /**< out: comp
|
||||
ecma_number_t *num_p = ecma_alloc_number ();
|
||||
*num_p = ret_num;
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (num_p));
|
||||
return ecma_make_normal_completion_value (ecma_make_number_value (num_p));
|
||||
} /* ecma_builtin_math_object_max */
|
||||
|
||||
/**
|
||||
@@ -431,12 +438,13 @@ ecma_builtin_math_object_max (ecma_completion_value_t &ret_value, /**< out: comp
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_math_object_min (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg __unused, /**< 'this' argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_math_object_min (const ecma_value_t& this_arg __unused, /**< 'this' argument */
|
||||
const ecma_value_t args[], /**< arguments list */
|
||||
ecma_length_t args_number) /**< number of arguments */
|
||||
{
|
||||
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
|
||||
|
||||
ecma_number_t ret_num = ecma_number_make_infinity (false);
|
||||
|
||||
bool is_just_convert = false;
|
||||
@@ -494,7 +502,7 @@ ecma_builtin_math_object_min (ecma_completion_value_t &ret_value, /**< out: comp
|
||||
|
||||
if (ecma_is_completion_value_throw (ret_value))
|
||||
{
|
||||
return;
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
JERRY_ASSERT (ecma_is_completion_value_empty (ret_value));
|
||||
@@ -505,7 +513,7 @@ ecma_builtin_math_object_min (ecma_completion_value_t &ret_value, /**< out: comp
|
||||
ecma_number_t *num_p = ecma_alloc_number ();
|
||||
*num_p = ret_num;
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (num_p));
|
||||
return ecma_make_normal_completion_value (ecma_make_number_value (num_p));
|
||||
} /* ecma_builtin_math_object_min */
|
||||
|
||||
/**
|
||||
@@ -517,12 +525,13 @@ ecma_builtin_math_object_min (ecma_completion_value_t &ret_value, /**< out: comp
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_math_object_pow (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg __unused, /**< 'this' argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_math_object_pow (const ecma_value_t& this_arg __unused, /**< 'this' argument */
|
||||
const ecma_value_t& arg1, /**< first routine's argument */
|
||||
const ecma_value_t& arg2) /**< second routine's argument */
|
||||
{
|
||||
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
|
||||
|
||||
ECMA_OP_TO_NUMBER_TRY_CATCH (x, arg1, ret_value);
|
||||
ECMA_OP_TO_NUMBER_TRY_CATCH (y, arg2, ret_value);
|
||||
|
||||
@@ -733,10 +742,12 @@ ecma_builtin_math_object_pow (ecma_completion_value_t &ret_value, /**< out: comp
|
||||
}
|
||||
}
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (num_p));
|
||||
ret_value = ecma_make_normal_completion_value (ecma_make_number_value (num_p));
|
||||
|
||||
ECMA_OP_TO_NUMBER_FINALIZE (y);
|
||||
ECMA_OP_TO_NUMBER_FINALIZE (x);
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_builtin_math_object_pow */
|
||||
|
||||
/**
|
||||
@@ -748,9 +759,8 @@ ecma_builtin_math_object_pow (ecma_completion_value_t &ret_value, /**< out: comp
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_math_object_random (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg __unused) /**< 'this' argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_math_object_random (const ecma_value_t& this_arg __unused) /**< 'this' argument */
|
||||
{
|
||||
/* Implementation of George Marsaglia's XorShift random number generator */
|
||||
TODO (/* Check for license issues */);
|
||||
@@ -778,7 +788,7 @@ ecma_builtin_math_object_random (ecma_completion_value_t &ret_value, /**< out: c
|
||||
ecma_number_t *rand_p = ecma_alloc_number ();
|
||||
*rand_p = rand;
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (rand_p));
|
||||
return ecma_make_normal_completion_value (ecma_make_number_value (rand_p));
|
||||
} /* ecma_builtin_math_object_random */
|
||||
|
||||
/**
|
||||
@@ -790,11 +800,12 @@ ecma_builtin_math_object_random (ecma_completion_value_t &ret_value, /**< out: c
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_math_object_round (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg __unused, /**< 'this' argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_math_object_round (const ecma_value_t& this_arg __unused, /**< 'this' argument */
|
||||
const ecma_value_t& arg) /**< routine's argument */
|
||||
{
|
||||
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
|
||||
|
||||
ECMA_OP_TO_NUMBER_TRY_CATCH (arg_num, arg, ret_value);
|
||||
|
||||
ecma_number_t *num_p = ecma_alloc_number ();
|
||||
@@ -827,9 +838,11 @@ ecma_builtin_math_object_round (ecma_completion_value_t &ret_value, /**< out: co
|
||||
}
|
||||
}
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (num_p));
|
||||
ret_value = ecma_make_normal_completion_value (ecma_make_number_value (num_p));
|
||||
|
||||
ECMA_OP_TO_NUMBER_FINALIZE (arg_num);
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_builtin_math_object_round */
|
||||
|
||||
/**
|
||||
@@ -841,11 +854,12 @@ ecma_builtin_math_object_round (ecma_completion_value_t &ret_value, /**< out: co
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_math_object_sin (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg __unused, /**< 'this' argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_math_object_sin (const ecma_value_t& this_arg __unused, /**< 'this' argument */
|
||||
const ecma_value_t& arg) /**< routine's argument */
|
||||
{
|
||||
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
|
||||
|
||||
ECMA_OP_TO_NUMBER_TRY_CATCH (arg_num, arg, ret_value);
|
||||
|
||||
ecma_number_t *num_p = ecma_alloc_number ();
|
||||
@@ -892,9 +906,11 @@ ecma_builtin_math_object_sin (ecma_completion_value_t &ret_value, /**< out: comp
|
||||
*num_p = sum;
|
||||
}
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (num_p));
|
||||
ret_value = ecma_make_normal_completion_value (ecma_make_number_value (num_p));
|
||||
|
||||
ECMA_OP_TO_NUMBER_FINALIZE (arg_num);
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_builtin_math_object_sin */
|
||||
|
||||
/**
|
||||
@@ -906,11 +922,12 @@ ecma_builtin_math_object_sin (ecma_completion_value_t &ret_value, /**< out: comp
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_math_object_sqrt (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg __unused, /**< 'this' argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_math_object_sqrt (const ecma_value_t& this_arg __unused, /**< 'this' argument */
|
||||
const ecma_value_t& arg) /**< routine's argument */
|
||||
{
|
||||
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
|
||||
|
||||
ECMA_OP_TO_NUMBER_TRY_CATCH (arg_num, arg, ret_value);
|
||||
|
||||
ecma_number_t ret_num;
|
||||
@@ -939,9 +956,11 @@ ecma_builtin_math_object_sqrt (ecma_completion_value_t &ret_value, /**< out: com
|
||||
ecma_number_t *num_p = ecma_alloc_number ();
|
||||
*num_p = ret_num;
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (num_p));
|
||||
ret_value = ecma_make_normal_completion_value (ecma_make_number_value (num_p));
|
||||
|
||||
ECMA_OP_TO_NUMBER_FINALIZE (arg_num);
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_builtin_math_object_sqrt */
|
||||
|
||||
/**
|
||||
@@ -953,12 +972,11 @@ ecma_builtin_math_object_sqrt (ecma_completion_value_t &ret_value, /**< out: com
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_math_object_tan (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_math_object_tan (const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
const ecma_value_t& arg) /**< routine's argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arg);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg);
|
||||
} /* ecma_builtin_math_object_tan */
|
||||
|
||||
/**
|
||||
|
||||
@@ -53,9 +53,8 @@
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_number_prototype_object_to_string (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_number_prototype_object_to_string (const ecma_value_t& this_arg, /**< this argument */
|
||||
const ecma_value_t* arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
@@ -69,8 +68,7 @@ ecma_builtin_number_prototype_object_to_string (ecma_completion_value_t &ret_val
|
||||
}
|
||||
else if (ecma_is_value_object (this_arg))
|
||||
{
|
||||
ecma_object_ptr_t obj_p;
|
||||
ecma_get_object_from_value (obj_p, this_arg);
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (this_arg);
|
||||
|
||||
ecma_property_t *class_prop_p = ecma_get_internal_property (obj_p, ECMA_INTERNAL_PROPERTY_CLASS);
|
||||
|
||||
@@ -85,29 +83,22 @@ ecma_builtin_number_prototype_object_to_string (ecma_completion_value_t &ret_val
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_object_ptr_t exception_obj_p;
|
||||
ecma_new_standard_error (exception_obj_p, ECMA_ERROR_TYPE);
|
||||
ecma_make_throw_obj_completion_value (ret_value, exception_obj_p);
|
||||
return;
|
||||
return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_object_ptr_t exception_obj_p;
|
||||
ecma_new_standard_error (exception_obj_p, ECMA_ERROR_TYPE);
|
||||
ecma_make_throw_obj_completion_value (ret_value, exception_obj_p);
|
||||
return;
|
||||
return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||
}
|
||||
|
||||
if (arguments_list_len == 0)
|
||||
{
|
||||
ecma_string_t *ret_str_p = ecma_new_ecma_string_from_number (this_arg_number);
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (ret_str_p));
|
||||
return ecma_make_normal_completion_value (ecma_make_string_value (ret_str_p));
|
||||
}
|
||||
else
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, arguments_list_p);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (arguments_list_p);
|
||||
}
|
||||
} /* ecma_builtin_number_prototype_object_to_string */
|
||||
|
||||
@@ -120,11 +111,10 @@ ecma_builtin_number_prototype_object_to_string (ecma_completion_value_t &ret_val
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_number_prototype_object_to_locale_string (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg) /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_number_prototype_object_to_locale_string (const ecma_value_t& this_arg) /**< this argument */
|
||||
{
|
||||
ecma_builtin_number_prototype_object_to_string (ret_value, this_arg, NULL, 0);
|
||||
return ecma_builtin_number_prototype_object_to_string (this_arg, NULL, 0);
|
||||
} /* ecma_builtin_number_prototype_object_to_locale_string */
|
||||
|
||||
/**
|
||||
@@ -136,22 +126,16 @@ ecma_builtin_number_prototype_object_to_locale_string (ecma_completion_value_t &
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_number_prototype_object_value_of (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg) /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_number_prototype_object_value_of (const ecma_value_t& this_arg) /**< this argument */
|
||||
{
|
||||
if (ecma_is_value_number (this_arg))
|
||||
{
|
||||
ecma_value_t this_arg_copy;
|
||||
ecma_copy_value (this_arg_copy, this_arg, true);
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, this_arg_copy);
|
||||
return;
|
||||
return ecma_make_normal_completion_value (ecma_copy_value (this_arg, true));
|
||||
}
|
||||
else if (ecma_is_value_object (this_arg))
|
||||
{
|
||||
ecma_object_ptr_t obj_p;
|
||||
ecma_get_object_from_value (obj_p, this_arg);
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (this_arg);
|
||||
|
||||
ecma_property_t *class_prop_p = ecma_get_internal_property (obj_p, ECMA_INTERNAL_PROPERTY_CLASS);
|
||||
|
||||
@@ -166,14 +150,11 @@ ecma_builtin_number_prototype_object_value_of (ecma_completion_value_t &ret_valu
|
||||
ecma_number_t *ret_num_p = ecma_alloc_number ();
|
||||
*ret_num_p = *prim_value_num_p;
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (ret_num_p));
|
||||
return;
|
||||
return ecma_make_normal_completion_value (ecma_make_number_value (ret_num_p));
|
||||
}
|
||||
}
|
||||
|
||||
ecma_object_ptr_t exception_obj_p;
|
||||
ecma_new_standard_error (exception_obj_p, ECMA_ERROR_TYPE);
|
||||
ecma_make_throw_obj_completion_value (ret_value, exception_obj_p);
|
||||
return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||
} /* ecma_builtin_number_prototype_object_value_of */
|
||||
|
||||
/**
|
||||
@@ -185,12 +166,11 @@ ecma_builtin_number_prototype_object_value_of (ecma_completion_value_t &ret_valu
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_number_prototype_object_to_fixed (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_number_prototype_object_to_fixed (const ecma_value_t& this_arg, /**< this argument */
|
||||
const ecma_value_t& arg) /**< routine's argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arg);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg);
|
||||
} /* ecma_builtin_number_prototype_object_to_fixed */
|
||||
|
||||
/**
|
||||
@@ -202,12 +182,11 @@ ecma_builtin_number_prototype_object_to_fixed (ecma_completion_value_t &ret_valu
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_number_prototype_object_to_exponential (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_number_prototype_object_to_exponential (const ecma_value_t& this_arg, /**< this argument */
|
||||
const ecma_value_t& arg) /**< routine's argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arg);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg);
|
||||
} /* ecma_builtin_number_prototype_object_to_exponential */
|
||||
|
||||
/**
|
||||
@@ -219,12 +198,11 @@ ecma_builtin_number_prototype_object_to_exponential (ecma_completion_value_t &re
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_number_prototype_object_to_precision (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_number_prototype_object_to_precision (const ecma_value_t& this_arg, /**< this argument */
|
||||
const ecma_value_t& arg) /**< routine's argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arg);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg);
|
||||
} /* ecma_builtin_number_prototype_object_to_precision */
|
||||
|
||||
/**
|
||||
|
||||
@@ -37,7 +37,7 @@ OBJECT_ID (ECMA_BUILTIN_ID_NUMBER_PROTOTYPE)
|
||||
|
||||
// 15.7.4.1
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_CONSTRUCTOR,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_NUMBER),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_NUMBER),
|
||||
ECMA_PROPERTY_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_CONFIGURABLE)
|
||||
|
||||
@@ -49,24 +49,27 @@
|
||||
*
|
||||
* @return completion-value
|
||||
*/
|
||||
void
|
||||
ecma_builtin_number_dispatch_call (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_completion_value_t
|
||||
ecma_builtin_number_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
if (arguments_list_len == 0)
|
||||
{
|
||||
ecma_number_t *zero_num_p = ecma_alloc_number ();
|
||||
*zero_num_p = ECMA_NUMBER_ZERO;
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (zero_num_p));
|
||||
ret_value = ecma_make_normal_completion_value (ecma_make_number_value (zero_num_p));
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_op_to_number (ret_value, arguments_list_p [0]);
|
||||
ret_value = ecma_op_to_number (arguments_list_p [0]);
|
||||
}
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_builtin_number_dispatch_call */
|
||||
|
||||
/**
|
||||
@@ -74,9 +77,8 @@ ecma_builtin_number_dispatch_call (ecma_completion_value_t &ret_value, /**< out:
|
||||
*
|
||||
* @return completion-value
|
||||
*/
|
||||
void
|
||||
ecma_builtin_number_dispatch_construct (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_completion_value_t
|
||||
ecma_builtin_number_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
@@ -86,13 +88,15 @@ ecma_builtin_number_dispatch_construct (ecma_completion_value_t &ret_value, /**<
|
||||
ecma_number_t *zero_num_p = ecma_alloc_number ();
|
||||
*zero_num_p = ECMA_NUMBER_ZERO;
|
||||
|
||||
ecma_op_create_number_object (ret_value, ecma_value_t (zero_num_p));
|
||||
ecma_completion_value_t completion = ecma_op_create_number_object (ecma_make_number_value (zero_num_p));
|
||||
|
||||
ecma_dealloc_number (zero_num_p);
|
||||
|
||||
return completion;
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_op_create_number_object (ret_value, arguments_list_p[0]);
|
||||
return ecma_op_create_number_object (arguments_list_p[0]);
|
||||
}
|
||||
} /* ecma_builtin_number_dispatch_construct */
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ NUMBER_VALUE (ECMA_MAGIC_STRING_NEGATIVE_INFINITY_U,
|
||||
|
||||
// 15.7.3.1
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_PROTOTYPE,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_NUMBER_PROTOTYPE),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_NUMBER_PROTOTYPE),
|
||||
ECMA_PROPERTY_NOT_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_NOT_CONFIGURABLE)
|
||||
|
||||
@@ -51,9 +51,8 @@
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_object_prototype_object_to_string (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg) /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_object_prototype_object_to_string (const ecma_value_t& this_arg) /**< this argument */
|
||||
{
|
||||
ecma_magic_string_id_t type_string;
|
||||
|
||||
@@ -67,25 +66,22 @@ ecma_builtin_object_prototype_object_to_string (ecma_completion_value_t &ret_val
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_completion_value_t this_to_obj_completion;
|
||||
ecma_op_to_object (this_to_obj_completion, this_arg);
|
||||
ecma_completion_value_t obj_this = ecma_op_to_object (this_arg);
|
||||
|
||||
if (!ecma_is_completion_value_normal (this_to_obj_completion))
|
||||
if (!ecma_is_completion_value_normal (obj_this))
|
||||
{
|
||||
ret_value = this_to_obj_completion;
|
||||
return;
|
||||
return obj_this;
|
||||
}
|
||||
|
||||
ecma_value_t obj_this_value;
|
||||
ecma_get_completion_value_value (obj_this_value, this_to_obj_completion);
|
||||
JERRY_ASSERT (ecma_is_value_object (ecma_get_completion_value_value (obj_this)));
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_object (obj_this_value));
|
||||
ecma_object_ptr_t obj_this_p;
|
||||
ecma_get_object_from_value (obj_this_p, obj_this_value);
|
||||
ecma_property_t *class_prop_p = ecma_get_internal_property (obj_this_p, ECMA_INTERNAL_PROPERTY_CLASS);
|
||||
ecma_object_t *obj_p = ecma_get_object_from_completion_value (obj_this);
|
||||
|
||||
ecma_property_t *class_prop_p = ecma_get_internal_property (obj_p,
|
||||
ECMA_INTERNAL_PROPERTY_CLASS);
|
||||
type_string = (ecma_magic_string_id_t) class_prop_p->u.internal_property.value;
|
||||
|
||||
ecma_free_completion_value (this_to_obj_completion);
|
||||
ecma_free_completion_value (obj_this);
|
||||
}
|
||||
|
||||
ecma_string_t *ret_string_p;
|
||||
@@ -131,7 +127,7 @@ ecma_builtin_object_prototype_object_to_string (ecma_completion_value_t &ret_val
|
||||
|
||||
MEM_FINALIZE_LOCAL_ARRAY (str_buffer);
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (ret_string_p));
|
||||
return ecma_make_normal_completion_value (ecma_make_string_value (ret_string_p));
|
||||
} /* ecma_builtin_object_prototype_object_to_string */
|
||||
|
||||
/**
|
||||
@@ -143,11 +139,10 @@ ecma_builtin_object_prototype_object_to_string (ecma_completion_value_t &ret_val
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_object_prototype_object_value_of (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg) /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_object_prototype_object_value_of (const ecma_value_t& this_arg) /**< this argument */
|
||||
{
|
||||
ecma_op_to_object (ret_value, this_arg);
|
||||
return ecma_op_to_object (this_arg);
|
||||
} /* ecma_builtin_object_prototype_object_value_of */
|
||||
|
||||
/**
|
||||
@@ -159,11 +154,10 @@ ecma_builtin_object_prototype_object_value_of (ecma_completion_value_t &ret_valu
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_object_prototype_object_to_locale_string (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg) /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_object_prototype_object_to_locale_string (const ecma_value_t& this_arg) /**< this argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg);
|
||||
} /* ecma_builtin_object_prototype_object_to_locale_string */
|
||||
|
||||
/**
|
||||
@@ -175,12 +169,11 @@ ecma_builtin_object_prototype_object_to_locale_string (ecma_completion_value_t &
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_object_prototype_object_has_own_property (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_object_prototype_object_has_own_property (const ecma_value_t& this_arg, /**< this argument */
|
||||
const ecma_value_t& arg) /**< first argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arg);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg);
|
||||
} /* ecma_builtin_object_prototype_object_has_own_property */
|
||||
|
||||
/**
|
||||
@@ -192,12 +185,11 @@ ecma_builtin_object_prototype_object_has_own_property (ecma_completion_value_t &
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_object_prototype_object_is_prototype_of (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_object_prototype_object_is_prototype_of (const ecma_value_t& this_arg, /**< this argument */
|
||||
const ecma_value_t& arg) /**< routine's first argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arg);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg);
|
||||
} /* ecma_builtin_object_prototype_object_is_prototype_of */
|
||||
|
||||
/**
|
||||
@@ -209,13 +201,11 @@ ecma_builtin_object_prototype_object_is_prototype_of (ecma_completion_value_t &r
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_object_prototype_object_property_is_enumerable (ecma_completion_value_t &ret_value, /**< out: completion
|
||||
* value */
|
||||
const ecma_value_t& this_arg, /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_object_prototype_object_property_is_enumerable (const ecma_value_t& this_arg, /**< this argument */
|
||||
const ecma_value_t& arg) /**< routine's first argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arg);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg);
|
||||
} /* ecma_builtin_object_prototype_object_property_is_enumerable */
|
||||
|
||||
/**
|
||||
|
||||
@@ -37,7 +37,7 @@ OBJECT_ID (ECMA_BUILTIN_ID_OBJECT_PROTOTYPE)
|
||||
|
||||
// 15.2.4.1
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_CONSTRUCTOR,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_OBJECT),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_OBJECT),
|
||||
ECMA_PROPERTY_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_CONFIGURABLE)
|
||||
|
||||
@@ -47,23 +47,26 @@
|
||||
*
|
||||
* @return completion-value
|
||||
*/
|
||||
void
|
||||
ecma_builtin_object_dispatch_call (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_completion_value_t
|
||||
ecma_builtin_object_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
if (arguments_list_len == 0
|
||||
|| ecma_is_value_undefined (arguments_list_p[0])
|
||||
|| ecma_is_value_null (arguments_list_p [0]))
|
||||
{
|
||||
ecma_builtin_object_dispatch_construct (ret_value, arguments_list_p, arguments_list_len);
|
||||
ret_value = ecma_builtin_object_dispatch_construct (arguments_list_p, arguments_list_len);
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_op_to_object (ret_value, arguments_list_p [0]);
|
||||
ret_value = ecma_op_to_object (arguments_list_p [0]);
|
||||
}
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_builtin_object_dispatch_call */
|
||||
|
||||
/**
|
||||
@@ -71,35 +74,29 @@ ecma_builtin_object_dispatch_call (ecma_completion_value_t &ret_value, /**< out:
|
||||
*
|
||||
* @return completion-value
|
||||
*/
|
||||
void
|
||||
ecma_builtin_object_dispatch_construct (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_completion_value_t
|
||||
ecma_builtin_object_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
if (arguments_list_len == 0)
|
||||
{
|
||||
ecma_object_ptr_t obj_p;
|
||||
ecma_op_create_object_object_noarg (obj_p);
|
||||
ecma_object_t *obj_p = ecma_op_create_object_object_noarg ();
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (obj_p));
|
||||
return ecma_make_normal_completion_value (ecma_make_object_value (obj_p));
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_completion_value_t new_obj_completion;
|
||||
ecma_op_create_object_object_arg (new_obj_completion, arguments_list_p [0]);
|
||||
ecma_completion_value_t new_obj_value = ecma_op_create_object_object_arg (arguments_list_p [0]);
|
||||
|
||||
if (!ecma_is_completion_value_normal (new_obj_completion))
|
||||
if (!ecma_is_completion_value_normal (new_obj_value))
|
||||
{
|
||||
ret_value = new_obj_completion;
|
||||
return new_obj_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_value_t new_obj_value;
|
||||
ecma_get_completion_value_value (new_obj_value, new_obj_completion);
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, new_obj_value);
|
||||
return ecma_make_normal_completion_value (ecma_get_completion_value_value (new_obj_value));
|
||||
}
|
||||
}
|
||||
} /* ecma_builtin_object_dispatch_construct */
|
||||
@@ -113,12 +110,11 @@ ecma_builtin_object_dispatch_construct (ecma_completion_value_t &ret_value, /**<
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_object_object_get_prototype_of (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_object_object_get_prototype_of (const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
const ecma_value_t& arg) /**< routine's argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arg);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg);
|
||||
} /* ecma_builtin_object_object_get_prototype_of */
|
||||
|
||||
/**
|
||||
@@ -130,12 +126,11 @@ ecma_builtin_object_object_get_prototype_of (ecma_completion_value_t &ret_value,
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_object_object_get_own_property_names (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_object_object_get_own_property_names (const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
const ecma_value_t& arg) /**< routine's argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arg);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg);
|
||||
} /* ecma_builtin_object_object_get_own_property_names */
|
||||
|
||||
/**
|
||||
@@ -147,12 +142,11 @@ ecma_builtin_object_object_get_own_property_names (ecma_completion_value_t &ret_
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_object_object_seal (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_object_object_seal (const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
const ecma_value_t& arg) /**< routine's argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arg);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg);
|
||||
} /* ecma_builtin_object_object_seal */
|
||||
|
||||
/**
|
||||
@@ -164,12 +158,11 @@ ecma_builtin_object_object_seal (ecma_completion_value_t &ret_value, /**< out: c
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_object_object_freeze (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_object_object_freeze (const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
const ecma_value_t& arg) /**< routine's argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arg);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg);
|
||||
} /* ecma_builtin_object_object_freeze */
|
||||
|
||||
/**
|
||||
@@ -181,12 +174,11 @@ ecma_builtin_object_object_freeze (ecma_completion_value_t &ret_value, /**< out:
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_object_object_prevent_extensions (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_object_object_prevent_extensions (const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
const ecma_value_t& arg) /**< routine's argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arg);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg);
|
||||
} /* ecma_builtin_object_object_prevent_extensions */
|
||||
|
||||
/**
|
||||
@@ -198,12 +190,11 @@ ecma_builtin_object_object_prevent_extensions (ecma_completion_value_t &ret_valu
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_object_object_is_sealed (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_object_object_is_sealed (const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
const ecma_value_t& arg) /**< routine's argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arg);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg);
|
||||
} /* ecma_builtin_object_object_is_sealed */
|
||||
|
||||
/**
|
||||
@@ -215,12 +206,11 @@ ecma_builtin_object_object_is_sealed (ecma_completion_value_t &ret_value, /**< o
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_object_object_is_frozen (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_object_object_is_frozen (const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
const ecma_value_t& arg) /**< routine's argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arg);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg);
|
||||
} /* ecma_builtin_object_object_is_frozen */
|
||||
|
||||
/**
|
||||
@@ -232,12 +222,11 @@ ecma_builtin_object_object_is_frozen (ecma_completion_value_t &ret_value, /**< o
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_object_object_is_extensible (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_object_object_is_extensible (const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
const ecma_value_t& arg) /**< routine's argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arg);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg);
|
||||
} /* ecma_builtin_object_object_is_extensible */
|
||||
|
||||
/**
|
||||
@@ -249,12 +238,11 @@ ecma_builtin_object_object_is_extensible (ecma_completion_value_t &ret_value, /*
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_object_object_keys (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_object_object_keys (const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
const ecma_value_t& arg) /**< routine's argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arg);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg);
|
||||
} /* ecma_builtin_object_object_keys */
|
||||
|
||||
/**
|
||||
@@ -266,14 +254,12 @@ ecma_builtin_object_object_keys (ecma_completion_value_t &ret_value, /**< out: c
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_object_object_get_own_property_descriptor (ecma_completion_value_t &ret_value, /**< out: completion
|
||||
* value */
|
||||
const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_object_object_get_own_property_descriptor (const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
const ecma_value_t& arg1, /**< routine's first argument */
|
||||
const ecma_value_t& arg2) /**< routine's second argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arg1, arg2);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg1, arg2);
|
||||
} /* ecma_builtin_object_object_get_own_property_descriptor */
|
||||
|
||||
/**
|
||||
@@ -285,13 +271,12 @@ ecma_builtin_object_object_get_own_property_descriptor (ecma_completion_value_t
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_object_object_create (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_object_object_create (const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
const ecma_value_t& arg1, /**< routine's first argument */
|
||||
const ecma_value_t& arg2) /**< routine's second argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arg1, arg2);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg1, arg2);
|
||||
} /* ecma_builtin_object_object_create */
|
||||
|
||||
/**
|
||||
@@ -303,13 +288,12 @@ ecma_builtin_object_object_create (ecma_completion_value_t &ret_value, /**< out:
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_object_object_define_properties (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_object_object_define_properties (const ecma_value_t& this_arg, /**< 'this' argument */
|
||||
const ecma_value_t& arg1, /**< routine's first argument */
|
||||
const ecma_value_t& arg2) /**< routine's second argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arg1, arg2);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg1, arg2);
|
||||
} /* ecma_builtin_object_object_define_properties */
|
||||
|
||||
/**
|
||||
@@ -321,45 +305,50 @@ ecma_builtin_object_object_define_properties (ecma_completion_value_t &ret_value
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_object_object_define_property (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg __unused, /**< 'this' argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_object_object_define_property (const ecma_value_t& this_arg __unused, /**< 'this' argument */
|
||||
const ecma_value_t& arg1, /**< routine's first argument */
|
||||
const ecma_value_t& arg2, /**< routine's second argument */
|
||||
const ecma_value_t& arg3) /**< routine's third argument */
|
||||
{
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
if (!ecma_is_value_object (arg1))
|
||||
{
|
||||
ecma_object_ptr_t exception_obj_p;
|
||||
ecma_new_standard_error (exception_obj_p, ECMA_ERROR_TYPE);
|
||||
ecma_make_throw_obj_completion_value (ret_value, exception_obj_p);
|
||||
ret_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_object_ptr_t obj_p;
|
||||
ecma_get_object_from_value (obj_p, arg1);
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (arg1);
|
||||
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_to_string, name_str_value, arg2);
|
||||
ECMA_TRY_CATCH (name_str_value,
|
||||
ecma_op_to_string (arg2),
|
||||
ret_value);
|
||||
|
||||
ecma_string_t *name_str_p = ecma_get_string_from_value (name_str_value);
|
||||
|
||||
ecma_property_descriptor_t prop_desc;
|
||||
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_to_property_descriptor, conv_result, arg3, &prop_desc);
|
||||
ECMA_TRY_CATCH (conv_result,
|
||||
ecma_op_to_property_descriptor (arg3, &prop_desc),
|
||||
ret_value);
|
||||
|
||||
ECMA_TRY_CATCH (ret_value,
|
||||
ecma_op_object_define_own_property, define_own_prop_ret, obj_p, name_str_p, &prop_desc, true);
|
||||
ECMA_TRY_CATCH (define_own_prop_ret,
|
||||
ecma_op_object_define_own_property (obj_p,
|
||||
name_str_p,
|
||||
&prop_desc,
|
||||
true),
|
||||
ret_value);
|
||||
|
||||
ecma_value_t arg1_copy;
|
||||
ecma_copy_value (arg1_copy, arg1, true);
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, arg1_copy);
|
||||
ret_value = ecma_make_normal_completion_value (ecma_copy_value (arg1, true));
|
||||
|
||||
ECMA_FINALIZE (define_own_prop_ret);
|
||||
ecma_free_property_descriptor (&prop_desc);
|
||||
ECMA_FINALIZE (conv_result);
|
||||
ECMA_FINALIZE (name_str_value);
|
||||
}
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_builtin_object_object_define_property */
|
||||
|
||||
/**
|
||||
|
||||
@@ -51,7 +51,7 @@ NUMBER_VALUE (ECMA_MAGIC_STRING_LENGTH,
|
||||
|
||||
// 15.2.3.1
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_PROTOTYPE,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_OBJECT_PROTOTYPE),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_OBJECT_PROTOTYPE),
|
||||
ECMA_PROPERTY_NOT_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_NOT_CONFIGURABLE)
|
||||
|
||||
@@ -37,7 +37,7 @@ OBJECT_ID (ECMA_BUILTIN_ID_RANGE_ERROR_PROTOTYPE)
|
||||
|
||||
// 15.11.7.8
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_CONSTRUCTOR,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_RANGE_ERROR),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_RANGE_ERROR),
|
||||
ECMA_PROPERTY_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_CONFIGURABLE)
|
||||
|
||||
@@ -48,9 +48,8 @@
|
||||
*
|
||||
* @return completion-value
|
||||
*/
|
||||
void
|
||||
ecma_builtin_range_error_dispatch_call (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_completion_value_t
|
||||
ecma_builtin_range_error_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
@@ -58,21 +57,26 @@ ecma_builtin_range_error_dispatch_call (ecma_completion_value_t &ret_value, /**<
|
||||
if (arguments_list_len != 0
|
||||
&& !ecma_is_value_undefined (arguments_list_p [0]))
|
||||
{
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_to_string, msg_str_value, arguments_list_p[0]);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
ECMA_TRY_CATCH (msg_str_value,
|
||||
ecma_op_to_string (arguments_list_p[0]),
|
||||
ret_value);
|
||||
|
||||
ecma_string_t *message_string_p = ecma_get_string_from_value (msg_str_value);
|
||||
ecma_object_ptr_t new_error_object_p;
|
||||
ecma_new_standard_error_with_message (new_error_object_p, ECMA_ERROR_RANGE, message_string_p);
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (new_error_object_p));
|
||||
ecma_object_t *new_error_object_p = ecma_new_standard_error_with_message (ECMA_ERROR_RANGE,
|
||||
message_string_p);
|
||||
ret_value = ecma_make_normal_completion_value (ecma_make_object_value (new_error_object_p));
|
||||
|
||||
ECMA_FINALIZE (msg_str_value);
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_object_ptr_t new_error_object_p;
|
||||
ecma_new_standard_error (new_error_object_p, ECMA_ERROR_RANGE);
|
||||
ecma_object_t *new_error_object_p = ecma_new_standard_error (ECMA_ERROR_RANGE);
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (new_error_object_p));
|
||||
return ecma_make_normal_completion_value (ecma_make_object_value (new_error_object_p));
|
||||
}
|
||||
} /* ecma_builtin_range_error_dispatch_call */
|
||||
|
||||
@@ -81,12 +85,11 @@ ecma_builtin_range_error_dispatch_call (ecma_completion_value_t &ret_value, /**<
|
||||
*
|
||||
* @return completion-value
|
||||
*/
|
||||
void
|
||||
ecma_builtin_range_error_dispatch_construct (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_completion_value_t
|
||||
ecma_builtin_range_error_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
ecma_builtin_range_error_dispatch_call (ret_value, arguments_list_p, arguments_list_len);
|
||||
return ecma_builtin_range_error_dispatch_call (arguments_list_p, arguments_list_len);
|
||||
} /* ecma_builtin_range_error_dispatch_construct */
|
||||
|
||||
/**
|
||||
|
||||
@@ -51,7 +51,7 @@ NUMBER_VALUE (ECMA_MAGIC_STRING_LENGTH,
|
||||
|
||||
// 15.11.3.1
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_PROTOTYPE,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_RANGE_ERROR_PROTOTYPE),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_RANGE_ERROR_PROTOTYPE),
|
||||
ECMA_PROPERTY_NOT_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_NOT_CONFIGURABLE)
|
||||
|
||||
@@ -37,7 +37,7 @@ OBJECT_ID (ECMA_BUILTIN_ID_REFERENCE_ERROR_PROTOTYPE)
|
||||
|
||||
// 15.11.7.8
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_CONSTRUCTOR,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_REFERENCE_ERROR),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_REFERENCE_ERROR),
|
||||
ECMA_PROPERTY_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_CONFIGURABLE)
|
||||
|
||||
@@ -48,9 +48,8 @@
|
||||
*
|
||||
* @return completion-value
|
||||
*/
|
||||
void
|
||||
ecma_builtin_reference_error_dispatch_call (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_completion_value_t
|
||||
ecma_builtin_reference_error_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
@@ -58,21 +57,26 @@ ecma_builtin_reference_error_dispatch_call (ecma_completion_value_t &ret_value,
|
||||
if (arguments_list_len != 0
|
||||
&& !ecma_is_value_undefined (arguments_list_p [0]))
|
||||
{
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_to_string, msg_str_value, arguments_list_p[0]);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
ECMA_TRY_CATCH (msg_str_value,
|
||||
ecma_op_to_string (arguments_list_p[0]),
|
||||
ret_value);
|
||||
|
||||
ecma_string_t *message_string_p = ecma_get_string_from_value (msg_str_value);
|
||||
ecma_object_ptr_t new_error_object_p;
|
||||
ecma_new_standard_error_with_message (new_error_object_p, ECMA_ERROR_REFERENCE, message_string_p);
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (new_error_object_p));
|
||||
ecma_object_t *new_error_object_p = ecma_new_standard_error_with_message (ECMA_ERROR_REFERENCE,
|
||||
message_string_p);
|
||||
ret_value = ecma_make_normal_completion_value (ecma_make_object_value (new_error_object_p));
|
||||
|
||||
ECMA_FINALIZE (msg_str_value);
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_object_ptr_t new_error_object_p;
|
||||
ecma_new_standard_error (new_error_object_p, ECMA_ERROR_REFERENCE);
|
||||
ecma_object_t *new_error_object_p = ecma_new_standard_error (ECMA_ERROR_REFERENCE);
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (new_error_object_p));
|
||||
return ecma_make_normal_completion_value (ecma_make_object_value (new_error_object_p));
|
||||
}
|
||||
} /* ecma_builtin_reference_error_dispatch_call */
|
||||
|
||||
@@ -81,12 +85,11 @@ ecma_builtin_reference_error_dispatch_call (ecma_completion_value_t &ret_value,
|
||||
*
|
||||
* @return completion-value
|
||||
*/
|
||||
void
|
||||
ecma_builtin_reference_error_dispatch_construct (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_completion_value_t
|
||||
ecma_builtin_reference_error_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
ecma_builtin_reference_error_dispatch_call (ret_value, arguments_list_p, arguments_list_len);
|
||||
return ecma_builtin_reference_error_dispatch_call (arguments_list_p, arguments_list_len);
|
||||
} /* ecma_builtin_reference_error_dispatch_construct */
|
||||
|
||||
/**
|
||||
|
||||
@@ -51,7 +51,7 @@ NUMBER_VALUE (ECMA_MAGIC_STRING_LENGTH,
|
||||
|
||||
// 15.11.3.1
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_PROTOTYPE,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_REFERENCE_ERROR_PROTOTYPE),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_REFERENCE_ERROR_PROTOTYPE),
|
||||
ECMA_PROPERTY_NOT_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_NOT_CONFIGURABLE)
|
||||
|
||||
@@ -53,22 +53,16 @@
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_string_prototype_object_to_string (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg) /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_string_prototype_object_to_string (const ecma_value_t& this_arg) /**< this argument */
|
||||
{
|
||||
if (ecma_is_value_string (this_arg))
|
||||
{
|
||||
ecma_value_t this_arg_copy;
|
||||
ecma_copy_value (this_arg_copy, this_arg, true);
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, this_arg_copy);
|
||||
return;
|
||||
return ecma_make_normal_completion_value (ecma_copy_value (this_arg, true));
|
||||
}
|
||||
else if (ecma_is_value_object (this_arg))
|
||||
{
|
||||
ecma_object_ptr_t obj_p;
|
||||
ecma_get_object_from_value (obj_p, this_arg);
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (this_arg);
|
||||
|
||||
ecma_property_t *class_prop_p = ecma_get_internal_property (obj_p, ECMA_INTERNAL_PROPERTY_CLASS);
|
||||
|
||||
@@ -82,14 +76,11 @@ ecma_builtin_string_prototype_object_to_string (ecma_completion_value_t &ret_val
|
||||
|
||||
prim_value_str_p = ecma_copy_or_ref_ecma_string (prim_value_str_p);
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (prim_value_str_p));
|
||||
return;
|
||||
return ecma_make_normal_completion_value (ecma_make_string_value (prim_value_str_p));
|
||||
}
|
||||
}
|
||||
|
||||
ecma_object_ptr_t exception_obj_p;
|
||||
ecma_new_standard_error (exception_obj_p, ECMA_ERROR_TYPE);
|
||||
ecma_make_throw_obj_completion_value (ret_value, exception_obj_p);
|
||||
return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||
} /* ecma_builtin_string_prototype_object_to_string */
|
||||
|
||||
/**
|
||||
@@ -101,11 +92,10 @@ ecma_builtin_string_prototype_object_to_string (ecma_completion_value_t &ret_val
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_string_prototype_object_value_of (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg) /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_string_prototype_object_value_of (const ecma_value_t& this_arg) /**< this argument */
|
||||
{
|
||||
ecma_builtin_string_prototype_object_to_string (ret_value, this_arg);
|
||||
return ecma_builtin_string_prototype_object_to_string (this_arg);
|
||||
} /* ecma_builtin_string_prototype_object_value_of */
|
||||
|
||||
/**
|
||||
@@ -117,12 +107,11 @@ ecma_builtin_string_prototype_object_value_of (ecma_completion_value_t &ret_valu
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_string_prototype_object_char_at (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_string_prototype_object_char_at (const ecma_value_t& this_arg, /**< this argument */
|
||||
const ecma_value_t& arg) /**< routine's argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arg);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg);
|
||||
} /* ecma_builtin_string_prototype_object_char_at */
|
||||
|
||||
/**
|
||||
@@ -134,12 +123,11 @@ ecma_builtin_string_prototype_object_char_at (ecma_completion_value_t &ret_value
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_string_prototype_object_char_code_at (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_string_prototype_object_char_code_at (const ecma_value_t& this_arg, /**< this argument */
|
||||
const ecma_value_t& arg) /**< routine's argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arg);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg);
|
||||
} /* ecma_builtin_string_prototype_object_char_code_at */
|
||||
|
||||
/**
|
||||
@@ -151,13 +139,12 @@ ecma_builtin_string_prototype_object_char_code_at (ecma_completion_value_t &ret_
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_string_prototype_object_concat (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_string_prototype_object_concat (const 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_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, argument_list_p, arguments_number);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, argument_list_p, arguments_number);
|
||||
} /* ecma_builtin_string_prototype_object_concat */
|
||||
|
||||
/**
|
||||
@@ -169,13 +156,12 @@ ecma_builtin_string_prototype_object_concat (ecma_completion_value_t &ret_value,
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_string_prototype_object_index_of (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_string_prototype_object_index_of (const ecma_value_t& this_arg, /**< this argument */
|
||||
const ecma_value_t& arg1, /**< routine's first argument */
|
||||
const ecma_value_t& arg2) /**< routine's second argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arg1, arg2);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg1, arg2);
|
||||
} /* ecma_builtin_string_prototype_object_index_of */
|
||||
|
||||
/**
|
||||
@@ -187,13 +173,12 @@ ecma_builtin_string_prototype_object_index_of (ecma_completion_value_t &ret_valu
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_string_prototype_object_last_index_of (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_string_prototype_object_last_index_of (const ecma_value_t& this_arg, /**< this argument */
|
||||
const ecma_value_t& arg1, /**< routine's first argument */
|
||||
const ecma_value_t& arg2) /**< routine's second argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arg1, arg2);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg1, arg2);
|
||||
} /* ecma_builtin_string_prototype_object_last_index_of */
|
||||
|
||||
/**
|
||||
@@ -205,12 +190,11 @@ ecma_builtin_string_prototype_object_last_index_of (ecma_completion_value_t &ret
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_string_prototype_object_locale_compare (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_string_prototype_object_locale_compare (const ecma_value_t& this_arg, /**< this argument */
|
||||
const ecma_value_t& arg) /**< routine's argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arg);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg);
|
||||
} /* ecma_builtin_string_prototype_object_locale_compare */
|
||||
|
||||
/**
|
||||
@@ -222,12 +206,11 @@ ecma_builtin_string_prototype_object_locale_compare (ecma_completion_value_t &re
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_string_prototype_object_match (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_string_prototype_object_match (const ecma_value_t& this_arg, /**< this argument */
|
||||
const ecma_value_t& arg) /**< routine's argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arg);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg);
|
||||
} /* ecma_builtin_string_prototype_object_match */
|
||||
|
||||
/**
|
||||
@@ -239,13 +222,12 @@ ecma_builtin_string_prototype_object_match (ecma_completion_value_t &ret_value,
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_string_prototype_object_replace (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_string_prototype_object_replace (const ecma_value_t& this_arg, /**< this argument */
|
||||
const ecma_value_t& arg1, /**< routine's first argument */
|
||||
const ecma_value_t& arg2) /**< routine's second argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arg1, arg2);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg1, arg2);
|
||||
} /* ecma_builtin_string_prototype_object_replace */
|
||||
|
||||
/**
|
||||
@@ -257,12 +239,11 @@ ecma_builtin_string_prototype_object_replace (ecma_completion_value_t &ret_value
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_string_prototype_object_search (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_string_prototype_object_search (const ecma_value_t& this_arg, /**< this argument */
|
||||
const ecma_value_t& arg) /**< routine's argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arg);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg);
|
||||
} /* ecma_builtin_string_prototype_object_search */
|
||||
|
||||
/**
|
||||
@@ -274,13 +255,12 @@ ecma_builtin_string_prototype_object_search (ecma_completion_value_t &ret_value,
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_string_prototype_object_slice (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_string_prototype_object_slice (const ecma_value_t& this_arg, /**< this argument */
|
||||
const ecma_value_t& arg1, /**< routine's first argument */
|
||||
const ecma_value_t& arg2) /**< routine's second argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arg1, arg2);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg1, arg2);
|
||||
} /* ecma_builtin_string_prototype_object_slice */
|
||||
|
||||
/**
|
||||
@@ -292,13 +272,12 @@ ecma_builtin_string_prototype_object_slice (ecma_completion_value_t &ret_value,
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_string_prototype_object_split (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_string_prototype_object_split (const ecma_value_t& this_arg, /**< this argument */
|
||||
const ecma_value_t& arg1, /**< routine's first argument */
|
||||
const ecma_value_t& arg2) /**< routine's second argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arg1, arg2);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg1, arg2);
|
||||
} /* ecma_builtin_string_prototype_object_split */
|
||||
|
||||
/**
|
||||
@@ -310,13 +289,12 @@ ecma_builtin_string_prototype_object_split (ecma_completion_value_t &ret_value,
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_string_prototype_object_substring (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg, /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_string_prototype_object_substring (const ecma_value_t& this_arg, /**< this argument */
|
||||
const ecma_value_t& arg1, /**< routine's first argument */
|
||||
const ecma_value_t& arg2) /**< routine's second argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg, arg1, arg2);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg, arg1, arg2);
|
||||
} /* ecma_builtin_string_prototype_object_substring */
|
||||
|
||||
/**
|
||||
@@ -328,11 +306,10 @@ ecma_builtin_string_prototype_object_substring (ecma_completion_value_t &ret_val
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_string_prototype_object_to_lower_case (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg) /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_string_prototype_object_to_lower_case (const ecma_value_t& this_arg) /**< this argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg);
|
||||
} /* ecma_builtin_string_prototype_object_to_lower_case */
|
||||
|
||||
/**
|
||||
@@ -344,12 +321,10 @@ ecma_builtin_string_prototype_object_to_lower_case (ecma_completion_value_t &ret
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_string_prototype_object_to_locale_lower_case (ecma_completion_value_t &ret_value, /**< out: completion
|
||||
* value */
|
||||
const ecma_value_t& this_arg) /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_string_prototype_object_to_locale_lower_case (const ecma_value_t& this_arg) /**< this argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg);
|
||||
} /* ecma_builtin_string_prototype_object_to_locale_lower_case */
|
||||
|
||||
/**
|
||||
@@ -361,12 +336,10 @@ ecma_builtin_string_prototype_object_to_locale_lower_case (ecma_completion_value
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_string_prototype_object_to_upper_case (ecma_completion_value_t &ret_value, /**< out: completion
|
||||
* value */
|
||||
const ecma_value_t& this_arg) /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_string_prototype_object_to_upper_case (const ecma_value_t& this_arg) /**< this argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg);
|
||||
} /* ecma_builtin_string_prototype_object_to_upper_case */
|
||||
|
||||
/**
|
||||
@@ -378,12 +351,10 @@ ecma_builtin_string_prototype_object_to_upper_case (ecma_completion_value_t &ret
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_string_prototype_object_to_locale_upper_case (ecma_completion_value_t &ret_value, /**< out: completion
|
||||
* value */
|
||||
const ecma_value_t& this_arg) /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_string_prototype_object_to_locale_upper_case (const ecma_value_t& this_arg) /**< this argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg);
|
||||
} /* ecma_builtin_string_prototype_object_to_locale_upper_case */
|
||||
|
||||
/**
|
||||
@@ -395,11 +366,10 @@ ecma_builtin_string_prototype_object_to_locale_upper_case (ecma_completion_value
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_string_prototype_object_trim (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg) /**< this argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_string_prototype_object_trim (const ecma_value_t& this_arg) /**< this argument */
|
||||
{
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (ret_value, this_arg);
|
||||
ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg);
|
||||
} /* ecma_builtin_string_prototype_object_trim */
|
||||
|
||||
/**
|
||||
|
||||
@@ -37,7 +37,7 @@ OBJECT_ID (ECMA_BUILTIN_ID_STRING_PROTOTYPE)
|
||||
|
||||
// 15.5.4.1
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_CONSTRUCTOR,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_STRING),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_STRING),
|
||||
ECMA_PROPERTY_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_CONFIGURABLE)
|
||||
|
||||
@@ -53,12 +53,13 @@
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_string_object_from_char_code (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& this_arg __unused, /**< 'this' argument */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_string_object_from_char_code (const ecma_value_t& this_arg __unused, /**< 'this' argument */
|
||||
const ecma_value_t args[], /**< arguments list */
|
||||
ecma_length_t args_number) /**< number of arguments */
|
||||
{
|
||||
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
|
||||
|
||||
size_t zt_str_buffer_size = sizeof (ecma_char_t) * (args_number + 1u);
|
||||
|
||||
ecma_char_t *ret_zt_str_p = (ecma_char_t*) mem_heap_alloc_block (zt_str_buffer_size,
|
||||
@@ -77,9 +78,7 @@ ecma_builtin_string_object_from_char_code (ecma_completion_value_t &ret_value, /
|
||||
#if CONFIG_ECMA_CHAR_ENCODING == CONFIG_ECMA_CHAR_ASCII
|
||||
if ((uint16_char_code >> JERRY_BITSINBYTE) != 0)
|
||||
{
|
||||
ecma_object_ptr_t exception_obj_p;
|
||||
ecma_new_standard_error (exception_obj_p, ECMA_ERROR_TYPE);
|
||||
ecma_make_throw_obj_completion_value (ret_value, exception_obj_p);
|
||||
ret_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -95,7 +94,7 @@ ecma_builtin_string_object_from_char_code (ecma_completion_value_t &ret_value, /
|
||||
{
|
||||
mem_heap_free_block (ret_zt_str_p);
|
||||
|
||||
return;
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
JERRY_ASSERT (ecma_is_completion_value_empty (ret_value));
|
||||
@@ -105,7 +104,7 @@ ecma_builtin_string_object_from_char_code (ecma_completion_value_t &ret_value, /
|
||||
|
||||
mem_heap_free_block (ret_zt_str_p);
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (ret_str_p));
|
||||
return ecma_make_normal_completion_value (ecma_make_string_value (ret_str_p));
|
||||
} /* ecma_builtin_string_object_from_char_code */
|
||||
|
||||
/**
|
||||
@@ -113,24 +112,27 @@ ecma_builtin_string_object_from_char_code (ecma_completion_value_t &ret_value, /
|
||||
*
|
||||
* @return completion-value
|
||||
*/
|
||||
void
|
||||
ecma_builtin_string_dispatch_call (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_completion_value_t
|
||||
ecma_builtin_string_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
if (arguments_list_len == 0)
|
||||
{
|
||||
ecma_string_t *str_p = ecma_new_ecma_string_from_magic_string_id (ECMA_MAGIC_STRING__EMPTY);
|
||||
ecma_value_t str_value (str_p);
|
||||
ecma_value_t str_value = ecma_make_string_value (str_p);
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, str_value);
|
||||
ret_value = ecma_make_normal_completion_value (str_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_op_to_string (ret_value, arguments_list_p [0]);
|
||||
ret_value = ecma_op_to_string (arguments_list_p [0]);
|
||||
}
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_builtin_string_dispatch_call */
|
||||
|
||||
/**
|
||||
@@ -138,14 +140,13 @@ ecma_builtin_string_dispatch_call (ecma_completion_value_t &ret_value, /**< out:
|
||||
*
|
||||
* @return completion-value
|
||||
*/
|
||||
void
|
||||
ecma_builtin_string_dispatch_construct (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_completion_value_t
|
||||
ecma_builtin_string_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
ecma_op_create_string_object (ret_value, arguments_list_p, arguments_list_len);
|
||||
return ecma_op_create_string_object (arguments_list_p, arguments_list_len);
|
||||
} /* ecma_builtin_string_dispatch_construct */
|
||||
|
||||
/**
|
||||
|
||||
@@ -51,7 +51,7 @@ NUMBER_VALUE (ECMA_MAGIC_STRING_LENGTH,
|
||||
|
||||
// 15.7.3.1
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_PROTOTYPE,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_STRING_PROTOTYPE),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_STRING_PROTOTYPE),
|
||||
ECMA_PROPERTY_NOT_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_NOT_CONFIGURABLE)
|
||||
|
||||
@@ -37,7 +37,7 @@ OBJECT_ID (ECMA_BUILTIN_ID_SYNTAX_ERROR_PROTOTYPE)
|
||||
|
||||
// 15.11.7.8
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_CONSTRUCTOR,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_SYNTAX_ERROR),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_SYNTAX_ERROR),
|
||||
ECMA_PROPERTY_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_CONFIGURABLE)
|
||||
|
||||
@@ -48,9 +48,8 @@
|
||||
*
|
||||
* @return completion-value
|
||||
*/
|
||||
void
|
||||
ecma_builtin_syntax_error_dispatch_call (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_completion_value_t
|
||||
ecma_builtin_syntax_error_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
@@ -58,21 +57,26 @@ ecma_builtin_syntax_error_dispatch_call (ecma_completion_value_t &ret_value, /**
|
||||
if (arguments_list_len != 0
|
||||
&& !ecma_is_value_undefined (arguments_list_p [0]))
|
||||
{
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_to_string, msg_str_value, arguments_list_p[0]);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
ECMA_TRY_CATCH (msg_str_value,
|
||||
ecma_op_to_string (arguments_list_p[0]),
|
||||
ret_value);
|
||||
|
||||
ecma_string_t *message_string_p = ecma_get_string_from_value (msg_str_value);
|
||||
ecma_object_ptr_t new_error_object_p;
|
||||
ecma_new_standard_error_with_message (new_error_object_p, ECMA_ERROR_SYNTAX, message_string_p);
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (new_error_object_p));
|
||||
ecma_object_t *new_error_object_p = ecma_new_standard_error_with_message (ECMA_ERROR_SYNTAX,
|
||||
message_string_p);
|
||||
ret_value = ecma_make_normal_completion_value (ecma_make_object_value (new_error_object_p));
|
||||
|
||||
ECMA_FINALIZE (msg_str_value);
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_object_ptr_t new_error_object_p;
|
||||
ecma_new_standard_error (new_error_object_p, ECMA_ERROR_SYNTAX);
|
||||
ecma_object_t *new_error_object_p = ecma_new_standard_error (ECMA_ERROR_SYNTAX);
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (new_error_object_p));
|
||||
return ecma_make_normal_completion_value (ecma_make_object_value (new_error_object_p));
|
||||
}
|
||||
} /* ecma_builtin_syntax_error_dispatch_call */
|
||||
|
||||
@@ -81,12 +85,11 @@ ecma_builtin_syntax_error_dispatch_call (ecma_completion_value_t &ret_value, /**
|
||||
*
|
||||
* @return completion-value
|
||||
*/
|
||||
void
|
||||
ecma_builtin_syntax_error_dispatch_construct (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_completion_value_t
|
||||
ecma_builtin_syntax_error_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
ecma_builtin_syntax_error_dispatch_call (ret_value, arguments_list_p, arguments_list_len);
|
||||
return ecma_builtin_syntax_error_dispatch_call (arguments_list_p, arguments_list_len);
|
||||
} /* ecma_builtin_syntax_error_dispatch_construct */
|
||||
|
||||
/**
|
||||
|
||||
@@ -51,7 +51,7 @@ NUMBER_VALUE (ECMA_MAGIC_STRING_LENGTH,
|
||||
|
||||
// 15.11.3.1
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_PROTOTYPE,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_SYNTAX_ERROR_PROTOTYPE),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_SYNTAX_ERROR_PROTOTYPE),
|
||||
ECMA_PROPERTY_NOT_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_NOT_CONFIGURABLE)
|
||||
|
||||
@@ -49,17 +49,14 @@
|
||||
*
|
||||
* @return completion-value
|
||||
*/
|
||||
void
|
||||
ecma_builtin_type_error_thrower_dispatch_call (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_completion_value_t
|
||||
ecma_builtin_type_error_thrower_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
/* The object should throw TypeError */
|
||||
ecma_object_ptr_t exception_obj_p;
|
||||
ecma_new_standard_error (exception_obj_p, ECMA_ERROR_TYPE);
|
||||
ecma_make_throw_obj_completion_value (ret_value, exception_obj_p);
|
||||
return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||
} /* ecma_builtin_type_error_thrower_dispatch_call */
|
||||
|
||||
/**
|
||||
@@ -70,17 +67,14 @@ ecma_builtin_type_error_thrower_dispatch_call (ecma_completion_value_t &ret_valu
|
||||
*
|
||||
* @return completion-value
|
||||
*/
|
||||
void
|
||||
ecma_builtin_type_error_thrower_dispatch_construct (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_completion_value_t
|
||||
ecma_builtin_type_error_thrower_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
/* The object is not a constructor */
|
||||
ecma_object_ptr_t exception_obj_p;
|
||||
ecma_new_standard_error (exception_obj_p, ECMA_ERROR_TYPE);
|
||||
ecma_make_throw_obj_completion_value (ret_value, exception_obj_p);
|
||||
return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||
} /* ecma_builtin_type_error_thrower_dispatch_construct */
|
||||
|
||||
/**
|
||||
|
||||
@@ -37,7 +37,7 @@ OBJECT_ID (ECMA_BUILTIN_ID_TYPE_ERROR_PROTOTYPE)
|
||||
|
||||
// 15.11.7.8
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_CONSTRUCTOR,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_TYPE_ERROR),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_TYPE_ERROR),
|
||||
ECMA_PROPERTY_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_CONFIGURABLE)
|
||||
|
||||
@@ -48,9 +48,8 @@
|
||||
*
|
||||
* @return completion-value
|
||||
*/
|
||||
void
|
||||
ecma_builtin_type_error_dispatch_call (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_completion_value_t
|
||||
ecma_builtin_type_error_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
@@ -58,21 +57,26 @@ ecma_builtin_type_error_dispatch_call (ecma_completion_value_t &ret_value, /**<
|
||||
if (arguments_list_len != 0
|
||||
&& !ecma_is_value_undefined (arguments_list_p [0]))
|
||||
{
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_to_string, msg_str_value, arguments_list_p[0]);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
ECMA_TRY_CATCH (msg_str_value,
|
||||
ecma_op_to_string (arguments_list_p[0]),
|
||||
ret_value);
|
||||
|
||||
ecma_string_t *message_string_p = ecma_get_string_from_value (msg_str_value);
|
||||
ecma_object_ptr_t new_error_object_p;
|
||||
ecma_new_standard_error_with_message (new_error_object_p, ECMA_ERROR_TYPE, message_string_p);
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (new_error_object_p));
|
||||
ecma_object_t *new_error_object_p = ecma_new_standard_error_with_message (ECMA_ERROR_TYPE,
|
||||
message_string_p);
|
||||
ret_value = ecma_make_normal_completion_value (ecma_make_object_value (new_error_object_p));
|
||||
|
||||
ECMA_FINALIZE (msg_str_value);
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_object_ptr_t new_error_object_p;
|
||||
ecma_new_standard_error (new_error_object_p, ECMA_ERROR_TYPE);
|
||||
ecma_object_t *new_error_object_p = ecma_new_standard_error (ECMA_ERROR_TYPE);
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (new_error_object_p));
|
||||
return ecma_make_normal_completion_value (ecma_make_object_value (new_error_object_p));
|
||||
}
|
||||
} /* ecma_builtin_type_error_dispatch_call */
|
||||
|
||||
@@ -81,12 +85,11 @@ ecma_builtin_type_error_dispatch_call (ecma_completion_value_t &ret_value, /**<
|
||||
*
|
||||
* @return completion-value
|
||||
*/
|
||||
void
|
||||
ecma_builtin_type_error_dispatch_construct (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_completion_value_t
|
||||
ecma_builtin_type_error_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
ecma_builtin_type_error_dispatch_call (ret_value, arguments_list_p, arguments_list_len);
|
||||
return ecma_builtin_type_error_dispatch_call (arguments_list_p, arguments_list_len);
|
||||
} /* ecma_builtin_type_error_dispatch_construct */
|
||||
|
||||
/**
|
||||
|
||||
@@ -51,7 +51,7 @@ NUMBER_VALUE (ECMA_MAGIC_STRING_LENGTH,
|
||||
|
||||
// 15.11.3.1
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_PROTOTYPE,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_TYPE_ERROR_PROTOTYPE),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_TYPE_ERROR_PROTOTYPE),
|
||||
ECMA_PROPERTY_NOT_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_NOT_CONFIGURABLE)
|
||||
|
||||
@@ -37,7 +37,7 @@ OBJECT_ID (ECMA_BUILTIN_ID_URI_ERROR_PROTOTYPE)
|
||||
|
||||
// 15.11.7.8
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_CONSTRUCTOR,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_URI_ERROR),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_URI_ERROR),
|
||||
ECMA_PROPERTY_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_CONFIGURABLE)
|
||||
|
||||
@@ -48,9 +48,8 @@
|
||||
*
|
||||
* @return completion-value
|
||||
*/
|
||||
void
|
||||
ecma_builtin_uri_error_dispatch_call (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_completion_value_t
|
||||
ecma_builtin_uri_error_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
@@ -58,21 +57,26 @@ ecma_builtin_uri_error_dispatch_call (ecma_completion_value_t &ret_value, /**< o
|
||||
if (arguments_list_len != 0
|
||||
&& !ecma_is_value_undefined (arguments_list_p [0]))
|
||||
{
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_to_string, msg_str_value, arguments_list_p[0]);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
ECMA_TRY_CATCH (msg_str_value,
|
||||
ecma_op_to_string (arguments_list_p[0]),
|
||||
ret_value);
|
||||
|
||||
ecma_string_t *message_string_p = ecma_get_string_from_value (msg_str_value);
|
||||
ecma_object_ptr_t new_error_object_p;
|
||||
ecma_new_standard_error_with_message (new_error_object_p, ECMA_ERROR_URI, message_string_p);
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (new_error_object_p));
|
||||
ecma_object_t *new_error_object_p = ecma_new_standard_error_with_message (ECMA_ERROR_URI,
|
||||
message_string_p);
|
||||
ret_value = ecma_make_normal_completion_value (ecma_make_object_value (new_error_object_p));
|
||||
|
||||
ECMA_FINALIZE (msg_str_value);
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_object_ptr_t new_error_object_p;
|
||||
ecma_new_standard_error (new_error_object_p, ECMA_ERROR_URI);
|
||||
ecma_object_t *new_error_object_p = ecma_new_standard_error (ECMA_ERROR_URI);
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (new_error_object_p));
|
||||
return ecma_make_normal_completion_value (ecma_make_object_value (new_error_object_p));
|
||||
}
|
||||
} /* ecma_builtin_uri_error_dispatch_call */
|
||||
|
||||
@@ -81,12 +85,11 @@ ecma_builtin_uri_error_dispatch_call (ecma_completion_value_t &ret_value, /**< o
|
||||
*
|
||||
* @return completion-value
|
||||
*/
|
||||
void
|
||||
ecma_builtin_uri_error_dispatch_construct (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_completion_value_t
|
||||
ecma_builtin_uri_error_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
ecma_builtin_uri_error_dispatch_call (ret_value, arguments_list_p, arguments_list_len);
|
||||
return ecma_builtin_uri_error_dispatch_call (arguments_list_p, arguments_list_len);
|
||||
} /* ecma_builtin_uri_error_dispatch_construct */
|
||||
|
||||
/**
|
||||
|
||||
@@ -51,7 +51,7 @@ NUMBER_VALUE (ECMA_MAGIC_STRING_LENGTH,
|
||||
|
||||
// 15.11.3.1
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_PROTOTYPE,
|
||||
ecma_builtin_get (object_out_p, ECMA_BUILTIN_ID_URI_ERROR_PROTOTYPE),
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_URI_ERROR_PROTOTYPE),
|
||||
ECMA_PROPERTY_NOT_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_NOT_CONFIGURABLE)
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-value.h"
|
||||
|
||||
/**
|
||||
* Position of built-in object's id field in [[Built-in routine ID]] internal property
|
||||
@@ -47,9 +46,8 @@
|
||||
#define ECMA_BUILTIN_ROUTINE_ID_BUILT_IN_ROUTINE_ID_WIDTH (16)
|
||||
|
||||
/* ecma-builtins.c */
|
||||
extern void
|
||||
ecma_builtin_make_function_object_for_routine (ecma_object_ptr_t &ret_val,
|
||||
ecma_builtin_id_t builtin_id,
|
||||
extern ecma_object_t*
|
||||
ecma_builtin_make_function_object_for_routine (ecma_builtin_id_t builtin_id,
|
||||
ecma_magic_string_id_t routine_id,
|
||||
ecma_number_t length_prop_num_value);
|
||||
extern int32_t
|
||||
@@ -63,22 +61,19 @@ ecma_builtin_bin_search_for_magic_string_id_in_array (const ecma_magic_string_id
|
||||
object_prototype_builtin_id, \
|
||||
is_extensible, \
|
||||
lowercase_name) \
|
||||
extern void \
|
||||
ecma_builtin_ ## lowercase_name ## _dispatch_call (ecma_completion_value_t &ret_value, \
|
||||
const ecma_value_t *arguments_list_p, \
|
||||
extern ecma_completion_value_t \
|
||||
ecma_builtin_ ## lowercase_name ## _dispatch_call (const ecma_value_t *arguments_list_p, \
|
||||
ecma_length_t arguments_list_len); \
|
||||
extern void \
|
||||
ecma_builtin_ ## lowercase_name ## _dispatch_construct (ecma_completion_value_t &ret_value, \
|
||||
const ecma_value_t *arguments_list_p, \
|
||||
extern ecma_completion_value_t \
|
||||
ecma_builtin_ ## lowercase_name ## _dispatch_construct (const ecma_value_t *arguments_list_p, \
|
||||
ecma_length_t arguments_list_len); \
|
||||
extern void \
|
||||
ecma_builtin_ ## lowercase_name ## _dispatch_routine (ecma_completion_value_t &ret_value, \
|
||||
ecma_magic_string_id_t builtin_routine_id, \
|
||||
extern ecma_completion_value_t \
|
||||
ecma_builtin_ ## lowercase_name ## _dispatch_routine (ecma_magic_string_id_t builtin_routine_id, \
|
||||
const ecma_value_t& this_arg_value, \
|
||||
const ecma_value_t arguments_list [], \
|
||||
ecma_length_t arguments_number); \
|
||||
extern ecma_property_t* \
|
||||
ecma_builtin_ ## lowercase_name ## _try_to_instantiate_property (const ecma_object_ptr_t& obj_p, \
|
||||
ecma_builtin_ ## lowercase_name ## _try_to_instantiate_property (ecma_object_t *obj_p, \
|
||||
ecma_string_t *prop_name_p); \
|
||||
extern void \
|
||||
ecma_builtin_ ## lowercase_name ## _sort_property_names (void);
|
||||
@@ -95,10 +90,8 @@ ecma_builtin_ ## lowercase_name ## _sort_property_names (void);
|
||||
{ \
|
||||
jerry_ref_unused_variables (0, __VA_ARGS__); \
|
||||
} \
|
||||
ecma_object_ptr_t cp_error_p; \
|
||||
ecma_builtin_get (cp_error_p, ECMA_BUILTIN_ID_COMPACT_PROFILE_ERROR); \
|
||||
ecma_make_throw_obj_completion_value (ret_value, cp_error_p); \
|
||||
return; \
|
||||
ecma_object_t *cp_error_p = ecma_builtin_get (ECMA_BUILTIN_ID_COMPACT_PROFILE_ERROR); \
|
||||
return ecma_make_throw_obj_completion_value (cp_error_p); \
|
||||
}
|
||||
#endif /* CONFIG_ECMA_COMPACT_PROFILE */
|
||||
|
||||
|
||||
@@ -31,9 +31,8 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
static void
|
||||
ecma_builtin_dispatch_routine (ecma_completion_value_t &ret_value,
|
||||
ecma_builtin_id_t builtin_object_id,
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_dispatch_routine (ecma_builtin_id_t builtin_object_id,
|
||||
ecma_magic_string_id_t builtin_routine_id,
|
||||
const ecma_value_t& this_arg_value,
|
||||
const ecma_value_t arguments_list [],
|
||||
@@ -49,21 +48,18 @@ static ecma_object_t* ecma_builtin_objects [ECMA_BUILTIN_ID__COUNT];
|
||||
* Check if passed object is the instance of specified built-in.
|
||||
*/
|
||||
bool
|
||||
ecma_builtin_is (const ecma_object_ptr_t& obj_p, /**< pointer to an object */
|
||||
ecma_builtin_is (ecma_object_t *obj_p, /**< pointer to an object */
|
||||
ecma_builtin_id_t builtin_id) /**< id of built-in to check on */
|
||||
{
|
||||
JERRY_ASSERT (obj_p.is_not_null () && !ecma_is_lexical_environment (obj_p));
|
||||
JERRY_ASSERT (obj_p != NULL && !ecma_is_lexical_environment (obj_p));
|
||||
JERRY_ASSERT (builtin_id < ECMA_BUILTIN_ID__COUNT);
|
||||
|
||||
ecma_object_ptr_t builtin_obj_p;
|
||||
builtin_obj_p = ecma_builtin_objects [builtin_id];
|
||||
|
||||
if (unlikely (builtin_obj_p.is_null ()))
|
||||
if (unlikely (ecma_builtin_objects [builtin_id] == NULL))
|
||||
{
|
||||
ecma_instantiate_builtin (builtin_id);
|
||||
}
|
||||
|
||||
return (obj_p == builtin_obj_p);
|
||||
return (obj_p == ecma_builtin_objects [builtin_id]);
|
||||
} /* ecma_builtin_is */
|
||||
|
||||
/**
|
||||
@@ -71,24 +67,19 @@ ecma_builtin_is (const ecma_object_ptr_t& obj_p, /**< pointer to an object */
|
||||
*
|
||||
* @return pointer to the object's instance
|
||||
*/
|
||||
void
|
||||
ecma_builtin_get (ecma_object_ptr_t &ret_val, /**< out: object pointer */
|
||||
ecma_builtin_id_t builtin_id) /**< id of built-in to check on */
|
||||
ecma_object_t*
|
||||
ecma_builtin_get (ecma_builtin_id_t builtin_id) /**< id of built-in to check on */
|
||||
{
|
||||
JERRY_ASSERT (builtin_id < ECMA_BUILTIN_ID__COUNT);
|
||||
|
||||
ecma_object_ptr_t builtin_obj_p;
|
||||
builtin_obj_p = ecma_builtin_objects [builtin_id];
|
||||
|
||||
if (unlikely (builtin_obj_p.is_null ()))
|
||||
if (unlikely (ecma_builtin_objects [builtin_id] == NULL))
|
||||
{
|
||||
ecma_instantiate_builtin (builtin_id);
|
||||
builtin_obj_p = ecma_builtin_objects [builtin_id];
|
||||
}
|
||||
|
||||
ecma_ref_object (builtin_obj_p);
|
||||
ecma_ref_object (ecma_builtin_objects [builtin_id]);
|
||||
|
||||
ret_val = builtin_obj_p;
|
||||
return ecma_builtin_objects [builtin_id];
|
||||
} /* ecma_builtin_get */
|
||||
|
||||
/**
|
||||
@@ -99,15 +90,14 @@ ecma_builtin_get (ecma_object_ptr_t &ret_val, /**< out: object pointer */
|
||||
*
|
||||
* @return pointer to the object
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_init_object (ecma_object_ptr_t &object_obj_p, /**< out: object pointer */
|
||||
ecma_builtin_id_t obj_builtin_id, /**< built-in ID */
|
||||
const ecma_object_ptr_t& prototype_obj_p, /**< prototype object */
|
||||
static ecma_object_t*
|
||||
ecma_builtin_init_object (ecma_builtin_id_t obj_builtin_id, /**< built-in ID */
|
||||
ecma_object_t* prototype_obj_p, /**< prototype object */
|
||||
ecma_object_type_t obj_type, /**< object's type */
|
||||
ecma_magic_string_id_t obj_class, /**< object's class */
|
||||
bool is_extensible) /**< value of object's [[Extensible]] property */
|
||||
{
|
||||
ecma_create_object (object_obj_p, prototype_obj_p, is_extensible, obj_type);
|
||||
ecma_object_t *object_obj_p = ecma_create_object (prototype_obj_p, is_extensible, obj_type);
|
||||
|
||||
ecma_property_t *class_prop_p = ecma_create_internal_property (object_obj_p,
|
||||
ECMA_INTERNAL_PROPERTY_CLASS);
|
||||
@@ -165,6 +155,8 @@ ecma_builtin_init_object (ecma_object_ptr_t &object_obj_p, /**< out: object poin
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return object_obj_p;
|
||||
} /* ecma_builtin_init_object */
|
||||
|
||||
/**
|
||||
@@ -200,26 +192,27 @@ ecma_instantiate_builtin (ecma_builtin_id_t id) /**< built-in id */
|
||||
JERRY_ASSERT (ecma_builtin_objects [builtin_id] == NULL); \
|
||||
ecma_builtin_ ## lowercase_name ## _sort_property_names (); \
|
||||
\
|
||||
ecma_object_ptr_t prototype_obj_p; \
|
||||
if (object_prototype_builtin_id != ECMA_BUILTIN_ID__COUNT) \
|
||||
ecma_object_t *prototype_obj_p; \
|
||||
if (object_prototype_builtin_id == ECMA_BUILTIN_ID__COUNT) \
|
||||
{ \
|
||||
prototype_obj_p = ecma_builtin_objects [object_prototype_builtin_id]; \
|
||||
if (prototype_obj_p.is_null ()) \
|
||||
prototype_obj_p = NULL; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
if (ecma_builtin_objects [object_prototype_builtin_id] == NULL) \
|
||||
{ \
|
||||
ecma_instantiate_builtin (object_prototype_builtin_id); \
|
||||
} \
|
||||
prototype_obj_p = ecma_builtin_objects [object_prototype_builtin_id]; \
|
||||
JERRY_ASSERT (prototype_obj_p.is_not_null ()); \
|
||||
JERRY_ASSERT (prototype_obj_p != NULL); \
|
||||
} \
|
||||
\
|
||||
ecma_object_ptr_t builtin_obj_p; \
|
||||
ecma_builtin_init_object (builtin_obj_p, \
|
||||
builtin_id, \
|
||||
prototype_obj_p, \
|
||||
object_type, \
|
||||
object_class, \
|
||||
is_extensible); \
|
||||
ecma_builtin_objects [builtin_id] = (ecma_object_t*) builtin_obj_p; \
|
||||
ecma_object_t *builtin_obj_p = ecma_builtin_init_object (builtin_id, \
|
||||
prototype_obj_p, \
|
||||
object_type, \
|
||||
object_class, \
|
||||
is_extensible); \
|
||||
ecma_builtin_objects [builtin_id] = builtin_obj_p; \
|
||||
\
|
||||
break; \
|
||||
}
|
||||
@@ -244,11 +237,10 @@ ecma_finalize_builtins (void)
|
||||
id < ECMA_BUILTIN_ID__COUNT;
|
||||
id = (ecma_builtin_id_t) (id + 1))
|
||||
{
|
||||
ecma_object_ptr_t builtin_obj_p;
|
||||
builtin_obj_p = ecma_builtin_objects [id];
|
||||
if (builtin_obj_p.is_not_null ())
|
||||
if (ecma_builtin_objects [id] != NULL)
|
||||
{
|
||||
ecma_deref_object (builtin_obj_p);
|
||||
ecma_deref_object (ecma_builtin_objects [id]);
|
||||
|
||||
ecma_builtin_objects [id] = NULL;
|
||||
}
|
||||
}
|
||||
@@ -263,7 +255,7 @@ ecma_finalize_builtins (void)
|
||||
* NULL - otherwise.
|
||||
*/
|
||||
ecma_property_t*
|
||||
ecma_builtin_try_to_instantiate_property (const ecma_object_ptr_t& object_p, /**< object */
|
||||
ecma_builtin_try_to_instantiate_property (ecma_object_t *object_p, /**< object */
|
||||
ecma_string_t *string_p) /**< property's name */
|
||||
{
|
||||
JERRY_ASSERT (ecma_get_object_is_builtin (object_p));
|
||||
@@ -314,9 +306,8 @@ ecma_builtin_try_to_instantiate_property (const ecma_object_ptr_t& object_p, /**
|
||||
*
|
||||
* @return pointer to constructed Function object
|
||||
*/
|
||||
void
|
||||
ecma_builtin_make_function_object_for_routine (ecma_object_ptr_t &func_obj_p, /**< out: object pointer */
|
||||
ecma_builtin_id_t builtin_id, /**< identifier of built-in object
|
||||
ecma_object_t*
|
||||
ecma_builtin_make_function_object_for_routine (ecma_builtin_id_t builtin_id, /**< identifier of built-in object
|
||||
that initially contains property
|
||||
with the routine */
|
||||
ecma_magic_string_id_t routine_id, /**< name of the built-in
|
||||
@@ -325,10 +316,9 @@ ecma_builtin_make_function_object_for_routine (ecma_object_ptr_t &func_obj_p, /*
|
||||
of 'length' property
|
||||
of function object to create */
|
||||
{
|
||||
ecma_object_ptr_t prototype_obj_p;
|
||||
ecma_builtin_get (prototype_obj_p, ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE);
|
||||
ecma_object_t *prototype_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE);
|
||||
|
||||
ecma_create_object (func_obj_p, prototype_obj_p, true, ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION);
|
||||
ecma_object_t *func_obj_p = ecma_create_object (prototype_obj_p, true, ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION);
|
||||
|
||||
ecma_deref_object (prototype_obj_p);
|
||||
|
||||
@@ -358,7 +348,9 @@ ecma_builtin_make_function_object_for_routine (ecma_object_ptr_t &func_obj_p, /*
|
||||
ecma_number_t* len_p = ecma_alloc_number ();
|
||||
*len_p = length_prop_num_value;
|
||||
|
||||
ecma_set_named_data_property_value (len_prop_p, ecma_value_t (len_p));
|
||||
ecma_set_named_data_property_value (len_prop_p, ecma_make_number_value (len_p));
|
||||
|
||||
return func_obj_p;
|
||||
} /* ecma_builtin_make_function_object_for_routine */
|
||||
|
||||
/**
|
||||
@@ -366,9 +358,8 @@ ecma_builtin_make_function_object_for_routine (ecma_object_ptr_t &func_obj_p, /*
|
||||
*
|
||||
* @return completion-value
|
||||
*/
|
||||
void
|
||||
ecma_builtin_dispatch_call (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_object_ptr_t& obj_p, /**< built-in object */
|
||||
ecma_completion_value_t
|
||||
ecma_builtin_dispatch_call (ecma_object_t *obj_p, /**< built-in object */
|
||||
const ecma_value_t& this_arg_value, /**< 'this' argument value */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< length of the arguments list */
|
||||
@@ -395,13 +386,11 @@ ecma_builtin_dispatch_call (ecma_completion_value_t &ret_value, /**< out: comple
|
||||
ecma_builtin_id_t built_in_id = (ecma_builtin_id_t) built_in_id_field;
|
||||
ecma_magic_string_id_t routine_id = (ecma_magic_string_id_t) routine_id_field;
|
||||
|
||||
ecma_builtin_dispatch_routine (ret_value,
|
||||
built_in_id,
|
||||
routine_id,
|
||||
this_arg_value,
|
||||
arguments_list_p,
|
||||
arguments_list_len);
|
||||
return;
|
||||
return ecma_builtin_dispatch_routine (built_in_id,
|
||||
routine_id,
|
||||
this_arg_value,
|
||||
arguments_list_p,
|
||||
arguments_list_len);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -425,10 +414,8 @@ ecma_builtin_dispatch_call (ecma_completion_value_t &ret_value, /**< out: comple
|
||||
{ \
|
||||
if (object_type == ECMA_OBJECT_TYPE_FUNCTION) \
|
||||
{ \
|
||||
ecma_builtin_ ## lowercase_name ## _dispatch_call (ret_value, \
|
||||
arguments_list_p, \
|
||||
arguments_list_len); \
|
||||
return; \
|
||||
return ecma_builtin_ ## lowercase_name ## _dispatch_call (arguments_list_p, \
|
||||
arguments_list_len); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
@@ -461,9 +448,8 @@ ecma_builtin_dispatch_call (ecma_completion_value_t &ret_value, /**< out: comple
|
||||
*
|
||||
* @return completion-value
|
||||
*/
|
||||
void
|
||||
ecma_builtin_dispatch_construct (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_object_ptr_t& obj_p, /**< built-in object */
|
||||
ecma_completion_value_t
|
||||
ecma_builtin_dispatch_construct (ecma_object_t *obj_p, /**< built-in object */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< length of the arguments list */
|
||||
{
|
||||
@@ -490,10 +476,8 @@ ecma_builtin_dispatch_construct (ecma_completion_value_t &ret_value, /**< out: c
|
||||
{ \
|
||||
if (object_type == ECMA_OBJECT_TYPE_FUNCTION) \
|
||||
{ \
|
||||
ecma_builtin_ ## lowercase_name ## _dispatch_construct (ret_value, \
|
||||
arguments_list_p, \
|
||||
arguments_list_len); \
|
||||
return; \
|
||||
return ecma_builtin_ ## lowercase_name ## _dispatch_construct (arguments_list_p, \
|
||||
arguments_list_len); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
@@ -526,9 +510,8 @@ ecma_builtin_dispatch_construct (ecma_completion_value_t &ret_value, /**< out: c
|
||||
* @return completion-value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
static void
|
||||
ecma_builtin_dispatch_routine (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
ecma_builtin_id_t builtin_object_id, /**< built-in object' identifier */
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_dispatch_routine (ecma_builtin_id_t builtin_object_id, /**< built-in object' identifier */
|
||||
ecma_magic_string_id_t builtin_routine_id, /**< name of the built-in object's
|
||||
routine property */
|
||||
const ecma_value_t& this_arg_value, /**< 'this' argument value */
|
||||
@@ -545,12 +528,10 @@ ecma_builtin_dispatch_routine (ecma_completion_value_t &ret_value, /**< out: com
|
||||
lowercase_name) \
|
||||
case builtin_id: \
|
||||
{ \
|
||||
ecma_builtin_ ## lowercase_name ## _dispatch_routine (ret_value, \
|
||||
builtin_routine_id, \
|
||||
this_arg_value, \
|
||||
arguments_list, \
|
||||
arguments_number); \
|
||||
return; \
|
||||
return ecma_builtin_ ## lowercase_name ## _dispatch_routine (builtin_routine_id, \
|
||||
this_arg_value, \
|
||||
arguments_list, \
|
||||
arguments_number); \
|
||||
}
|
||||
#include "ecma-builtins.inc.h"
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#define ECMA_BUILTINS_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-value.h"
|
||||
|
||||
/**
|
||||
* A built-in object's identifier
|
||||
@@ -39,24 +38,21 @@ typedef enum
|
||||
extern void ecma_init_builtins (void);
|
||||
extern void ecma_finalize_builtins (void);
|
||||
|
||||
extern void
|
||||
ecma_builtin_dispatch_call (ecma_completion_value_t &ret_value,
|
||||
const ecma_object_ptr_t& obj_p,
|
||||
extern ecma_completion_value_t
|
||||
ecma_builtin_dispatch_call (ecma_object_t *obj_p,
|
||||
const ecma_value_t& this_arg,
|
||||
const ecma_value_t *arguments_list_p,
|
||||
ecma_length_t arguments_list_len);
|
||||
extern void
|
||||
ecma_builtin_dispatch_construct (ecma_completion_value_t &ret_value,
|
||||
const ecma_object_ptr_t& obj_p,
|
||||
extern ecma_completion_value_t
|
||||
ecma_builtin_dispatch_construct (ecma_object_t *obj_p,
|
||||
const ecma_value_t *arguments_list_p,
|
||||
ecma_length_t arguments_list_len);
|
||||
extern ecma_property_t*
|
||||
ecma_builtin_try_to_instantiate_property (const ecma_object_ptr_t& object_p,
|
||||
ecma_builtin_try_to_instantiate_property (ecma_object_t *object_p,
|
||||
ecma_string_t *string_p);
|
||||
extern bool
|
||||
ecma_builtin_is (const ecma_object_ptr_t& obj_p,
|
||||
ecma_builtin_is (ecma_object_t *obj_p,
|
||||
ecma_builtin_id_t builtin_id);
|
||||
extern void
|
||||
ecma_builtin_get (ecma_object_ptr_t &ret_val,
|
||||
ecma_builtin_id_t builtin_id);
|
||||
extern ecma_object_t*
|
||||
ecma_builtin_get (ecma_builtin_id_t builtin_id);
|
||||
#endif /* !ECMA_BUILTINS_H */
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "globals.h"
|
||||
#include "mem-poolman.h"
|
||||
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_value_packed_t) <= sizeof (uint16_t));
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_value_t) <= sizeof (uint16_t));
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_property_t) <= sizeof (uint64_t));
|
||||
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_object_t) <= sizeof (uint64_t));
|
||||
@@ -30,6 +30,7 @@ JERRY_STATIC_ASSERT (ECMA_OBJECT_LEX_ENV_TYPE_SIZE <= sizeof (uint64_t) * JERRY_
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_collection_header_t) == sizeof (uint64_t));
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_collection_chunk_t) == sizeof (uint64_t));
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_string_t) == sizeof (uint64_t));
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_completion_value_t) == sizeof (uint32_t));
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_label_descriptor_t) == sizeof (uint64_t));
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -73,41 +74,14 @@ JERRY_STATIC_ASSERT (sizeof (ecma_label_descriptor_t) == sizeof (uint64_t));
|
||||
mem_pools_free ((uint8_t*) p ## ecma_type); \
|
||||
}
|
||||
|
||||
/**
|
||||
* Template of an allocation routine.
|
||||
*/
|
||||
#define ALLOC_MANAGED_PTR(ecma_type) void \
|
||||
ecma_alloc_ ## ecma_type (ecma_ ## ecma_type ## _ptr_t &ret_ ## ecma_type ## _p) \
|
||||
{ \
|
||||
ret_ ## ecma_type ## _p = (ecma_ ## ecma_type ## _t *) mem_pools_alloc (); \
|
||||
\
|
||||
JERRY_ASSERT (ret_ ## ecma_type ## _p.is_not_null ()); \
|
||||
}
|
||||
|
||||
/**
|
||||
* Deallocation routine template
|
||||
*/
|
||||
#define DEALLOC_MANAGED_PTR(ecma_type) void \
|
||||
ecma_dealloc_ ## ecma_type (ecma_ ## ecma_type ## _ptr_t& ecma_type ## _p) \
|
||||
{ \
|
||||
ecma_ ## ecma_type ## _t* ecma_type ## _tmp_p = (ecma_ ## ecma_type ## _t*) ecma_type ## _p; \
|
||||
ecma_type ## _p = (ecma_ ## ecma_type ## _t *) NULL; \
|
||||
\
|
||||
mem_pools_free ((uint8_t*) ecma_type ## _tmp_p); \
|
||||
}
|
||||
|
||||
/**
|
||||
* Declaration of alloc/free routine for specified ecma-type.
|
||||
*/
|
||||
#define DECLARE_ROUTINES_FOR(ecma_type) \
|
||||
ALLOC(ecma_type) \
|
||||
DEALLOC(ecma_type)
|
||||
#define DECLARE_MANAGED_PTR_ROUTINES_FOR(ecma_type) \
|
||||
ALLOC_MANAGED_PTR(ecma_type) \
|
||||
DEALLOC_MANAGED_PTR(ecma_type)
|
||||
|
||||
DECLARE_MANAGED_PTR_ROUTINES_FOR (object)
|
||||
|
||||
DECLARE_ROUTINES_FOR (object)
|
||||
DECLARE_ROUTINES_FOR (property)
|
||||
DECLARE_ROUTINES_FOR (number)
|
||||
DECLARE_ROUTINES_FOR (collection_header)
|
||||
|
||||
@@ -30,12 +30,12 @@
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern void ecma_alloc_object (ecma_object_ptr_t &ret_obj_p);
|
||||
extern ecma_object_t *ecma_alloc_object (void);
|
||||
|
||||
/**
|
||||
* Dealloc memory from an ecma-object
|
||||
*/
|
||||
extern void ecma_dealloc_object (ecma_object_ptr_t &object_p);
|
||||
extern void ecma_dealloc_object (ecma_object_t *object_p);
|
||||
|
||||
/**
|
||||
* Allocate memory for ecma-property
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
/* Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "mem-allocator.h"
|
||||
|
||||
#ifndef ECMA_COMPRESSED_POINTERS_H
|
||||
#define ECMA_COMPRESSED_POINTERS_H
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** \addtogroup compressedpointer Compressed pointer
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ecma-pointer field is used to calculate ecma-value's address.
|
||||
*
|
||||
* Ecma-pointer contains value's shifted offset from common Ecma-pointers' base.
|
||||
* The offset is shifted right by MEM_ALIGNMENT_LOG.
|
||||
* Least significant MEM_ALIGNMENT_LOG bits of non-shifted offset are zeroes.
|
||||
*/
|
||||
#define ECMA_POINTER_FIELD_WIDTH MEM_COMPRESSED_POINTER_WIDTH
|
||||
|
||||
/**
|
||||
* The NULL value for compressed pointers
|
||||
*/
|
||||
#define ECMA_NULL_POINTER MEM_COMPRESSED_POINTER_NULL
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** \addtogroup ecmacompressedpointers Helpers for operations with compressed heap pointers
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get value of pointer from specified non-null compressed pointer field.
|
||||
*/
|
||||
#define ECMA_GET_NON_NULL_POINTER(type, field) \
|
||||
((type *) mem_decompress_pointer (field))
|
||||
|
||||
/**
|
||||
* Get value of pointer from specified compressed pointer field.
|
||||
*/
|
||||
#define ECMA_GET_POINTER(type, field) \
|
||||
(((unlikely (field == ECMA_NULL_POINTER)) ? NULL : ECMA_GET_NON_NULL_POINTER (type, field)))
|
||||
|
||||
/**
|
||||
* Set value of non-null compressed pointer field so that it will correspond
|
||||
* to specified non_compressed_pointer.
|
||||
*/
|
||||
#define ECMA_SET_NON_NULL_POINTER(field, non_compressed_pointer) \
|
||||
(field) = (mem_compress_pointer (non_compressed_pointer) & ((1u << ECMA_POINTER_FIELD_WIDTH) - 1))
|
||||
|
||||
/**
|
||||
* Set value of compressed pointer field so that it will correspond
|
||||
* to specified non_compressed_pointer.
|
||||
*/
|
||||
#define ECMA_SET_POINTER(field, non_compressed_pointer) \
|
||||
do \
|
||||
{ \
|
||||
auto __temp_pointer = non_compressed_pointer; \
|
||||
non_compressed_pointer = __temp_pointer; \
|
||||
} while (0); \
|
||||
\
|
||||
(field) = (unlikely ((non_compressed_pointer) == NULL) ? ECMA_NULL_POINTER \
|
||||
: (mem_compress_pointer (non_compressed_pointer) \
|
||||
& ((1u << ECMA_POINTER_FIELD_WIDTH) - 1)))
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* ECMA_COMPRESSED_POINTERS_H */
|
||||
+114
-139
@@ -37,20 +37,20 @@
|
||||
/**
|
||||
* Global lists of objects sorted by generation identifier.
|
||||
*/
|
||||
static ecma_object_t* ecma_gc_objects_lists[ ECMA_GC_GEN_COUNT ];
|
||||
static ecma_object_t *ecma_gc_objects_lists[ ECMA_GC_GEN_COUNT ];
|
||||
|
||||
static void ecma_gc_mark (const ecma_object_ptr_t &object_p, ecma_gc_gen_t maximum_gen_to_traverse);
|
||||
static void ecma_gc_sweep (ecma_object_ptr_t &object_p);
|
||||
static void ecma_gc_mark (ecma_object_t *object_p, ecma_gc_gen_t maximum_gen_to_traverse);
|
||||
static void ecma_gc_sweep (ecma_object_t *object_p);
|
||||
|
||||
/**
|
||||
* Get GC reference counter of the object.
|
||||
*/
|
||||
static uint32_t
|
||||
ecma_gc_get_object_refs (const ecma_object_ptr_t &object_p) /**< object */
|
||||
ecma_gc_get_object_refs (ecma_object_t *object_p) /**< object */
|
||||
{
|
||||
JERRY_ASSERT (object_p.is_not_null ());
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
|
||||
return (uint32_t) jrt_extract_bit_field (((ecma_object_t*) object_p)->container,
|
||||
return (uint32_t) jrt_extract_bit_field (object_p->container,
|
||||
ECMA_OBJECT_GC_REFS_POS,
|
||||
ECMA_OBJECT_GC_REFS_WIDTH);
|
||||
} /* ecma_gc_get_object_refs */
|
||||
@@ -59,26 +59,26 @@ ecma_gc_get_object_refs (const ecma_object_ptr_t &object_p) /**< object */
|
||||
* Set GC reference counter of the object.
|
||||
*/
|
||||
static void
|
||||
ecma_gc_set_object_refs (const ecma_object_ptr_t &object_p, /**< object */
|
||||
ecma_gc_set_object_refs (ecma_object_t *object_p, /**< object */
|
||||
uint32_t refs) /**< new reference counter */
|
||||
{
|
||||
JERRY_ASSERT (object_p.is_not_null ());
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
|
||||
((ecma_object_t*) object_p)->container = jrt_set_bit_field_value (((ecma_object_t*) object_p)->container,
|
||||
refs,
|
||||
ECMA_OBJECT_GC_REFS_POS,
|
||||
ECMA_OBJECT_GC_REFS_WIDTH);
|
||||
object_p->container = jrt_set_bit_field_value (object_p->container,
|
||||
refs,
|
||||
ECMA_OBJECT_GC_REFS_POS,
|
||||
ECMA_OBJECT_GC_REFS_WIDTH);
|
||||
} /* ecma_gc_set_object_refs */
|
||||
|
||||
/**
|
||||
* Get GC generation of the object.
|
||||
*/
|
||||
static ecma_gc_gen_t
|
||||
ecma_gc_get_object_generation (const ecma_object_ptr_t &object_p) /**< object */
|
||||
ecma_gc_get_object_generation (ecma_object_t *object_p) /**< object */
|
||||
{
|
||||
JERRY_ASSERT (object_p.is_not_null ());
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
|
||||
ecma_gc_gen_t ret = (ecma_gc_gen_t) jrt_extract_bit_field (((ecma_object_t*) object_p)->container,
|
||||
ecma_gc_gen_t ret = (ecma_gc_gen_t) jrt_extract_bit_field (object_p->container,
|
||||
ECMA_OBJECT_GC_GENERATION_POS,
|
||||
ECMA_OBJECT_GC_GENERATION_WIDTH);
|
||||
|
||||
@@ -91,50 +91,48 @@ ecma_gc_get_object_generation (const ecma_object_ptr_t &object_p) /**< object */
|
||||
* Set GC generation of the object.
|
||||
*/
|
||||
static void
|
||||
ecma_gc_set_object_generation (const ecma_object_ptr_t &object_p, /**< object */
|
||||
ecma_gc_set_object_generation (ecma_object_t *object_p, /**< object */
|
||||
ecma_gc_gen_t generation) /**< generation */
|
||||
{
|
||||
JERRY_ASSERT (object_p.is_not_null ());
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
JERRY_ASSERT (generation < ECMA_GC_GEN_COUNT);
|
||||
|
||||
((ecma_object_t*) object_p)->container = jrt_set_bit_field_value (((ecma_object_t*) object_p)->container,
|
||||
generation,
|
||||
ECMA_OBJECT_GC_GENERATION_POS,
|
||||
ECMA_OBJECT_GC_GENERATION_WIDTH);
|
||||
object_p->container = jrt_set_bit_field_value (object_p->container,
|
||||
generation,
|
||||
ECMA_OBJECT_GC_GENERATION_POS,
|
||||
ECMA_OBJECT_GC_GENERATION_WIDTH);
|
||||
} /* ecma_gc_set_object_generation */
|
||||
|
||||
/**
|
||||
* Get next object in list of objects with same generation.
|
||||
*/
|
||||
static void
|
||||
ecma_gc_get_object_next (ecma_object_ptr_t & ret_val, /**< out: object pointer */
|
||||
const ecma_object_ptr_t &object_p) /**< object */
|
||||
static ecma_object_t*
|
||||
ecma_gc_get_object_next (ecma_object_t *object_p) /**< object */
|
||||
{
|
||||
JERRY_ASSERT (object_p.is_not_null ());
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
|
||||
JERRY_ASSERT (sizeof (uintptr_t) * JERRY_BITSINBYTE >= ECMA_OBJECT_GC_NEXT_CP_WIDTH);
|
||||
uintptr_t next_cp = (uintptr_t) jrt_extract_bit_field (((ecma_object_t*) object_p)->container,
|
||||
uintptr_t next_cp = (uintptr_t) jrt_extract_bit_field (object_p->container,
|
||||
ECMA_OBJECT_GC_NEXT_CP_POS,
|
||||
ECMA_OBJECT_GC_NEXT_CP_WIDTH);
|
||||
|
||||
ret_val.unpack_from (next_cp, true);
|
||||
return ECMA_GET_POINTER (ecma_object_t,
|
||||
next_cp);
|
||||
} /* ecma_gc_get_object_next */
|
||||
|
||||
/**
|
||||
* Set next object in list of objects with same generation.
|
||||
*/
|
||||
static void
|
||||
ecma_gc_set_object_next (const ecma_object_ptr_t &object_mp, /**< object */
|
||||
const ecma_object_ptr_t &next_object_p) /**< next object */
|
||||
ecma_gc_set_object_next (ecma_object_t *object_p, /**< object */
|
||||
ecma_object_t *next_object_p) /**< next object */
|
||||
{
|
||||
JERRY_ASSERT (object_mp.is_not_null ());
|
||||
|
||||
JERRY_ASSERT (sizeof (uintptr_t) * JERRY_BITSINBYTE >= ECMA_OBJECT_GC_NEXT_CP_WIDTH);
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
|
||||
uintptr_t next_cp;
|
||||
next_object_p.pack_to (next_cp, true);
|
||||
ECMA_SET_POINTER (next_cp, next_object_p);
|
||||
|
||||
ecma_object_t *object_p = (ecma_object_t*) object_mp;
|
||||
JERRY_ASSERT (sizeof (uintptr_t) * JERRY_BITSINBYTE >= ECMA_OBJECT_GC_NEXT_CP_WIDTH);
|
||||
object_p->container = jrt_set_bit_field_value (object_p->container,
|
||||
next_cp,
|
||||
ECMA_OBJECT_GC_NEXT_CP_POS,
|
||||
@@ -145,11 +143,11 @@ ecma_gc_set_object_next (const ecma_object_ptr_t &object_mp, /**< object */
|
||||
* Get visited flag of the object.
|
||||
*/
|
||||
static bool
|
||||
ecma_gc_is_object_visited (const ecma_object_ptr_t &object_p) /**< object */
|
||||
ecma_gc_is_object_visited (ecma_object_t *object_p) /**< object */
|
||||
{
|
||||
JERRY_ASSERT (object_p.is_not_null ());
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
|
||||
return jrt_extract_bit_field (((ecma_object_t*) object_p)->container,
|
||||
return jrt_extract_bit_field (object_p->container,
|
||||
ECMA_OBJECT_GC_VISITED_POS,
|
||||
ECMA_OBJECT_GC_VISITED_WIDTH);
|
||||
} /* ecma_gc_is_object_visited */
|
||||
@@ -158,12 +156,11 @@ ecma_gc_is_object_visited (const ecma_object_ptr_t &object_p) /**< object */
|
||||
* Set visited flag of the object.
|
||||
*/
|
||||
static void
|
||||
ecma_gc_set_object_visited (const ecma_object_ptr_t &object_mp, /**< object */
|
||||
ecma_gc_set_object_visited (ecma_object_t *object_p, /**< object */
|
||||
bool is_visited) /**< flag value */
|
||||
{
|
||||
JERRY_ASSERT (object_mp.is_not_null ());
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
|
||||
ecma_object_t *object_p = (ecma_object_t*) object_mp;
|
||||
object_p->container = jrt_set_bit_field_value (object_p->container,
|
||||
is_visited,
|
||||
ECMA_OBJECT_GC_VISITED_POS,
|
||||
@@ -174,11 +171,11 @@ ecma_gc_set_object_visited (const ecma_object_ptr_t &object_mp, /**< object */
|
||||
* Get may_ref_younger_objects flag of the object.
|
||||
*/
|
||||
static bool
|
||||
ecma_gc_is_object_may_ref_younger_objects (const ecma_object_ptr_t &object_p) /**< object */
|
||||
ecma_gc_is_object_may_ref_younger_objects (ecma_object_t *object_p) /**< object */
|
||||
{
|
||||
JERRY_ASSERT (object_p.is_not_null ());
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
|
||||
return jrt_extract_bit_field (((ecma_object_t*) object_p)->container,
|
||||
return jrt_extract_bit_field (object_p->container,
|
||||
ECMA_OBJECT_GC_MAY_REF_YOUNGER_OBJECTS_POS,
|
||||
ECMA_OBJECT_GC_MAY_REF_YOUNGER_OBJECTS_WIDTH);
|
||||
} /* ecma_gc_is_object_may_ref_younger_objects */
|
||||
@@ -187,12 +184,11 @@ ecma_gc_is_object_may_ref_younger_objects (const ecma_object_ptr_t &object_p) /*
|
||||
* Set may_ref_younger_objects flag of the object.
|
||||
*/
|
||||
static void
|
||||
ecma_gc_set_object_may_ref_younger_objects (const ecma_object_ptr_t &object_mp, /**< object */
|
||||
ecma_gc_set_object_may_ref_younger_objects (ecma_object_t *object_p, /**< object */
|
||||
bool is_may_ref_younger_objects) /**< flag value */
|
||||
{
|
||||
JERRY_ASSERT (object_mp.is_not_null ());
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
|
||||
ecma_object_t *object_p = (ecma_object_t*) object_mp;
|
||||
object_p->container = jrt_set_bit_field_value (object_p->container,
|
||||
is_may_ref_younger_objects,
|
||||
ECMA_OBJECT_GC_MAY_REF_YOUNGER_OBJECTS_POS,
|
||||
@@ -203,41 +199,37 @@ ecma_gc_set_object_may_ref_younger_objects (const ecma_object_ptr_t &object_mp,
|
||||
* Initialize GC information for the object
|
||||
*/
|
||||
void
|
||||
ecma_init_gc_info (const ecma_object_ptr_t& object_mp) /**< object */
|
||||
ecma_init_gc_info (ecma_object_t *object_p) /**< object */
|
||||
{
|
||||
ecma_gc_set_object_refs (object_mp, 1);
|
||||
ecma_gc_set_object_refs (object_p, 1);
|
||||
|
||||
ecma_object_ptr_t next_object_mp;
|
||||
next_object_mp = ecma_gc_objects_lists[ ECMA_GC_GEN_0 ];
|
||||
|
||||
ecma_gc_set_object_generation (object_mp, ECMA_GC_GEN_0);
|
||||
ecma_gc_set_object_next (object_mp, next_object_mp);
|
||||
ecma_gc_objects_lists[ ECMA_GC_GEN_0 ] = (ecma_object_t*) object_mp;
|
||||
ecma_gc_set_object_generation (object_p, ECMA_GC_GEN_0);
|
||||
ecma_gc_set_object_next (object_p, ecma_gc_objects_lists[ ECMA_GC_GEN_0 ]);
|
||||
ecma_gc_objects_lists[ ECMA_GC_GEN_0 ] = object_p;
|
||||
|
||||
/* Should be set to false at the beginning of garbage collection */
|
||||
ecma_gc_set_object_visited (object_mp, true);
|
||||
ecma_gc_set_object_visited (object_p, true);
|
||||
|
||||
ecma_gc_set_object_may_ref_younger_objects (object_mp, false);
|
||||
ecma_gc_set_object_may_ref_younger_objects (object_p, false);
|
||||
} /* ecma_init_gc_info */
|
||||
|
||||
/**
|
||||
* Increase reference counter of an object
|
||||
*/
|
||||
void
|
||||
ecma_ref_object (const ecma_object_ptr_t& object_mp) /**< object */
|
||||
ecma_ref_object (ecma_object_t *object_p) /**< object */
|
||||
{
|
||||
ecma_gc_set_object_refs (object_mp, ecma_gc_get_object_refs (object_mp) + 1);
|
||||
ecma_gc_set_object_refs (object_p, ecma_gc_get_object_refs (object_p) + 1);
|
||||
} /* ecma_ref_object */
|
||||
|
||||
/**
|
||||
* Decrease reference counter of an object
|
||||
*/
|
||||
void
|
||||
ecma_deref_object (const ecma_object_ptr_t& object_mp) /**< object */
|
||||
ecma_deref_object (ecma_object_t *object_p) /**< object */
|
||||
{
|
||||
JERRY_ASSERT(ecma_gc_get_object_refs (object_mp) > 0);
|
||||
|
||||
ecma_gc_set_object_refs (object_mp, ecma_gc_get_object_refs (object_mp) - 1);
|
||||
JERRY_ASSERT(ecma_gc_get_object_refs (object_p) > 0);
|
||||
ecma_gc_set_object_refs (object_p, ecma_gc_get_object_refs (object_p) - 1);
|
||||
} /* ecma_deref_object */
|
||||
|
||||
/**
|
||||
@@ -246,7 +238,7 @@ ecma_deref_object (const ecma_object_ptr_t& object_mp) /**< object */
|
||||
* is less than generation of object specified by obj_p.
|
||||
*/
|
||||
void
|
||||
ecma_gc_update_may_ref_younger_object_flag_by_value (const ecma_object_ptr_t& obj_mp, /**< object */
|
||||
ecma_gc_update_may_ref_younger_object_flag_by_value (ecma_object_t *obj_p, /**< object */
|
||||
const ecma_value_t& value) /**< value */
|
||||
{
|
||||
if (!ecma_is_value_object (value))
|
||||
@@ -254,26 +246,25 @@ ecma_gc_update_may_ref_younger_object_flag_by_value (const ecma_object_ptr_t& ob
|
||||
return;
|
||||
}
|
||||
|
||||
ecma_object_ptr_t ref_obj_p;
|
||||
ecma_get_object_from_value (ref_obj_p, value);
|
||||
JERRY_ASSERT(ref_obj_p.is_not_null ());
|
||||
ecma_object_t *ref_obj_p = ecma_get_object_from_value (value);
|
||||
JERRY_ASSERT(ref_obj_p != NULL);
|
||||
|
||||
ecma_gc_update_may_ref_younger_object_flag_by_object (obj_mp, ref_obj_p);
|
||||
ecma_gc_update_may_ref_younger_object_flag_by_object (obj_p, ref_obj_p);
|
||||
} /* ecma_gc_update_may_ref_younger_object_flag_by_value */
|
||||
|
||||
void
|
||||
ecma_gc_update_may_ref_younger_object_flag_by_object (const ecma_object_ptr_t& obj_mp, /**< object */
|
||||
const ecma_object_ptr_t& ref_obj_mp) /**< referenced object
|
||||
* or NULL */
|
||||
ecma_gc_update_may_ref_younger_object_flag_by_object (ecma_object_t *obj_p, /**< object */
|
||||
ecma_object_t *ref_obj_p) /**< referenced object
|
||||
or NULL */
|
||||
{
|
||||
if (ref_obj_mp.is_null ())
|
||||
if (ref_obj_p == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (ecma_gc_get_object_generation (ref_obj_mp) < ecma_gc_get_object_generation (obj_mp))
|
||||
if (ecma_gc_get_object_generation (ref_obj_p) < ecma_gc_get_object_generation (obj_p))
|
||||
{
|
||||
ecma_gc_set_object_may_ref_younger_objects (obj_mp, true);
|
||||
ecma_gc_set_object_may_ref_younger_objects (obj_p, true);
|
||||
}
|
||||
} /* ecma_gc_update_may_ref_younger_object_flag_by_object */
|
||||
|
||||
@@ -283,10 +274,7 @@ ecma_gc_update_may_ref_younger_object_flag_by_object (const ecma_object_ptr_t& o
|
||||
void
|
||||
ecma_gc_init (void)
|
||||
{
|
||||
for (uint32_t i = 0; i < ECMA_GC_GEN_COUNT; i++)
|
||||
{
|
||||
ecma_gc_objects_lists [i] = NULL;
|
||||
}
|
||||
__memset (ecma_gc_objects_lists, 0, sizeof (ecma_gc_objects_lists));
|
||||
} /* ecma_gc_init */
|
||||
|
||||
/**
|
||||
@@ -294,12 +282,12 @@ ecma_gc_init (void)
|
||||
* if referenced object's generation is less or equal to maximum_gen_to_traverse.
|
||||
*/
|
||||
void
|
||||
ecma_gc_mark (const ecma_object_ptr_t& object_p, /**< start object */
|
||||
ecma_gc_mark (ecma_object_t *object_p, /**< start object */
|
||||
ecma_gc_gen_t maximum_gen_to_traverse) /**< start recursive traverse
|
||||
if referenced object generation
|
||||
is less or equal to maximum_gen_to_traverse */
|
||||
{
|
||||
JERRY_ASSERT(object_p.is_not_null ());
|
||||
JERRY_ASSERT(object_p != NULL);
|
||||
|
||||
ecma_gc_set_object_visited (object_p, true);
|
||||
|
||||
@@ -308,9 +296,8 @@ ecma_gc_mark (const ecma_object_ptr_t& object_p, /**< start object */
|
||||
|
||||
if (ecma_is_lexical_environment (object_p))
|
||||
{
|
||||
ecma_object_ptr_t lex_env_p (ecma_pointer_t::is_linked_arg::not_linked);
|
||||
ecma_get_lex_env_outer_reference (lex_env_p, object_p);
|
||||
if (lex_env_p.is_not_null ())
|
||||
ecma_object_t *lex_env_p = ecma_get_lex_env_outer_reference (object_p);
|
||||
if (lex_env_p != NULL)
|
||||
{
|
||||
if (ecma_gc_get_object_generation (lex_env_p) <= maximum_gen_to_traverse)
|
||||
{
|
||||
@@ -328,8 +315,7 @@ ecma_gc_mark (const ecma_object_ptr_t& object_p, /**< start object */
|
||||
|
||||
if (ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND)
|
||||
{
|
||||
ecma_object_ptr_t binding_object_p;
|
||||
ecma_get_lex_env_binding_object (binding_object_p, object_p);
|
||||
ecma_object_t *binding_object_p = ecma_get_lex_env_binding_object (object_p);
|
||||
if (ecma_gc_get_object_generation (binding_object_p) <= maximum_gen_to_traverse)
|
||||
{
|
||||
if (!ecma_gc_is_object_visited (binding_object_p))
|
||||
@@ -348,9 +334,8 @@ ecma_gc_mark (const ecma_object_ptr_t& object_p, /**< start object */
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_object_ptr_t proto_p (ecma_pointer_t::is_linked_arg::not_linked);
|
||||
ecma_get_object_prototype (proto_p, object_p);
|
||||
if (proto_p.is_not_null ())
|
||||
ecma_object_t *proto_p = ecma_get_object_prototype (object_p);
|
||||
if (proto_p != NULL)
|
||||
{
|
||||
if (ecma_gc_get_object_generation (proto_p) <= maximum_gen_to_traverse)
|
||||
{
|
||||
@@ -380,13 +365,11 @@ ecma_gc_mark (const ecma_object_ptr_t& object_p, /**< start object */
|
||||
{
|
||||
case ECMA_PROPERTY_NAMEDDATA:
|
||||
{
|
||||
ecma_value_t value;
|
||||
ecma_get_named_data_property_value (value, property_p);
|
||||
ecma_value_t value = ecma_get_named_data_property_value (property_p);
|
||||
|
||||
if (ecma_is_value_object (value))
|
||||
{
|
||||
ecma_object_ptr_t value_obj_p;
|
||||
ecma_get_object_from_value (value_obj_p, value);
|
||||
ecma_object_t *value_obj_p = ecma_get_object_from_value (value);
|
||||
|
||||
if (ecma_gc_get_object_generation (value_obj_p) <= maximum_gen_to_traverse)
|
||||
{
|
||||
@@ -407,11 +390,12 @@ ecma_gc_mark (const ecma_object_ptr_t& object_p, /**< start object */
|
||||
|
||||
case ECMA_PROPERTY_NAMEDACCESSOR:
|
||||
{
|
||||
ecma_object_ptr_t getter_obj_p, setter_obj_p;
|
||||
getter_obj_p.unpack_from (property_p->u.named_accessor_property.get_p, true);
|
||||
setter_obj_p.unpack_from (property_p->u.named_accessor_property.set_p, true);
|
||||
ecma_object_t *getter_obj_p = ECMA_GET_POINTER (ecma_object_t,
|
||||
property_p->u.named_accessor_property.get_p);
|
||||
ecma_object_t *setter_obj_p = ECMA_GET_POINTER (ecma_object_t,
|
||||
property_p->u.named_accessor_property.set_p);
|
||||
|
||||
if (getter_obj_p.is_not_null ())
|
||||
if (getter_obj_p != NULL)
|
||||
{
|
||||
if (ecma_gc_get_object_generation (getter_obj_p) <= maximum_gen_to_traverse)
|
||||
{
|
||||
@@ -427,7 +411,7 @@ ecma_gc_mark (const ecma_object_ptr_t& object_p, /**< start object */
|
||||
}
|
||||
}
|
||||
|
||||
if (setter_obj_p.is_not_null ())
|
||||
if (setter_obj_p != NULL)
|
||||
{
|
||||
if (ecma_gc_get_object_generation (setter_obj_p) <= maximum_gen_to_traverse)
|
||||
{
|
||||
@@ -486,8 +470,7 @@ ecma_gc_mark (const ecma_object_ptr_t& object_p, /**< start object */
|
||||
case ECMA_INTERNAL_PROPERTY_SCOPE: /* a lexical environment */
|
||||
case ECMA_INTERNAL_PROPERTY_PARAMETERS_MAP: /* an object */
|
||||
{
|
||||
ecma_object_ptr_t obj_p;
|
||||
obj_p.unpack_from (property_value);
|
||||
ecma_object_t *obj_p = ECMA_GET_NON_NULL_POINTER(ecma_object_t, property_value);
|
||||
|
||||
if (ecma_gc_get_object_generation (obj_p) <= maximum_gen_to_traverse)
|
||||
{
|
||||
@@ -522,11 +505,11 @@ ecma_gc_mark (const ecma_object_ptr_t& object_p, /**< start object */
|
||||
* Free specified object
|
||||
*/
|
||||
void
|
||||
ecma_gc_sweep (ecma_object_ptr_t &object_p) /**< object to free */
|
||||
ecma_gc_sweep (ecma_object_t *object_p) /**< object to free */
|
||||
{
|
||||
JERRY_ASSERT (object_p.is_not_null ()
|
||||
&& !ecma_gc_is_object_visited (object_p)
|
||||
&& ecma_gc_get_object_refs (object_p) == 0);
|
||||
JERRY_ASSERT(object_p != NULL
|
||||
&& !ecma_gc_is_object_visited (object_p)
|
||||
&& ecma_gc_get_object_refs (object_p) == 0);
|
||||
|
||||
if (!ecma_is_lexical_environment (object_p) ||
|
||||
ecma_get_lex_env_type (object_p) != ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND)
|
||||
@@ -556,10 +539,9 @@ ecma_gc_run (ecma_gc_gen_t max_gen_to_collect) /**< maximum generation to run co
|
||||
/* clearing visited flags for all objects of generations to be processed */
|
||||
for (ecma_gc_gen_t gen_id = ECMA_GC_GEN_0; gen_id <= max_gen_to_collect; gen_id = (ecma_gc_gen_t) (gen_id + 1))
|
||||
{
|
||||
ecma_object_ptr_t obj_iter_p, obj_iter_next_p;
|
||||
for (obj_iter_p = ecma_gc_objects_lists[ gen_id ];
|
||||
obj_iter_p.is_not_null ();
|
||||
ecma_gc_get_object_next (obj_iter_next_p, obj_iter_p), obj_iter_p = obj_iter_next_p)
|
||||
for (ecma_object_t *obj_iter_p = ecma_gc_objects_lists[ gen_id ];
|
||||
obj_iter_p != NULL;
|
||||
obj_iter_p = ecma_gc_get_object_next (obj_iter_p))
|
||||
{
|
||||
ecma_gc_set_object_visited (obj_iter_p, false);
|
||||
}
|
||||
@@ -569,11 +551,9 @@ ecma_gc_run (ecma_gc_gen_t max_gen_to_collect) /**< maximum generation to run co
|
||||
* start recursive marking traverse from the object */
|
||||
for (ecma_gc_gen_t gen_id = ECMA_GC_GEN_0; gen_id <= max_gen_to_collect; gen_id = (ecma_gc_gen_t) (gen_id + 1))
|
||||
{
|
||||
ecma_object_ptr_t obj_iter_p, obj_iter_next_p;
|
||||
|
||||
for (obj_iter_p = ecma_gc_objects_lists[ gen_id ];
|
||||
obj_iter_p.is_not_null ();
|
||||
ecma_gc_get_object_next (obj_iter_next_p, obj_iter_p), obj_iter_p = obj_iter_next_p)
|
||||
for (ecma_object_t *obj_iter_p = ecma_gc_objects_lists[ gen_id ];
|
||||
obj_iter_p != NULL;
|
||||
obj_iter_p = ecma_gc_get_object_next (obj_iter_p))
|
||||
{
|
||||
if (ecma_gc_get_object_refs (obj_iter_p) > 0
|
||||
&& !ecma_gc_is_object_visited (obj_iter_p))
|
||||
@@ -591,13 +571,11 @@ ecma_gc_run (ecma_gc_gen_t max_gen_to_collect) /**< maximum generation to run co
|
||||
{
|
||||
for (int32_t reg_index = 0; reg_index < frame_iter_p->regs_number; reg_index++)
|
||||
{
|
||||
ecma_value_t reg_value;
|
||||
ecma_stack_frame_get_reg_value (reg_value, frame_iter_p, reg_index);
|
||||
ecma_value_t reg_value = ecma_stack_frame_get_reg_value (frame_iter_p, reg_index);
|
||||
|
||||
if (ecma_is_value_object (reg_value))
|
||||
{
|
||||
ecma_object_ptr_t obj_p;
|
||||
ecma_get_object_from_value (obj_p, reg_value);
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (reg_value);
|
||||
|
||||
if (!ecma_gc_is_object_visited (obj_p))
|
||||
{
|
||||
@@ -614,11 +592,9 @@ ecma_gc_run (ecma_gc_gen_t max_gen_to_collect) /**< maximum generation to run co
|
||||
gen_id < ECMA_GC_GEN_COUNT;
|
||||
gen_id = (ecma_gc_gen_t) (gen_id + 1))
|
||||
{
|
||||
ecma_object_ptr_t obj_iter_p, obj_iter_next_p;
|
||||
|
||||
for (obj_iter_p = ecma_gc_objects_lists[ gen_id ];
|
||||
obj_iter_p.is_not_null ();
|
||||
ecma_gc_get_object_next (obj_iter_next_p, obj_iter_p), obj_iter_p = obj_iter_next_p)
|
||||
for (ecma_object_t *obj_iter_p = ecma_gc_objects_lists[ gen_id ];
|
||||
obj_iter_p != NULL;
|
||||
obj_iter_p = ecma_gc_get_object_next (obj_iter_p))
|
||||
{
|
||||
if (ecma_gc_is_object_may_ref_younger_objects (obj_iter_p))
|
||||
{
|
||||
@@ -636,31 +612,33 @@ ecma_gc_run (ecma_gc_gen_t max_gen_to_collect) /**< maximum generation to run co
|
||||
}
|
||||
|
||||
JERRY_ASSERT (max_gen_to_collect <= ECMA_GC_GEN_COUNT);
|
||||
ecma_object_ptr_t gen_last_obj_p[ ECMA_GC_GEN_COUNT ];
|
||||
ecma_object_t *gen_last_obj_p[ ECMA_GC_GEN_COUNT ];
|
||||
#ifndef JERRY_NDEBUG
|
||||
__memset (gen_last_obj_p, 0, sizeof (gen_last_obj_p));
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
|
||||
for (ecma_gc_gen_t gen_id = ECMA_GC_GEN_0; gen_id <= max_gen_to_collect; gen_id = (ecma_gc_gen_t) (gen_id + 1))
|
||||
{
|
||||
ecma_object_ptr_t obj_prev_p;
|
||||
ecma_object_t *obj_prev_p = NULL;
|
||||
|
||||
ecma_object_ptr_t obj_iter_p, obj_iter_next_p;
|
||||
|
||||
for (obj_iter_p = ecma_gc_objects_lists[ gen_id ];
|
||||
obj_iter_p.is_not_null ();
|
||||
obj_iter_p = obj_iter_next_p)
|
||||
for (ecma_object_t *obj_iter_p = ecma_gc_objects_lists[ gen_id ],
|
||||
*obj_next_p;
|
||||
obj_iter_p != NULL;
|
||||
obj_iter_p = obj_next_p)
|
||||
{
|
||||
ecma_gc_get_object_next (obj_iter_next_p, obj_iter_p);
|
||||
obj_next_p = ecma_gc_get_object_next (obj_iter_p);
|
||||
|
||||
if (!ecma_gc_is_object_visited (obj_iter_p))
|
||||
{
|
||||
ecma_gc_sweep (obj_iter_p);
|
||||
|
||||
if (likely (obj_prev_p.is_not_null ()))
|
||||
if (likely (obj_prev_p != NULL))
|
||||
{
|
||||
ecma_gc_set_object_next (obj_prev_p, obj_iter_next_p);
|
||||
ecma_gc_set_object_next (obj_prev_p, obj_next_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_gc_objects_lists[ gen_id ] = (ecma_object_t*) obj_iter_next_p;
|
||||
ecma_gc_objects_lists[ gen_id ] = obj_next_p;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -686,11 +664,9 @@ ecma_gc_run (ecma_gc_gen_t max_gen_to_collect) /**< maximum generation to run co
|
||||
}
|
||||
|
||||
/* promoting to next generation */
|
||||
if (gen_last_obj_p[ gen_to_promote ].is_not_null ())
|
||||
if (gen_last_obj_p[ gen_to_promote ] != NULL)
|
||||
{
|
||||
ecma_object_ptr_t next_object_mp;
|
||||
next_object_mp = ecma_gc_objects_lists[ gen_to_promote + 1 ];
|
||||
ecma_gc_set_object_next (gen_last_obj_p [gen_to_promote], next_object_mp);
|
||||
ecma_gc_set_object_next (gen_last_obj_p [gen_to_promote], ecma_gc_objects_lists[ gen_to_promote + 1 ]);
|
||||
ecma_gc_objects_lists[ gen_to_promote + 1 ] = ecma_gc_objects_lists[ gen_to_promote ];
|
||||
ecma_gc_objects_lists[ gen_to_promote ] = NULL;
|
||||
}
|
||||
@@ -708,10 +684,9 @@ ecma_gc_run (ecma_gc_gen_t max_gen_to_collect) /**< maximum generation to run co
|
||||
gen_id < ECMA_GC_GEN_COUNT;
|
||||
gen_id = (ecma_gc_gen_t) (gen_id + 1))
|
||||
{
|
||||
ecma_object_ptr_t obj_iter_p, obj_iter_next_p;
|
||||
for (obj_iter_p = ecma_gc_objects_lists[ gen_id ];
|
||||
obj_iter_p.is_not_null ();
|
||||
ecma_gc_get_object_next (obj_iter_next_p, obj_iter_p), obj_iter_p = obj_iter_next_p)
|
||||
for (ecma_object_t *obj_iter_p = ecma_gc_objects_lists[ gen_id ];
|
||||
obj_iter_p != NULL;
|
||||
obj_iter_p = ecma_gc_get_object_next (obj_iter_p))
|
||||
{
|
||||
JERRY_ASSERT(ecma_gc_get_object_generation (obj_iter_p) == gen_id);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#define ECMA_GC_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-value.h"
|
||||
#include "mem-allocator.h"
|
||||
|
||||
/**
|
||||
@@ -39,15 +38,11 @@ typedef enum
|
||||
} ecma_gc_gen_t;
|
||||
|
||||
extern void ecma_gc_init (void);
|
||||
extern void ecma_init_gc_info (const ecma_object_ptr_t& object_p);
|
||||
extern void ecma_ref_object (const ecma_object_ptr_t& object_p);
|
||||
extern void ecma_deref_object (const ecma_object_ptr_t& object_p);
|
||||
extern void
|
||||
ecma_gc_update_may_ref_younger_object_flag_by_value (const ecma_object_ptr_t& obj_p,
|
||||
const ecma_value_t& value);
|
||||
extern void
|
||||
ecma_gc_update_may_ref_younger_object_flag_by_object (const ecma_object_ptr_t& obj_p,
|
||||
const ecma_object_ptr_t& ref_obj_p);
|
||||
extern void ecma_init_gc_info (ecma_object_t *object_p);
|
||||
extern void ecma_ref_object (ecma_object_t *object_p);
|
||||
extern void ecma_deref_object (ecma_object_t *object_p);
|
||||
extern void ecma_gc_update_may_ref_younger_object_flag_by_value (ecma_object_t *obj_p, const ecma_value_t& value);
|
||||
extern void ecma_gc_update_may_ref_younger_object_flag_by_object (ecma_object_t *obj_p, ecma_object_t *ref_obj_p);
|
||||
extern void ecma_gc_run (ecma_gc_gen_t max_gen_to_collect);
|
||||
extern void ecma_try_to_give_back_some_memory (mem_try_give_memory_back_severity_t severity);
|
||||
|
||||
|
||||
@@ -24,10 +24,31 @@
|
||||
#define JERRY_ECMA_GLOBALS_H
|
||||
|
||||
#include "config.h"
|
||||
#include "ecma-compressed-pointers.h"
|
||||
#include "globals.h"
|
||||
#include "mem-allocator.h"
|
||||
|
||||
/** \addtogroup compressedpointer Compressed pointer
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ecma-pointer field is used to calculate ecma-value's address.
|
||||
*
|
||||
* Ecma-pointer contains value's shifted offset from common Ecma-pointers' base.
|
||||
* The offset is shifted right by MEM_ALIGNMENT_LOG.
|
||||
* Least significant MEM_ALIGNMENT_LOG bits of non-shifted offset are zeroes.
|
||||
*/
|
||||
#define ECMA_POINTER_FIELD_WIDTH MEM_COMPRESSED_POINTER_WIDTH
|
||||
|
||||
/**
|
||||
* The NULL value for compressed pointers
|
||||
*/
|
||||
#define ECMA_NULL_POINTER MEM_COMPRESSED_POINTER_NULL
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Type of ecma-value
|
||||
*/
|
||||
@@ -80,6 +101,8 @@ typedef enum
|
||||
{
|
||||
ECMA_COMPLETION_TYPE_NORMAL, /**< default block completion */
|
||||
ECMA_COMPLETION_TYPE_RETURN, /**< block completed with return */
|
||||
ECMA_COMPLETION_TYPE_BREAK, /**< block completed with break */
|
||||
ECMA_COMPLETION_TYPE_CONTINUE, /**< block completed with continue */
|
||||
#ifdef CONFIG_ECMA_EXCEPTION_SUPPORT
|
||||
ECMA_COMPLETION_TYPE_THROW, /**< block completed with throw */
|
||||
#endif /* CONFIG_ECMA_EXCEPTION_SUPPORT */
|
||||
@@ -90,11 +113,11 @@ typedef enum
|
||||
} ecma_completion_type_t;
|
||||
|
||||
/**
|
||||
* Description of an packed ecma-value representation
|
||||
* Description of an ecma-value
|
||||
*
|
||||
* Bit-field structure: type (2) | value (ECMA_POINTER_FIELD_WIDTH)
|
||||
*/
|
||||
typedef uint16_t ecma_value_packed_t;
|
||||
typedef uint16_t ecma_value_t;
|
||||
|
||||
/**
|
||||
* Value type (ecma_type_t)
|
||||
@@ -110,10 +133,52 @@ typedef uint16_t ecma_value_packed_t;
|
||||
#define ECMA_VALUE_VALUE_WIDTH (ECMA_POINTER_FIELD_WIDTH)
|
||||
|
||||
/**
|
||||
* ecma_value_packed_t size
|
||||
* ecma_value_t size
|
||||
*/
|
||||
#define ECMA_VALUE_SIZE (ECMA_VALUE_VALUE_POS + ECMA_VALUE_VALUE_WIDTH)
|
||||
|
||||
/**
|
||||
* Description of a block completion value
|
||||
*
|
||||
* See also: ECMA-262 v5, 8.9.
|
||||
*
|
||||
* value (16)
|
||||
* Bit-field structure: type (8) | padding (8) <
|
||||
* label_desc_cp (16)
|
||||
*/
|
||||
typedef uint32_t ecma_completion_value_t;
|
||||
|
||||
/**
|
||||
* Type (ecma_completion_type_t)
|
||||
*/
|
||||
#define ECMA_COMPLETION_VALUE_TYPE_POS (0)
|
||||
#define ECMA_COMPLETION_VALUE_TYPE_WIDTH (8)
|
||||
|
||||
/**
|
||||
* Padding (1 byte)
|
||||
*/
|
||||
#define ECMA_COMPLETION_VALUE_PADDING_WIDTH (8)
|
||||
|
||||
/**
|
||||
* Value
|
||||
*
|
||||
* Used for normal, return, throw and exit completion types.
|
||||
*/
|
||||
#define ECMA_COMPLETION_VALUE_VALUE_POS (ECMA_COMPLETION_VALUE_TYPE_POS + \
|
||||
ECMA_COMPLETION_VALUE_TYPE_WIDTH + \
|
||||
ECMA_COMPLETION_VALUE_PADDING_WIDTH)
|
||||
#define ECMA_COMPLETION_VALUE_VALUE_WIDTH (ECMA_VALUE_SIZE)
|
||||
|
||||
/**
|
||||
* Label
|
||||
*
|
||||
* Used for break and continue completion types.
|
||||
*/
|
||||
#define ECMA_COMPLETION_VALUE_LABEL_DESC_CP_POS (ECMA_COMPLETION_VALUE_TYPE_POS + \
|
||||
ECMA_COMPLETION_VALUE_TYPE_WIDTH + \
|
||||
ECMA_COMPLETION_VALUE_PADDING_WIDTH)
|
||||
#define ECMA_COMPLETION_VALUE_LABEL_DESC_CP_WIDTH (ECMA_POINTER_FIELD_WIDTH)
|
||||
|
||||
/**
|
||||
* Label
|
||||
*
|
||||
@@ -239,7 +304,7 @@ typedef struct ecma_property_t
|
||||
unsigned int is_lcached : 1;
|
||||
|
||||
/** Value */
|
||||
ecma_value_packed_t value;
|
||||
ecma_value_t value;
|
||||
} named_data_property;
|
||||
|
||||
/** Description of named accessor property */
|
||||
@@ -466,7 +531,7 @@ typedef struct
|
||||
unsigned int is_configurable_defined : 1;
|
||||
|
||||
/** [[Value]] */
|
||||
ecma_value_packed_t value;
|
||||
ecma_value_t value;
|
||||
|
||||
/** [[Get]] */
|
||||
ecma_object_t* get_p;
|
||||
@@ -748,168 +813,6 @@ typedef struct
|
||||
} u;
|
||||
} ecma_string_t;
|
||||
|
||||
/** \addtogroup ecmamanagedpointers ECMA managed on-stack pointers
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* ECMA managed on-stack pointer
|
||||
*/
|
||||
class ecma_pointer_t
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Argument specifying should the pointer
|
||||
* be linked into managed pointers list
|
||||
*/
|
||||
enum class is_linked_arg
|
||||
{
|
||||
linked, /**< perform link */
|
||||
not_linked /**< do not perform link */
|
||||
};
|
||||
|
||||
/* Constructors */
|
||||
__attribute_always_inline__
|
||||
ecma_pointer_t () : ecma_pointer_t (is_linked_arg::linked) { }
|
||||
|
||||
__attribute_always_inline__
|
||||
ecma_pointer_t (is_linked_arg is_linked) /**< should the pointer
|
||||
* be linked into managed
|
||||
* pointers list? */
|
||||
: _ptr (NULL)
|
||||
{
|
||||
if (is_linked == is_linked_arg::linked)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
||||
ecma_pointer_t (const ecma_pointer_t&) = delete;
|
||||
ecma_pointer_t (ecma_pointer_t&) = delete;
|
||||
ecma_pointer_t (ecma_pointer_t&&) = delete;
|
||||
|
||||
/* Destructor */
|
||||
~ecma_pointer_t ()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
/* Getter */
|
||||
template<typename T>
|
||||
__attribute_always_inline__
|
||||
explicit operator T* () const
|
||||
{
|
||||
return static_cast<T*> (_ptr);
|
||||
}
|
||||
|
||||
/* Assignment operators */
|
||||
template<typename T>
|
||||
__attribute_always_inline__
|
||||
ecma_pointer_t& operator = (T* ptr) /**< new pointer value */
|
||||
{
|
||||
_ptr = ptr;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
__attribute_always_inline__
|
||||
ecma_pointer_t& operator = (const T& value) /**< value to assign to variable
|
||||
* under the pointer */
|
||||
{
|
||||
*static_cast<T*> (_ptr) = value;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
__attribute_always_inline__
|
||||
ecma_pointer_t& operator = (const ecma_pointer_t& ptr) /**< managed pointer
|
||||
* to take value from */
|
||||
{
|
||||
_ptr = ptr._ptr;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
__attribute_always_inline__
|
||||
ecma_pointer_t& operator = (ecma_pointer_t& ptr) /**< managed pointer
|
||||
* to take value from */
|
||||
{
|
||||
const ecma_pointer_t &ptr_const = ptr;
|
||||
*this = ptr_const;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
ecma_pointer_t& operator = (ecma_pointer_t &&) = delete;
|
||||
|
||||
/* Comparison */
|
||||
__attribute_always_inline__
|
||||
bool operator == (const ecma_pointer_t &ptr) const /**< raw pointer */
|
||||
{
|
||||
return (_ptr == ptr._ptr);
|
||||
}
|
||||
|
||||
__attribute_always_inline__
|
||||
bool is_null (void) const
|
||||
{
|
||||
return (_ptr == NULL);
|
||||
}
|
||||
|
||||
__attribute_always_inline__
|
||||
bool is_not_null (void) const
|
||||
{
|
||||
return (_ptr != NULL);
|
||||
}
|
||||
|
||||
/* Packing to compressed pointer */
|
||||
__attribute_always_inline__
|
||||
void pack_to (uintptr_t& compressed_pointer, /**< reference to compressed pointer */
|
||||
bool may_be_null = false) const /**< flag indicating the pointer can be NULL */
|
||||
{
|
||||
void *ptr = _ptr;
|
||||
|
||||
if (may_be_null)
|
||||
{
|
||||
ECMA_SET_POINTER (compressed_pointer, ptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
ECMA_SET_NON_NULL_POINTER (compressed_pointer, ptr);
|
||||
}
|
||||
}
|
||||
|
||||
/* Unpacking from compressed pointer */
|
||||
__attribute_always_inline__
|
||||
void unpack_from (uintptr_t compressed_pointer, /**< compressed pointer */
|
||||
bool may_be_null = false) /**< flag indicating the pointer can be NULL */
|
||||
{
|
||||
if (may_be_null)
|
||||
{
|
||||
_ptr = ECMA_GET_POINTER (void, compressed_pointer);
|
||||
}
|
||||
else
|
||||
{
|
||||
_ptr = ECMA_GET_NON_NULL_POINTER (void, compressed_pointer);
|
||||
}
|
||||
}
|
||||
protected: /* accessible to ecma_pointer_t */
|
||||
void *_ptr; /* pointer storage */
|
||||
};
|
||||
|
||||
#define ECMA_DECLARE_PTR_TYPE_AND_POINTER_OPERATORS_FOR(type_name) \
|
||||
typedef ecma_pointer_t ecma_ ## type_name ## _ptr_t; \
|
||||
template ecma_pointer_t::operator ecma_ ## type_name ## _t * () const; \
|
||||
template ecma_pointer_t& ecma_pointer_t::operator = (ecma_ ## type_name ## _t *); \
|
||||
template ecma_pointer_t& ecma_pointer_t::operator = (const ecma_ ## type_name ## _t &);
|
||||
|
||||
/**
|
||||
* ECMA managed pointers' operators explicit instantiation
|
||||
*/
|
||||
ECMA_DECLARE_PTR_TYPE_AND_POINTER_OPERATORS_FOR (number)
|
||||
ECMA_DECLARE_PTR_TYPE_AND_POINTER_OPERATORS_FOR (string)
|
||||
ECMA_DECLARE_PTR_TYPE_AND_POINTER_OPERATORS_FOR (object)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,979 @@
|
||||
/* Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmahelpers Helpers for operations with ECMA data types
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "globals.h"
|
||||
#include "jrt-bit-fields.h"
|
||||
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_value_t) * JERRY_BITSINBYTE == ECMA_VALUE_SIZE);
|
||||
|
||||
/**
|
||||
* Get type field of ecma-value
|
||||
*
|
||||
* @return type field
|
||||
*/
|
||||
static ecma_type_t __attribute_pure__
|
||||
ecma_get_value_type_field (const ecma_value_t& value) /**< ecma-value */
|
||||
{
|
||||
return (ecma_type_t) jrt_extract_bit_field (value,
|
||||
ECMA_VALUE_TYPE_POS,
|
||||
ECMA_VALUE_TYPE_WIDTH);
|
||||
} /* ecma_get_value_type_field */
|
||||
|
||||
/**
|
||||
* Get value field of ecma-value
|
||||
*
|
||||
* @return value field
|
||||
*/
|
||||
static uintptr_t __attribute_pure__
|
||||
ecma_get_value_value_field (const ecma_value_t& value) /**< ecma-value */
|
||||
{
|
||||
return (uintptr_t) jrt_extract_bit_field (value,
|
||||
ECMA_VALUE_VALUE_POS,
|
||||
ECMA_VALUE_VALUE_WIDTH);
|
||||
} /* ecma_get_value_value_field */
|
||||
|
||||
/**
|
||||
* Set type field of ecma-value
|
||||
*
|
||||
* @return ecma-value with updated field
|
||||
*/
|
||||
static ecma_value_t __attribute_pure__
|
||||
ecma_set_value_type_field (const ecma_value_t& value, /**< ecma-value to set field in */
|
||||
ecma_type_t type_field) /**< new field value */
|
||||
{
|
||||
return (ecma_value_t) jrt_set_bit_field_value (value,
|
||||
type_field,
|
||||
ECMA_VALUE_TYPE_POS,
|
||||
ECMA_VALUE_TYPE_WIDTH);
|
||||
} /* ecma_set_value_type_field */
|
||||
|
||||
/**
|
||||
* Set value field of ecma-value
|
||||
*
|
||||
* @return ecma-value with updated field
|
||||
*/
|
||||
static ecma_value_t __attribute_pure__
|
||||
ecma_set_value_value_field (const ecma_value_t& value, /**< ecma-value to set field in */
|
||||
uintptr_t value_field) /**< new field value */
|
||||
{
|
||||
return (ecma_value_t) jrt_set_bit_field_value (value,
|
||||
value_field,
|
||||
ECMA_VALUE_VALUE_POS,
|
||||
ECMA_VALUE_VALUE_WIDTH);
|
||||
} /* ecma_set_value_value_field */
|
||||
|
||||
/**
|
||||
* Check if the value is empty.
|
||||
*
|
||||
* @return true - if the value contains implementation-defined empty simple value,
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool __attribute_pure__ __attribute_always_inline__
|
||||
ecma_is_value_empty (const ecma_value_t& value) /**< ecma-value */
|
||||
{
|
||||
return (ecma_get_value_type_field (value) == ECMA_TYPE_SIMPLE
|
||||
&& ecma_get_value_value_field (value) == ECMA_SIMPLE_VALUE_EMPTY);
|
||||
} /* ecma_is_value_empty */
|
||||
|
||||
/**
|
||||
* Check if the value is undefined.
|
||||
*
|
||||
* @return true - if the value contains ecma-undefined simple value,
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool __attribute_pure__ __attribute_always_inline__
|
||||
ecma_is_value_undefined (const ecma_value_t& value) /**< ecma-value */
|
||||
{
|
||||
return (ecma_get_value_type_field (value) == ECMA_TYPE_SIMPLE
|
||||
&& ecma_get_value_value_field (value) == ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||
} /* ecma_is_value_undefined */
|
||||
|
||||
/**
|
||||
* Check if the value is null.
|
||||
*
|
||||
* @return true - if the value contains ecma-null simple value,
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool __attribute_pure__ __attribute_always_inline__
|
||||
ecma_is_value_null (const ecma_value_t& value) /**< ecma-value */
|
||||
{
|
||||
return (ecma_get_value_type_field (value) == ECMA_TYPE_SIMPLE
|
||||
&& ecma_get_value_value_field (value) == ECMA_SIMPLE_VALUE_NULL);
|
||||
} /* ecma_is_value_null */
|
||||
|
||||
/**
|
||||
* Check if the value is boolean.
|
||||
*
|
||||
* @return true - if the value contains ecma-true or ecma-false simple values,
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool __attribute_pure__ __attribute_always_inline__
|
||||
ecma_is_value_boolean (const ecma_value_t& value) /**< ecma-value */
|
||||
{
|
||||
return (ecma_get_value_type_field (value) == ECMA_TYPE_SIMPLE
|
||||
&& (ecma_get_value_value_field (value) == ECMA_SIMPLE_VALUE_TRUE
|
||||
|| ecma_get_value_value_field (value) == ECMA_SIMPLE_VALUE_FALSE));
|
||||
} /* ecma_is_value_boolean */
|
||||
|
||||
/**
|
||||
* Check if the value is true.
|
||||
*
|
||||
* Warning:
|
||||
* value must be boolean
|
||||
*
|
||||
* @return true - if the value contains ecma-true simple value,
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool __attribute_pure__ __attribute_always_inline__
|
||||
ecma_is_value_true (const ecma_value_t& value) /**< ecma-value */
|
||||
{
|
||||
return (ecma_get_value_type_field (value) == ECMA_TYPE_SIMPLE
|
||||
&& ecma_get_value_value_field (value) == ECMA_SIMPLE_VALUE_TRUE);
|
||||
} /* ecma_is_value_true */
|
||||
|
||||
/**
|
||||
* Check if the value is ecma-number.
|
||||
*
|
||||
* @return true - if the value contains ecma-number value,
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool __attribute_pure__ __attribute_always_inline__
|
||||
ecma_is_value_number (const ecma_value_t& value) /**< ecma-value */
|
||||
{
|
||||
return (ecma_get_value_type_field (value) == ECMA_TYPE_NUMBER);
|
||||
} /* ecma_is_value_number */
|
||||
|
||||
/**
|
||||
* Check if the value is ecma-string.
|
||||
*
|
||||
* @return true - if the value contains ecma-string value,
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool __attribute_pure__ __attribute_always_inline__
|
||||
ecma_is_value_string (const ecma_value_t& value) /**< ecma-value */
|
||||
{
|
||||
return (ecma_get_value_type_field (value) == ECMA_TYPE_STRING);
|
||||
} /* ecma_is_value_string */
|
||||
|
||||
/**
|
||||
* Check if the value is object.
|
||||
*
|
||||
* @return true - if the value contains object value,
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool __attribute_pure__ __attribute_always_inline__
|
||||
ecma_is_value_object (const ecma_value_t& value) /**< ecma-value */
|
||||
{
|
||||
return (ecma_get_value_type_field (value) == ECMA_TYPE_OBJECT);
|
||||
} /* ecma_is_value_object */
|
||||
|
||||
/**
|
||||
* Debug assertion that specified value's type is one of ECMA-defined
|
||||
* script-visible types, i.e.: undefined, null, boolean, number, string, object.
|
||||
*/
|
||||
void
|
||||
ecma_check_value_type_is_spec_defined (const ecma_value_t& value) /**< ecma-value */
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_undefined (value)
|
||||
|| ecma_is_value_null (value)
|
||||
|| ecma_is_value_boolean (value)
|
||||
|| ecma_is_value_number (value)
|
||||
|| ecma_is_value_string (value)
|
||||
|| ecma_is_value_object (value));
|
||||
} /* ecma_check_value_type_is_spec_defined */
|
||||
|
||||
/**
|
||||
* Simple value constructor
|
||||
*/
|
||||
ecma_value_t __attribute_const__ __attribute_always_inline__
|
||||
ecma_make_simple_value (ecma_simple_value_t value) /**< simple value */
|
||||
{
|
||||
ecma_value_t ret_value = 0;
|
||||
|
||||
ret_value = ecma_set_value_type_field (ret_value, ECMA_TYPE_SIMPLE);
|
||||
ret_value = ecma_set_value_value_field (ret_value, value);
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_make_simple_value */
|
||||
|
||||
/**
|
||||
* Number value constructor
|
||||
*/
|
||||
ecma_value_t __attribute_const__
|
||||
ecma_make_number_value (ecma_number_t* num_p) /**< number to reference in value */
|
||||
{
|
||||
JERRY_ASSERT(num_p != NULL);
|
||||
|
||||
uint16_t num_cp;
|
||||
ECMA_SET_NON_NULL_POINTER (num_cp, num_p);
|
||||
|
||||
ecma_value_t ret_value = 0;
|
||||
|
||||
ret_value = ecma_set_value_type_field (ret_value, ECMA_TYPE_NUMBER);
|
||||
ret_value = ecma_set_value_value_field (ret_value, num_cp);
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_make_number_value */
|
||||
|
||||
/**
|
||||
* String value constructor
|
||||
*/
|
||||
ecma_value_t __attribute_const__
|
||||
ecma_make_string_value (ecma_string_t* ecma_string_p) /**< string to reference in value */
|
||||
{
|
||||
JERRY_ASSERT(ecma_string_p != NULL);
|
||||
|
||||
uint16_t string_cp;
|
||||
ECMA_SET_NON_NULL_POINTER (string_cp, ecma_string_p);
|
||||
|
||||
ecma_value_t ret_value = 0;
|
||||
|
||||
ret_value = ecma_set_value_type_field (ret_value, ECMA_TYPE_STRING);
|
||||
ret_value = ecma_set_value_value_field (ret_value, string_cp);
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_make_string_value */
|
||||
|
||||
/**
|
||||
* object value constructor
|
||||
*/
|
||||
ecma_value_t __attribute_const__
|
||||
ecma_make_object_value (ecma_object_t* object_p) /**< object to reference in value */
|
||||
{
|
||||
JERRY_ASSERT(object_p != NULL);
|
||||
|
||||
uint16_t object_cp;
|
||||
ECMA_SET_NON_NULL_POINTER (object_cp, object_p);
|
||||
|
||||
ecma_value_t ret_value = 0;
|
||||
|
||||
ret_value = ecma_set_value_type_field (ret_value, ECMA_TYPE_OBJECT);
|
||||
ret_value = ecma_set_value_value_field (ret_value, object_cp);
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_make_object_value */
|
||||
|
||||
/**
|
||||
* Get pointer to ecma-number from ecma-value
|
||||
*
|
||||
* @return the pointer
|
||||
*/
|
||||
ecma_number_t* __attribute_pure__
|
||||
ecma_get_number_from_value (const ecma_value_t& value) /**< ecma-value */
|
||||
{
|
||||
JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_NUMBER);
|
||||
|
||||
return ECMA_GET_NON_NULL_POINTER (ecma_number_t,
|
||||
ecma_get_value_value_field (value));
|
||||
} /* ecma_get_number_from_value */
|
||||
|
||||
/**
|
||||
* Get pointer to ecma-string from ecma-value
|
||||
*
|
||||
* @return the pointer
|
||||
*/
|
||||
ecma_string_t* __attribute_pure__
|
||||
ecma_get_string_from_value (const ecma_value_t& value) /**< ecma-value */
|
||||
{
|
||||
JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_STRING);
|
||||
|
||||
return ECMA_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
ecma_get_value_value_field (value));
|
||||
} /* ecma_get_string_from_value */
|
||||
|
||||
/**
|
||||
* Get pointer to ecma-object from ecma-value
|
||||
*
|
||||
* @return the pointer
|
||||
*/
|
||||
ecma_object_t* __attribute_pure__
|
||||
ecma_get_object_from_value (const ecma_value_t& value) /**< ecma-value */
|
||||
{
|
||||
JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_OBJECT);
|
||||
|
||||
return ECMA_GET_NON_NULL_POINTER (ecma_object_t,
|
||||
ecma_get_value_value_field (value));
|
||||
} /* ecma_get_object_from_value */
|
||||
|
||||
/**
|
||||
* Copy ecma-value.
|
||||
*
|
||||
* Note:
|
||||
* Operation algorithm.
|
||||
* switch (valuetype)
|
||||
* case simple:
|
||||
* simply return the value as it was passed;
|
||||
* case number:
|
||||
* copy the number
|
||||
* and return new ecma-value
|
||||
* pointing to copy of the number;
|
||||
* case string:
|
||||
* increase reference counter of the string
|
||||
* and return the value as it was passed.
|
||||
* case object;
|
||||
* increase reference counter of the object if do_ref_if_object is true
|
||||
* and return the value as it was passed.
|
||||
*
|
||||
* @return See note.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_copy_value (const ecma_value_t& value, /**< ecma-value */
|
||||
bool do_ref_if_object) /**< if the value is object value,
|
||||
increment reference counter of the object */
|
||||
{
|
||||
ecma_value_t value_copy = 0;
|
||||
|
||||
switch (ecma_get_value_type_field (value))
|
||||
{
|
||||
case ECMA_TYPE_SIMPLE:
|
||||
{
|
||||
value_copy = value;
|
||||
|
||||
break;
|
||||
}
|
||||
case ECMA_TYPE_NUMBER:
|
||||
{
|
||||
ecma_number_t *num_p = ecma_get_number_from_value (value);
|
||||
|
||||
ecma_number_t *number_copy_p = ecma_alloc_number ();
|
||||
*number_copy_p = *num_p;
|
||||
|
||||
value_copy = ecma_make_number_value (number_copy_p);
|
||||
|
||||
break;
|
||||
}
|
||||
case ECMA_TYPE_STRING:
|
||||
{
|
||||
ecma_string_t *string_p = ecma_get_string_from_value (value);
|
||||
|
||||
string_p = ecma_copy_or_ref_ecma_string (string_p);
|
||||
|
||||
value_copy = ecma_make_string_value (string_p);
|
||||
|
||||
break;
|
||||
}
|
||||
case ECMA_TYPE_OBJECT:
|
||||
{
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (value);
|
||||
|
||||
if (do_ref_if_object)
|
||||
{
|
||||
ecma_ref_object (obj_p);
|
||||
}
|
||||
|
||||
value_copy = value;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return value_copy;
|
||||
} /* ecma_copy_value */
|
||||
|
||||
/**
|
||||
* Free the ecma-value
|
||||
*/
|
||||
void
|
||||
ecma_free_value (ecma_value_t& value, /**< value description */
|
||||
bool do_deref_if_object) /**< if the value is object value,
|
||||
decrement reference counter of the object */
|
||||
{
|
||||
switch (ecma_get_value_type_field (value))
|
||||
{
|
||||
case ECMA_TYPE_SIMPLE:
|
||||
{
|
||||
/* doesn't hold additional memory */
|
||||
break;
|
||||
}
|
||||
|
||||
case ECMA_TYPE_NUMBER:
|
||||
{
|
||||
ecma_number_t *number_p = ecma_get_number_from_value (value);
|
||||
ecma_dealloc_number (number_p);
|
||||
break;
|
||||
}
|
||||
|
||||
case ECMA_TYPE_STRING:
|
||||
{
|
||||
ecma_string_t *string_p = ecma_get_string_from_value (value);
|
||||
ecma_deref_ecma_string (string_p);
|
||||
break;
|
||||
}
|
||||
|
||||
case ECMA_TYPE_OBJECT:
|
||||
{
|
||||
if (do_deref_if_object)
|
||||
{
|
||||
ecma_deref_object (ecma_get_object_from_value (value));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} /* ecma_free_value */
|
||||
|
||||
/**
|
||||
* Get type field of completion value
|
||||
*
|
||||
* @return type field
|
||||
*/
|
||||
static ecma_completion_type_t __attribute_const__
|
||||
ecma_get_completion_value_type_field (ecma_completion_value_t completion_value) /**< completion value */
|
||||
{
|
||||
return (ecma_completion_type_t) jrt_extract_bit_field (completion_value,
|
||||
ECMA_COMPLETION_VALUE_TYPE_POS,
|
||||
ECMA_COMPLETION_VALUE_TYPE_WIDTH);
|
||||
} /* ecma_get_completion_value_type_field */
|
||||
|
||||
/**
|
||||
* Get value field of completion value
|
||||
*
|
||||
* @return value field
|
||||
*/
|
||||
static ecma_value_t __attribute_const__
|
||||
ecma_get_completion_value_value_field (ecma_completion_value_t completion_value) /**< completion value */
|
||||
{
|
||||
return (ecma_value_t) jrt_extract_bit_field (completion_value,
|
||||
ECMA_COMPLETION_VALUE_VALUE_POS,
|
||||
ECMA_COMPLETION_VALUE_VALUE_WIDTH);
|
||||
} /* ecma_get_completion_value_value_field */
|
||||
|
||||
/**
|
||||
* Get pointer to label descriptor from completion value
|
||||
*
|
||||
* @return pointer to label descriptor
|
||||
*/
|
||||
static ecma_label_descriptor_t* __attribute_const__
|
||||
ecma_get_completion_value_label_descriptor (ecma_completion_value_t completion_value) /**< completion value */
|
||||
{
|
||||
return ECMA_GET_NON_NULL_POINTER (ecma_label_descriptor_t,
|
||||
(uintptr_t) jrt_extract_bit_field (completion_value,
|
||||
ECMA_COMPLETION_VALUE_LABEL_DESC_CP_POS,
|
||||
ECMA_COMPLETION_VALUE_LABEL_DESC_CP_WIDTH));
|
||||
} /* ecma_get_completion_value_label_descriptor */
|
||||
|
||||
/**
|
||||
* Set type field of completion value
|
||||
*
|
||||
* @return completion value with updated field
|
||||
*/
|
||||
static ecma_completion_value_t __attribute_const__
|
||||
ecma_set_completion_value_type_field (ecma_completion_value_t completion_value, /**< completion value
|
||||
* to set field in */
|
||||
ecma_completion_type_t type_field) /**< new field value */
|
||||
{
|
||||
return (ecma_completion_value_t) jrt_set_bit_field_value (completion_value,
|
||||
type_field,
|
||||
ECMA_COMPLETION_VALUE_TYPE_POS,
|
||||
ECMA_COMPLETION_VALUE_TYPE_WIDTH);
|
||||
} /* ecma_set_completion_value_type_field */
|
||||
|
||||
/**
|
||||
* Set value field of completion value
|
||||
*
|
||||
* @return completion value with updated field
|
||||
*/
|
||||
static ecma_completion_value_t __attribute_pure__
|
||||
ecma_set_completion_value_value_field (ecma_completion_value_t completion_value, /**< completion value
|
||||
* to set field in */
|
||||
const ecma_value_t& value_field) /**< new field value */
|
||||
{
|
||||
return (ecma_completion_value_t) jrt_set_bit_field_value (completion_value,
|
||||
value_field,
|
||||
ECMA_COMPLETION_VALUE_VALUE_POS,
|
||||
ECMA_COMPLETION_VALUE_VALUE_WIDTH);
|
||||
} /* ecma_set_completion_value_value_field */
|
||||
|
||||
/**
|
||||
* Set label descriptor of completion value
|
||||
*
|
||||
* @return completion value with updated field
|
||||
*/
|
||||
static ecma_completion_value_t __attribute_const__
|
||||
ecma_set_completion_value_label_descriptor (ecma_completion_value_t completion_value, /**< completion value
|
||||
* to set field in */
|
||||
ecma_label_descriptor_t* label_desc_p) /**< pointer to the
|
||||
* label descriptor */
|
||||
{
|
||||
uintptr_t label_desc_cp;
|
||||
ECMA_SET_NON_NULL_POINTER (label_desc_cp, label_desc_p);
|
||||
|
||||
return (ecma_completion_value_t) jrt_set_bit_field_value (completion_value,
|
||||
label_desc_cp,
|
||||
ECMA_COMPLETION_VALUE_LABEL_DESC_CP_POS,
|
||||
ECMA_COMPLETION_VALUE_LABEL_DESC_CP_WIDTH);
|
||||
} /* ecma_set_completion_value_label_descriptor */
|
||||
|
||||
/**
|
||||
* Normal, throw, return, exit and meta completion values constructor
|
||||
*
|
||||
* @return completion value
|
||||
*/
|
||||
ecma_completion_value_t __attribute_pure__ __attribute_always_inline__
|
||||
ecma_make_completion_value (ecma_completion_type_t type, /**< type */
|
||||
const ecma_value_t& value) /**< value */
|
||||
{
|
||||
const bool is_type_ok = (type == ECMA_COMPLETION_TYPE_NORMAL
|
||||
#ifdef CONFIG_ECMA_EXCEPTION_SUPPORT
|
||||
|| type == ECMA_COMPLETION_TYPE_THROW
|
||||
#endif /* CONFIG_ECMA_EXCEPTION_SUPPORT */
|
||||
|| type == ECMA_COMPLETION_TYPE_RETURN
|
||||
|| type == ECMA_COMPLETION_TYPE_EXIT
|
||||
|| (type == ECMA_COMPLETION_TYPE_META
|
||||
&& ecma_is_value_empty (value)));
|
||||
|
||||
JERRY_ASSERT (is_type_ok);
|
||||
|
||||
ecma_completion_value_t completion_value = 0;
|
||||
|
||||
completion_value = ecma_set_completion_value_type_field (completion_value,
|
||||
type);
|
||||
completion_value = ecma_set_completion_value_value_field (completion_value,
|
||||
value);
|
||||
|
||||
return completion_value;
|
||||
} /* ecma_make_completion_value */
|
||||
|
||||
/**
|
||||
* Break and continue completion values constructor
|
||||
*
|
||||
* @return completion value
|
||||
*/
|
||||
ecma_completion_value_t __attribute_const__
|
||||
ecma_make_label_completion_value (ecma_completion_type_t type, /**< type */
|
||||
uint8_t depth_level, /**< depth level (in try constructions,
|
||||
with blocks, etc.) */
|
||||
uint16_t offset) /**< offset to label from end of last block */
|
||||
{
|
||||
JERRY_ASSERT (type == ECMA_COMPLETION_TYPE_BREAK
|
||||
|| type == ECMA_COMPLETION_TYPE_CONTINUE);
|
||||
|
||||
ecma_label_descriptor_t *label_desc_p = ecma_alloc_label_descriptor ();
|
||||
label_desc_p->offset = offset;
|
||||
label_desc_p->depth = depth_level;
|
||||
|
||||
ecma_completion_value_t completion_value = 0;
|
||||
|
||||
completion_value = ecma_set_completion_value_type_field (completion_value,
|
||||
type);
|
||||
completion_value = ecma_set_completion_value_label_descriptor (completion_value,
|
||||
label_desc_p);
|
||||
|
||||
return completion_value;
|
||||
} /* ecma_make_label_completion_value */
|
||||
|
||||
/**
|
||||
* Simple normal completion value constructor
|
||||
*
|
||||
* @return completion value
|
||||
*/
|
||||
ecma_completion_value_t __attribute_const__ __attribute_always_inline__
|
||||
ecma_make_simple_completion_value (ecma_simple_value_t simple_value) /**< simple ecma-value */
|
||||
{
|
||||
JERRY_ASSERT(simple_value == ECMA_SIMPLE_VALUE_UNDEFINED
|
||||
|| simple_value == ECMA_SIMPLE_VALUE_NULL
|
||||
|| simple_value == ECMA_SIMPLE_VALUE_FALSE
|
||||
|| simple_value == ECMA_SIMPLE_VALUE_TRUE);
|
||||
|
||||
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
|
||||
ecma_make_simple_value (simple_value));
|
||||
} /* ecma_make_simple_completion_value */
|
||||
|
||||
/**
|
||||
* Normal completion value constructor
|
||||
*
|
||||
* @return completion value
|
||||
*/
|
||||
ecma_completion_value_t __attribute_pure__ __attribute_always_inline__
|
||||
ecma_make_normal_completion_value (const ecma_value_t& value) /**< value */
|
||||
{
|
||||
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL, value);
|
||||
} /* ecma_make_normal_completion_value */
|
||||
|
||||
/**
|
||||
* Throw completion value constructor
|
||||
*
|
||||
* @return completion value
|
||||
*/
|
||||
ecma_completion_value_t __attribute_pure__ __attribute_always_inline__
|
||||
ecma_make_throw_completion_value (const ecma_value_t& value) /**< value */
|
||||
{
|
||||
#ifdef CONFIG_ECMA_EXCEPTION_SUPPORT
|
||||
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_THROW, value);
|
||||
#else /* CONFIG_ECMA_EXCEPTION_SUPPORT */
|
||||
(void) value;
|
||||
|
||||
jerry_exit (ERR_UNHANDLED_EXCEPTION);
|
||||
#endif /* !CONFIG_ECMA_EXCEPTION_SUPPORT */
|
||||
} /* ecma_make_throw_completion_value */
|
||||
|
||||
/**
|
||||
* Throw completion value constructor.
|
||||
*
|
||||
* @return 'throw' completion value
|
||||
*/
|
||||
ecma_completion_value_t __attribute_const__
|
||||
ecma_make_throw_obj_completion_value (ecma_object_t *exception_p) /**< an object */
|
||||
{
|
||||
JERRY_ASSERT(exception_p != NULL
|
||||
&& !ecma_is_lexical_environment (exception_p));
|
||||
|
||||
ecma_value_t exception = ecma_make_object_value (exception_p);
|
||||
|
||||
return ecma_make_throw_completion_value (exception);
|
||||
} /* ecma_make_throw_obj_completion_value */
|
||||
|
||||
/**
|
||||
* Empty completion value constructor.
|
||||
*
|
||||
* @return (normal, empty, reserved) completion value.
|
||||
*/
|
||||
ecma_completion_value_t __attribute_const__ __attribute_always_inline__
|
||||
ecma_make_empty_completion_value (void)
|
||||
{
|
||||
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
|
||||
ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY));
|
||||
} /* ecma_make_empty_completion_value */
|
||||
|
||||
/**
|
||||
* Return completion value constructor
|
||||
*
|
||||
* @return completion value
|
||||
*/
|
||||
ecma_completion_value_t __attribute_pure__ __attribute_always_inline__
|
||||
ecma_make_return_completion_value (const ecma_value_t& value) /**< value */
|
||||
{
|
||||
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_RETURN, value);
|
||||
} /* ecma_make_return_completion_value */
|
||||
|
||||
/**
|
||||
* Exit completion value constructor
|
||||
*
|
||||
* @return completion value
|
||||
*/
|
||||
ecma_completion_value_t __attribute_const__ __attribute_always_inline__
|
||||
ecma_make_exit_completion_value (bool is_successful) /**< does completion value indicate
|
||||
successfulness completion
|
||||
of script execution (true) or not (false) */
|
||||
{
|
||||
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_EXIT,
|
||||
ecma_make_simple_value (is_successful ? ECMA_SIMPLE_VALUE_TRUE
|
||||
: ECMA_SIMPLE_VALUE_FALSE));
|
||||
} /* ecma_make_exit_completion_value */
|
||||
|
||||
/**
|
||||
* Meta completion value constructor
|
||||
*
|
||||
* @return completion value
|
||||
*/
|
||||
ecma_completion_value_t __attribute_const__ __attribute_always_inline__
|
||||
ecma_make_meta_completion_value (void)
|
||||
{
|
||||
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_META,
|
||||
ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY));
|
||||
} /* ecma_make_meta_completion_value */
|
||||
|
||||
/**
|
||||
* Get ecma-value from specified completion value
|
||||
*
|
||||
* @return ecma-value
|
||||
*/
|
||||
ecma_value_t __attribute_const__ __attribute_always_inline__
|
||||
ecma_get_completion_value_value (ecma_completion_value_t completion_value) /**< completion value */
|
||||
{
|
||||
const ecma_completion_type_t type = ecma_get_completion_value_type_field (completion_value);
|
||||
|
||||
const bool is_type_ok = (type == ECMA_COMPLETION_TYPE_NORMAL
|
||||
#ifdef CONFIG_ECMA_EXCEPTION_SUPPORT
|
||||
|| type == ECMA_COMPLETION_TYPE_THROW
|
||||
#endif /* CONFIG_ECMA_EXCEPTION_SUPPORT */
|
||||
|| type == ECMA_COMPLETION_TYPE_RETURN
|
||||
|| type == ECMA_COMPLETION_TYPE_EXIT);
|
||||
|
||||
JERRY_ASSERT (is_type_ok);
|
||||
|
||||
return ecma_get_completion_value_value_field (completion_value);
|
||||
} /* ecma_get_completion_value_value */
|
||||
|
||||
/**
|
||||
* Get pointer to ecma-number from completion value
|
||||
*
|
||||
* @return pointer
|
||||
*/
|
||||
ecma_number_t* __attribute_const__
|
||||
ecma_get_number_from_completion_value (ecma_completion_value_t completion_value) /**< completion value */
|
||||
{
|
||||
return ecma_get_number_from_value (ecma_get_completion_value_value (completion_value));
|
||||
} /* ecma_get_number_from_completion_value */
|
||||
|
||||
/**
|
||||
* Get pointer to ecma-string from completion value
|
||||
*
|
||||
* @return pointer
|
||||
*/
|
||||
ecma_string_t* __attribute_const__
|
||||
ecma_get_string_from_completion_value (ecma_completion_value_t completion_value) /**< completion value */
|
||||
{
|
||||
return ecma_get_string_from_value (ecma_get_completion_value_value (completion_value));
|
||||
} /* ecma_get_string_from_completion_value */
|
||||
|
||||
/**
|
||||
* Get pointer to ecma-object from completion value
|
||||
*
|
||||
* @return pointer
|
||||
*/
|
||||
ecma_object_t* __attribute_const__
|
||||
ecma_get_object_from_completion_value (ecma_completion_value_t completion_value) /**< completion value */
|
||||
{
|
||||
return ecma_get_object_from_value (ecma_get_completion_value_value (completion_value));
|
||||
} /* ecma_get_object_from_completion_value */
|
||||
|
||||
/**
|
||||
* Copy ecma-completion value.
|
||||
*
|
||||
* @return (source.type, ecma_copy_value (source.value), source.target).
|
||||
*/
|
||||
ecma_completion_value_t
|
||||
ecma_copy_completion_value (ecma_completion_value_t value) /**< completion value */
|
||||
{
|
||||
const ecma_completion_type_t type = ecma_get_completion_value_type_field (value);
|
||||
const bool is_type_ok = (type == ECMA_COMPLETION_TYPE_NORMAL
|
||||
#ifdef CONFIG_ECMA_EXCEPTION_SUPPORT
|
||||
|| type == ECMA_COMPLETION_TYPE_THROW
|
||||
#endif /* CONFIG_ECMA_EXCEPTION_SUPPORT */
|
||||
|| type == ECMA_COMPLETION_TYPE_RETURN
|
||||
|| type == ECMA_COMPLETION_TYPE_EXIT);
|
||||
|
||||
JERRY_ASSERT (is_type_ok);
|
||||
|
||||
return ecma_make_completion_value (type,
|
||||
ecma_copy_value (ecma_get_completion_value_value_field (value),
|
||||
true));
|
||||
} /* ecma_copy_completion_value */
|
||||
|
||||
/**
|
||||
* Free the completion value.
|
||||
*/
|
||||
void
|
||||
ecma_free_completion_value (ecma_completion_value_t completion_value) /**< completion value */
|
||||
{
|
||||
switch (ecma_get_completion_value_type_field (completion_value))
|
||||
{
|
||||
case ECMA_COMPLETION_TYPE_NORMAL:
|
||||
#ifdef CONFIG_ECMA_EXCEPTION_SUPPORT
|
||||
case ECMA_COMPLETION_TYPE_THROW:
|
||||
#endif /* CONFIG_ECMA_EXCEPTION_SUPPORT */
|
||||
case ECMA_COMPLETION_TYPE_RETURN:
|
||||
{
|
||||
ecma_value_t v = ecma_get_completion_value_value_field (completion_value);
|
||||
ecma_free_value (v, true);
|
||||
break;
|
||||
}
|
||||
case ECMA_COMPLETION_TYPE_EXIT:
|
||||
{
|
||||
ecma_value_t v = ecma_get_completion_value_value_field (completion_value);
|
||||
JERRY_ASSERT(ecma_get_value_type_field (v) == ECMA_TYPE_SIMPLE);
|
||||
break;
|
||||
}
|
||||
case ECMA_COMPLETION_TYPE_CONTINUE:
|
||||
case ECMA_COMPLETION_TYPE_BREAK:
|
||||
{
|
||||
ecma_dealloc_label_descriptor (ecma_get_completion_value_label_descriptor (completion_value));
|
||||
break;
|
||||
}
|
||||
case ECMA_COMPLETION_TYPE_META:
|
||||
{
|
||||
JERRY_UNREACHABLE ();
|
||||
}
|
||||
}
|
||||
} /* ecma_free_completion_value */
|
||||
|
||||
/**
|
||||
* Check if the completion value is normal value.
|
||||
*
|
||||
* @return true - if the completion type is normal,
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool __attribute_const__ __attribute_always_inline__
|
||||
ecma_is_completion_value_normal (ecma_completion_value_t value) /**< completion value */
|
||||
{
|
||||
return (ecma_get_completion_value_type_field (value) == ECMA_COMPLETION_TYPE_NORMAL);
|
||||
} /* ecma_is_completion_value_normal */
|
||||
|
||||
/**
|
||||
* Check if the completion value is throw value.
|
||||
*
|
||||
* @return true - if the completion type is throw,
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool __attribute_const__ __attribute_always_inline__
|
||||
ecma_is_completion_value_throw (ecma_completion_value_t value) /**< completion value */
|
||||
{
|
||||
#ifdef CONFIG_ECMA_EXCEPTION_SUPPORT
|
||||
return (ecma_get_completion_value_type_field (value) == ECMA_COMPLETION_TYPE_THROW);
|
||||
#else /* CONFIG_ECMA_EXCEPTION_SUPPORT */
|
||||
(void) value;
|
||||
|
||||
return false;
|
||||
#endif /* !CONFIG_ECMA_EXCEPTION_SUPPORT */
|
||||
} /* ecma_is_completion_value_throw */
|
||||
|
||||
/**
|
||||
* Check if the completion value is return value.
|
||||
*
|
||||
* @return true - if the completion type is return,
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool __attribute_const__ __attribute_always_inline__
|
||||
ecma_is_completion_value_return (ecma_completion_value_t value) /**< completion value */
|
||||
{
|
||||
return (ecma_get_completion_value_type_field (value) == ECMA_COMPLETION_TYPE_RETURN);
|
||||
} /* ecma_is_completion_value_return */
|
||||
|
||||
/**
|
||||
* Check if the completion value is exit value.
|
||||
*
|
||||
* @return true - if the completion type is exit,
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool __attribute_const__ __attribute_always_inline__
|
||||
ecma_is_completion_value_exit (ecma_completion_value_t value) /**< completion value */
|
||||
{
|
||||
if (ecma_get_completion_value_type_field (value) == ECMA_COMPLETION_TYPE_EXIT)
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_boolean (ecma_get_completion_value_value_field (value)));
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
} /* ecma_is_completion_value_exit */
|
||||
|
||||
/**
|
||||
* Check if the completion value is meta value.
|
||||
*
|
||||
* @return true - if the completion type is meta,
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool __attribute_const__ __attribute_always_inline__
|
||||
ecma_is_completion_value_meta (ecma_completion_value_t value) /**< completion value */
|
||||
{
|
||||
if (ecma_get_completion_value_type_field (value) == ECMA_COMPLETION_TYPE_META)
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_empty (ecma_get_completion_value_value_field (value)));
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
} /* ecma_is_completion_value_meta */
|
||||
|
||||
/**
|
||||
* Check if the completion value is break value.
|
||||
*
|
||||
* @return true - if the completion type is break,
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool __attribute_const__ __attribute_always_inline__
|
||||
ecma_is_completion_value_break (ecma_completion_value_t value) /**< completion value */
|
||||
{
|
||||
return (ecma_get_completion_value_type_field (value) == ECMA_COMPLETION_TYPE_BREAK);
|
||||
} /* ecma_is_completion_value_break */
|
||||
|
||||
/**
|
||||
* Check if the completion value is continue value.
|
||||
*
|
||||
* @return true - if the completion type is continue,
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool __attribute_const__ __attribute_always_inline__
|
||||
ecma_is_completion_value_continue (ecma_completion_value_t value) /**< completion value */
|
||||
{
|
||||
return (ecma_get_completion_value_type_field (value) == ECMA_COMPLETION_TYPE_CONTINUE);
|
||||
} /* ecma_is_completion_value_continue */
|
||||
|
||||
/**
|
||||
* Check if the completion value is specified normal simple value.
|
||||
*
|
||||
* @return true - if the completion type is normal and
|
||||
* value contains specified simple ecma-value,
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool __attribute_const__ __attribute_always_inline__
|
||||
ecma_is_completion_value_normal_simple_value (ecma_completion_value_t value, /**< completion value */
|
||||
ecma_simple_value_t simple_value) /**< simple value to check
|
||||
for equality with */
|
||||
{
|
||||
return (value == ecma_make_simple_completion_value (simple_value));
|
||||
} /* ecma_is_completion_value_normal_simple_value */
|
||||
|
||||
/**
|
||||
* Check if the completion value is normal true.
|
||||
*
|
||||
* @return true - if the completion type is normal and
|
||||
* value contains ecma-true simple value,
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool __attribute_const__ __attribute_always_inline__
|
||||
ecma_is_completion_value_normal_true (ecma_completion_value_t value) /**< completion value */
|
||||
{
|
||||
return ecma_is_completion_value_normal_simple_value (value, ECMA_SIMPLE_VALUE_TRUE);
|
||||
} /* ecma_is_completion_value_normal_true */
|
||||
|
||||
/**
|
||||
* Check if the completion value is normal false.
|
||||
*
|
||||
* @return true - if the completion type is normal and
|
||||
* value contains ecma-false simple value,
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool __attribute_const__ __attribute_always_inline__
|
||||
ecma_is_completion_value_normal_false (ecma_completion_value_t value) /**< completion value */
|
||||
{
|
||||
return ecma_is_completion_value_normal_simple_value (value, ECMA_SIMPLE_VALUE_FALSE);
|
||||
} /* ecma_is_completion_value_normal_false */
|
||||
|
||||
/**
|
||||
* Check if the completion value is normal empty value.
|
||||
*
|
||||
* @return true - if the completion type is normal and
|
||||
* value contains empty simple value,
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool __attribute_const__ __attribute_always_inline__
|
||||
ecma_is_completion_value_empty (ecma_completion_value_t value) /**< completion value */
|
||||
{
|
||||
return (ecma_is_completion_value_normal (value)
|
||||
&& ecma_is_value_empty (ecma_get_completion_value_value_field (value)));
|
||||
} /* ecma_is_completion_value_empty */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
@@ -44,9 +44,8 @@ ecma_new_values_collection (const ecma_value_t values_buffer[], /**< ecma-values
|
||||
header_p->unit_number = values_number;
|
||||
|
||||
uint16_t* next_chunk_cp_p = &header_p->next_chunk_cp;
|
||||
ecma_value_packed_t *cur_value_buf_iter_p, *cur_value_buf_end_p;
|
||||
cur_value_buf_iter_p = (ecma_value_packed_t*) header_p->data;
|
||||
cur_value_buf_end_p = cur_value_buf_iter_p + sizeof (header_p->data) / sizeof (ecma_value_packed_t);
|
||||
ecma_value_t* cur_value_buf_iter_p = (ecma_value_t*) header_p->data;
|
||||
ecma_value_t* cur_value_buf_end_p = cur_value_buf_iter_p + sizeof (header_p->data) / sizeof (ecma_value_t);
|
||||
|
||||
for (ecma_length_t value_index = 0;
|
||||
value_index < values_number;
|
||||
@@ -58,15 +57,13 @@ ecma_new_values_collection (const ecma_value_t values_buffer[], /**< ecma-values
|
||||
ECMA_SET_POINTER (*next_chunk_cp_p, chunk_p);
|
||||
next_chunk_cp_p = &chunk_p->next_chunk_cp;
|
||||
|
||||
cur_value_buf_iter_p = (ecma_value_packed_t*) chunk_p->data;
|
||||
cur_value_buf_end_p = cur_value_buf_iter_p + sizeof (chunk_p->data) / sizeof (ecma_value_packed_t);
|
||||
cur_value_buf_iter_p = (ecma_value_t*) chunk_p->data;
|
||||
cur_value_buf_end_p = cur_value_buf_iter_p + sizeof (chunk_p->data) / sizeof (ecma_value_t);
|
||||
}
|
||||
|
||||
JERRY_ASSERT (cur_value_buf_iter_p + 1 <= cur_value_buf_end_p);
|
||||
|
||||
ecma_value_t value_copy;
|
||||
ecma_copy_value (value_copy, values_buffer [value_index], do_ref_if_object);
|
||||
*cur_value_buf_iter_p++ = (ecma_value_packed_t) value_copy;
|
||||
*cur_value_buf_iter_p++ = ecma_copy_value (values_buffer[value_index], do_ref_if_object);
|
||||
}
|
||||
|
||||
*next_chunk_cp_p = ECMA_NULL_POINTER;
|
||||
@@ -84,9 +81,8 @@ ecma_free_values_collection (ecma_collection_header_t* header_p, /**< collection
|
||||
{
|
||||
JERRY_ASSERT (header_p != NULL);
|
||||
|
||||
ecma_value_packed_t *cur_value_buf_iter_p, *cur_value_buf_end_p;
|
||||
cur_value_buf_iter_p = (ecma_value_packed_t*) header_p->data;
|
||||
cur_value_buf_end_p = cur_value_buf_iter_p + sizeof (header_p->data) / sizeof (ecma_value_packed_t);
|
||||
ecma_value_t* cur_value_buf_iter_p = (ecma_value_t*) header_p->data;
|
||||
ecma_value_t* cur_value_buf_end_p = cur_value_buf_iter_p + sizeof (header_p->data) / sizeof (ecma_value_t);
|
||||
|
||||
ecma_length_t string_index = 0;
|
||||
while (cur_value_buf_iter_p != cur_value_buf_end_p
|
||||
@@ -94,8 +90,7 @@ ecma_free_values_collection (ecma_collection_header_t* header_p, /**< collection
|
||||
{
|
||||
JERRY_ASSERT (cur_value_buf_iter_p < cur_value_buf_end_p);
|
||||
|
||||
ecma_value_t value_to_free (*cur_value_buf_iter_p);
|
||||
ecma_free_value (value_to_free, do_deref_if_object);
|
||||
ecma_free_value (*cur_value_buf_iter_p, do_deref_if_object);
|
||||
|
||||
cur_value_buf_iter_p++;
|
||||
string_index++;
|
||||
@@ -108,16 +103,15 @@ ecma_free_values_collection (ecma_collection_header_t* header_p, /**< collection
|
||||
{
|
||||
JERRY_ASSERT (string_index < header_p->unit_number);
|
||||
|
||||
cur_value_buf_iter_p = (ecma_value_packed_t*) chunk_p->data;
|
||||
cur_value_buf_end_p = cur_value_buf_iter_p + sizeof (chunk_p->data) / sizeof (ecma_value_packed_t);
|
||||
cur_value_buf_iter_p = (ecma_value_t*) chunk_p->data;
|
||||
cur_value_buf_end_p = cur_value_buf_iter_p + sizeof (chunk_p->data) / sizeof (ecma_value_t);
|
||||
|
||||
while (cur_value_buf_iter_p != cur_value_buf_end_p
|
||||
&& string_index < header_p->unit_number)
|
||||
{
|
||||
JERRY_ASSERT (cur_value_buf_iter_p < cur_value_buf_end_p);
|
||||
|
||||
ecma_value_t value_to_free (*cur_value_buf_iter_p);
|
||||
ecma_free_value (value_to_free, do_deref_if_object);
|
||||
ecma_free_value (*cur_value_buf_iter_p, do_deref_if_object);
|
||||
|
||||
cur_value_buf_iter_p++;
|
||||
string_index++;
|
||||
@@ -152,7 +146,7 @@ ecma_new_strings_collection (ecma_string_t* string_ptrs_buffer[], /**< pointers
|
||||
string_index < strings_number;
|
||||
string_index++)
|
||||
{
|
||||
values_buffer[string_index] = string_ptrs_buffer[string_index];
|
||||
values_buffer[string_index] = ecma_make_string_value (string_ptrs_buffer[string_index]);
|
||||
}
|
||||
|
||||
new_collection_p = ecma_new_values_collection (values_buffer,
|
||||
@@ -175,8 +169,8 @@ ecma_collection_iterator_init (ecma_collection_iterator_t *iterator_p, /**< cont
|
||||
iterator_p->next_chunk_cp = collection_p->next_chunk_cp;
|
||||
iterator_p->current_index = 0;
|
||||
iterator_p->current_value_p = NULL;
|
||||
iterator_p->current_chunk_end_p = ((ecma_value_packed_t*) iterator_p->header_p->data
|
||||
+ sizeof (iterator_p->header_p->data) / sizeof (ecma_value_packed_t));
|
||||
iterator_p->current_chunk_end_p = ((ecma_value_t*) iterator_p->header_p->data
|
||||
+ sizeof (iterator_p->header_p->data) / sizeof (ecma_value_t));
|
||||
} /* ecma_collection_iterator_init */
|
||||
|
||||
/**
|
||||
@@ -196,7 +190,7 @@ ecma_collection_iterator_next (ecma_collection_iterator_t *iterator_p) /**< cont
|
||||
if (iterator_p->current_value_p == NULL)
|
||||
{
|
||||
JERRY_ASSERT (iterator_p->current_index == 0);
|
||||
iterator_p->current_value_p = (ecma_value_packed_t*) iterator_p->header_p->data;
|
||||
iterator_p->current_value_p = (ecma_value_t*) iterator_p->header_p->data;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -218,9 +212,8 @@ ecma_collection_iterator_next (ecma_collection_iterator_t *iterator_p) /**< cont
|
||||
JERRY_ASSERT (next_chunk_p != NULL);
|
||||
|
||||
iterator_p->next_chunk_cp = next_chunk_p->next_chunk_cp;
|
||||
iterator_p->current_value_p = (ecma_value_packed_t*) &next_chunk_p->data;
|
||||
iterator_p->current_chunk_end_p = (iterator_p->current_value_p +
|
||||
sizeof (next_chunk_p->data) / sizeof (ecma_value_packed_t));
|
||||
iterator_p->current_value_p = (ecma_value_t*) &next_chunk_p->data;
|
||||
iterator_p->current_chunk_end_p = iterator_p->current_value_p + sizeof (next_chunk_p->data) / sizeof (ecma_value_t);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+138
-190
@@ -36,17 +36,14 @@
|
||||
*
|
||||
* @return pointer to the object's descriptor
|
||||
*/
|
||||
void
|
||||
ecma_create_object (ecma_object_ptr_t &object_mp, /**< out: object pointer */
|
||||
const ecma_object_ptr_t& prototype_object_p, /**< pointer to prototybe of the object (or NULL) */
|
||||
ecma_object_t*
|
||||
ecma_create_object (ecma_object_t *prototype_object_p, /**< pointer to prototybe of the object (or NULL) */
|
||||
bool is_extensible, /**< value of extensible attribute */
|
||||
ecma_object_type_t type) /**< object type */
|
||||
{
|
||||
ecma_alloc_object (object_mp);
|
||||
ecma_object_t *object_p = ecma_alloc_object ();
|
||||
|
||||
ecma_init_gc_info (object_mp);
|
||||
|
||||
ecma_object_t *object_p = (ecma_object_t*) object_mp;
|
||||
ecma_init_gc_info (object_p);
|
||||
|
||||
object_p->container = jrt_set_bit_field_value (object_p->container,
|
||||
ECMA_NULL_POINTER,
|
||||
@@ -65,16 +62,18 @@ ecma_create_object (ecma_object_ptr_t &object_mp, /**< out: object pointer */
|
||||
ECMA_OBJECT_OBJ_TYPE_POS,
|
||||
ECMA_OBJECT_OBJ_TYPE_WIDTH);
|
||||
|
||||
uintptr_t prototype_object_cp;
|
||||
prototype_object_p.pack_to (prototype_object_cp, true);
|
||||
uint64_t prototype_object_cp;
|
||||
ECMA_SET_POINTER (prototype_object_cp, prototype_object_p);
|
||||
|
||||
object_p->container = jrt_set_bit_field_value (object_p->container,
|
||||
prototype_object_cp,
|
||||
ECMA_OBJECT_OBJ_PROTOTYPE_OBJECT_CP_POS,
|
||||
ECMA_OBJECT_OBJ_PROTOTYPE_OBJECT_CP_WIDTH);
|
||||
ecma_gc_update_may_ref_younger_object_flag_by_object (object_mp, prototype_object_p);
|
||||
ecma_gc_update_may_ref_younger_object_flag_by_object (object_p, prototype_object_p);
|
||||
|
||||
ecma_set_object_is_builtin (object_mp, false);
|
||||
ecma_set_object_is_builtin (object_p, false);
|
||||
|
||||
return object_p;
|
||||
} /* ecma_create_object */
|
||||
|
||||
/**
|
||||
@@ -87,15 +86,12 @@ ecma_create_object (ecma_object_ptr_t &object_mp, /**< out: object pointer */
|
||||
*
|
||||
* @return pointer to the descriptor of lexical environment
|
||||
*/
|
||||
void
|
||||
ecma_create_decl_lex_env (ecma_object_ptr_t &new_lexical_environment_mp, /**< out: lexical environment pointer */
|
||||
const ecma_object_ptr_t& outer_lexical_environment_p) /**< outer lexical environment */
|
||||
ecma_object_t*
|
||||
ecma_create_decl_lex_env (ecma_object_t *outer_lexical_environment_p) /**< outer lexical environment */
|
||||
{
|
||||
ecma_alloc_object (new_lexical_environment_mp);
|
||||
ecma_object_t *new_lexical_environment_p = ecma_alloc_object ();
|
||||
|
||||
ecma_init_gc_info (new_lexical_environment_mp);
|
||||
|
||||
ecma_object_t *new_lexical_environment_p = (ecma_object_t*) new_lexical_environment_mp;
|
||||
ecma_init_gc_info (new_lexical_environment_p);
|
||||
|
||||
new_lexical_environment_p->container = jrt_set_bit_field_value (new_lexical_environment_p->container,
|
||||
ECMA_NULL_POINTER,
|
||||
@@ -111,14 +107,13 @@ ecma_create_decl_lex_env (ecma_object_ptr_t &new_lexical_environment_mp, /**< ou
|
||||
ECMA_OBJECT_LEX_ENV_TYPE_POS,
|
||||
ECMA_OBJECT_LEX_ENV_TYPE_WIDTH);
|
||||
|
||||
uintptr_t outer_reference_cp;
|
||||
outer_lexical_environment_p.pack_to (outer_reference_cp, true);
|
||||
|
||||
uint64_t outer_reference_cp;
|
||||
ECMA_SET_POINTER (outer_reference_cp, outer_lexical_environment_p);
|
||||
new_lexical_environment_p->container = jrt_set_bit_field_value (new_lexical_environment_p->container,
|
||||
outer_reference_cp,
|
||||
ECMA_OBJECT_LEX_ENV_OUTER_REFERENCE_CP_POS,
|
||||
ECMA_OBJECT_LEX_ENV_OUTER_REFERENCE_CP_WIDTH);
|
||||
ecma_gc_update_may_ref_younger_object_flag_by_object (new_lexical_environment_mp, outer_lexical_environment_p);
|
||||
ecma_gc_update_may_ref_younger_object_flag_by_object (new_lexical_environment_p, outer_lexical_environment_p);
|
||||
|
||||
/*
|
||||
* Declarative lexical environments do not really have the flag,
|
||||
@@ -128,6 +123,8 @@ ecma_create_decl_lex_env (ecma_object_ptr_t &new_lexical_environment_mp, /**< ou
|
||||
false,
|
||||
ECMA_OBJECT_LEX_ENV_PROVIDE_THIS_POS,
|
||||
ECMA_OBJECT_LEX_ENV_PROVIDE_THIS_WIDTH);
|
||||
|
||||
return new_lexical_environment_p;
|
||||
} /* ecma_create_decl_lex_env */
|
||||
|
||||
/**
|
||||
@@ -140,20 +137,17 @@ ecma_create_decl_lex_env (ecma_object_ptr_t &new_lexical_environment_mp, /**< ou
|
||||
*
|
||||
* @return pointer to the descriptor of lexical environment
|
||||
*/
|
||||
void
|
||||
ecma_create_object_lex_env (ecma_object_ptr_t &new_lexical_environment_mp, /**< out: lexical environment pointer */
|
||||
const ecma_object_ptr_t& outer_lexical_environment_p, /**< outer lexical environment */
|
||||
const ecma_object_ptr_t& binding_obj_p, /**< binding object */
|
||||
ecma_object_t*
|
||||
ecma_create_object_lex_env (ecma_object_t *outer_lexical_environment_p, /**< outer lexical environment */
|
||||
ecma_object_t *binding_obj_p, /**< binding object */
|
||||
bool provide_this) /**< provideThis flag */
|
||||
{
|
||||
JERRY_ASSERT(binding_obj_p.is_not_null ()
|
||||
JERRY_ASSERT(binding_obj_p != NULL
|
||||
&& !ecma_is_lexical_environment (binding_obj_p));
|
||||
|
||||
ecma_alloc_object (new_lexical_environment_mp);
|
||||
ecma_object_t *new_lexical_environment_p = ecma_alloc_object ();
|
||||
|
||||
ecma_init_gc_info (new_lexical_environment_mp);
|
||||
|
||||
ecma_object_t *new_lexical_environment_p = (ecma_object_t*) new_lexical_environment_mp;
|
||||
ecma_init_gc_info (new_lexical_environment_p);
|
||||
|
||||
new_lexical_environment_p->container = jrt_set_bit_field_value (new_lexical_environment_p->container,
|
||||
true,
|
||||
@@ -165,37 +159,37 @@ ecma_create_object_lex_env (ecma_object_ptr_t &new_lexical_environment_mp, /**<
|
||||
ECMA_OBJECT_LEX_ENV_TYPE_POS,
|
||||
ECMA_OBJECT_LEX_ENV_TYPE_WIDTH);
|
||||
|
||||
uintptr_t outer_reference_cp;
|
||||
outer_lexical_environment_p.pack_to (outer_reference_cp, true);
|
||||
uint64_t outer_reference_cp;
|
||||
ECMA_SET_POINTER (outer_reference_cp, outer_lexical_environment_p);
|
||||
new_lexical_environment_p->container = jrt_set_bit_field_value (new_lexical_environment_p->container,
|
||||
outer_reference_cp,
|
||||
ECMA_OBJECT_LEX_ENV_OUTER_REFERENCE_CP_POS,
|
||||
ECMA_OBJECT_LEX_ENV_OUTER_REFERENCE_CP_WIDTH);
|
||||
ecma_gc_update_may_ref_younger_object_flag_by_object (new_lexical_environment_mp, outer_lexical_environment_p);
|
||||
ecma_gc_update_may_ref_younger_object_flag_by_object (new_lexical_environment_p, outer_lexical_environment_p);
|
||||
|
||||
new_lexical_environment_p->container = jrt_set_bit_field_value (new_lexical_environment_p->container,
|
||||
provide_this,
|
||||
ECMA_OBJECT_LEX_ENV_PROVIDE_THIS_POS,
|
||||
ECMA_OBJECT_LEX_ENV_PROVIDE_THIS_WIDTH);
|
||||
|
||||
uintptr_t bound_object_cp;
|
||||
binding_obj_p.pack_to (bound_object_cp);
|
||||
uint64_t bound_object_cp;
|
||||
ECMA_SET_NON_NULL_POINTER (bound_object_cp, binding_obj_p);
|
||||
new_lexical_environment_p->container = jrt_set_bit_field_value (new_lexical_environment_p->container,
|
||||
bound_object_cp,
|
||||
ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_POS,
|
||||
ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_WIDTH);
|
||||
ecma_gc_update_may_ref_younger_object_flag_by_object (new_lexical_environment_mp, binding_obj_p);
|
||||
ecma_gc_update_may_ref_younger_object_flag_by_object (new_lexical_environment_p, binding_obj_p);
|
||||
|
||||
return new_lexical_environment_p;
|
||||
} /* ecma_create_object_lex_env */
|
||||
|
||||
/**
|
||||
* Check if the object is lexical environment.
|
||||
*/
|
||||
bool __attribute_pure__
|
||||
ecma_is_lexical_environment (const ecma_object_ptr_t& object_mp) /**< object or lexical environment */
|
||||
ecma_is_lexical_environment (const ecma_object_t *object_p) /**< object or lexical environment */
|
||||
{
|
||||
JERRY_ASSERT (object_mp.is_not_null ());
|
||||
|
||||
ecma_object_t *object_p = (ecma_object_t*) object_mp;
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
|
||||
return jrt_extract_bit_field (object_p->container,
|
||||
ECMA_OBJECT_IS_LEXICAL_ENVIRONMENT_POS,
|
||||
@@ -206,12 +200,10 @@ ecma_is_lexical_environment (const ecma_object_ptr_t& object_mp) /**< object or
|
||||
* Get value of [[Extensible]] object's internal property.
|
||||
*/
|
||||
bool __attribute_pure__
|
||||
ecma_get_object_extensible (const ecma_object_ptr_t& object_mp) /**< object */
|
||||
ecma_get_object_extensible (const ecma_object_t *object_p) /**< object */
|
||||
{
|
||||
JERRY_ASSERT (object_mp.is_not_null ());
|
||||
JERRY_ASSERT (!ecma_is_lexical_environment (object_mp));
|
||||
|
||||
ecma_object_t *object_p = (ecma_object_t*) object_mp;
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
JERRY_ASSERT (!ecma_is_lexical_environment (object_p));
|
||||
|
||||
return jrt_extract_bit_field (object_p->container,
|
||||
ECMA_OBJECT_OBJ_EXTENSIBLE_POS,
|
||||
@@ -222,13 +214,11 @@ ecma_get_object_extensible (const ecma_object_ptr_t& object_mp) /**< object */
|
||||
* Set value of [[Extensible]] object's internal property.
|
||||
*/
|
||||
void
|
||||
ecma_set_object_extensible (const ecma_object_ptr_t& object_mp, /**< object */
|
||||
ecma_set_object_extensible (ecma_object_t *object_p, /**< object */
|
||||
bool is_extensible) /**< value of [[Extensible]] */
|
||||
{
|
||||
JERRY_ASSERT (object_mp.is_not_null ());
|
||||
JERRY_ASSERT (!ecma_is_lexical_environment (object_mp));
|
||||
|
||||
ecma_object_t *object_p = (ecma_object_t*) object_mp;
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
JERRY_ASSERT (!ecma_is_lexical_environment (object_p));
|
||||
|
||||
object_p->container = jrt_set_bit_field_value (object_p->container,
|
||||
is_extensible,
|
||||
@@ -240,12 +230,10 @@ ecma_set_object_extensible (const ecma_object_ptr_t& object_mp, /**< object */
|
||||
* Get object's internal implementation-defined type.
|
||||
*/
|
||||
ecma_object_type_t __attribute_pure__
|
||||
ecma_get_object_type (const ecma_object_ptr_t& object_mp) /**< object */
|
||||
ecma_get_object_type (const ecma_object_t *object_p) /**< object */
|
||||
{
|
||||
JERRY_ASSERT (object_mp.is_not_null ());
|
||||
JERRY_ASSERT (!ecma_is_lexical_environment (object_mp));
|
||||
|
||||
ecma_object_t *object_p = (ecma_object_t*) object_mp;
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
JERRY_ASSERT (!ecma_is_lexical_environment (object_p));
|
||||
|
||||
return (ecma_object_type_t) jrt_extract_bit_field (object_p->container,
|
||||
ECMA_OBJECT_OBJ_TYPE_POS,
|
||||
@@ -256,13 +244,11 @@ ecma_get_object_type (const ecma_object_ptr_t& object_mp) /**< object */
|
||||
* Set object's internal implementation-defined type.
|
||||
*/
|
||||
void
|
||||
ecma_set_object_type (const ecma_object_ptr_t& object_mp, /**< object */
|
||||
ecma_set_object_type (ecma_object_t *object_p, /**< object */
|
||||
ecma_object_type_t type) /**< type */
|
||||
{
|
||||
JERRY_ASSERT (object_mp.is_not_null ());
|
||||
JERRY_ASSERT (!ecma_is_lexical_environment (object_mp));
|
||||
|
||||
ecma_object_t *object_p = (ecma_object_t*) object_mp;
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
JERRY_ASSERT (!ecma_is_lexical_environment (object_p));
|
||||
|
||||
object_p->container = jrt_set_bit_field_value (object_p->container,
|
||||
type,
|
||||
@@ -273,20 +259,18 @@ ecma_set_object_type (const ecma_object_ptr_t& object_mp, /**< object */
|
||||
/**
|
||||
* Get object's prototype.
|
||||
*/
|
||||
void
|
||||
ecma_get_object_prototype (ecma_object_ptr_t &ret_val, /**< out: object pointer */
|
||||
const ecma_object_ptr_t& object_mp) /**< object */
|
||||
ecma_object_t* __attribute_pure__
|
||||
ecma_get_object_prototype (const ecma_object_t *object_p) /**< object */
|
||||
{
|
||||
JERRY_ASSERT (object_mp.is_not_null ());
|
||||
JERRY_ASSERT (!ecma_is_lexical_environment (object_mp));
|
||||
|
||||
ecma_object_t *object_p = (ecma_object_t*) object_mp;
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
JERRY_ASSERT (!ecma_is_lexical_environment (object_p));
|
||||
|
||||
JERRY_ASSERT (sizeof (uintptr_t) * JERRY_BITSINBYTE >= ECMA_OBJECT_OBJ_PROTOTYPE_OBJECT_CP_WIDTH);
|
||||
uintptr_t prototype_object_cp = (uintptr_t) jrt_extract_bit_field (object_p->container,
|
||||
ECMA_OBJECT_OBJ_PROTOTYPE_OBJECT_CP_POS,
|
||||
ECMA_OBJECT_OBJ_PROTOTYPE_OBJECT_CP_WIDTH);
|
||||
ret_val.unpack_from (prototype_object_cp, true);
|
||||
return ECMA_GET_POINTER (ecma_object_t,
|
||||
prototype_object_cp);
|
||||
} /* ecma_get_object_prototype */
|
||||
|
||||
/**
|
||||
@@ -295,18 +279,16 @@ ecma_get_object_prototype (ecma_object_ptr_t &ret_val, /**< out: object pointer
|
||||
* @return true / false
|
||||
*/
|
||||
bool __attribute_pure__
|
||||
ecma_get_object_is_builtin (const ecma_object_ptr_t& object_mp) /**< object */
|
||||
ecma_get_object_is_builtin (const ecma_object_t *object_p) /**< object */
|
||||
{
|
||||
JERRY_ASSERT (object_mp.is_not_null ());
|
||||
JERRY_ASSERT (!ecma_is_lexical_environment (object_mp));
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
JERRY_ASSERT (!ecma_is_lexical_environment (object_p));
|
||||
|
||||
const uint32_t offset = ECMA_OBJECT_OBJ_IS_BUILTIN_POS;
|
||||
const uint32_t width = ECMA_OBJECT_OBJ_IS_BUILTIN_WIDTH;
|
||||
|
||||
JERRY_ASSERT (sizeof (uintptr_t) * JERRY_BITSINBYTE >= width);
|
||||
|
||||
ecma_object_t *object_p = (ecma_object_t*) object_mp;
|
||||
|
||||
uintptr_t flag_value = (uintptr_t) jrt_extract_bit_field (object_p->container,
|
||||
offset,
|
||||
width);
|
||||
@@ -318,17 +300,15 @@ ecma_get_object_is_builtin (const ecma_object_ptr_t& object_mp) /**< object */
|
||||
* Set flag indicating whether the object is a built-in object
|
||||
*/
|
||||
void
|
||||
ecma_set_object_is_builtin (const ecma_object_ptr_t& object_mp, /**< object */
|
||||
ecma_set_object_is_builtin (ecma_object_t *object_p, /**< object */
|
||||
bool is_builtin) /**< value of flag */
|
||||
{
|
||||
JERRY_ASSERT (object_mp.is_not_null ());
|
||||
JERRY_ASSERT (!ecma_is_lexical_environment (object_mp));
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
JERRY_ASSERT (!ecma_is_lexical_environment (object_p));
|
||||
|
||||
const uint32_t offset = ECMA_OBJECT_OBJ_IS_BUILTIN_POS;
|
||||
const uint32_t width = ECMA_OBJECT_OBJ_IS_BUILTIN_WIDTH;
|
||||
|
||||
ecma_object_t *object_p = (ecma_object_t*) object_mp;
|
||||
|
||||
object_p->container = jrt_set_bit_field_value (object_p->container,
|
||||
(uintptr_t) is_builtin,
|
||||
offset,
|
||||
@@ -339,12 +319,10 @@ ecma_set_object_is_builtin (const ecma_object_ptr_t& object_mp, /**< object */
|
||||
* Get type of lexical environment.
|
||||
*/
|
||||
ecma_lexical_environment_type_t __attribute_pure__
|
||||
ecma_get_lex_env_type (const ecma_object_ptr_t& object_mp) /**< lexical environment */
|
||||
ecma_get_lex_env_type (const ecma_object_t *object_p) /**< lexical environment */
|
||||
{
|
||||
JERRY_ASSERT (object_mp.is_not_null ());
|
||||
JERRY_ASSERT (ecma_is_lexical_environment (object_mp));
|
||||
|
||||
ecma_object_t *object_p = (ecma_object_t*) object_mp;
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
JERRY_ASSERT (ecma_is_lexical_environment (object_p));
|
||||
|
||||
return (ecma_lexical_environment_type_t) jrt_extract_bit_field (object_p->container,
|
||||
ECMA_OBJECT_LEX_ENV_TYPE_POS,
|
||||
@@ -354,57 +332,52 @@ ecma_get_lex_env_type (const ecma_object_ptr_t& object_mp) /**< lexical environm
|
||||
/**
|
||||
* Get outer reference of lexical environment.
|
||||
*/
|
||||
void
|
||||
ecma_get_lex_env_outer_reference (ecma_object_ptr_t &ret_val, /**< out: object pointer */
|
||||
const ecma_object_ptr_t& object_mp) /**< lexical environment */
|
||||
ecma_object_t* __attribute_pure__
|
||||
ecma_get_lex_env_outer_reference (const ecma_object_t *object_p) /**< lexical environment */
|
||||
{
|
||||
JERRY_ASSERT (object_mp.is_not_null ());
|
||||
JERRY_ASSERT (ecma_is_lexical_environment (object_mp));
|
||||
|
||||
ecma_object_t *object_p = (ecma_object_t*) object_mp;
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
JERRY_ASSERT (ecma_is_lexical_environment (object_p));
|
||||
|
||||
JERRY_ASSERT (sizeof (uintptr_t) * JERRY_BITSINBYTE >= ECMA_OBJECT_LEX_ENV_OUTER_REFERENCE_CP_WIDTH);
|
||||
uintptr_t outer_reference_cp = (uintptr_t) jrt_extract_bit_field (object_p->container,
|
||||
ECMA_OBJECT_LEX_ENV_OUTER_REFERENCE_CP_POS,
|
||||
ECMA_OBJECT_LEX_ENV_OUTER_REFERENCE_CP_WIDTH);
|
||||
ret_val.unpack_from (outer_reference_cp, true);
|
||||
return ECMA_GET_POINTER (ecma_object_t,
|
||||
outer_reference_cp);
|
||||
} /* ecma_get_lex_env_outer_reference */
|
||||
|
||||
/**
|
||||
* Get object's/lexical environment's property list.
|
||||
*/
|
||||
ecma_property_t* __attribute_pure__
|
||||
ecma_get_property_list (const ecma_object_ptr_t& object_mp) /**< object or lexical environment */
|
||||
ecma_get_property_list (const ecma_object_t *object_p) /**< object or lexical environment */
|
||||
{
|
||||
JERRY_ASSERT (object_mp.is_not_null ());
|
||||
JERRY_ASSERT (!ecma_is_lexical_environment (object_mp) ||
|
||||
ecma_get_lex_env_type (object_mp) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE);
|
||||
|
||||
ecma_object_t *object_p = (ecma_object_t*) object_mp;
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
JERRY_ASSERT (!ecma_is_lexical_environment (object_p) ||
|
||||
ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE);
|
||||
|
||||
JERRY_ASSERT (sizeof (uintptr_t) * JERRY_BITSINBYTE >= ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_WIDTH);
|
||||
uintptr_t properties_cp = (uintptr_t) jrt_extract_bit_field (object_p->container,
|
||||
ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_POS,
|
||||
ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_WIDTH);
|
||||
return ECMA_GET_POINTER (ecma_property_t, properties_cp);
|
||||
return ECMA_GET_POINTER (ecma_property_t,
|
||||
properties_cp);
|
||||
} /* ecma_get_property_list */
|
||||
|
||||
/**
|
||||
* Set object's/lexical environment's property list.
|
||||
*/
|
||||
static void
|
||||
ecma_set_property_list (const ecma_object_ptr_t& object_mp, /**< object or lexical environment */
|
||||
ecma_set_property_list (ecma_object_t *object_p, /**< object or lexical environment */
|
||||
ecma_property_t *property_list_p) /**< properties' list */
|
||||
{
|
||||
JERRY_ASSERT (object_mp.is_not_null ());
|
||||
JERRY_ASSERT (!ecma_is_lexical_environment (object_mp) ||
|
||||
ecma_get_lex_env_type (object_mp) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE);
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
JERRY_ASSERT (!ecma_is_lexical_environment (object_p) ||
|
||||
ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE);
|
||||
|
||||
uintptr_t properties_cp;
|
||||
uint64_t properties_cp;
|
||||
ECMA_SET_POINTER (properties_cp, property_list_p);
|
||||
|
||||
ecma_object_t *object_p = (ecma_object_t*) object_mp;
|
||||
|
||||
object_p->container = jrt_set_bit_field_value (object_p->container,
|
||||
properties_cp,
|
||||
ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_POS,
|
||||
@@ -415,16 +388,13 @@ ecma_set_property_list (const ecma_object_ptr_t& object_mp, /**< object or lexic
|
||||
* Get lexical environment's 'provideThis' property
|
||||
*/
|
||||
bool __attribute_pure__
|
||||
ecma_get_lex_env_provide_this (const ecma_object_ptr_t& object_mp) /**< object-bound lexical environment */
|
||||
ecma_get_lex_env_provide_this (const ecma_object_t *object_p) /**< object-bound lexical environment */
|
||||
{
|
||||
JERRY_ASSERT (object_mp.is_not_null ());
|
||||
JERRY_ASSERT (ecma_is_lexical_environment (object_mp) &&
|
||||
ecma_get_lex_env_type (object_mp) == ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND);
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
JERRY_ASSERT (ecma_is_lexical_environment (object_p) &&
|
||||
ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND);
|
||||
|
||||
JERRY_ASSERT (sizeof (uintptr_t) * JERRY_BITSINBYTE >= ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_WIDTH);
|
||||
|
||||
ecma_object_t *object_p = (ecma_object_t*) object_mp;
|
||||
|
||||
bool provide_this = (jrt_extract_bit_field (object_p->container,
|
||||
ECMA_OBJECT_LEX_ENV_PROVIDE_THIS_POS,
|
||||
ECMA_OBJECT_LEX_ENV_PROVIDE_THIS_WIDTH) != 0);
|
||||
@@ -435,21 +405,18 @@ ecma_get_lex_env_provide_this (const ecma_object_ptr_t& object_mp) /**< object-b
|
||||
/**
|
||||
* Get lexical environment's bound object.
|
||||
*/
|
||||
void
|
||||
ecma_get_lex_env_binding_object (ecma_object_ptr_t &ret_val, /**< out: object pointer */
|
||||
const ecma_object_ptr_t& object_mp) /**< object-bound lexical environment */
|
||||
ecma_object_t* __attribute_pure__
|
||||
ecma_get_lex_env_binding_object (const ecma_object_t *object_p) /**< object-bound lexical environment */
|
||||
{
|
||||
JERRY_ASSERT (object_mp.is_not_null ());
|
||||
JERRY_ASSERT (ecma_is_lexical_environment (object_mp) &&
|
||||
ecma_get_lex_env_type (object_mp) == ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND);
|
||||
|
||||
ecma_object_t *object_p = (ecma_object_t*) object_mp;
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
JERRY_ASSERT (ecma_is_lexical_environment (object_p) &&
|
||||
ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND);
|
||||
|
||||
JERRY_ASSERT (sizeof (uintptr_t) * JERRY_BITSINBYTE >= ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_WIDTH);
|
||||
uintptr_t object_cp = (uintptr_t) jrt_extract_bit_field (object_p->container,
|
||||
ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_POS,
|
||||
ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_WIDTH);
|
||||
ret_val.unpack_from (object_cp);
|
||||
return ECMA_GET_NON_NULL_POINTER (ecma_object_t, object_cp);
|
||||
} /* ecma_get_lex_env_binding_object */
|
||||
|
||||
/**
|
||||
@@ -459,7 +426,7 @@ ecma_get_lex_env_binding_object (ecma_object_ptr_t &ret_val, /**< out: object po
|
||||
* @return pointer to newly created property
|
||||
*/
|
||||
ecma_property_t*
|
||||
ecma_create_internal_property (const ecma_object_ptr_t& object_p, /**< the object */
|
||||
ecma_create_internal_property (ecma_object_t *object_p, /**< the object */
|
||||
ecma_internal_property_id_t property_id) /**< internal property identifier */
|
||||
{
|
||||
JERRY_ASSERT (ecma_find_internal_property (object_p, property_id) == NULL);
|
||||
@@ -488,10 +455,10 @@ ecma_create_internal_property (const ecma_object_ptr_t& object_p, /**< the objec
|
||||
* NULL - otherwise.
|
||||
*/
|
||||
ecma_property_t*
|
||||
ecma_find_internal_property (const ecma_object_ptr_t& object_p, /**< object descriptor */
|
||||
ecma_find_internal_property (ecma_object_t *object_p, /**< object descriptor */
|
||||
ecma_internal_property_id_t property_id) /**< internal property identifier */
|
||||
{
|
||||
JERRY_ASSERT(object_p.is_not_null ());
|
||||
JERRY_ASSERT(object_p != NULL);
|
||||
|
||||
JERRY_ASSERT(property_id != ECMA_INTERNAL_PROPERTY_PROTOTYPE
|
||||
&& property_id != ECMA_INTERNAL_PROPERTY_EXTENSIBLE);
|
||||
@@ -521,7 +488,7 @@ ecma_find_internal_property (const ecma_object_ptr_t& object_p, /**< object desc
|
||||
* @return pointer to the property
|
||||
*/
|
||||
ecma_property_t*
|
||||
ecma_get_internal_property (const ecma_object_ptr_t& object_p, /**< object descriptor */
|
||||
ecma_get_internal_property (ecma_object_t *object_p, /**< object descriptor */
|
||||
ecma_internal_property_id_t property_id) /**< internal property identifier */
|
||||
{
|
||||
ecma_property_t *property_p = ecma_find_internal_property (object_p, property_id);
|
||||
@@ -538,13 +505,13 @@ ecma_get_internal_property (const ecma_object_ptr_t& object_p, /**< object descr
|
||||
* @return pointer to newly created property
|
||||
*/
|
||||
ecma_property_t*
|
||||
ecma_create_named_data_property (const ecma_object_ptr_t& obj_p, /**< object */
|
||||
ecma_create_named_data_property (ecma_object_t *obj_p, /**< object */
|
||||
ecma_string_t *name_p, /**< property name */
|
||||
bool is_writable, /**< 'Writable' attribute */
|
||||
bool is_enumerable, /**< 'Enumerable' attribute */
|
||||
bool is_configurable) /**< 'Configurable' attribute */
|
||||
{
|
||||
JERRY_ASSERT(obj_p.is_not_null () && name_p != NULL);
|
||||
JERRY_ASSERT(obj_p != NULL && name_p != NULL);
|
||||
JERRY_ASSERT(ecma_find_named_property (obj_p, name_p) == NULL);
|
||||
|
||||
ecma_property_t *prop_p = ecma_alloc_property ();
|
||||
@@ -561,7 +528,7 @@ ecma_create_named_data_property (const ecma_object_ptr_t& obj_p, /**< object */
|
||||
|
||||
prop_p->u.named_data_property.is_lcached = false;
|
||||
|
||||
prop_p->u.named_data_property.value = (ecma_value_packed_t) ecma_value_t (ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||
prop_p->u.named_data_property.value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||
|
||||
ecma_lcache_invalidate (obj_p, name_p, NULL);
|
||||
|
||||
@@ -578,14 +545,14 @@ ecma_create_named_data_property (const ecma_object_ptr_t& obj_p, /**< object */
|
||||
* @return pointer to newly created property
|
||||
*/
|
||||
ecma_property_t*
|
||||
ecma_create_named_accessor_property (const ecma_object_ptr_t& obj_p, /**< object */
|
||||
ecma_create_named_accessor_property (ecma_object_t *obj_p, /**< object */
|
||||
ecma_string_t *name_p, /**< property name */
|
||||
const ecma_object_ptr_t& get_p, /**< getter */
|
||||
const ecma_object_ptr_t& set_p, /**< setter */
|
||||
ecma_object_t *get_p, /**< getter */
|
||||
ecma_object_t *set_p, /**< setter */
|
||||
bool is_enumerable, /**< 'enumerable' attribute */
|
||||
bool is_configurable) /**< 'configurable' attribute */
|
||||
{
|
||||
JERRY_ASSERT(obj_p.is_not_null () && name_p != NULL);
|
||||
JERRY_ASSERT(obj_p != NULL && name_p != NULL);
|
||||
JERRY_ASSERT(ecma_find_named_property (obj_p, name_p) == NULL);
|
||||
|
||||
ecma_property_t *prop_p = ecma_alloc_property ();
|
||||
@@ -595,16 +562,10 @@ ecma_create_named_accessor_property (const ecma_object_ptr_t& obj_p, /**< object
|
||||
name_p = ecma_copy_or_ref_ecma_string (name_p);
|
||||
ECMA_SET_NON_NULL_POINTER(prop_p->u.named_accessor_property.name_p, name_p);
|
||||
|
||||
{
|
||||
ecma_object_t *get_tmp_p = (ecma_object_t*) get_p;
|
||||
ECMA_SET_POINTER (prop_p->u.named_accessor_property.get_p, get_tmp_p);
|
||||
}
|
||||
ECMA_SET_POINTER(prop_p->u.named_accessor_property.get_p, get_p);
|
||||
ecma_gc_update_may_ref_younger_object_flag_by_object (obj_p, get_p);
|
||||
|
||||
{
|
||||
ecma_object_t *set_tmp_p = (ecma_object_t*) set_p;
|
||||
ECMA_SET_POINTER (prop_p->u.named_accessor_property.set_p, set_tmp_p);
|
||||
}
|
||||
ECMA_SET_POINTER(prop_p->u.named_accessor_property.set_p, set_p);
|
||||
ecma_gc_update_may_ref_younger_object_flag_by_object (obj_p, set_p);
|
||||
|
||||
prop_p->u.named_accessor_property.enumerable = (is_enumerable ?
|
||||
@@ -630,10 +591,10 @@ ecma_create_named_accessor_property (const ecma_object_ptr_t& obj_p, /**< object
|
||||
* NULL - otherwise.
|
||||
*/
|
||||
ecma_property_t*
|
||||
ecma_find_named_property (const ecma_object_ptr_t& obj_p, /**< object to find property in */
|
||||
ecma_find_named_property (ecma_object_t *obj_p, /**< object to find property in */
|
||||
ecma_string_t *name_p) /**< property's name */
|
||||
{
|
||||
JERRY_ASSERT(obj_p.is_not_null ());
|
||||
JERRY_ASSERT(obj_p != NULL);
|
||||
JERRY_ASSERT(name_p != NULL);
|
||||
|
||||
ecma_property_t *property_p;
|
||||
@@ -687,10 +648,10 @@ ecma_find_named_property (const ecma_object_ptr_t& obj_p, /**< object to find pr
|
||||
* NULL - otherwise.
|
||||
*/
|
||||
ecma_property_t*
|
||||
ecma_get_named_property (const ecma_object_ptr_t& obj_p, /**< object to find property in */
|
||||
ecma_get_named_property (ecma_object_t *obj_p, /**< object to find property in */
|
||||
ecma_string_t *name_p) /**< property's name */
|
||||
{
|
||||
JERRY_ASSERT(obj_p.is_not_null ());
|
||||
JERRY_ASSERT(obj_p != NULL);
|
||||
JERRY_ASSERT(name_p != NULL);
|
||||
|
||||
ecma_property_t *property_p = ecma_find_named_property (obj_p, name_p);
|
||||
@@ -710,10 +671,10 @@ ecma_get_named_property (const ecma_object_ptr_t& obj_p, /**< object to find pro
|
||||
* NULL - otherwise.
|
||||
*/
|
||||
ecma_property_t*
|
||||
ecma_get_named_data_property (const ecma_object_ptr_t& obj_p, /**< object to find property in */
|
||||
ecma_get_named_data_property (ecma_object_t *obj_p, /**< object to find property in */
|
||||
ecma_string_t *name_p) /**< property's name */
|
||||
{
|
||||
JERRY_ASSERT (obj_p.is_not_null ());
|
||||
JERRY_ASSERT (obj_p != NULL);
|
||||
JERRY_ASSERT (name_p != NULL);
|
||||
|
||||
ecma_property_t *property_p = ecma_find_named_property (obj_p, name_p);
|
||||
@@ -727,10 +688,10 @@ ecma_get_named_data_property (const ecma_object_ptr_t& obj_p, /**< object to fin
|
||||
* Free the named data property and values it references.
|
||||
*/
|
||||
static void
|
||||
ecma_free_named_data_property (const ecma_object_ptr_t& object_p, /**< object the property belongs to */
|
||||
ecma_free_named_data_property (ecma_object_t *object_p, /**< object the property belongs to */
|
||||
ecma_property_t *property_p) /**< the property */
|
||||
{
|
||||
JERRY_ASSERT (object_p.is_not_null ());
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
JERRY_ASSERT (property_p != NULL && property_p->type == ECMA_PROPERTY_NAMEDDATA);
|
||||
|
||||
ecma_lcache_invalidate (object_p, NULL, property_p);
|
||||
@@ -738,8 +699,8 @@ ecma_free_named_data_property (const ecma_object_ptr_t& object_p, /**< object th
|
||||
ecma_deref_ecma_string (ECMA_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
property_p->u.named_data_property.name_p));
|
||||
|
||||
ecma_value_t value_to_free (property_p->u.named_data_property.value);
|
||||
ecma_free_value (value_to_free, false);
|
||||
ecma_value_t v = property_p->u.named_data_property.value;
|
||||
ecma_free_value (v, false);
|
||||
|
||||
ecma_dealloc_property (property_p);
|
||||
} /* ecma_free_named_data_property */
|
||||
@@ -748,10 +709,10 @@ ecma_free_named_data_property (const ecma_object_ptr_t& object_p, /**< object th
|
||||
* Free the named accessor property and values it references.
|
||||
*/
|
||||
static void
|
||||
ecma_free_named_accessor_property (const ecma_object_ptr_t& object_p, /**< object the property belongs to */
|
||||
ecma_free_named_accessor_property (ecma_object_t *object_p, /**< object the property belongs to */
|
||||
ecma_property_t *property_p) /**< the property */
|
||||
{
|
||||
JERRY_ASSERT (object_p.is_not_null ());
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
JERRY_ASSERT (property_p != NULL && property_p->type == ECMA_PROPERTY_NAMEDACCESSOR);
|
||||
|
||||
ecma_lcache_invalidate (object_p, NULL, property_p);
|
||||
@@ -843,7 +804,7 @@ ecma_free_internal_property (ecma_property_t *property_p) /**< the property */
|
||||
* Free the property and values it references.
|
||||
*/
|
||||
void
|
||||
ecma_free_property (const ecma_object_ptr_t& object_p, /**< object the property belongs to */
|
||||
ecma_free_property (ecma_object_t *object_p, /**< object the property belongs to */
|
||||
ecma_property_t *prop_p) /**< property */
|
||||
{
|
||||
switch ((ecma_property_type_t) prop_p->type)
|
||||
@@ -877,7 +838,7 @@ ecma_free_property (const ecma_object_ptr_t& object_p, /**< object the property
|
||||
* Warning: specified property must be owned by specified object.
|
||||
*/
|
||||
void
|
||||
ecma_delete_property (const ecma_object_ptr_t& obj_p, /**< object */
|
||||
ecma_delete_property (ecma_object_t *obj_p, /**< object */
|
||||
ecma_property_t *prop_p) /**< property */
|
||||
{
|
||||
for (ecma_property_t *cur_prop_p = ecma_get_property_list (obj_p), *prev_prop_p = NULL, *next_prop_p;
|
||||
@@ -912,13 +873,12 @@ ecma_delete_property (const ecma_object_ptr_t& obj_p, /**< object */
|
||||
*
|
||||
* @return ecma-value
|
||||
*/
|
||||
void
|
||||
ecma_get_named_data_property_value (ecma_value_t &ret, /**< out: value */
|
||||
const ecma_property_t *prop_p) /**< property */
|
||||
ecma_value_t
|
||||
ecma_get_named_data_property_value (const ecma_property_t *prop_p) /**< property */
|
||||
{
|
||||
JERRY_ASSERT (prop_p->type == ECMA_PROPERTY_NAMEDDATA);
|
||||
|
||||
ret = prop_p->u.named_data_property.value;
|
||||
return prop_p->u.named_data_property.value;
|
||||
} /* ecma_get_named_data_property_value */
|
||||
|
||||
/**
|
||||
@@ -933,7 +893,7 @@ ecma_set_named_data_property_value (ecma_property_t *prop_p, /**< property */
|
||||
/* 'May ref younger' flag should be updated upon assignment of object value */
|
||||
JERRY_ASSERT (!ecma_is_value_object (value));
|
||||
|
||||
prop_p->u.named_data_property.value = (ecma_value_packed_t) value;
|
||||
prop_p->u.named_data_property.value = value;
|
||||
} /* ecma_set_named_data_property_value */
|
||||
|
||||
/**
|
||||
@@ -943,7 +903,7 @@ ecma_set_named_data_property_value (ecma_property_t *prop_p, /**< property */
|
||||
* value previously stored in the property is freed
|
||||
*/
|
||||
void
|
||||
ecma_named_data_property_assign_value (const ecma_object_ptr_t& obj_p, /**< object */
|
||||
ecma_named_data_property_assign_value (ecma_object_t *obj_p, /**< object */
|
||||
ecma_property_t *prop_p, /**< property */
|
||||
const ecma_value_t& value) /**< value to assign */
|
||||
{
|
||||
@@ -963,29 +923,23 @@ ecma_named_data_property_assign_value (const ecma_object_ptr_t& obj_p, /**< obje
|
||||
JERRY_ASSERT (prop_iter_p != NULL);
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
|
||||
if (ecma_is_value_number (value))
|
||||
if (ecma_is_value_number (value)
|
||||
&& ecma_is_value_number (prop_p->u.named_data_property.value))
|
||||
{
|
||||
ecma_value_t num_value (prop_p->u.named_data_property.value);
|
||||
const ecma_number_t *num_src_p = ecma_get_number_from_value (value);
|
||||
ecma_number_t *num_dst_p = ecma_get_number_from_value (prop_p->u.named_data_property.value);
|
||||
|
||||
if (ecma_is_value_number (num_value))
|
||||
{
|
||||
const ecma_number_t *num_src_p = ecma_get_number_from_value (value);
|
||||
ecma_number_t *num_dst_p = ecma_get_number_from_value (num_value);
|
||||
|
||||
*num_dst_p = *num_src_p;
|
||||
|
||||
return;
|
||||
}
|
||||
*num_dst_p = *num_src_p;
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_value_t v = ecma_get_named_data_property_value (prop_p);
|
||||
ecma_free_value (v, false);
|
||||
|
||||
ecma_value_t v;
|
||||
ecma_get_named_data_property_value (v, prop_p);
|
||||
ecma_free_value (v, false);
|
||||
|
||||
ecma_value_t value_copy;
|
||||
ecma_copy_value (value_copy, value, false);
|
||||
prop_p->u.named_data_property.value = (ecma_value_packed_t) value_copy;
|
||||
ecma_gc_update_may_ref_younger_object_flag_by_value (obj_p, value_copy);
|
||||
prop_p->u.named_data_property.value = ecma_copy_value (value, false);
|
||||
ecma_gc_update_may_ref_younger_object_flag_by_value (obj_p,
|
||||
prop_p->u.named_data_property.value);
|
||||
}
|
||||
} /* ecma_named_data_property_assign_value */
|
||||
|
||||
/**
|
||||
@@ -1152,7 +1106,7 @@ ecma_make_empty_property_descriptor (void)
|
||||
ecma_property_descriptor_t prop_desc;
|
||||
|
||||
prop_desc.is_value_defined = false;
|
||||
prop_desc.value = (ecma_value_packed_t) ecma_value_t (ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||
prop_desc.value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||
prop_desc.is_writable_defined = false;
|
||||
prop_desc.is_writable = false;
|
||||
prop_desc.is_enumerable_defined = false;
|
||||
@@ -1176,25 +1130,19 @@ ecma_free_property_descriptor (ecma_property_descriptor_t *prop_desc_p) /**< pro
|
||||
{
|
||||
if (prop_desc_p->is_value_defined)
|
||||
{
|
||||
ecma_value_t value_to_free (prop_desc_p->value);
|
||||
|
||||
ecma_free_value (value_to_free, true);
|
||||
ecma_free_value (prop_desc_p->value, true);
|
||||
}
|
||||
|
||||
if (prop_desc_p->is_get_defined
|
||||
&& prop_desc_p->get_p != NULL)
|
||||
{
|
||||
ecma_object_ptr_t get_p;
|
||||
get_p = prop_desc_p->get_p;
|
||||
ecma_deref_object (get_p);
|
||||
ecma_deref_object (prop_desc_p->get_p);
|
||||
}
|
||||
|
||||
if (prop_desc_p->is_set_defined
|
||||
&& prop_desc_p->set_p != NULL)
|
||||
{
|
||||
ecma_object_ptr_t set_p;
|
||||
set_p = prop_desc_p->set_p;
|
||||
ecma_deref_object (set_p);
|
||||
ecma_deref_object (prop_desc_p->set_p);
|
||||
}
|
||||
|
||||
*prop_desc_p = ecma_make_empty_property_descriptor ();
|
||||
|
||||
@@ -24,8 +24,100 @@
|
||||
#define JERRY_ECMA_HELPERS_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-compressed-pointers.h"
|
||||
#include "ecma-value.h"
|
||||
#include "mem-allocator.h"
|
||||
|
||||
/**
|
||||
* Get value of pointer from specified non-null compressed pointer field.
|
||||
*/
|
||||
#define ECMA_GET_NON_NULL_POINTER(type, field) \
|
||||
((type *) mem_decompress_pointer (field))
|
||||
|
||||
/**
|
||||
* Get value of pointer from specified compressed pointer field.
|
||||
*/
|
||||
#define ECMA_GET_POINTER(type, field) \
|
||||
(((unlikely (field == ECMA_NULL_POINTER)) ? NULL : ECMA_GET_NON_NULL_POINTER (type, field)))
|
||||
|
||||
/**
|
||||
* Set value of non-null compressed pointer field so that it will correspond
|
||||
* to specified non_compressed_pointer.
|
||||
*/
|
||||
#define ECMA_SET_NON_NULL_POINTER(field, non_compressed_pointer) \
|
||||
(field) = (mem_compress_pointer (non_compressed_pointer) & ((1u << ECMA_POINTER_FIELD_WIDTH) - 1))
|
||||
|
||||
/**
|
||||
* Set value of compressed pointer field so that it will correspond
|
||||
* to specified non_compressed_pointer.
|
||||
*/
|
||||
#define ECMA_SET_POINTER(field, non_compressed_pointer) \
|
||||
do \
|
||||
{ \
|
||||
auto __temp_pointer = non_compressed_pointer; \
|
||||
non_compressed_pointer = __temp_pointer; \
|
||||
} while (0); \
|
||||
\
|
||||
(field) = (unlikely ((non_compressed_pointer) == NULL) ? ECMA_NULL_POINTER \
|
||||
: (mem_compress_pointer (non_compressed_pointer) \
|
||||
& ((1u << ECMA_POINTER_FIELD_WIDTH) - 1)))
|
||||
|
||||
/* ecma-helpers-value.c */
|
||||
extern bool ecma_is_value_empty (const ecma_value_t& value);
|
||||
extern bool ecma_is_value_undefined (const ecma_value_t& value);
|
||||
extern bool ecma_is_value_null (const ecma_value_t& value);
|
||||
extern bool ecma_is_value_boolean (const ecma_value_t& value);
|
||||
extern bool ecma_is_value_true (const ecma_value_t& value);
|
||||
|
||||
extern bool ecma_is_value_number (const ecma_value_t& value);
|
||||
extern bool ecma_is_value_string (const ecma_value_t& value);
|
||||
extern bool ecma_is_value_object (const ecma_value_t& value);
|
||||
|
||||
extern void ecma_check_value_type_is_spec_defined (const ecma_value_t& value);
|
||||
|
||||
extern ecma_value_t ecma_make_simple_value (ecma_simple_value_t value);
|
||||
extern ecma_value_t ecma_make_number_value (ecma_number_t* num_p);
|
||||
extern ecma_value_t ecma_make_string_value (ecma_string_t* ecma_string_p);
|
||||
extern ecma_value_t ecma_make_object_value (ecma_object_t* object_p);
|
||||
extern ecma_number_t* __attribute_pure__ ecma_get_number_from_value (const ecma_value_t& value);
|
||||
extern ecma_string_t* __attribute_pure__ ecma_get_string_from_value (const ecma_value_t& value);
|
||||
extern ecma_object_t* __attribute_pure__ ecma_get_object_from_value (const ecma_value_t& value);
|
||||
extern ecma_value_t ecma_copy_value (const ecma_value_t& value, bool do_ref_if_object);
|
||||
extern void ecma_free_value (ecma_value_t& value, bool do_deref_if_object);
|
||||
|
||||
extern ecma_completion_value_t ecma_make_completion_value (ecma_completion_type_t type,
|
||||
const ecma_value_t& value);
|
||||
extern ecma_completion_value_t ecma_make_label_completion_value (ecma_completion_type_t type,
|
||||
uint8_t depth_level,
|
||||
uint16_t offset);
|
||||
extern ecma_completion_value_t ecma_make_simple_completion_value (ecma_simple_value_t simple_value);
|
||||
extern ecma_completion_value_t ecma_make_normal_completion_value (const ecma_value_t& value);
|
||||
extern ecma_completion_value_t ecma_make_throw_completion_value (const ecma_value_t& value);
|
||||
extern ecma_completion_value_t ecma_make_throw_obj_completion_value (ecma_object_t *exception_p);
|
||||
extern ecma_completion_value_t ecma_make_empty_completion_value (void);
|
||||
extern ecma_completion_value_t ecma_make_return_completion_value (const ecma_value_t& value);
|
||||
extern ecma_completion_value_t ecma_make_exit_completion_value (bool is_successful);
|
||||
extern ecma_completion_value_t ecma_make_meta_completion_value (void);
|
||||
extern ecma_value_t ecma_get_completion_value_value (ecma_completion_value_t completion_value);
|
||||
extern ecma_number_t* __attribute_const__
|
||||
ecma_get_number_from_completion_value (ecma_completion_value_t completion_value);
|
||||
extern ecma_string_t* __attribute_const__
|
||||
ecma_get_string_from_completion_value (ecma_completion_value_t completion_value);
|
||||
extern ecma_object_t* __attribute_const__
|
||||
ecma_get_object_from_completion_value (ecma_completion_value_t completion_value);
|
||||
extern ecma_completion_value_t ecma_copy_completion_value (ecma_completion_value_t value);
|
||||
extern void ecma_free_completion_value (ecma_completion_value_t completion_value);
|
||||
|
||||
extern bool ecma_is_completion_value_normal (ecma_completion_value_t value);
|
||||
extern bool ecma_is_completion_value_throw (ecma_completion_value_t value);
|
||||
extern bool ecma_is_completion_value_return (ecma_completion_value_t value);
|
||||
extern bool ecma_is_completion_value_exit (ecma_completion_value_t value);
|
||||
extern bool ecma_is_completion_value_meta (ecma_completion_value_t value);
|
||||
extern bool ecma_is_completion_value_break (ecma_completion_value_t value);
|
||||
extern bool ecma_is_completion_value_continue (ecma_completion_value_t value);
|
||||
extern bool ecma_is_completion_value_normal_simple_value (ecma_completion_value_t value,
|
||||
ecma_simple_value_t simple_value);
|
||||
extern bool ecma_is_completion_value_normal_true (ecma_completion_value_t value);
|
||||
extern bool ecma_is_completion_value_normal_false (ecma_completion_value_t value);
|
||||
extern bool ecma_is_completion_value_empty (ecma_completion_value_t value);
|
||||
|
||||
/* ecma-helpers-string.c */
|
||||
extern ecma_string_t* ecma_new_ecma_string (const ecma_char_t *string_p);
|
||||
@@ -119,9 +211,9 @@ typedef struct
|
||||
ecma_collection_header_t *header_p; /**< collection header */
|
||||
uint16_t next_chunk_cp; /**< compressed pointer to next chunk */
|
||||
ecma_length_t current_index; /**< index of current element */
|
||||
const ecma_value_packed_t *current_value_p; /**< pointer to current element */
|
||||
const ecma_value_packed_t *current_chunk_beg_p; /**< pointer to beginning of current chunk's data */
|
||||
const ecma_value_packed_t *current_chunk_end_p; /**< pointer to place right after the end of current chunk's data */
|
||||
const ecma_value_t *current_value_p; /**< pointer to current element */
|
||||
const ecma_value_t *current_chunk_beg_p; /**< pointer to beginning of current chunk's data */
|
||||
const ecma_value_t *current_chunk_end_p; /**< pointer to place right after the end of current chunk's data */
|
||||
} ecma_collection_iterator_t;
|
||||
|
||||
extern void
|
||||
@@ -131,73 +223,60 @@ extern bool
|
||||
ecma_collection_iterator_next (ecma_collection_iterator_t *iterator_p);
|
||||
|
||||
/* ecma-helpers.c */
|
||||
extern void
|
||||
ecma_create_object (ecma_object_ptr_t &ret_val,
|
||||
const ecma_object_ptr_t& prototype_object_p,
|
||||
bool is_extensible,
|
||||
ecma_object_type_t type);
|
||||
extern void
|
||||
ecma_create_decl_lex_env (ecma_object_ptr_t &ret_val,
|
||||
const ecma_object_ptr_t& outer_lexical_environment_p);
|
||||
extern void
|
||||
ecma_create_object_lex_env (ecma_object_ptr_t &ret_val,
|
||||
const ecma_object_ptr_t& outer_lexical_environment_p,
|
||||
const ecma_object_ptr_t& binding_obj_p,
|
||||
bool provide_this);
|
||||
extern bool __attribute_pure__ ecma_is_lexical_environment (const ecma_object_ptr_t& object_p);
|
||||
extern bool __attribute_pure__ ecma_get_object_extensible (const ecma_object_ptr_t& object_p);
|
||||
extern void ecma_set_object_extensible (const ecma_object_ptr_t& object_p, bool is_extensible);
|
||||
extern ecma_object_type_t __attribute_pure__ ecma_get_object_type (const ecma_object_ptr_t& object_p);
|
||||
extern void ecma_set_object_type (const ecma_object_ptr_t& object_p, ecma_object_type_t type);
|
||||
extern void
|
||||
ecma_get_object_prototype (ecma_object_ptr_t &ret_val,
|
||||
const ecma_object_ptr_t& object_p);
|
||||
extern bool __attribute_pure__ ecma_get_object_is_builtin (const ecma_object_ptr_t& object_p);
|
||||
extern void ecma_set_object_is_builtin (const ecma_object_ptr_t& object_p,
|
||||
extern ecma_object_t* ecma_create_object (ecma_object_t *prototype_object_p,
|
||||
bool is_extensible,
|
||||
ecma_object_type_t type);
|
||||
extern ecma_object_t* ecma_create_decl_lex_env (ecma_object_t *outer_lexical_environment_p);
|
||||
extern ecma_object_t* ecma_create_object_lex_env (ecma_object_t *outer_lexical_environment_p,
|
||||
ecma_object_t *binding_obj_p,
|
||||
bool provide_this);
|
||||
extern bool __attribute_pure__ ecma_is_lexical_environment (const ecma_object_t *object_p);
|
||||
extern bool __attribute_pure__ ecma_get_object_extensible (const ecma_object_t *object_p);
|
||||
extern void ecma_set_object_extensible (ecma_object_t *object_p, bool is_extensible);
|
||||
extern ecma_object_type_t __attribute_pure__ ecma_get_object_type (const ecma_object_t *object_p);
|
||||
extern void ecma_set_object_type (ecma_object_t *object_p, ecma_object_type_t type);
|
||||
extern ecma_object_t* __attribute_pure__ ecma_get_object_prototype (const ecma_object_t *object_p);
|
||||
extern bool __attribute_pure__ ecma_get_object_is_builtin (const ecma_object_t *object_p);
|
||||
extern void ecma_set_object_is_builtin (ecma_object_t *object_p,
|
||||
bool is_builtin);
|
||||
extern ecma_lexical_environment_type_t __attribute_pure__
|
||||
ecma_get_lex_env_type (const ecma_object_ptr_t& object_p);
|
||||
extern void
|
||||
ecma_get_lex_env_outer_reference (ecma_object_ptr_t &ret_val,
|
||||
const ecma_object_ptr_t& object_p);
|
||||
extern ecma_property_t* __attribute_pure__ ecma_get_property_list (const ecma_object_ptr_t& object_p);
|
||||
extern void
|
||||
ecma_get_lex_env_binding_object (ecma_object_ptr_t &ret_val,
|
||||
const ecma_object_ptr_t& object_p);
|
||||
extern bool __attribute_pure__ ecma_get_lex_env_provide_this (const ecma_object_ptr_t& object_p);
|
||||
extern ecma_lexical_environment_type_t __attribute_pure__ ecma_get_lex_env_type (const ecma_object_t *object_p);
|
||||
extern ecma_object_t* __attribute_pure__ ecma_get_lex_env_outer_reference (const ecma_object_t *object_p);
|
||||
extern ecma_property_t* __attribute_pure__ ecma_get_property_list (const ecma_object_t *object_p);
|
||||
extern ecma_object_t* __attribute_pure__ ecma_get_lex_env_binding_object (const ecma_object_t *object_p);
|
||||
extern bool __attribute_pure__ ecma_get_lex_env_provide_this (const ecma_object_t *object_p);
|
||||
|
||||
extern ecma_property_t* ecma_create_internal_property (const ecma_object_ptr_t& object_p,
|
||||
extern ecma_property_t* ecma_create_internal_property (ecma_object_t *object_p,
|
||||
ecma_internal_property_id_t property_id);
|
||||
extern ecma_property_t* ecma_find_internal_property (const ecma_object_ptr_t& object_p,
|
||||
extern ecma_property_t* ecma_find_internal_property (ecma_object_t *object_p,
|
||||
ecma_internal_property_id_t property_id);
|
||||
extern ecma_property_t* ecma_get_internal_property (const ecma_object_ptr_t& object_p,
|
||||
extern ecma_property_t* ecma_get_internal_property (ecma_object_t *object_p,
|
||||
ecma_internal_property_id_t property_id);
|
||||
|
||||
extern ecma_property_t *ecma_create_named_data_property (const ecma_object_ptr_t& obj_p,
|
||||
extern ecma_property_t *ecma_create_named_data_property (ecma_object_t *obj_p,
|
||||
ecma_string_t *name_p,
|
||||
bool is_writable,
|
||||
bool is_enumerable,
|
||||
bool is_configurable);
|
||||
extern ecma_property_t *ecma_create_named_accessor_property (const ecma_object_ptr_t& obj_p,
|
||||
extern ecma_property_t *ecma_create_named_accessor_property (ecma_object_t *obj_p,
|
||||
ecma_string_t *name_p,
|
||||
const ecma_object_ptr_t& get_p,
|
||||
const ecma_object_ptr_t& set_p,
|
||||
ecma_object_t *get_p,
|
||||
ecma_object_t *set_p,
|
||||
bool is_enumerable,
|
||||
bool is_configurable);
|
||||
extern ecma_property_t *ecma_find_named_property (const ecma_object_ptr_t& obj_p,
|
||||
extern ecma_property_t *ecma_find_named_property (ecma_object_t *obj_p,
|
||||
ecma_string_t *name_p);
|
||||
extern ecma_property_t *ecma_get_named_property (const ecma_object_ptr_t& obj_p,
|
||||
extern ecma_property_t *ecma_get_named_property (ecma_object_t *obj_p,
|
||||
ecma_string_t *name_p);
|
||||
extern ecma_property_t *ecma_get_named_data_property (const ecma_object_ptr_t& obj_p,
|
||||
extern ecma_property_t *ecma_get_named_data_property (ecma_object_t *obj_p,
|
||||
ecma_string_t *name_p);
|
||||
|
||||
extern void ecma_free_property (const ecma_object_ptr_t& obj_p, ecma_property_t *prop_p);
|
||||
extern void ecma_free_property (ecma_object_t *obj_p, ecma_property_t *prop_p);
|
||||
|
||||
extern void ecma_delete_property (const ecma_object_ptr_t& obj_p, ecma_property_t *prop_p);
|
||||
extern void ecma_delete_property (ecma_object_t *obj_p, ecma_property_t *prop_p);
|
||||
|
||||
extern void ecma_get_named_data_property_value (ecma_value_t &ret, const ecma_property_t *prop_p);
|
||||
extern ecma_value_t ecma_get_named_data_property_value (const ecma_property_t *prop_p);
|
||||
extern void ecma_set_named_data_property_value (ecma_property_t *prop_p, const ecma_value_t& value);
|
||||
extern void ecma_named_data_property_assign_value (const ecma_object_ptr_t& obj_p,
|
||||
extern void ecma_named_data_property_assign_value (ecma_object_t *obj_p,
|
||||
ecma_property_t *prop_p,
|
||||
const ecma_value_t& value);
|
||||
|
||||
|
||||
@@ -84,9 +84,8 @@ ecma_lcache_invalidate_entry (ecma_lcache_hash_entry_t *entry_p) /**< entry to i
|
||||
JERRY_ASSERT (entry_p != NULL);
|
||||
JERRY_ASSERT (entry_p->object_cp != ECMA_NULL_POINTER);
|
||||
|
||||
ecma_object_ptr_t entry_object_p;
|
||||
entry_object_p.unpack_from (entry_p->object_cp);
|
||||
ecma_deref_object (entry_object_p);
|
||||
ecma_deref_object (ECMA_GET_NON_NULL_POINTER (ecma_object_t,
|
||||
entry_p->object_cp));
|
||||
|
||||
entry_p->object_cp = ECMA_NULL_POINTER;
|
||||
ecma_deref_ecma_string (ECMA_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
@@ -123,11 +122,11 @@ ecma_lcache_invalidate_all (void)
|
||||
*/
|
||||
static void
|
||||
ecma_lcache_invalidate_row_for_object_property_pair (uint32_t row_index, /**< index of the row */
|
||||
uintptr_t object_cp, /**< compressed pointer
|
||||
* to an object */
|
||||
uintptr_t property_cp) /**< compressed pointer
|
||||
* to the object's
|
||||
* property */
|
||||
unsigned int object_cp, /**< compressed pointer
|
||||
* to an object */
|
||||
unsigned property_cp) /**< compressed pointer
|
||||
* to the object's
|
||||
* property */
|
||||
{
|
||||
for (uint32_t entry_index = 0; entry_index < ECMA_LCACHE_HASH_ROW_LENGTH; entry_index++)
|
||||
{
|
||||
@@ -143,13 +142,13 @@ ecma_lcache_invalidate_row_for_object_property_pair (uint32_t row_index, /**< in
|
||||
* Insert an entry into LCache
|
||||
*/
|
||||
void
|
||||
ecma_lcache_insert (const ecma_object_ptr_t& object_p, /**< object */
|
||||
ecma_lcache_insert (ecma_object_t *object_p, /**< object */
|
||||
ecma_string_t *prop_name_p, /**< property's name */
|
||||
ecma_property_t *prop_p) /**< pointer to associated property or NULL
|
||||
* (NULL indicates that the object doesn't have property
|
||||
* with the name specified) */
|
||||
{
|
||||
JERRY_ASSERT (object_p.is_not_null ());
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
JERRY_ASSERT (prop_name_p != NULL);
|
||||
|
||||
prop_name_p = ecma_copy_or_ref_ecma_string (prop_name_p);
|
||||
@@ -170,9 +169,9 @@ ecma_lcache_insert (const ecma_object_ptr_t& object_p, /**< object */
|
||||
&& ecma_lcache_hash_table[hash_key][entry_index].prop_cp == prop_cp)
|
||||
{
|
||||
#ifndef JERRY_NDEBUG
|
||||
ecma_object_ptr_t obj_in_entry_p;
|
||||
obj_in_entry_p.unpack_from (ecma_lcache_hash_table[hash_key][entry_index].object_cp);
|
||||
|
||||
ecma_object_t* obj_in_entry_p;
|
||||
obj_in_entry_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t,
|
||||
ecma_lcache_hash_table[hash_key][entry_index].object_cp);
|
||||
JERRY_ASSERT (obj_in_entry_p == object_p);
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
break;
|
||||
@@ -208,10 +207,7 @@ ecma_lcache_insert (const ecma_object_ptr_t& object_p, /**< object */
|
||||
}
|
||||
|
||||
ecma_ref_object (object_p);
|
||||
{
|
||||
ecma_object_t *object_tmp_p = (ecma_object_t*) object_p;
|
||||
ECMA_SET_NON_NULL_POINTER (ecma_lcache_hash_table[ hash_key ][ entry_index ].object_cp, object_tmp_p);
|
||||
}
|
||||
ECMA_SET_NON_NULL_POINTER (ecma_lcache_hash_table[ hash_key ][ entry_index ].object_cp, object_p);
|
||||
ECMA_SET_NON_NULL_POINTER (ecma_lcache_hash_table[ hash_key ][ entry_index ].prop_name_cp, prop_name_p);
|
||||
ECMA_SET_POINTER (ecma_lcache_hash_table[ hash_key ][ entry_index ].prop_cp, prop_p);
|
||||
} /* ecma_lcache_insert */
|
||||
@@ -223,7 +219,7 @@ ecma_lcache_insert (const ecma_object_ptr_t& object_p, /**< object */
|
||||
* false - probably, not registered.
|
||||
*/
|
||||
bool __attribute_always_inline__
|
||||
ecma_lcache_lookup (const ecma_object_ptr_t& object_p, /**< object */
|
||||
ecma_lcache_lookup (ecma_object_t *object_p, /**< object */
|
||||
const ecma_string_t *prop_name_p, /**< property's name */
|
||||
ecma_property_t **prop_p_p) /**< out: if return value is true,
|
||||
* then here will be pointer to property,
|
||||
@@ -234,8 +230,8 @@ ecma_lcache_lookup (const ecma_object_ptr_t& object_p, /**< object */
|
||||
{
|
||||
ecma_string_hash_t hash_key = ecma_string_hash (prop_name_p);
|
||||
|
||||
uintptr_t object_cp;
|
||||
object_p.pack_to (object_cp);
|
||||
unsigned int object_cp;
|
||||
ECMA_SET_NON_NULL_POINTER (object_cp, object_p);
|
||||
|
||||
for (uint32_t i = 0; i < ECMA_LCACHE_HASH_ROW_LENGTH; i++)
|
||||
{
|
||||
@@ -273,11 +269,11 @@ ecma_lcache_lookup (const ecma_object_ptr_t& object_p, /**< object */
|
||||
* from property's description.
|
||||
*/
|
||||
void
|
||||
ecma_lcache_invalidate (const ecma_object_ptr_t& object_p, /**< object */
|
||||
ecma_lcache_invalidate (ecma_object_t *object_p, /**< object */
|
||||
ecma_string_t *prop_name_arg_p, /**< property's name (See also: Note) */
|
||||
ecma_property_t *prop_p) /**< property (See also: Note) */
|
||||
{
|
||||
JERRY_ASSERT (object_p.is_not_null ());
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
JERRY_ASSERT (prop_p != NULL || prop_name_arg_p != NULL);
|
||||
|
||||
ecma_string_t *prop_name_p = NULL;
|
||||
@@ -312,8 +308,8 @@ ecma_lcache_invalidate (const ecma_object_ptr_t& object_p, /**< object */
|
||||
prop_name_p = prop_name_arg_p;
|
||||
}
|
||||
|
||||
uintptr_t object_cp, prop_cp;
|
||||
object_p.pack_to (object_cp);
|
||||
unsigned int object_cp, prop_cp;
|
||||
ECMA_SET_NON_NULL_POINTER (object_cp, object_p);
|
||||
ECMA_SET_POINTER (prop_cp, prop_p);
|
||||
|
||||
ecma_string_hash_t hash_key = ecma_string_hash (prop_name_p);
|
||||
|
||||
@@ -25,15 +25,9 @@
|
||||
|
||||
extern void ecma_lcache_init (void);
|
||||
extern void ecma_lcache_invalidate_all (void);
|
||||
extern void ecma_lcache_insert (const ecma_object_ptr_t& object_p, ecma_string_t *prop_name_p, ecma_property_t *prop_p);
|
||||
extern bool
|
||||
ecma_lcache_lookup (const ecma_object_ptr_t& object_p,
|
||||
const ecma_string_t *prop_name_p,
|
||||
ecma_property_t **prop_p_p);
|
||||
extern void
|
||||
ecma_lcache_invalidate (const ecma_object_ptr_t& object_p,
|
||||
ecma_string_t *prop_name_arg_p,
|
||||
ecma_property_t *prop_p);
|
||||
extern void ecma_lcache_insert (ecma_object_t *object_p, ecma_string_t *prop_name_p, ecma_property_t *prop_p);
|
||||
extern bool ecma_lcache_lookup (ecma_object_t *object_p, const ecma_string_t *prop_name_p, ecma_property_t **prop_p_p);
|
||||
extern void ecma_lcache_invalidate (ecma_object_t *object_p, ecma_string_t *prop_name_arg_p, ecma_property_t *prop_p);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -74,7 +74,7 @@ ecma_stack_get_top_frame (void)
|
||||
*/
|
||||
void
|
||||
ecma_stack_add_frame (ecma_stack_frame_t *frame_p, /**< frame to initialize */
|
||||
ecma_value_packed_t *regs_p, /**< array of register variables' values */
|
||||
ecma_value_t *regs_p, /**< array of register variables' values */
|
||||
int32_t regs_num) /**< number of register variables */
|
||||
{
|
||||
frame_p->prev_frame_p = ecma_stack_top_frame_p;
|
||||
@@ -88,7 +88,7 @@ ecma_stack_add_frame (ecma_stack_frame_t *frame_p, /**< frame to initialize */
|
||||
|
||||
for (int32_t i = 0; i < regs_num; i++)
|
||||
{
|
||||
regs_p [i] = (ecma_value_packed_t) ecma_value_t (ECMA_SIMPLE_VALUE_EMPTY);
|
||||
regs_p [i] = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
|
||||
}
|
||||
} /* ecma_stack_add_frame */
|
||||
|
||||
@@ -115,8 +115,7 @@ ecma_stack_free_frame (ecma_stack_frame_t *frame_p) /**< frame to initialize */
|
||||
reg_index < frame_p->regs_number;
|
||||
reg_index++)
|
||||
{
|
||||
ecma_value_t value_to_free (frame_p->regs_p [reg_index]);
|
||||
ecma_free_value (value_to_free, false);
|
||||
ecma_free_value (frame_p->regs_p [reg_index], false);
|
||||
}
|
||||
} /* ecma_stack_free_frame */
|
||||
|
||||
@@ -125,14 +124,13 @@ ecma_stack_free_frame (ecma_stack_frame_t *frame_p) /**< frame to initialize */
|
||||
*
|
||||
* @return ecma-value
|
||||
*/
|
||||
void
|
||||
ecma_stack_frame_get_reg_value (ecma_value_t &ret, /**< out: ecma-value */
|
||||
ecma_stack_frame_t *frame_p, /**< frame */
|
||||
ecma_value_t
|
||||
ecma_stack_frame_get_reg_value (ecma_stack_frame_t *frame_p, /**< frame */
|
||||
int32_t reg_index) /**< index of register variable */
|
||||
{
|
||||
JERRY_ASSERT (reg_index >= 0 && reg_index < frame_p->regs_number);
|
||||
|
||||
ret = frame_p->regs_p [reg_index];
|
||||
return frame_p->regs_p [reg_index];
|
||||
} /* ecma_stack_frame_get_reg_value */
|
||||
|
||||
/**
|
||||
@@ -141,11 +139,11 @@ ecma_stack_frame_get_reg_value (ecma_value_t &ret, /**< out: ecma-value */
|
||||
void
|
||||
ecma_stack_frame_set_reg_value (ecma_stack_frame_t *frame_p, /**< frame */
|
||||
int32_t reg_index, /**< index of register variable */
|
||||
const ecma_value_t& value) /**< ecma-value */
|
||||
ecma_value_t value) /**< ecma-value */
|
||||
{
|
||||
JERRY_ASSERT (reg_index >= 0 && reg_index < frame_p->regs_number);
|
||||
|
||||
frame_p->regs_p [reg_index] = (ecma_value_packed_t) value;
|
||||
frame_p->regs_p [reg_index] = value;
|
||||
} /* ecma_stack_frame_set_reg_value */
|
||||
|
||||
/**
|
||||
@@ -179,7 +177,7 @@ ecma_stack_push_value_longpath (ecma_stack_frame_t *frame_p) /**< ecma-stack fra
|
||||
ECMA_SET_POINTER (chunk_p->prev_chunk_p, frame_p->top_chunk_p);
|
||||
|
||||
frame_p->top_chunk_p = chunk_p;
|
||||
frame_p->dynamically_allocated_value_slots_p = (ecma_value_packed_t*) (frame_p->top_chunk_p + 1);
|
||||
frame_p->dynamically_allocated_value_slots_p = (ecma_value_t*) (frame_p->top_chunk_p + 1);
|
||||
frame_p->current_slot_index = 0;
|
||||
}
|
||||
} /* ecma_stack_push_value_longpath */
|
||||
@@ -201,21 +199,20 @@ ecma_stack_push_value (ecma_stack_frame_t *frame_p, /**< ecma-stack frame */
|
||||
|
||||
JERRY_ASSERT (frame_p->current_slot_index < ecma_stack_slots_in_top_chunk (frame_p));
|
||||
|
||||
frame_p->dynamically_allocated_value_slots_p [frame_p->current_slot_index] = (ecma_value_packed_t) value;
|
||||
frame_p->dynamically_allocated_value_slots_p [frame_p->current_slot_index] = value;
|
||||
} /* ecma_stack_push_value */
|
||||
|
||||
/**
|
||||
* Get top value from ecma-stack
|
||||
*/
|
||||
void __attribute_always_inline__
|
||||
ecma_stack_top_value (ecma_value_t &ret, /**< out: ecma-value */
|
||||
ecma_stack_frame_t *frame_p) /**< ecma-stack frame */
|
||||
ecma_value_t __attribute_always_inline__
|
||||
ecma_stack_top_value (ecma_stack_frame_t *frame_p) /**< ecma-stack frame */
|
||||
{
|
||||
const size_t slots_in_top_chunk = ecma_stack_slots_in_top_chunk (frame_p);
|
||||
|
||||
JERRY_ASSERT (frame_p->current_slot_index < slots_in_top_chunk);
|
||||
|
||||
ret = frame_p->dynamically_allocated_value_slots_p [frame_p->current_slot_index];
|
||||
return frame_p->dynamically_allocated_value_slots_p [frame_p->current_slot_index];
|
||||
} /* ecma_stack_top_value */
|
||||
|
||||
/**
|
||||
@@ -232,7 +229,7 @@ ecma_stack_pop_longpath (ecma_stack_frame_t *frame_p) /**< ecma-stack frame */
|
||||
|
||||
if (frame_p->top_chunk_p != NULL)
|
||||
{
|
||||
frame_p->dynamically_allocated_value_slots_p = (ecma_value_packed_t*) (frame_p->top_chunk_p + 1);
|
||||
frame_p->dynamically_allocated_value_slots_p = (ecma_value_t*) (frame_p->top_chunk_p + 1);
|
||||
frame_p->current_slot_index = (uint32_t) (ECMA_STACK_SLOTS_IN_DYNAMIC_CHUNK - 1u);
|
||||
}
|
||||
else
|
||||
@@ -252,8 +249,7 @@ ecma_stack_pop (ecma_stack_frame_t *frame_p) /**< ecma-stack frame */
|
||||
{
|
||||
JERRY_ASSERT (frame_p->current_slot_index < ecma_stack_slots_in_top_chunk (frame_p));
|
||||
|
||||
ecma_value_t value;
|
||||
ecma_stack_top_value (value, frame_p);
|
||||
ecma_value_t value = ecma_stack_top_value (frame_p);
|
||||
|
||||
if (unlikely (frame_p->current_slot_index == 0
|
||||
&& frame_p->top_chunk_p != NULL))
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
#include "config.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-value.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
@@ -47,14 +46,13 @@ typedef struct ecma_stack_frame_t
|
||||
{
|
||||
struct ecma_stack_frame_t *prev_frame_p; /**< previous frame */
|
||||
ecma_stack_chunk_header_t *top_chunk_p; /**< the top-most chunk of the frame */
|
||||
ecma_value_packed_t *dynamically_allocated_value_slots_p; /**< pointer to dynamically allocated value slots
|
||||
* in the top-most chunk */
|
||||
ecma_value_t *dynamically_allocated_value_slots_p; /**< pointer to dynamically allocated value slots
|
||||
* in the top-most chunk */
|
||||
uint32_t current_slot_index; /**< index of first free slot in the top chunk */
|
||||
ecma_value_packed_t inlined_values [ECMA_STACK_FRAME_INLINED_VALUES_NUMBER]; /**< place for values inlined
|
||||
* in stack frame (instead of
|
||||
* being dynamically allocated
|
||||
* on the heap) */
|
||||
ecma_value_packed_t *regs_p; /**< register variables */
|
||||
ecma_value_t inlined_values [ECMA_STACK_FRAME_INLINED_VALUES_NUMBER]; /**< place for values inlined in stack frame
|
||||
* (instead of being dynamically allocated
|
||||
* on the heap) */
|
||||
ecma_value_t *regs_p; /**< register variables */
|
||||
int32_t regs_number; /**< number of register variables */
|
||||
} ecma_stack_frame_t;
|
||||
|
||||
@@ -64,18 +62,13 @@ extern ecma_stack_frame_t*
|
||||
ecma_stack_get_top_frame (void);
|
||||
extern void
|
||||
ecma_stack_add_frame (ecma_stack_frame_t *frame_p,
|
||||
ecma_value_packed_t *regs_p,
|
||||
ecma_value_t *regs_p,
|
||||
int32_t regs_num);
|
||||
extern void ecma_stack_free_frame (ecma_stack_frame_t *frame_p);
|
||||
extern void ecma_stack_frame_get_reg_value (ecma_value_t &ret,
|
||||
ecma_stack_frame_t *frame_p,
|
||||
int32_t reg_index);
|
||||
extern void
|
||||
ecma_stack_frame_set_reg_value (ecma_stack_frame_t *frame_p,
|
||||
int32_t reg_index,
|
||||
const ecma_value_t& value);
|
||||
extern ecma_value_t ecma_stack_frame_get_reg_value (ecma_stack_frame_t *frame_p, int32_t reg_index);
|
||||
extern void ecma_stack_frame_set_reg_value (ecma_stack_frame_t *frame_p, int32_t reg_index, ecma_value_t value);
|
||||
extern void ecma_stack_push_value (ecma_stack_frame_t *frame_p, ecma_value_t value);
|
||||
extern void ecma_stack_top_value (ecma_value_t &ret, ecma_stack_frame_t *frame_p);
|
||||
extern ecma_value_t ecma_stack_top_value (ecma_stack_frame_t *frame_p);
|
||||
extern void ecma_stack_pop (ecma_stack_frame_t *frame_p);
|
||||
extern void ecma_stack_pop_multiple (ecma_stack_frame_t *frame_p, uint32_t number);
|
||||
|
||||
|
||||
@@ -1,269 +0,0 @@
|
||||
/* Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-value.h"
|
||||
#include "globals.h"
|
||||
#include "jrt-bit-fields.h"
|
||||
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_value_packed_t) * JERRY_BITSINBYTE == ECMA_VALUE_SIZE);
|
||||
|
||||
/**
|
||||
* Get pointer to ecma-number from ecma-value
|
||||
*
|
||||
* @return the pointer
|
||||
*/
|
||||
ecma_number_t* __attribute_pure__
|
||||
ecma_get_number_from_value (const ecma_value_t& value) /**< ecma-value */
|
||||
{
|
||||
return value.get_number ();
|
||||
} /* ecma_get_number_from_value */
|
||||
|
||||
/**
|
||||
* Get pointer to ecma-string from ecma-value
|
||||
*
|
||||
* @return the pointer
|
||||
*/
|
||||
ecma_string_t* __attribute_pure__
|
||||
ecma_get_string_from_value (const ecma_value_t& value) /**< ecma-value */
|
||||
{
|
||||
return value.get_string ();
|
||||
} /* ecma_get_string_from_value */
|
||||
|
||||
/**
|
||||
* Get pointer to ecma-object from ecma-value
|
||||
*
|
||||
* @return the pointer
|
||||
*/
|
||||
void
|
||||
ecma_get_object_from_value (ecma_object_ptr_t &ret_val, /**< out: object pointer */
|
||||
const ecma_value_t& value) /**< ecma-value */
|
||||
{
|
||||
ret_val = value.get_object ();
|
||||
} /* ecma_get_object_from_value */
|
||||
|
||||
/**
|
||||
* Copy ecma-value.
|
||||
*
|
||||
* Note:
|
||||
* Operation algorithm.
|
||||
* switch (valuetype)
|
||||
* case simple:
|
||||
* simply return the value as it was passed;
|
||||
* case number:
|
||||
* copy the number
|
||||
* and return new ecma-value
|
||||
* pointing to copy of the number;
|
||||
* case string:
|
||||
* increase reference counter of the string
|
||||
* and return the value as it was passed.
|
||||
* case object;
|
||||
* increase reference counter of the object if do_ref_if_object is true
|
||||
* and return the value as it was passed.
|
||||
*
|
||||
* @return See note.
|
||||
*/
|
||||
void
|
||||
ecma_copy_value (ecma_value_t &ret, /**< out: ecma-value */
|
||||
const ecma_value_t& value, /**< ecma-value */
|
||||
bool do_ref_if_object) /**< if the value is object value,
|
||||
increment reference counter of the object */
|
||||
{
|
||||
switch (ecma_get_value_type_field (value))
|
||||
{
|
||||
case ECMA_TYPE_SIMPLE:
|
||||
{
|
||||
ret = value;
|
||||
|
||||
break;
|
||||
}
|
||||
case ECMA_TYPE_NUMBER:
|
||||
{
|
||||
ecma_number_t *num_p = ecma_get_number_from_value (value);
|
||||
|
||||
ecma_number_t *number_copy_p = ecma_alloc_number ();
|
||||
*number_copy_p = *num_p;
|
||||
|
||||
ret = number_copy_p;
|
||||
|
||||
break;
|
||||
}
|
||||
case ECMA_TYPE_STRING:
|
||||
{
|
||||
ecma_string_t *string_p = ecma_get_string_from_value (value);
|
||||
|
||||
string_p = ecma_copy_or_ref_ecma_string (string_p);
|
||||
|
||||
ret = string_p;
|
||||
|
||||
break;
|
||||
}
|
||||
case ECMA_TYPE_OBJECT:
|
||||
{
|
||||
ecma_object_ptr_t obj_p;
|
||||
ecma_get_object_from_value (obj_p, value);
|
||||
|
||||
if (do_ref_if_object)
|
||||
{
|
||||
ecma_ref_object (obj_p);
|
||||
}
|
||||
|
||||
ret = value;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
} /* ecma_copy_value */
|
||||
|
||||
/**
|
||||
* Free the ecma-value
|
||||
*/
|
||||
void
|
||||
ecma_free_value (ecma_value_t& value, /**< value description */
|
||||
bool do_deref_if_object) /**< if the value is object value,
|
||||
decrement reference counter of the object */
|
||||
{
|
||||
switch (ecma_get_value_type_field (value))
|
||||
{
|
||||
case ECMA_TYPE_SIMPLE:
|
||||
{
|
||||
/* doesn't hold additional memory */
|
||||
break;
|
||||
}
|
||||
|
||||
case ECMA_TYPE_NUMBER:
|
||||
{
|
||||
ecma_number_t *number_p = ecma_get_number_from_value (value);
|
||||
ecma_dealloc_number (number_p);
|
||||
break;
|
||||
}
|
||||
|
||||
case ECMA_TYPE_STRING:
|
||||
{
|
||||
ecma_string_t *string_p = ecma_get_string_from_value (value);
|
||||
ecma_deref_ecma_string (string_p);
|
||||
break;
|
||||
}
|
||||
|
||||
case ECMA_TYPE_OBJECT:
|
||||
{
|
||||
if (do_deref_if_object)
|
||||
{
|
||||
ecma_object_ptr_t obj_p;
|
||||
ecma_get_object_from_value (obj_p, value);
|
||||
ecma_deref_object (obj_p);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} /* ecma_free_value */
|
||||
|
||||
/**
|
||||
* Throw completion value constructor.
|
||||
*
|
||||
* @return 'throw' completion value
|
||||
*/
|
||||
void
|
||||
ecma_make_throw_obj_completion_value (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_object_ptr_t& exception_p) /**< an object */
|
||||
{
|
||||
JERRY_ASSERT(exception_p.is_not_null ()
|
||||
&& !ecma_is_lexical_environment (exception_p));
|
||||
|
||||
ecma_value_t exception (exception_p);
|
||||
|
||||
ecma_make_throw_completion_value (ret_value, exception);
|
||||
} /* ecma_make_throw_obj_completion_value */
|
||||
|
||||
/**
|
||||
* Copy ecma-completion value.
|
||||
*
|
||||
* @return (source.type, ecma_copy_value (source.value), source.target).
|
||||
*/
|
||||
void
|
||||
ecma_copy_completion_value (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_completion_value_t& value) /**< completion value */
|
||||
{
|
||||
const ecma_completion_type_t type = (ecma_completion_type_t) (value);
|
||||
const bool is_type_ok = (type == ECMA_COMPLETION_TYPE_NORMAL
|
||||
#ifdef CONFIG_ECMA_EXCEPTION_SUPPORT
|
||||
|| type == ECMA_COMPLETION_TYPE_THROW
|
||||
#endif /* CONFIG_ECMA_EXCEPTION_SUPPORT */
|
||||
|| type == ECMA_COMPLETION_TYPE_RETURN
|
||||
|| type == ECMA_COMPLETION_TYPE_EXIT);
|
||||
|
||||
JERRY_ASSERT (is_type_ok);
|
||||
|
||||
ecma_value_t v ((ecma_value_packed_t) value);
|
||||
|
||||
ecma_value_t value_copy;
|
||||
ecma_copy_value (value_copy, v, true);
|
||||
|
||||
ecma_make_completion_value (ret_value, type, value_copy);
|
||||
} /* ecma_copy_completion_value */
|
||||
|
||||
/**
|
||||
* Free the completion value.
|
||||
*/
|
||||
void
|
||||
ecma_free_completion_value (ecma_completion_value_t& completion_value) /**< completion value */
|
||||
{
|
||||
switch ((ecma_completion_type_t) (completion_value))
|
||||
{
|
||||
case ECMA_COMPLETION_TYPE_NORMAL:
|
||||
#ifdef CONFIG_ECMA_EXCEPTION_SUPPORT
|
||||
case ECMA_COMPLETION_TYPE_THROW:
|
||||
#endif /* CONFIG_ECMA_EXCEPTION_SUPPORT */
|
||||
case ECMA_COMPLETION_TYPE_RETURN:
|
||||
{
|
||||
ecma_value_t v ((ecma_value_packed_t) completion_value);
|
||||
|
||||
ecma_free_value (v, true);
|
||||
break;
|
||||
}
|
||||
case ECMA_COMPLETION_TYPE_EXIT:
|
||||
{
|
||||
const ecma_value_t& v = completion_value;
|
||||
|
||||
JERRY_ASSERT (v.is_simple ());
|
||||
|
||||
break;
|
||||
}
|
||||
case ECMA_COMPLETION_TYPE_META:
|
||||
{
|
||||
JERRY_UNREACHABLE ();
|
||||
}
|
||||
}
|
||||
|
||||
ecma_make_empty_completion_value (completion_value);
|
||||
} /* ecma_free_completion_value */
|
||||
|
||||
/**
|
||||
* Debug assertion that specified value's type is one of ECMA-defined
|
||||
* script-visible types, i.e.: undefined, null, boolean, number, string, object.
|
||||
*/
|
||||
void
|
||||
ecma_check_value_type_is_spec_defined (const ecma_value_t& value) /**< ecma-value */
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_undefined (value)
|
||||
|| ecma_is_value_null (value)
|
||||
|| ecma_is_value_boolean (value)
|
||||
|| ecma_is_value_number (value)
|
||||
|| ecma_is_value_string (value)
|
||||
|| ecma_is_value_object (value));
|
||||
} /* ecma_check_value_type_is_spec_defined */
|
||||
@@ -1,838 +0,0 @@
|
||||
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-compressed-pointers.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "jrt-bit-fields.h"
|
||||
|
||||
#ifndef ECMA_VALUE_H
|
||||
#define ECMA_VALUE_H
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmavalue ECMA value on-stack storage
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get type field of ecma-value
|
||||
*
|
||||
* @return type field
|
||||
*/
|
||||
inline ecma_type_t __attribute_pure__ __attribute_always_inline__
|
||||
ecma_get_value_type_field (ecma_value_packed_t packed_value) /**< packed ecma-value */
|
||||
{
|
||||
return (ecma_type_t) jrt_extract_bit_field (packed_value,
|
||||
ECMA_VALUE_TYPE_POS,
|
||||
ECMA_VALUE_TYPE_WIDTH);
|
||||
} /* ecma_get_value_type_field */
|
||||
|
||||
/**
|
||||
* Get value field of ecma-value
|
||||
*
|
||||
* @return value field
|
||||
*/
|
||||
inline uintptr_t __attribute_pure__ __attribute_always_inline__
|
||||
ecma_get_value_value_field (ecma_value_packed_t packed_value) /**< packed ecma-value */
|
||||
{
|
||||
return (uintptr_t) jrt_extract_bit_field (packed_value,
|
||||
ECMA_VALUE_VALUE_POS,
|
||||
ECMA_VALUE_VALUE_WIDTH);
|
||||
} /* ecma_get_value_value_field */
|
||||
|
||||
/**
|
||||
* Description of ecma-value on-stack storage
|
||||
*/
|
||||
class ecma_value_t
|
||||
{
|
||||
public:
|
||||
/* Constructors */
|
||||
__attribute_always_inline__
|
||||
ecma_value_t (ecma_simple_value_t simple_value)
|
||||
: _type (ECMA_TYPE_SIMPLE), _simple_value (simple_value) { }
|
||||
|
||||
__attribute_always_inline__
|
||||
ecma_value_t () : ecma_value_t (ECMA_SIMPLE_VALUE_EMPTY) { }
|
||||
|
||||
__attribute_always_inline__
|
||||
explicit ecma_value_t (ecma_number_t *num_p)
|
||||
{
|
||||
*this = num_p;
|
||||
}
|
||||
|
||||
__attribute_always_inline__
|
||||
explicit ecma_value_t (ecma_string_t *str_p)
|
||||
{
|
||||
*this = str_p;
|
||||
}
|
||||
|
||||
__attribute_always_inline__
|
||||
explicit ecma_value_t (ecma_object_t* obj_p)
|
||||
{
|
||||
*this = obj_p;
|
||||
}
|
||||
|
||||
__attribute_always_inline__
|
||||
explicit ecma_value_t (const ecma_object_ptr_t& obj_p)
|
||||
{
|
||||
*this = obj_p;
|
||||
}
|
||||
|
||||
__attribute_always_inline__
|
||||
explicit ecma_value_t (ecma_value_packed_t v)
|
||||
{
|
||||
*this = v;
|
||||
}
|
||||
|
||||
ecma_value_t (const ecma_value_t&) = delete;
|
||||
ecma_value_t (ecma_value_t&) = delete;
|
||||
ecma_value_t (ecma_value_t&&) = delete;
|
||||
ecma_value_t& operator = (ecma_value_t &) = delete;
|
||||
ecma_value_t& operator = (ecma_value_t &&) = delete;
|
||||
|
||||
/* Extraction of packed representation */
|
||||
explicit operator ecma_value_packed_t () const
|
||||
{
|
||||
uintptr_t value;
|
||||
|
||||
if (_type == ECMA_TYPE_SIMPLE)
|
||||
{
|
||||
value = _simple_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (_type == ECMA_TYPE_NUMBER
|
||||
|| _type == ECMA_TYPE_STRING
|
||||
|| _type == ECMA_TYPE_OBJECT);
|
||||
|
||||
_value_p.pack_to (value);
|
||||
}
|
||||
|
||||
return pack (_type, value);
|
||||
}
|
||||
|
||||
/* Assignment operators */
|
||||
__attribute_always_inline__
|
||||
ecma_value_t& operator = (ecma_simple_value_t v)
|
||||
{
|
||||
_type = ECMA_TYPE_SIMPLE;
|
||||
_simple_value = v;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
__attribute_always_inline__
|
||||
ecma_value_t& operator = (ecma_number_t* num_p)
|
||||
{
|
||||
JERRY_ASSERT(num_p != NULL);
|
||||
|
||||
_type = ECMA_TYPE_NUMBER;
|
||||
_value_p = num_p;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
__attribute_always_inline__
|
||||
ecma_value_t& operator = (ecma_string_t* str_p)
|
||||
{
|
||||
JERRY_ASSERT(str_p != NULL);
|
||||
|
||||
_type = ECMA_TYPE_STRING;
|
||||
_value_p = str_p;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
__attribute_always_inline__
|
||||
ecma_value_t& operator = (ecma_object_t* obj_p)
|
||||
{
|
||||
JERRY_ASSERT(obj_p != NULL);
|
||||
|
||||
_type = ECMA_TYPE_OBJECT;
|
||||
_value_p = obj_p;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
__attribute_always_inline__
|
||||
ecma_value_t& operator = (const ecma_object_ptr_t& obj_p)
|
||||
{
|
||||
JERRY_ASSERT (obj_p.is_not_null ());
|
||||
|
||||
_type = ECMA_TYPE_OBJECT;
|
||||
_value_p = obj_p;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
__attribute_always_inline__
|
||||
ecma_value_t& operator = (ecma_value_packed_t packed)
|
||||
{
|
||||
_type = ecma_get_value_type_field (packed);
|
||||
|
||||
uintptr_t value = ecma_get_value_value_field (packed);
|
||||
|
||||
if (_type == ECMA_TYPE_SIMPLE)
|
||||
{
|
||||
_simple_value = (ecma_simple_value_t) value;
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (_type == ECMA_TYPE_NUMBER
|
||||
|| _type == ECMA_TYPE_STRING
|
||||
|| _type == ECMA_TYPE_OBJECT);
|
||||
|
||||
_value_p.unpack_from (value);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
__attribute_always_inline__
|
||||
ecma_value_t& operator = (const ecma_value_t &v)
|
||||
{
|
||||
_type = v._type;
|
||||
if (_type == ECMA_TYPE_SIMPLE)
|
||||
{
|
||||
_simple_value = v._simple_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (_type == ECMA_TYPE_NUMBER
|
||||
|| _type == ECMA_TYPE_STRING
|
||||
|| _type == ECMA_TYPE_OBJECT);
|
||||
|
||||
_value_p = v._value_p;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/* Getters */
|
||||
__attribute_always_inline__
|
||||
ecma_type_t get_type (void) const
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
__attribute_always_inline__
|
||||
bool is_simple (void) const
|
||||
{
|
||||
return (_type == ECMA_TYPE_SIMPLE);
|
||||
}
|
||||
|
||||
__attribute_always_inline__
|
||||
bool is_simple (ecma_simple_value_t simple_value) const
|
||||
{
|
||||
return (is_simple () && _simple_value == simple_value);
|
||||
}
|
||||
|
||||
__attribute_always_inline__
|
||||
bool is_empty () const
|
||||
{
|
||||
return is_simple (ECMA_SIMPLE_VALUE_EMPTY);
|
||||
}
|
||||
|
||||
__attribute_always_inline__
|
||||
bool is_undefined () const
|
||||
{
|
||||
return is_simple (ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||
}
|
||||
|
||||
__attribute_always_inline__
|
||||
bool is_null () const
|
||||
{
|
||||
return is_simple (ECMA_SIMPLE_VALUE_NULL);
|
||||
}
|
||||
|
||||
__attribute_always_inline__
|
||||
bool is_boolean () const
|
||||
{
|
||||
return (is_simple (ECMA_SIMPLE_VALUE_TRUE) || is_simple (ECMA_SIMPLE_VALUE_FALSE));
|
||||
}
|
||||
|
||||
__attribute_always_inline__
|
||||
bool is_true () const
|
||||
{
|
||||
return is_simple (ECMA_SIMPLE_VALUE_TRUE);
|
||||
}
|
||||
|
||||
__attribute_always_inline__
|
||||
bool is_number () const
|
||||
{
|
||||
return (_type == ECMA_TYPE_NUMBER);
|
||||
}
|
||||
|
||||
__attribute_always_inline__
|
||||
bool is_string () const
|
||||
{
|
||||
return (_type == ECMA_TYPE_STRING);
|
||||
}
|
||||
|
||||
__attribute_always_inline__
|
||||
bool is_object () const
|
||||
{
|
||||
return (_type == ECMA_TYPE_OBJECT);
|
||||
}
|
||||
|
||||
__attribute_always_inline__
|
||||
ecma_number_t* get_number () const
|
||||
{
|
||||
JERRY_ASSERT (_type == ECMA_TYPE_NUMBER);
|
||||
|
||||
return static_cast<ecma_number_t*> (_value_p);
|
||||
}
|
||||
|
||||
__attribute_always_inline__
|
||||
ecma_string_t* get_string () const
|
||||
{
|
||||
JERRY_ASSERT (_type == ECMA_TYPE_STRING);
|
||||
|
||||
return static_cast<ecma_string_t*> (_value_p);
|
||||
}
|
||||
|
||||
__attribute_always_inline__
|
||||
ecma_object_t* get_object () const
|
||||
{
|
||||
JERRY_ASSERT (_type == ECMA_TYPE_OBJECT);
|
||||
|
||||
return static_cast<ecma_object_t*> (_value_p);
|
||||
}
|
||||
private:
|
||||
/**
|
||||
* Combining type and value fields to packed representation
|
||||
*
|
||||
* @return packed ecma-value representation
|
||||
*/
|
||||
static __attribute_always_inline__
|
||||
ecma_value_packed_t pack (ecma_type_t type,
|
||||
uintptr_t value)
|
||||
{
|
||||
ecma_value_packed_t packed;
|
||||
|
||||
packed = (ecma_value_packed_t) jrt_set_bit_field_value (0,
|
||||
type,
|
||||
ECMA_VALUE_TYPE_POS,
|
||||
ECMA_VALUE_TYPE_WIDTH);
|
||||
|
||||
packed = (ecma_value_packed_t) jrt_set_bit_field_value (packed,
|
||||
value,
|
||||
ECMA_VALUE_VALUE_POS,
|
||||
ECMA_VALUE_VALUE_WIDTH);
|
||||
|
||||
return packed;
|
||||
}
|
||||
|
||||
ecma_type_t _type;
|
||||
ecma_simple_value_t _simple_value;
|
||||
ecma_pointer_t _value_p;
|
||||
};
|
||||
|
||||
/**
|
||||
* Description of a block completion value
|
||||
*
|
||||
* See also: ECMA-262 v5, 8.9.
|
||||
*/
|
||||
class ecma_completion_value_t : public ecma_value_t
|
||||
{
|
||||
public:
|
||||
/* Constructors */
|
||||
__attribute_always_inline__
|
||||
ecma_completion_value_t ()
|
||||
: ecma_value_t (),
|
||||
_type (ECMA_COMPLETION_TYPE_NORMAL) { }
|
||||
|
||||
__attribute_always_inline__
|
||||
ecma_completion_value_t (ecma_completion_type_t type,
|
||||
const ecma_value_t &value)
|
||||
:
|
||||
_type (type) { *this = value; }
|
||||
|
||||
/* Assignment operators */
|
||||
__attribute_always_inline__
|
||||
ecma_completion_value_t & operator = (ecma_completion_type_t type)
|
||||
{
|
||||
_type = type;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
__attribute_always_inline__
|
||||
ecma_completion_value_t & operator = (const ecma_value_t& value)
|
||||
{
|
||||
*static_cast<ecma_value_t*> (this) = value;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/* Completion type extraction */
|
||||
__attribute_always_inline__
|
||||
explicit operator ecma_completion_type_t () const
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
__attribute_always_inline__
|
||||
ecma_completion_value_t& operator = (const ecma_completion_value_t &) = default;
|
||||
|
||||
ecma_completion_value_t (const ecma_completion_value_t&) = delete;
|
||||
ecma_completion_value_t (ecma_completion_value_t&) = delete;
|
||||
ecma_completion_value_t (ecma_completion_value_t&&) = delete;
|
||||
ecma_completion_value_t& operator = (ecma_completion_value_t &&) = delete;
|
||||
private:
|
||||
ecma_completion_type_t _type; /**< completion type */
|
||||
};
|
||||
|
||||
/**
|
||||
* Get type field of ecma-value
|
||||
*
|
||||
* @return type field
|
||||
*/
|
||||
inline ecma_type_t __attribute_pure__ __attribute_always_inline__
|
||||
ecma_get_value_type_field (const ecma_value_t& value) /**< ecma-value */
|
||||
{
|
||||
return value.get_type ();
|
||||
} /* ecma_get_value_type_field */
|
||||
|
||||
/**
|
||||
* Check if the value is empty.
|
||||
*
|
||||
* @return true - if the value contains implementation-defined empty simple value,
|
||||
* false - otherwise.
|
||||
*/
|
||||
inline bool __attribute_pure__ __attribute_always_inline__
|
||||
ecma_is_value_empty (const ecma_value_t& value) /**< ecma-value */
|
||||
{
|
||||
return value.is_empty ();
|
||||
} /* ecma_is_value_empty */
|
||||
|
||||
/**
|
||||
* Check if the value is undefined.
|
||||
*
|
||||
* @return true - if the value contains ecma-undefined simple value,
|
||||
* false - otherwise.
|
||||
*/
|
||||
inline bool __attribute_pure__ __attribute_always_inline__
|
||||
ecma_is_value_undefined (const ecma_value_t& value) /**< ecma-value */
|
||||
{
|
||||
return value.is_undefined ();
|
||||
} /* ecma_is_value_undefined */
|
||||
|
||||
/**
|
||||
* Check if the value is null.
|
||||
*
|
||||
* @return true - if the value contains ecma-null simple value,
|
||||
* false - otherwise.
|
||||
*/
|
||||
inline bool __attribute_pure__ __attribute_always_inline__
|
||||
ecma_is_value_null (const ecma_value_t& value) /**< ecma-value */
|
||||
{
|
||||
return value.is_null ();
|
||||
} /* ecma_is_value_null */
|
||||
|
||||
/**
|
||||
* Check if the value is boolean.
|
||||
*
|
||||
* @return true - if the value contains ecma-true or ecma-false simple values,
|
||||
* false - otherwise.
|
||||
*/
|
||||
inline bool __attribute_pure__ __attribute_always_inline__
|
||||
ecma_is_value_boolean (const ecma_value_t& value) /**< ecma-value */
|
||||
{
|
||||
return value.is_boolean ();
|
||||
} /* ecma_is_value_boolean */
|
||||
|
||||
/**
|
||||
* Check if the value is true.
|
||||
*
|
||||
* Warning:
|
||||
* value must be boolean
|
||||
*
|
||||
* @return true - if the value contains ecma-true simple value,
|
||||
* false - otherwise.
|
||||
*/
|
||||
inline bool __attribute_pure__ __attribute_always_inline__
|
||||
ecma_is_value_true (const ecma_value_t& value) /**< ecma-value */
|
||||
{
|
||||
return value.is_true ();
|
||||
} /* ecma_is_value_true */
|
||||
|
||||
/**
|
||||
* Check if the value is ecma-number.
|
||||
*
|
||||
* @return true - if the value contains ecma-number value,
|
||||
* false - otherwise.
|
||||
*/
|
||||
inline bool __attribute_pure__ __attribute_always_inline__
|
||||
ecma_is_value_number (const ecma_value_t& value) /**< ecma-value */
|
||||
{
|
||||
return value.is_number ();
|
||||
} /* ecma_is_value_number */
|
||||
|
||||
/**
|
||||
* Check if the value is ecma-string.
|
||||
*
|
||||
* @return true - if the value contains ecma-string value,
|
||||
* false - otherwise.
|
||||
*/
|
||||
inline bool __attribute_pure__ __attribute_always_inline__
|
||||
ecma_is_value_string (const ecma_value_t& value) /**< ecma-value */
|
||||
{
|
||||
return value.is_string ();
|
||||
} /* ecma_is_value_string */
|
||||
|
||||
/**
|
||||
* Check if the value is object.
|
||||
*
|
||||
* @return true - if the value contains object value,
|
||||
* false - otherwise.
|
||||
*/
|
||||
inline bool __attribute_pure__ __attribute_always_inline__
|
||||
ecma_is_value_object (const ecma_value_t& value) /**< ecma-value */
|
||||
{
|
||||
return value.is_object ();
|
||||
} /* ecma_is_value_object */
|
||||
|
||||
extern ecma_number_t* __attribute_pure__ ecma_get_number_from_value (const ecma_value_t& value);
|
||||
extern ecma_string_t* __attribute_pure__ ecma_get_string_from_value (const ecma_value_t& value);
|
||||
extern void
|
||||
ecma_get_object_from_value (ecma_object_ptr_t &ret_val,
|
||||
const ecma_value_t& value);
|
||||
extern void ecma_copy_value (ecma_value_t &ret, const ecma_value_t& value, bool do_ref_if_object);
|
||||
extern void ecma_free_value (ecma_value_t& value, bool do_deref_if_object);
|
||||
|
||||
/**
|
||||
* Normal, throw, return, exit and meta completion values constructor
|
||||
*
|
||||
* @return completion value
|
||||
*/
|
||||
inline void __attribute_always_inline__
|
||||
ecma_make_completion_value (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
ecma_completion_type_t type, /**< type */
|
||||
const ecma_value_t& value) /**< value */
|
||||
{
|
||||
const bool is_type_ok = (type == ECMA_COMPLETION_TYPE_NORMAL
|
||||
#ifdef CONFIG_ECMA_EXCEPTION_SUPPORT
|
||||
|| type == ECMA_COMPLETION_TYPE_THROW
|
||||
#endif /* CONFIG_ECMA_EXCEPTION_SUPPORT */
|
||||
|| type == ECMA_COMPLETION_TYPE_RETURN
|
||||
|| type == ECMA_COMPLETION_TYPE_EXIT
|
||||
|| (type == ECMA_COMPLETION_TYPE_META
|
||||
&& ecma_is_value_empty (value)));
|
||||
|
||||
JERRY_ASSERT (is_type_ok);
|
||||
|
||||
ret_value = type;
|
||||
ret_value = value;
|
||||
} /* ecma_make_completion_value */
|
||||
|
||||
/**
|
||||
* Simple normal completion value constructor
|
||||
*
|
||||
* @return completion value
|
||||
*/
|
||||
inline void __attribute_always_inline__
|
||||
ecma_make_simple_completion_value (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
ecma_simple_value_t simple_value) /**< simple ecma-value */
|
||||
{
|
||||
JERRY_ASSERT(simple_value == ECMA_SIMPLE_VALUE_UNDEFINED
|
||||
|| simple_value == ECMA_SIMPLE_VALUE_NULL
|
||||
|| simple_value == ECMA_SIMPLE_VALUE_FALSE
|
||||
|| simple_value == ECMA_SIMPLE_VALUE_TRUE);
|
||||
|
||||
ecma_make_completion_value (ret_value,
|
||||
ECMA_COMPLETION_TYPE_NORMAL,
|
||||
ecma_value_t (simple_value));
|
||||
} /* ecma_make_simple_completion_value */
|
||||
|
||||
/**
|
||||
* Normal completion value constructor
|
||||
*
|
||||
* @return completion value
|
||||
*/
|
||||
inline void __attribute_always_inline__
|
||||
ecma_make_normal_completion_value (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& value) /**< value */
|
||||
{
|
||||
ecma_make_completion_value (ret_value, ECMA_COMPLETION_TYPE_NORMAL, value);
|
||||
} /* ecma_make_normal_completion_value */
|
||||
|
||||
/**
|
||||
* Throw completion value constructor
|
||||
*
|
||||
* @return completion value
|
||||
*/
|
||||
inline void __attribute_always_inline__
|
||||
ecma_make_throw_completion_value (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& value) /**< value */
|
||||
{
|
||||
#ifdef CONFIG_ECMA_EXCEPTION_SUPPORT
|
||||
ecma_make_completion_value (ret_value, ECMA_COMPLETION_TYPE_THROW, value);
|
||||
#else /* CONFIG_ECMA_EXCEPTION_SUPPORT */
|
||||
(void) value;
|
||||
|
||||
jerry_exit (ERR_UNHANDLED_EXCEPTION);
|
||||
#endif /* !CONFIG_ECMA_EXCEPTION_SUPPORT */
|
||||
} /* ecma_make_throw_completion_value */
|
||||
|
||||
extern void
|
||||
ecma_make_throw_obj_completion_value (ecma_completion_value_t &ret_value,
|
||||
const ecma_object_ptr_t& exception_p);
|
||||
|
||||
/**
|
||||
* Empty completion value constructor.
|
||||
*
|
||||
* @return (normal, empty, reserved) completion value.
|
||||
*/
|
||||
inline void __attribute_always_inline__
|
||||
ecma_make_empty_completion_value (ecma_completion_value_t &ret_value) /**< out: completion value */
|
||||
{
|
||||
ecma_make_completion_value (ret_value,
|
||||
ECMA_COMPLETION_TYPE_NORMAL,
|
||||
ecma_value_t ());
|
||||
} /* ecma_make_empty_completion_value */
|
||||
|
||||
/**
|
||||
* Return completion value constructor
|
||||
*
|
||||
* @return completion value
|
||||
*/
|
||||
inline void __attribute_always_inline__
|
||||
ecma_make_return_completion_value (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& value) /**< value */
|
||||
{
|
||||
ecma_make_completion_value (ret_value, ECMA_COMPLETION_TYPE_RETURN, value);
|
||||
} /* ecma_make_return_completion_value */
|
||||
|
||||
/**
|
||||
* Exit completion value constructor
|
||||
*
|
||||
* @return completion value
|
||||
*/
|
||||
inline void __attribute_always_inline__
|
||||
ecma_make_exit_completion_value (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
bool is_successful) /**< does completion value indicate
|
||||
successfulness completion
|
||||
of script execution (true) or not (false) */
|
||||
{
|
||||
ecma_make_completion_value (ret_value,
|
||||
ECMA_COMPLETION_TYPE_EXIT,
|
||||
ecma_value_t (is_successful ? ECMA_SIMPLE_VALUE_TRUE
|
||||
: ECMA_SIMPLE_VALUE_FALSE));
|
||||
} /* ecma_make_exit_completion_value */
|
||||
|
||||
/**
|
||||
* Meta completion value constructor
|
||||
*
|
||||
* @return completion value
|
||||
*/
|
||||
inline void __attribute_always_inline__
|
||||
ecma_make_meta_completion_value (ecma_completion_value_t &ret_value) /**< out: completion value */
|
||||
{
|
||||
ecma_make_completion_value (ret_value,
|
||||
ECMA_COMPLETION_TYPE_META,
|
||||
ecma_value_t (ECMA_SIMPLE_VALUE_EMPTY));
|
||||
} /* ecma_make_meta_completion_value */
|
||||
|
||||
/**
|
||||
* Get ecma-value from specified completion value
|
||||
*
|
||||
* @return ecma-value
|
||||
*/
|
||||
inline void __attribute_always_inline__
|
||||
ecma_get_completion_value_value (ecma_value_t &ret, /**< out: ecma-value */
|
||||
const ecma_completion_value_t& completion_value) /**< completion value */
|
||||
{
|
||||
const ecma_completion_type_t type = (ecma_completion_type_t) completion_value;
|
||||
|
||||
const bool is_type_ok = (type == ECMA_COMPLETION_TYPE_NORMAL
|
||||
#ifdef CONFIG_ECMA_EXCEPTION_SUPPORT
|
||||
|| type == ECMA_COMPLETION_TYPE_THROW
|
||||
#endif /* CONFIG_ECMA_EXCEPTION_SUPPORT */
|
||||
|| type == ECMA_COMPLETION_TYPE_RETURN
|
||||
|| type == ECMA_COMPLETION_TYPE_EXIT);
|
||||
|
||||
JERRY_ASSERT (is_type_ok);
|
||||
|
||||
ret = completion_value;
|
||||
} /* ecma_get_completion_value_value */
|
||||
|
||||
extern void ecma_copy_completion_value (ecma_completion_value_t& ret_value, const ecma_completion_value_t& value);
|
||||
extern void ecma_free_completion_value (ecma_completion_value_t& completion_value);
|
||||
|
||||
/**
|
||||
* Check if the completion value is normal value.
|
||||
*
|
||||
* @return true - if the completion type is normal,
|
||||
* false - otherwise.
|
||||
*/
|
||||
inline bool __attribute_const__ __attribute_always_inline__
|
||||
ecma_is_completion_value_normal (const ecma_completion_value_t& value) /**< completion value */
|
||||
{
|
||||
return ((ecma_completion_type_t) value == ECMA_COMPLETION_TYPE_NORMAL);
|
||||
} /* ecma_is_completion_value_normal */
|
||||
|
||||
/**
|
||||
* Check if the completion value is throw value.
|
||||
*
|
||||
* @return true - if the completion type is throw,
|
||||
* false - otherwise.
|
||||
*/
|
||||
inline bool __attribute_const__ __attribute_always_inline__
|
||||
ecma_is_completion_value_throw (const ecma_completion_value_t& value) /**< completion value */
|
||||
{
|
||||
#ifdef CONFIG_ECMA_EXCEPTION_SUPPORT
|
||||
return ((ecma_completion_type_t) value == ECMA_COMPLETION_TYPE_THROW);
|
||||
#else /* CONFIG_ECMA_EXCEPTION_SUPPORT */
|
||||
(void) value;
|
||||
|
||||
return false;
|
||||
#endif /* !CONFIG_ECMA_EXCEPTION_SUPPORT */
|
||||
} /* ecma_is_completion_value_throw */
|
||||
|
||||
/**
|
||||
* Check if the completion value is return value.
|
||||
*
|
||||
* @return true - if the completion type is return,
|
||||
* false - otherwise.
|
||||
*/
|
||||
inline bool __attribute_const__ __attribute_always_inline__
|
||||
ecma_is_completion_value_return (const ecma_completion_value_t& value) /**< completion value */
|
||||
{
|
||||
return ((ecma_completion_type_t) value == ECMA_COMPLETION_TYPE_RETURN);
|
||||
} /* ecma_is_completion_value_return */
|
||||
|
||||
/**
|
||||
* Check if the completion value is exit value.
|
||||
*
|
||||
* @return true - if the completion type is exit,
|
||||
* false - otherwise.
|
||||
*/
|
||||
inline bool __attribute_const__ __attribute_always_inline__
|
||||
ecma_is_completion_value_exit (const ecma_completion_value_t& value) /**< completion value */
|
||||
{
|
||||
if ((ecma_completion_type_t) value == ECMA_COMPLETION_TYPE_EXIT)
|
||||
{
|
||||
#ifndef JERRY_NDEBUG
|
||||
const ecma_value_t& v = value;
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_boolean (v));
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
} /* ecma_is_completion_value_exit */
|
||||
|
||||
/**
|
||||
* Check if the completion value is meta value.
|
||||
*
|
||||
* @return true - if the completion type is meta,
|
||||
* false - otherwise.
|
||||
*/
|
||||
inline bool __attribute_const__ __attribute_always_inline__
|
||||
ecma_is_completion_value_meta (const ecma_completion_value_t& value) /**< completion value */
|
||||
{
|
||||
if ((ecma_completion_type_t) value == ECMA_COMPLETION_TYPE_META)
|
||||
{
|
||||
#ifndef JERRY_NDEBUG
|
||||
const ecma_value_t& v = value;
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_empty (v));
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
} /* ecma_is_completion_value_meta */
|
||||
|
||||
/**
|
||||
* Check if the completion value is specified normal simple value.
|
||||
*
|
||||
* @return true - if the completion type is normal and
|
||||
* value contains specified simple ecma-value,
|
||||
* false - otherwise.
|
||||
*/
|
||||
inline bool __attribute_const__ __attribute_always_inline__
|
||||
ecma_is_completion_value_normal_simple_value (const ecma_completion_value_t& value, /**< completion value */
|
||||
ecma_simple_value_t simple_value) /**< simple value to check
|
||||
for equality with */
|
||||
{
|
||||
return (ecma_is_completion_value_normal (value) && value.is_simple (simple_value));
|
||||
} /* ecma_is_completion_value_normal_simple_value */
|
||||
|
||||
/**
|
||||
* Check if the completion value is normal true.
|
||||
*
|
||||
* @return true - if the completion type is normal and
|
||||
* value contains ecma-true simple value,
|
||||
* false - otherwise.
|
||||
*/
|
||||
inline bool __attribute_const__ __attribute_always_inline__
|
||||
ecma_is_completion_value_normal_true (const ecma_completion_value_t& value) /**< completion value */
|
||||
{
|
||||
return ecma_is_completion_value_normal_simple_value (value, ECMA_SIMPLE_VALUE_TRUE);
|
||||
} /* ecma_is_completion_value_normal_true */
|
||||
|
||||
/**
|
||||
* Check if the completion value is normal false.
|
||||
*
|
||||
* @return true - if the completion type is normal and
|
||||
* value contains ecma-false simple value,
|
||||
* false - otherwise.
|
||||
*/
|
||||
inline bool __attribute_const__ __attribute_always_inline__
|
||||
ecma_is_completion_value_normal_false (const ecma_completion_value_t& value) /**< completion value */
|
||||
{
|
||||
return ecma_is_completion_value_normal_simple_value (value, ECMA_SIMPLE_VALUE_FALSE);
|
||||
} /* ecma_is_completion_value_normal_false */
|
||||
|
||||
/**
|
||||
* Check if the completion value is normal empty value.
|
||||
*
|
||||
* @return true - if the completion type is normal and
|
||||
* value contains empty simple value,
|
||||
* false - otherwise.
|
||||
*/
|
||||
inline bool __attribute_const__ __attribute_always_inline__
|
||||
ecma_is_completion_value_empty (const ecma_completion_value_t& value) /**< completion value */
|
||||
{
|
||||
if (ecma_is_completion_value_normal (value))
|
||||
{
|
||||
const ecma_value_t& v = value;
|
||||
|
||||
return ecma_is_value_empty (v);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
} /* ecma_is_completion_value_empty */
|
||||
|
||||
extern void ecma_check_value_type_is_spec_defined (const ecma_value_t& value);
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* !ECMA_VALUE_H */
|
||||
@@ -37,19 +37,16 @@
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
static void
|
||||
ecma_reject (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
bool is_throw) /**< Throw flag */
|
||||
static ecma_completion_value_t
|
||||
ecma_reject (bool is_throw) /**< Throw flag */
|
||||
{
|
||||
if (is_throw)
|
||||
{
|
||||
ecma_object_ptr_t exception_obj_p;
|
||||
ecma_new_standard_error (exception_obj_p, ECMA_ERROR_TYPE);
|
||||
ecma_make_throw_obj_completion_value (ret_value, exception_obj_p);
|
||||
return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_make_simple_completion_value (ret_value, ECMA_SIMPLE_VALUE_FALSE);
|
||||
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE);
|
||||
}
|
||||
} /* ecma_reject */
|
||||
|
||||
@@ -62,9 +59,8 @@ ecma_reject (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
ecma_op_create_array_object (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t *arguments_list_p, /**< list of arguments that
|
||||
ecma_completion_value_t
|
||||
ecma_op_create_array_object (const ecma_value_t *arguments_list_p, /**< list of arguments that
|
||||
are passed to Array constructor */
|
||||
ecma_length_t arguments_list_len, /**< length of the arguments' list */
|
||||
bool is_treat_single_arg_as_length) /**< if the value is true,
|
||||
@@ -89,10 +85,7 @@ ecma_op_create_array_object (ecma_completion_value_t &ret_value, /**< out: compl
|
||||
uint32_t num_uint32 = ecma_number_to_uint32 (*num_p);
|
||||
if (*num_p != ecma_uint32_to_number (num_uint32))
|
||||
{
|
||||
ecma_object_ptr_t exception_obj_p;
|
||||
ecma_new_standard_error (exception_obj_p, ECMA_ERROR_RANGE);
|
||||
ecma_make_throw_obj_completion_value (ret_value, exception_obj_p);
|
||||
return;
|
||||
return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_RANGE));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -109,15 +102,12 @@ ecma_op_create_array_object (ecma_completion_value_t &ret_value, /**< out: compl
|
||||
}
|
||||
|
||||
#ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_ARRAY_BUILTIN
|
||||
ecma_object_ptr_t array_prototype_obj_p;
|
||||
ecma_builtin_get (array_prototype_obj_p, ECMA_BUILTIN_ID_ARRAY_PROTOTYPE);
|
||||
ecma_object_t *array_prototype_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_ARRAY_PROTOTYPE);
|
||||
#else /* !CONFIG_ECMA_COMPACT_PROFILE_DISABLE_ARRAY_BUILTIN */
|
||||
ecma_object_ptr_t array_prototype_obj_p;
|
||||
ecma_builtin_get (array_prototype_obj_p, ECMA_BUILTIN_ID_OBJECT_PROTOTYPE);
|
||||
ecma_object_t *array_prototype_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_OBJECT_PROTOTYPE);
|
||||
#endif /* CONFIG_ECMA_COMPACT_PROFILE_DISABLE_ARRAY_BUILTIN */
|
||||
|
||||
ecma_object_ptr_t obj_p;
|
||||
ecma_create_object (obj_p, array_prototype_obj_p, true, ECMA_OBJECT_TYPE_ARRAY);
|
||||
ecma_object_t *obj_p = ecma_create_object (array_prototype_obj_p, true, ECMA_OBJECT_TYPE_ARRAY);
|
||||
ecma_deref_object (array_prototype_obj_p);
|
||||
|
||||
ecma_property_t *class_prop_p = ecma_create_internal_property (obj_p, ECMA_INTERNAL_PROPERTY_CLASS);
|
||||
@@ -130,7 +120,7 @@ ecma_op_create_array_object (ecma_completion_value_t &ret_value, /**< out: compl
|
||||
ecma_property_t *length_prop_p = ecma_create_named_data_property (obj_p,
|
||||
length_magic_string_p,
|
||||
true, false, false);
|
||||
ecma_set_named_data_property_value (length_prop_p, ecma_value_t (length_num_p));
|
||||
ecma_set_named_data_property_value (length_prop_p, ecma_make_number_value (length_num_p));
|
||||
|
||||
ecma_deref_ecma_string (length_magic_string_p);
|
||||
|
||||
@@ -143,7 +133,7 @@ ecma_op_create_array_object (ecma_completion_value_t &ret_value, /**< out: compl
|
||||
ecma_property_descriptor_t item_prop_desc = ecma_make_empty_property_descriptor ();
|
||||
{
|
||||
item_prop_desc.is_value_defined = true;
|
||||
item_prop_desc.value = (ecma_value_packed_t) array_items_p [index];
|
||||
item_prop_desc.value = array_items_p [index];
|
||||
|
||||
item_prop_desc.is_writable_defined = true;
|
||||
item_prop_desc.is_writable = true;
|
||||
@@ -155,18 +145,15 @@ ecma_op_create_array_object (ecma_completion_value_t &ret_value, /**< out: compl
|
||||
item_prop_desc.is_configurable = true;
|
||||
}
|
||||
|
||||
ecma_op_object_define_own_property (ret_value,
|
||||
obj_p,
|
||||
ecma_op_object_define_own_property (obj_p,
|
||||
item_name_string_p,
|
||||
&item_prop_desc,
|
||||
false);
|
||||
JERRY_ASSERT (ecma_is_completion_value_normal_true (ret_value)
|
||||
|| ecma_is_completion_value_normal_false (ret_value));
|
||||
|
||||
ecma_deref_ecma_string (item_name_string_p);
|
||||
}
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (obj_p));
|
||||
return ecma_make_normal_completion_value (ecma_make_object_value (obj_p));
|
||||
} /* ecma_op_create_array_object */
|
||||
|
||||
/**
|
||||
@@ -179,9 +166,8 @@ ecma_op_create_array_object (ecma_completion_value_t &ret_value, /**< out: compl
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
ecma_op_array_object_define_own_property (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_object_ptr_t& obj_p, /**< the array object */
|
||||
ecma_completion_value_t
|
||||
ecma_op_array_object_define_own_property (ecma_object_t *obj_p, /**< the array object */
|
||||
ecma_string_t *property_name_p, /**< property name */
|
||||
const ecma_property_descriptor_t* property_desc_p, /**< property descriptor */
|
||||
bool is_throw) /**< flag that controls failure handling */
|
||||
@@ -195,8 +181,7 @@ ecma_op_array_object_define_own_property (ecma_completion_value_t &ret_value, /*
|
||||
JERRY_ASSERT (len_prop_p != NULL && len_prop_p->type == ECMA_PROPERTY_NAMEDDATA);
|
||||
|
||||
// 2.
|
||||
ecma_value_t old_len_value;
|
||||
ecma_get_named_data_property_value (old_len_value, len_prop_p);
|
||||
ecma_value_t old_len_value = ecma_get_named_data_property_value (len_prop_p);
|
||||
|
||||
ecma_number_t *num_p = ecma_get_number_from_value (old_len_value);
|
||||
uint32_t old_len_uint32 = ecma_number_to_uint32 (*num_p);
|
||||
@@ -213,39 +198,31 @@ ecma_op_array_object_define_own_property (ecma_completion_value_t &ret_value, /*
|
||||
if (!property_desc_p->is_value_defined)
|
||||
{
|
||||
// i.
|
||||
ecma_op_general_object_define_own_property (ret_value, obj_p, property_name_p, property_desc_p, is_throw);
|
||||
return;
|
||||
return ecma_op_general_object_define_own_property (obj_p, property_name_p, property_desc_p, is_throw);
|
||||
}
|
||||
|
||||
ecma_number_t new_len_num;
|
||||
|
||||
// c.
|
||||
ecma_completion_value_t prop_val_to_num_completion;
|
||||
ecma_op_to_number (prop_val_to_num_completion, ecma_value_t (property_desc_p->value));
|
||||
if (ecma_is_completion_value_throw (prop_val_to_num_completion))
|
||||
ecma_completion_value_t completion = ecma_op_to_number (property_desc_p->value);
|
||||
if (ecma_is_completion_value_throw (completion))
|
||||
{
|
||||
ret_value = prop_val_to_num_completion;
|
||||
return;
|
||||
return completion;
|
||||
}
|
||||
|
||||
JERRY_ASSERT (ecma_is_completion_value_normal (prop_val_to_num_completion));
|
||||
JERRY_ASSERT (ecma_is_completion_value_normal (completion)
|
||||
&& ecma_is_value_number (ecma_get_completion_value_value (completion)));
|
||||
|
||||
ecma_value_t new_len_value;
|
||||
ecma_get_completion_value_value (new_len_value, prop_val_to_num_completion);
|
||||
new_len_num = *ecma_get_number_from_completion_value (completion);
|
||||
|
||||
new_len_num = *ecma_get_number_from_value (new_len_value);
|
||||
|
||||
ecma_free_completion_value (prop_val_to_num_completion);
|
||||
ecma_free_completion_value (completion);
|
||||
|
||||
uint32_t new_len_uint32 = ecma_number_to_uint32 (new_len_num);
|
||||
|
||||
// d.
|
||||
if (ecma_uint32_to_number (new_len_uint32) != new_len_num)
|
||||
{
|
||||
ecma_object_ptr_t exception_obj_p;
|
||||
ecma_new_standard_error (exception_obj_p, ECMA_ERROR_RANGE);
|
||||
ecma_make_throw_obj_completion_value (ret_value, exception_obj_p);
|
||||
return;
|
||||
return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_RANGE));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -254,18 +231,19 @@ ecma_op_array_object_define_own_property (ecma_completion_value_t &ret_value, /*
|
||||
*new_len_num_p = new_len_num;
|
||||
|
||||
ecma_property_descriptor_t new_len_property_desc = *property_desc_p;
|
||||
new_len_property_desc.value = (ecma_value_packed_t) ecma_value_t (new_len_num_p);
|
||||
new_len_property_desc.value = ecma_make_number_value (new_len_num_p);
|
||||
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
// f.
|
||||
if (new_len_uint32 >= old_len_uint32)
|
||||
{
|
||||
// i.
|
||||
magic_string_length_p = ecma_get_magic_string (ECMA_MAGIC_STRING_LENGTH);
|
||||
ecma_op_general_object_define_own_property (ret_value,
|
||||
obj_p,
|
||||
magic_string_length_p,
|
||||
&new_len_property_desc,
|
||||
is_throw);
|
||||
ret_value = ecma_op_general_object_define_own_property (obj_p,
|
||||
magic_string_length_p,
|
||||
&new_len_property_desc,
|
||||
is_throw);
|
||||
ecma_deref_ecma_string (magic_string_length_p);
|
||||
}
|
||||
else
|
||||
@@ -273,7 +251,7 @@ ecma_op_array_object_define_own_property (ecma_completion_value_t &ret_value, /*
|
||||
// g.
|
||||
if (!ecma_is_property_writable (len_prop_p))
|
||||
{
|
||||
ecma_reject (ret_value, is_throw);
|
||||
ret_value = ecma_reject (is_throw);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -296,12 +274,10 @@ ecma_op_array_object_define_own_property (ecma_completion_value_t &ret_value, /*
|
||||
|
||||
// j.
|
||||
magic_string_length_p = ecma_get_magic_string (ECMA_MAGIC_STRING_LENGTH);
|
||||
ecma_completion_value_t succeeded;
|
||||
ecma_op_general_object_define_own_property (succeeded,
|
||||
obj_p,
|
||||
magic_string_length_p,
|
||||
&new_len_property_desc,
|
||||
is_throw);
|
||||
ecma_completion_value_t succeeded = ecma_op_general_object_define_own_property (obj_p,
|
||||
magic_string_length_p,
|
||||
&new_len_property_desc,
|
||||
is_throw);
|
||||
ecma_deref_ecma_string (magic_string_length_p);
|
||||
|
||||
/* Handling normal false and throw values */
|
||||
@@ -327,20 +303,17 @@ ecma_op_array_object_define_own_property (ecma_completion_value_t &ret_value, /*
|
||||
|
||||
// ii
|
||||
ecma_string_t *old_length_string_p = ecma_new_ecma_string_from_uint32 (old_len_uint32);
|
||||
ecma_completion_value_t delete_succeeded;
|
||||
ecma_op_object_delete (delete_succeeded,
|
||||
obj_p,
|
||||
old_length_string_p,
|
||||
false);
|
||||
ecma_completion_value_t delete_succeeded = ecma_op_object_delete (obj_p,
|
||||
old_length_string_p,
|
||||
false);
|
||||
ecma_deref_ecma_string (old_length_string_p);
|
||||
|
||||
// iii
|
||||
if (ecma_is_completion_value_normal_false (delete_succeeded))
|
||||
{
|
||||
ecma_value_t new_len_value (new_len_property_desc.value);
|
||||
JERRY_ASSERT (ecma_is_value_number (new_len_value));
|
||||
JERRY_ASSERT (ecma_is_value_number (new_len_property_desc.value));
|
||||
|
||||
ecma_number_t *new_len_num_p = ecma_get_number_from_value (new_len_value);
|
||||
ecma_number_t *new_len_num_p = ecma_get_number_from_value (new_len_property_desc.value);
|
||||
|
||||
// 1.
|
||||
*new_len_num_p = ecma_uint32_to_number (old_len_uint32 + 1);
|
||||
@@ -354,12 +327,10 @@ ecma_op_array_object_define_own_property (ecma_completion_value_t &ret_value, /*
|
||||
|
||||
// 3.
|
||||
ecma_string_t *magic_string_length_p = ecma_get_magic_string (ECMA_MAGIC_STRING_LENGTH);
|
||||
ecma_completion_value_t completion;
|
||||
ecma_op_general_object_define_own_property (completion,
|
||||
obj_p,
|
||||
magic_string_length_p,
|
||||
&new_len_property_desc,
|
||||
false);
|
||||
ecma_completion_value_t completion = ecma_op_general_object_define_own_property (obj_p,
|
||||
magic_string_length_p,
|
||||
&new_len_property_desc,
|
||||
false);
|
||||
ecma_deref_ecma_string (magic_string_length_p);
|
||||
|
||||
JERRY_ASSERT (ecma_is_completion_value_normal_true (completion)
|
||||
@@ -373,7 +344,7 @@ ecma_op_array_object_define_own_property (ecma_completion_value_t &ret_value, /*
|
||||
|
||||
if (!reduce_succeeded)
|
||||
{
|
||||
ecma_reject (ret_value, is_throw);
|
||||
ret_value = ecma_reject (is_throw);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -387,16 +358,15 @@ ecma_op_array_object_define_own_property (ecma_completion_value_t &ret_value, /*
|
||||
|
||||
ecma_completion_value_t completion_set_not_writable;
|
||||
magic_string_length_p = ecma_get_magic_string (ECMA_MAGIC_STRING_LENGTH);
|
||||
ecma_op_general_object_define_own_property (completion_set_not_writable,
|
||||
obj_p,
|
||||
magic_string_length_p,
|
||||
&prop_desc_not_writable,
|
||||
false);
|
||||
completion_set_not_writable = ecma_op_general_object_define_own_property (obj_p,
|
||||
magic_string_length_p,
|
||||
&prop_desc_not_writable,
|
||||
false);
|
||||
ecma_deref_ecma_string (magic_string_length_p);
|
||||
JERRY_ASSERT (ecma_is_completion_value_normal_true (completion_set_not_writable));
|
||||
}
|
||||
|
||||
ecma_make_simple_completion_value (ret_value, ECMA_SIMPLE_VALUE_TRUE);
|
||||
ret_value = ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -404,7 +374,7 @@ ecma_op_array_object_define_own_property (ecma_completion_value_t &ret_value, /*
|
||||
|
||||
ecma_dealloc_number (new_len_num_p);
|
||||
|
||||
return;
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
JERRY_UNREACHABLE();
|
||||
@@ -438,12 +408,10 @@ ecma_op_array_object_define_own_property (ecma_completion_value_t &ret_value, /*
|
||||
if (!is_index)
|
||||
{
|
||||
// 5.
|
||||
ecma_op_general_object_define_own_property (ret_value,
|
||||
obj_p,
|
||||
property_name_p,
|
||||
property_desc_p,
|
||||
false);
|
||||
return;
|
||||
return ecma_op_general_object_define_own_property (obj_p,
|
||||
property_name_p,
|
||||
property_desc_p,
|
||||
false);
|
||||
}
|
||||
|
||||
// 4.
|
||||
@@ -452,25 +420,21 @@ ecma_op_array_object_define_own_property (ecma_completion_value_t &ret_value, /*
|
||||
if (index >= old_len_uint32
|
||||
&& !ecma_is_property_writable (len_prop_p))
|
||||
{
|
||||
ecma_reject (ret_value, is_throw);
|
||||
return;
|
||||
return ecma_reject (is_throw);
|
||||
}
|
||||
|
||||
// c.
|
||||
ecma_completion_value_t succeeded;
|
||||
ecma_op_general_object_define_own_property (succeeded,
|
||||
obj_p,
|
||||
property_name_p,
|
||||
property_desc_p,
|
||||
false);
|
||||
ecma_completion_value_t succeeded = ecma_op_general_object_define_own_property (obj_p,
|
||||
property_name_p,
|
||||
property_desc_p,
|
||||
false);
|
||||
// d.
|
||||
JERRY_ASSERT (ecma_is_completion_value_normal_true (succeeded)
|
||||
|| ecma_is_completion_value_normal_false (succeeded));
|
||||
|
||||
if (ecma_is_completion_value_normal_false (succeeded))
|
||||
{
|
||||
ecma_reject (ret_value, is_throw);
|
||||
return;
|
||||
return ecma_reject (is_throw);
|
||||
}
|
||||
|
||||
// e.
|
||||
@@ -480,14 +444,13 @@ ecma_op_array_object_define_own_property (ecma_completion_value_t &ret_value, /*
|
||||
ecma_number_t *num_p = ecma_alloc_number ();
|
||||
*num_p = ecma_number_add (ecma_uint32_to_number (index), ECMA_NUMBER_ONE);
|
||||
|
||||
ecma_named_data_property_assign_value (obj_p, len_prop_p, ecma_value_t (num_p));
|
||||
ecma_named_data_property_assign_value (obj_p, len_prop_p, ecma_make_number_value (num_p));
|
||||
|
||||
ecma_dealloc_number (num_p);
|
||||
}
|
||||
|
||||
// f.
|
||||
ecma_make_simple_completion_value (ret_value, ECMA_SIMPLE_VALUE_TRUE);
|
||||
return;
|
||||
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
|
||||
}
|
||||
|
||||
JERRY_UNREACHABLE();
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#define ECMA_ARRAY_OBJECT_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-value.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
@@ -26,15 +25,13 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern void
|
||||
ecma_op_create_array_object (ecma_completion_value_t &ret_value,
|
||||
const ecma_value_t *arguments_list_p,
|
||||
extern ecma_completion_value_t
|
||||
ecma_op_create_array_object (const ecma_value_t *arguments_list_p,
|
||||
ecma_length_t arguments_list_len,
|
||||
bool is_treat_single_arg_as_length);
|
||||
|
||||
extern void
|
||||
ecma_op_array_object_define_own_property (ecma_completion_value_t &ret_value,
|
||||
const ecma_object_ptr_t& obj_p,
|
||||
extern ecma_completion_value_t
|
||||
ecma_op_array_object_define_own_property (ecma_object_t *obj_p,
|
||||
ecma_string_t *property_name_p,
|
||||
const ecma_property_descriptor_t* property_desc_p,
|
||||
bool is_throw);
|
||||
|
||||
@@ -38,32 +38,28 @@
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
ecma_op_create_boolean_object (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& arg) /**< argument passed to the Boolean constructor */
|
||||
ecma_completion_value_t
|
||||
ecma_op_create_boolean_object (const ecma_value_t& arg) /**< argument passed to the Boolean constructor */
|
||||
{
|
||||
ecma_completion_value_t conv_to_boolean_completion;
|
||||
ecma_op_to_boolean (conv_to_boolean_completion, arg);
|
||||
ecma_completion_value_t conv_to_boolean_completion = ecma_op_to_boolean (arg);
|
||||
|
||||
if (!ecma_is_completion_value_normal (conv_to_boolean_completion))
|
||||
{
|
||||
ret_value = conv_to_boolean_completion;
|
||||
return;
|
||||
return conv_to_boolean_completion;
|
||||
}
|
||||
|
||||
ecma_simple_value_t bool_value = (ecma_is_completion_value_normal_true (conv_to_boolean_completion) ?
|
||||
ecma_simple_value_t bool_value = (ecma_is_value_true (ecma_get_completion_value_value (conv_to_boolean_completion)) ?
|
||||
ECMA_SIMPLE_VALUE_TRUE : ECMA_SIMPLE_VALUE_FALSE);
|
||||
|
||||
#ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_BOOLEAN_BUILTIN
|
||||
ecma_object_ptr_t prototype_obj_p;
|
||||
ecma_builtin_get (prototype_obj_p, ECMA_BUILTIN_ID_BOOLEAN_PROTOTYPE);
|
||||
ecma_object_t *prototype_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_BOOLEAN_PROTOTYPE);
|
||||
#else /* !CONFIG_ECMA_COMPACT_PROFILE_DISABLE_BOOLEAN_BUILTIN */
|
||||
ecma_object_ptr_t prototype_obj_p;
|
||||
ecma_builtin_get (prototype_obj_p, ECMA_BUILTIN_ID_OBJECT_PROTOTYPE);
|
||||
ecma_object_t *prototype_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_OBJECT_PROTOTYPE);
|
||||
#endif /* CONFIG_ECMA_COMPACT_PROFILE_DISABLE_BOOLEAN_BUILTIN */
|
||||
|
||||
ecma_object_ptr_t obj_p;
|
||||
ecma_create_object (obj_p, prototype_obj_p, true, ECMA_OBJECT_TYPE_GENERAL);
|
||||
ecma_object_t *obj_p = ecma_create_object (prototype_obj_p,
|
||||
true,
|
||||
ECMA_OBJECT_TYPE_GENERAL);
|
||||
ecma_deref_object (prototype_obj_p);
|
||||
|
||||
ecma_property_t *class_prop_p = ecma_create_internal_property (obj_p, ECMA_INTERNAL_PROPERTY_CLASS);
|
||||
@@ -73,5 +69,5 @@ ecma_op_create_boolean_object (ecma_completion_value_t &ret_value, /**< out: com
|
||||
ECMA_INTERNAL_PROPERTY_PRIMITIVE_BOOLEAN_VALUE);
|
||||
prim_value_prop_p->u.internal_property.value = bool_value;
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (obj_p));
|
||||
return ecma_make_normal_completion_value (ecma_make_object_value (obj_p));
|
||||
} /* ecma_op_create_boolean_object */
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#define ECMA_BOOLEAN_OBJECT_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-value.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
@@ -26,9 +25,7 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern void
|
||||
ecma_op_create_boolean_object (ecma_completion_value_t &ret_value,
|
||||
const ecma_value_t& arg);
|
||||
extern ecma_completion_value_t ecma_op_create_boolean_object (const ecma_value_t& arg);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -34,9 +34,8 @@
|
||||
* @return true - if values are equal,
|
||||
* false - otherwise.
|
||||
*/
|
||||
void
|
||||
ecma_op_abstract_equality_compare (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& x, /**< first operand */
|
||||
ecma_completion_value_t
|
||||
ecma_op_abstract_equality_compare (const ecma_value_t& x, /**< first operand */
|
||||
const ecma_value_t& y) /**< second operand */
|
||||
{
|
||||
const bool is_x_undefined = ecma_is_value_undefined (x);
|
||||
@@ -60,6 +59,8 @@ ecma_op_abstract_equality_compare (ecma_completion_value_t &ret_value, /**< out:
|
||||
|| (is_x_string && is_y_string)
|
||||
|| (is_x_object && is_y_object));
|
||||
|
||||
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
|
||||
|
||||
if (is_types_equal)
|
||||
{
|
||||
// 1.
|
||||
@@ -68,7 +69,7 @@ ecma_op_abstract_equality_compare (ecma_completion_value_t &ret_value, /**< out:
|
||||
|| is_x_null)
|
||||
{
|
||||
// a., b.
|
||||
ecma_make_simple_completion_value (ret_value, ECMA_SIMPLE_VALUE_TRUE);
|
||||
ret_value = ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
|
||||
}
|
||||
else if (is_x_number)
|
||||
{ // c.
|
||||
@@ -99,8 +100,8 @@ ecma_op_abstract_equality_compare (ecma_completion_value_t &ret_value, /**< out:
|
||||
JERRY_ASSERT (is_x_equal_to_y == is_x_equal_to_y_check);
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
|
||||
ecma_make_simple_completion_value (ret_value,
|
||||
is_x_equal_to_y ? ECMA_SIMPLE_VALUE_TRUE : ECMA_SIMPLE_VALUE_FALSE);
|
||||
ret_value = ecma_make_simple_completion_value (is_x_equal_to_y ?
|
||||
ECMA_SIMPLE_VALUE_TRUE : ECMA_SIMPLE_VALUE_FALSE);
|
||||
}
|
||||
else if (is_x_string)
|
||||
{ // d.
|
||||
@@ -109,65 +110,69 @@ ecma_op_abstract_equality_compare (ecma_completion_value_t &ret_value, /**< out:
|
||||
|
||||
bool is_equal = ecma_compare_ecma_strings (x_str_p, y_str_p);
|
||||
|
||||
ecma_make_simple_completion_value (ret_value, is_equal ? ECMA_SIMPLE_VALUE_TRUE : ECMA_SIMPLE_VALUE_FALSE);
|
||||
ret_value = ecma_make_simple_completion_value (is_equal ? ECMA_SIMPLE_VALUE_TRUE : ECMA_SIMPLE_VALUE_FALSE);
|
||||
}
|
||||
else if (is_x_boolean)
|
||||
{ // e.
|
||||
bool is_equal = (ecma_is_value_true (x) == ecma_is_value_true (y));
|
||||
|
||||
ecma_make_simple_completion_value (ret_value, is_equal ? ECMA_SIMPLE_VALUE_TRUE : ECMA_SIMPLE_VALUE_FALSE);
|
||||
ret_value = ecma_make_simple_completion_value (is_equal ? ECMA_SIMPLE_VALUE_TRUE : ECMA_SIMPLE_VALUE_FALSE);
|
||||
}
|
||||
else
|
||||
{ // f.
|
||||
JERRY_ASSERT(is_x_object);
|
||||
|
||||
ecma_object_ptr_t x_obj_p, y_obj_p;
|
||||
ecma_get_object_from_value (x_obj_p, x);
|
||||
ecma_get_object_from_value (y_obj_p, y);
|
||||
bool is_equal = (ecma_get_object_from_value (x) == ecma_get_object_from_value (y));
|
||||
|
||||
bool is_equal = (x_obj_p == y_obj_p);
|
||||
|
||||
ecma_make_simple_completion_value (ret_value, is_equal ? ECMA_SIMPLE_VALUE_TRUE : ECMA_SIMPLE_VALUE_FALSE);
|
||||
ret_value = ecma_make_simple_completion_value (is_equal ? ECMA_SIMPLE_VALUE_TRUE : ECMA_SIMPLE_VALUE_FALSE);
|
||||
}
|
||||
}
|
||||
else if ((is_x_null && is_y_undefined)
|
||||
|| (is_x_undefined && is_y_null))
|
||||
{ // 2., 3.
|
||||
ecma_make_simple_completion_value (ret_value, ECMA_SIMPLE_VALUE_TRUE);
|
||||
ret_value = ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
|
||||
}
|
||||
else if (is_x_number && is_y_string)
|
||||
{
|
||||
// 4.
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_to_number, y_num_value, y);
|
||||
ECMA_TRY_CATCH (y_num_value,
|
||||
ecma_op_to_number (y),
|
||||
ret_value);
|
||||
|
||||
ecma_op_abstract_equality_compare (ret_value, x, y_num_value);
|
||||
ret_value = ecma_op_abstract_equality_compare (x, y_num_value);
|
||||
|
||||
ECMA_FINALIZE (y_num_value);
|
||||
}
|
||||
else if (is_x_string && is_y_number)
|
||||
{
|
||||
// 5.
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_to_number, x_num_value, x);
|
||||
ECMA_TRY_CATCH (x_num_value,
|
||||
ecma_op_to_number (x),
|
||||
ret_value);
|
||||
|
||||
ecma_op_abstract_equality_compare (ret_value, x_num_value, y);
|
||||
ret_value = ecma_op_abstract_equality_compare (x_num_value, y);
|
||||
|
||||
ECMA_FINALIZE (x_num_value);
|
||||
}
|
||||
else if (is_x_boolean)
|
||||
{
|
||||
// 6.
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_to_number, x_num_value, x);
|
||||
ECMA_TRY_CATCH (x_num_value,
|
||||
ecma_op_to_number (x),
|
||||
ret_value);
|
||||
|
||||
ecma_op_abstract_equality_compare (ret_value, x_num_value, y);
|
||||
ret_value = ecma_op_abstract_equality_compare (x_num_value, y);
|
||||
|
||||
ECMA_FINALIZE (x_num_value);
|
||||
}
|
||||
else if (is_y_boolean)
|
||||
{
|
||||
// 7.
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_to_number, y_num_value, y);
|
||||
ECMA_TRY_CATCH (y_num_value,
|
||||
ecma_op_to_number (y),
|
||||
ret_value);
|
||||
|
||||
ecma_op_abstract_equality_compare (ret_value, x, y_num_value);
|
||||
ret_value = ecma_op_abstract_equality_compare (x, y_num_value);
|
||||
|
||||
ECMA_FINALIZE (y_num_value);
|
||||
}
|
||||
@@ -175,9 +180,11 @@ ecma_op_abstract_equality_compare (ecma_completion_value_t &ret_value, /**< out:
|
||||
&& (is_x_number || is_x_string))
|
||||
{
|
||||
// 8.
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_to_primitive, y_prim_value, y, ECMA_PREFERRED_TYPE_NO);
|
||||
ECMA_TRY_CATCH (y_prim_value,
|
||||
ecma_op_to_primitive (y, ECMA_PREFERRED_TYPE_NO),
|
||||
ret_value);
|
||||
|
||||
ecma_op_abstract_equality_compare (ret_value, x, y_prim_value);
|
||||
ret_value = ecma_op_abstract_equality_compare (x, y_prim_value);
|
||||
|
||||
ECMA_FINALIZE (y_prim_value);
|
||||
}
|
||||
@@ -185,16 +192,20 @@ ecma_op_abstract_equality_compare (ecma_completion_value_t &ret_value, /**< out:
|
||||
&& (is_y_number || is_y_string))
|
||||
{
|
||||
// 9.
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_to_primitive, x_prim_value, x, ECMA_PREFERRED_TYPE_NO);
|
||||
ECMA_TRY_CATCH (x_prim_value,
|
||||
ecma_op_to_primitive (x, ECMA_PREFERRED_TYPE_NO),
|
||||
ret_value);
|
||||
|
||||
ecma_op_abstract_equality_compare (ret_value, x_prim_value, y);
|
||||
ret_value = ecma_op_abstract_equality_compare (x_prim_value, y);
|
||||
|
||||
ECMA_FINALIZE (x_prim_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_make_simple_completion_value (ret_value, ECMA_SIMPLE_VALUE_FALSE);
|
||||
ret_value = ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE);
|
||||
}
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_op_abstract_equality_compare */
|
||||
|
||||
/**
|
||||
@@ -306,11 +317,7 @@ ecma_op_strict_equality_compare (const ecma_value_t& x, /**< first operand */
|
||||
// 7. Return true if x and y refer to the same object. Otherwise, return false.
|
||||
JERRY_ASSERT (is_x_object);
|
||||
|
||||
ecma_object_ptr_t x_obj_p, y_obj_p;
|
||||
ecma_get_object_from_value (x_obj_p, x);
|
||||
ecma_get_object_from_value (y_obj_p, y);
|
||||
|
||||
return (x_obj_p == y_obj_p);
|
||||
return (ecma_get_object_from_value (x) == ecma_get_object_from_value (y));
|
||||
} /* ecma_op_strict_equality_compare */
|
||||
|
||||
/**
|
||||
@@ -321,20 +328,23 @@ ecma_op_strict_equality_compare (const ecma_value_t& x, /**< first operand */
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
ecma_op_abstract_relational_compare (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& x, /**< first operand */
|
||||
ecma_completion_value_t
|
||||
ecma_op_abstract_relational_compare (const ecma_value_t& x, /**< first operand */
|
||||
const ecma_value_t& y, /**< second operand */
|
||||
bool left_first) /**< 'LeftFirst' flag */
|
||||
{
|
||||
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
|
||||
|
||||
const ecma_value_t& first_converted_value = left_first ? x : y;
|
||||
const ecma_value_t& second_converted_value = left_first ? y : x;
|
||||
|
||||
// 1., 2.
|
||||
ECMA_TRY_CATCH(ret_value,
|
||||
ecma_op_to_primitive, prim_first_converted_value, first_converted_value, ECMA_PREFERRED_TYPE_NUMBER);
|
||||
ECMA_TRY_CATCH(ret_value,
|
||||
ecma_op_to_primitive, prim_second_converted_value, second_converted_value, ECMA_PREFERRED_TYPE_NUMBER);
|
||||
ECMA_TRY_CATCH(prim_first_converted_value,
|
||||
ecma_op_to_primitive (first_converted_value, ECMA_PREFERRED_TYPE_NUMBER),
|
||||
ret_value);
|
||||
ECMA_TRY_CATCH(prim_second_converted_value,
|
||||
ecma_op_to_primitive (second_converted_value, ECMA_PREFERRED_TYPE_NUMBER),
|
||||
ret_value);
|
||||
|
||||
const ecma_value_t &px = left_first ? prim_first_converted_value : prim_second_converted_value;
|
||||
const ecma_value_t &py = left_first ? prim_second_converted_value : prim_first_converted_value;
|
||||
@@ -355,7 +365,7 @@ ecma_op_abstract_relational_compare (ecma_completion_value_t &ret_value, /**< ou
|
||||
|| ecma_number_is_nan (ny))
|
||||
{
|
||||
// c., d.
|
||||
ecma_make_simple_completion_value (ret_value, ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||
ret_value = ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -418,8 +428,8 @@ ecma_op_abstract_relational_compare (ecma_completion_value_t &ret_value, /**< ou
|
||||
JERRY_ASSERT (is_x_less_than_y_check == is_x_less_than_y);
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
|
||||
ecma_make_simple_completion_value (ret_value,
|
||||
is_x_less_than_y ? ECMA_SIMPLE_VALUE_TRUE : ECMA_SIMPLE_VALUE_FALSE);
|
||||
ret_value = ecma_make_simple_completion_value (is_x_less_than_y ?
|
||||
ECMA_SIMPLE_VALUE_TRUE : ECMA_SIMPLE_VALUE_FALSE);
|
||||
}
|
||||
|
||||
ECMA_OP_TO_NUMBER_FINALIZE (ny);
|
||||
@@ -434,12 +444,14 @@ ecma_op_abstract_relational_compare (ecma_completion_value_t &ret_value, /**< ou
|
||||
|
||||
bool is_px_less = ecma_compare_ecma_strings_relational (str_x_p, str_y_p);
|
||||
|
||||
ecma_make_simple_completion_value (ret_value,
|
||||
is_px_less ? ECMA_SIMPLE_VALUE_TRUE : ECMA_SIMPLE_VALUE_FALSE);
|
||||
ret_value = ecma_make_simple_completion_value (is_px_less ? ECMA_SIMPLE_VALUE_TRUE
|
||||
: ECMA_SIMPLE_VALUE_FALSE);
|
||||
}
|
||||
|
||||
ECMA_FINALIZE(prim_second_converted_value);
|
||||
ECMA_FINALIZE(prim_first_converted_value);
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_op_abstract_relational_compare */
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-value.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
@@ -27,18 +26,13 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern void
|
||||
ecma_op_abstract_equality_compare (ecma_completion_value_t &ret_value,
|
||||
const ecma_value_t& x,
|
||||
const ecma_value_t& y);
|
||||
extern bool
|
||||
ecma_op_strict_equality_compare (const ecma_value_t& x,
|
||||
const ecma_value_t& y);
|
||||
extern void
|
||||
ecma_op_abstract_relational_compare (ecma_completion_value_t &ret_value,
|
||||
const ecma_value_t& x,
|
||||
const ecma_value_t& y,
|
||||
bool left_first);
|
||||
extern ecma_completion_value_t ecma_op_abstract_equality_compare (const ecma_value_t& x,
|
||||
const ecma_value_t& y);
|
||||
extern bool ecma_op_strict_equality_compare (const ecma_value_t& x,
|
||||
const ecma_value_t& y);
|
||||
extern ecma_completion_value_t ecma_op_abstract_relational_compare (const ecma_value_t& x,
|
||||
const ecma_value_t& y,
|
||||
bool left_first);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -48,22 +48,19 @@
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
ecma_op_check_object_coercible (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& value) /**< ecma-value */
|
||||
ecma_completion_value_t
|
||||
ecma_op_check_object_coercible (const ecma_value_t& value) /**< ecma-value */
|
||||
{
|
||||
ecma_check_value_type_is_spec_defined (value);
|
||||
|
||||
if (ecma_is_value_undefined (value)
|
||||
|| ecma_is_value_null (value))
|
||||
{
|
||||
ecma_object_ptr_t exception_obj_p;
|
||||
ecma_new_standard_error (exception_obj_p, ECMA_ERROR_TYPE);
|
||||
ecma_make_throw_obj_completion_value (ret_value, exception_obj_p);
|
||||
return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_make_empty_completion_value (ret_value);
|
||||
return ecma_make_empty_completion_value ();
|
||||
}
|
||||
} /* ecma_op_check_object_coercible */
|
||||
|
||||
@@ -147,11 +144,7 @@ ecma_op_same_value (const ecma_value_t& x, /**< ecma-value */
|
||||
|
||||
JERRY_ASSERT(is_x_object);
|
||||
|
||||
ecma_object_ptr_t x_obj_p, y_obj_p;
|
||||
ecma_get_object_from_value (x_obj_p, x);
|
||||
ecma_get_object_from_value (y_obj_p, y);
|
||||
|
||||
return (x_obj_p == y_obj_p);
|
||||
return (ecma_get_object_from_value (x) == ecma_get_object_from_value (y));
|
||||
} /* ecma_op_same_value */
|
||||
|
||||
/**
|
||||
@@ -163,26 +156,21 @@ ecma_op_same_value (const ecma_value_t& x, /**< ecma-value */
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
ecma_op_to_primitive (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& value, /**< ecma-value */
|
||||
ecma_completion_value_t
|
||||
ecma_op_to_primitive (const ecma_value_t& value, /**< ecma-value */
|
||||
ecma_preferred_type_hint_t preferred_type) /**< preferred type hint */
|
||||
{
|
||||
ecma_check_value_type_is_spec_defined (value);
|
||||
|
||||
if (ecma_is_value_object (value))
|
||||
{
|
||||
ecma_object_ptr_t obj_p;
|
||||
ecma_get_object_from_value (obj_p, value);
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (value);
|
||||
|
||||
ecma_op_object_default_value (ret_value, obj_p, preferred_type);
|
||||
return ecma_op_object_default_value (obj_p, preferred_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_value_t value_copy;
|
||||
ecma_copy_value (value_copy, value, true);
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, value_copy);
|
||||
return ecma_make_normal_completion_value (ecma_copy_value (value, true));
|
||||
}
|
||||
} /* ecma_op_to_primitive */
|
||||
|
||||
@@ -196,23 +184,22 @@ ecma_op_to_primitive (ecma_completion_value_t &ret_value, /**< out: completion v
|
||||
* Returned value is simple and so need not be freed.
|
||||
* However, ecma_free_completion_value may be called for it, but it is a no-op.
|
||||
*/
|
||||
void
|
||||
ecma_op_to_boolean (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& value) /**< ecma-value */
|
||||
ecma_completion_value_t
|
||||
ecma_op_to_boolean (const ecma_value_t& value) /**< ecma-value */
|
||||
{
|
||||
ecma_check_value_type_is_spec_defined (value);
|
||||
|
||||
ecma_simple_value_t boolean;
|
||||
ecma_simple_value_t ret_value;
|
||||
|
||||
if (ecma_is_value_boolean (value))
|
||||
{
|
||||
boolean = (ecma_is_value_true (value) ?
|
||||
ret_value = (ecma_is_value_true (value) ?
|
||||
ECMA_SIMPLE_VALUE_TRUE : ECMA_SIMPLE_VALUE_FALSE);
|
||||
}
|
||||
else if (ecma_is_value_undefined (value)
|
||||
|| ecma_is_value_null (value))
|
||||
{
|
||||
boolean = ECMA_SIMPLE_VALUE_FALSE;
|
||||
ret_value = ECMA_SIMPLE_VALUE_FALSE;
|
||||
}
|
||||
else if (ecma_is_value_number (value))
|
||||
{
|
||||
@@ -221,11 +208,11 @@ ecma_op_to_boolean (ecma_completion_value_t &ret_value, /**< out: completion val
|
||||
if (ecma_number_is_nan (*num_p)
|
||||
|| ecma_number_is_zero (*num_p))
|
||||
{
|
||||
boolean = ECMA_SIMPLE_VALUE_FALSE;
|
||||
ret_value = ECMA_SIMPLE_VALUE_FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean = ECMA_SIMPLE_VALUE_TRUE;
|
||||
ret_value = ECMA_SIMPLE_VALUE_TRUE;
|
||||
}
|
||||
}
|
||||
else if (ecma_is_value_string (value))
|
||||
@@ -234,21 +221,21 @@ ecma_op_to_boolean (ecma_completion_value_t &ret_value, /**< out: completion val
|
||||
|
||||
if (ecma_string_get_length (str_p) == 0)
|
||||
{
|
||||
boolean = ECMA_SIMPLE_VALUE_FALSE;
|
||||
ret_value = ECMA_SIMPLE_VALUE_FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean = ECMA_SIMPLE_VALUE_TRUE;
|
||||
ret_value = ECMA_SIMPLE_VALUE_TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_object (value));
|
||||
|
||||
boolean = ECMA_SIMPLE_VALUE_TRUE;
|
||||
ret_value = ECMA_SIMPLE_VALUE_TRUE;
|
||||
}
|
||||
|
||||
ecma_make_simple_completion_value (ret_value, boolean);
|
||||
return ecma_make_simple_completion_value (ret_value);
|
||||
} /* ecma_op_to_boolean */
|
||||
|
||||
/**
|
||||
@@ -260,18 +247,14 @@ ecma_op_to_boolean (ecma_completion_value_t &ret_value, /**< out: completion val
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
ecma_op_to_number (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& value) /**< ecma-value */
|
||||
ecma_completion_value_t
|
||||
ecma_op_to_number (const ecma_value_t& value) /**< ecma-value */
|
||||
{
|
||||
ecma_check_value_type_is_spec_defined (value);
|
||||
|
||||
if (ecma_is_value_number (value))
|
||||
{
|
||||
ecma_value_t value_copy;
|
||||
ecma_copy_value (value_copy, value, true);
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, value_copy);
|
||||
return ecma_make_normal_completion_value (ecma_copy_value (value, true));
|
||||
}
|
||||
else if (ecma_is_value_string (value))
|
||||
{
|
||||
@@ -280,15 +263,21 @@ ecma_op_to_number (ecma_completion_value_t &ret_value, /**< out: completion valu
|
||||
ecma_number_t *num_p = ecma_alloc_number ();
|
||||
*num_p = ecma_string_to_number (str_p);
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (num_p));
|
||||
return ecma_make_normal_completion_value (ecma_make_number_value (num_p));
|
||||
}
|
||||
else if (ecma_is_value_object (value))
|
||||
{
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_to_primitive, primitive_value, value, ECMA_PREFERRED_TYPE_NUMBER);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
ecma_op_to_number (ret_value, primitive_value);
|
||||
ECMA_TRY_CATCH (primitive_value,
|
||||
ecma_op_to_primitive (value, ECMA_PREFERRED_TYPE_NUMBER),
|
||||
ret_value);
|
||||
|
||||
ret_value = ecma_op_to_number (primitive_value);
|
||||
|
||||
ECMA_FINALIZE (primitive_value);
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -316,7 +305,7 @@ ecma_op_to_number (ecma_completion_value_t &ret_value, /**< out: completion valu
|
||||
}
|
||||
}
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (num_p));
|
||||
return ecma_make_normal_completion_value (ecma_make_number_value (num_p));
|
||||
}
|
||||
} /* ecma_op_to_number */
|
||||
|
||||
@@ -329,21 +318,24 @@ ecma_op_to_number (ecma_completion_value_t &ret_value, /**< out: completion valu
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
ecma_op_to_string (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& value) /**< ecma-value */
|
||||
ecma_completion_value_t
|
||||
ecma_op_to_string (const ecma_value_t& value) /**< ecma-value */
|
||||
{
|
||||
ecma_check_value_type_is_spec_defined (value);
|
||||
|
||||
if (unlikely (ecma_is_value_object (value)))
|
||||
{
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_to_primitive, prim_value, value, ECMA_PREFERRED_TYPE_STRING);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
ecma_op_to_string (ret_value, prim_value);
|
||||
ECMA_TRY_CATCH (prim_value,
|
||||
ecma_op_to_primitive (value, ECMA_PREFERRED_TYPE_STRING),
|
||||
ret_value);
|
||||
|
||||
ret_value = ecma_op_to_string (prim_value);
|
||||
|
||||
ECMA_FINALIZE (prim_value);
|
||||
|
||||
return;
|
||||
return ret_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -381,7 +373,7 @@ ecma_op_to_string (ecma_completion_value_t &ret_value, /**< out: completion valu
|
||||
}
|
||||
}
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (res_p));
|
||||
return ecma_make_normal_completion_value (ecma_make_string_value (res_p));
|
||||
}
|
||||
} /* ecma_op_to_string */
|
||||
|
||||
@@ -394,41 +386,35 @@ ecma_op_to_string (ecma_completion_value_t &ret_value, /**< out: completion valu
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
ecma_op_to_object (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& value) /**< ecma-value */
|
||||
ecma_completion_value_t
|
||||
ecma_op_to_object (const ecma_value_t& value) /**< ecma-value */
|
||||
{
|
||||
ecma_check_value_type_is_spec_defined (value);
|
||||
|
||||
if (ecma_is_value_number (value))
|
||||
{
|
||||
ecma_op_create_number_object (ret_value, value);
|
||||
return ecma_op_create_number_object (value);
|
||||
}
|
||||
else if (ecma_is_value_string (value))
|
||||
{
|
||||
ecma_op_create_string_object (ret_value, &value, 1);
|
||||
return ecma_op_create_string_object (&value, 1);
|
||||
}
|
||||
else if (ecma_is_value_object (value))
|
||||
{
|
||||
ecma_value_t value_copy;
|
||||
ecma_copy_value (value_copy, value, true);
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, value_copy);
|
||||
return ecma_make_normal_completion_value (ecma_copy_value (value, true));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ecma_is_value_undefined (value)
|
||||
|| ecma_is_value_null (value))
|
||||
{
|
||||
ecma_object_ptr_t exception_obj_p;
|
||||
ecma_new_standard_error (exception_obj_p, ECMA_ERROR_TYPE);
|
||||
ecma_make_throw_obj_completion_value (ret_value, exception_obj_p);
|
||||
return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_boolean (value));
|
||||
|
||||
ecma_op_create_boolean_object (ret_value, value);
|
||||
return ecma_op_create_boolean_object (value);
|
||||
}
|
||||
}
|
||||
} /* ecma_op_to_object */
|
||||
@@ -441,12 +427,11 @@ ecma_op_to_object (ecma_completion_value_t &ret_value, /**< out: completion valu
|
||||
*
|
||||
* @return constructed object
|
||||
*/
|
||||
void
|
||||
ecma_op_from_property_descriptor (ecma_object_ptr_t &obj_p, /**< out: object pointer */
|
||||
const ecma_property_descriptor_t* src_prop_desc_p) /**< property descriptor */
|
||||
ecma_object_t*
|
||||
ecma_op_from_property_descriptor (const ecma_property_descriptor_t* src_prop_desc_p) /**< property descriptor */
|
||||
{
|
||||
// 2.
|
||||
ecma_op_create_object_object_noarg (obj_p);
|
||||
ecma_object_t *obj_p = ecma_op_create_object_object_noarg ();
|
||||
|
||||
ecma_completion_value_t completion;
|
||||
ecma_property_descriptor_t prop_desc = ecma_make_empty_property_descriptor ();
|
||||
@@ -473,25 +458,23 @@ ecma_op_from_property_descriptor (ecma_object_ptr_t &obj_p, /**< out: object poi
|
||||
prop_desc.value = src_prop_desc_p->value;
|
||||
|
||||
ecma_string_t *value_magic_string_p = ecma_get_magic_string (ECMA_MAGIC_STRING_VALUE);
|
||||
ecma_op_object_define_own_property (completion,
|
||||
obj_p,
|
||||
value_magic_string_p,
|
||||
&prop_desc,
|
||||
false);
|
||||
completion = ecma_op_object_define_own_property (obj_p,
|
||||
value_magic_string_p,
|
||||
&prop_desc,
|
||||
false);
|
||||
ecma_deref_ecma_string (value_magic_string_p);
|
||||
JERRY_ASSERT (ecma_is_completion_value_normal_true (completion));
|
||||
|
||||
// b.
|
||||
const bool is_writable = (src_prop_desc_p->is_writable);
|
||||
prop_desc.value = (ecma_value_packed_t) ecma_value_t (is_writable ? ECMA_SIMPLE_VALUE_TRUE
|
||||
prop_desc.value = ecma_make_simple_value (is_writable ? ECMA_SIMPLE_VALUE_TRUE
|
||||
: ECMA_SIMPLE_VALUE_FALSE);
|
||||
|
||||
ecma_string_t *writable_magic_string_p = ecma_get_magic_string (ECMA_MAGIC_STRING_WRITABLE);
|
||||
ecma_op_object_define_own_property (completion,
|
||||
obj_p,
|
||||
writable_magic_string_p,
|
||||
&prop_desc,
|
||||
false);
|
||||
completion = ecma_op_object_define_own_property (obj_p,
|
||||
writable_magic_string_p,
|
||||
&prop_desc,
|
||||
false);
|
||||
ecma_deref_ecma_string (writable_magic_string_p);
|
||||
JERRY_ASSERT (ecma_is_completion_value_normal_true (completion));
|
||||
}
|
||||
@@ -503,67 +486,65 @@ ecma_op_from_property_descriptor (ecma_object_ptr_t &obj_p, /**< out: object poi
|
||||
// a.
|
||||
if (src_prop_desc_p->get_p == NULL)
|
||||
{
|
||||
prop_desc.value = (ecma_value_packed_t) ecma_value_t (ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||
prop_desc.value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||
}
|
||||
else
|
||||
{
|
||||
prop_desc.value = (ecma_value_packed_t) ecma_value_t (src_prop_desc_p->get_p);
|
||||
prop_desc.value = ecma_make_object_value (src_prop_desc_p->get_p);
|
||||
}
|
||||
|
||||
ecma_string_t *get_magic_string_p = ecma_get_magic_string (ECMA_MAGIC_STRING_GET);
|
||||
ecma_op_object_define_own_property (completion,
|
||||
obj_p,
|
||||
get_magic_string_p,
|
||||
&prop_desc,
|
||||
false);
|
||||
completion = ecma_op_object_define_own_property (obj_p,
|
||||
get_magic_string_p,
|
||||
&prop_desc,
|
||||
false);
|
||||
ecma_deref_ecma_string (get_magic_string_p);
|
||||
JERRY_ASSERT (ecma_is_completion_value_normal_true (completion));
|
||||
|
||||
// b.
|
||||
if (src_prop_desc_p->set_p == NULL)
|
||||
{
|
||||
prop_desc.value = (ecma_value_packed_t) ecma_value_t (ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||
prop_desc.value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||
}
|
||||
else
|
||||
{
|
||||
prop_desc.value = (ecma_value_packed_t) ecma_value_t (src_prop_desc_p->set_p);
|
||||
prop_desc.value = ecma_make_object_value (src_prop_desc_p->set_p);
|
||||
}
|
||||
|
||||
ecma_string_t *set_magic_string_p = ecma_get_magic_string (ECMA_MAGIC_STRING_SET);
|
||||
ecma_op_object_define_own_property (completion,
|
||||
obj_p,
|
||||
set_magic_string_p,
|
||||
&prop_desc,
|
||||
false);
|
||||
completion = ecma_op_object_define_own_property (obj_p,
|
||||
set_magic_string_p,
|
||||
&prop_desc,
|
||||
false);
|
||||
ecma_deref_ecma_string (set_magic_string_p);
|
||||
JERRY_ASSERT (ecma_is_completion_value_normal_true (completion));
|
||||
}
|
||||
|
||||
const bool is_enumerable = src_prop_desc_p->is_enumerable;
|
||||
prop_desc.value = (ecma_value_packed_t) ecma_value_t (is_enumerable ? ECMA_SIMPLE_VALUE_TRUE
|
||||
: ECMA_SIMPLE_VALUE_FALSE);
|
||||
prop_desc.value = ecma_make_simple_value (is_enumerable ? ECMA_SIMPLE_VALUE_TRUE
|
||||
: ECMA_SIMPLE_VALUE_FALSE);
|
||||
|
||||
ecma_string_t *enumerable_magic_string_p = ecma_get_magic_string (ECMA_MAGIC_STRING_ENUMERABLE);
|
||||
ecma_op_object_define_own_property (completion,
|
||||
obj_p,
|
||||
enumerable_magic_string_p,
|
||||
&prop_desc,
|
||||
false);
|
||||
completion = ecma_op_object_define_own_property (obj_p,
|
||||
enumerable_magic_string_p,
|
||||
&prop_desc,
|
||||
false);
|
||||
ecma_deref_ecma_string (enumerable_magic_string_p);
|
||||
JERRY_ASSERT (ecma_is_completion_value_normal_true (completion));
|
||||
|
||||
const bool is_configurable = src_prop_desc_p->is_configurable;
|
||||
prop_desc.value = (ecma_value_packed_t) ecma_value_t (is_configurable ? ECMA_SIMPLE_VALUE_TRUE
|
||||
: ECMA_SIMPLE_VALUE_FALSE);
|
||||
prop_desc.value = ecma_make_simple_value (is_configurable ? ECMA_SIMPLE_VALUE_TRUE
|
||||
: ECMA_SIMPLE_VALUE_FALSE);
|
||||
|
||||
ecma_string_t *configurable_magic_string_p = ecma_get_magic_string (ECMA_MAGIC_STRING_CONFIGURABLE);
|
||||
ecma_op_object_define_own_property (completion,
|
||||
obj_p,
|
||||
configurable_magic_string_p,
|
||||
&prop_desc,
|
||||
false);
|
||||
completion = ecma_op_object_define_own_property (obj_p,
|
||||
configurable_magic_string_p,
|
||||
&prop_desc,
|
||||
false);
|
||||
ecma_deref_ecma_string (configurable_magic_string_p);
|
||||
JERRY_ASSERT (ecma_is_completion_value_normal_true (completion));
|
||||
|
||||
return obj_p;
|
||||
} /* ecma_op_from_property_descriptor */
|
||||
|
||||
/**
|
||||
@@ -575,26 +556,22 @@ ecma_op_from_property_descriptor (ecma_object_ptr_t &obj_p, /**< out: object poi
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
ecma_op_to_property_descriptor (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_value_t& obj_value, /**< object value */
|
||||
ecma_completion_value_t
|
||||
ecma_op_to_property_descriptor (const ecma_value_t& obj_value, /**< object value */
|
||||
ecma_property_descriptor_t *out_prop_desc_p) /**< out: filled property descriptor
|
||||
if return value is normal
|
||||
empty completion value */
|
||||
{
|
||||
ecma_make_empty_completion_value (ret_value);
|
||||
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
|
||||
|
||||
// 1.
|
||||
if (!ecma_is_value_object (obj_value))
|
||||
{
|
||||
ecma_object_ptr_t exception_obj_p;
|
||||
ecma_new_standard_error (exception_obj_p, ECMA_ERROR_TYPE);
|
||||
ecma_make_throw_obj_completion_value (ret_value, exception_obj_p);
|
||||
ret_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_object_ptr_t obj_p;
|
||||
ecma_get_object_from_value (obj_p, obj_value);
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (obj_value);
|
||||
|
||||
// 2.
|
||||
ecma_property_descriptor_t prop_desc = ecma_make_empty_property_descriptor ();
|
||||
@@ -604,8 +581,12 @@ ecma_op_to_property_descriptor (ecma_completion_value_t &ret_value, /**< out: co
|
||||
|
||||
if (ecma_op_object_get_property (obj_p, enumerable_magic_string_p) != NULL)
|
||||
{
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_object_get, enumerable_prop_value, obj_p, enumerable_magic_string_p);
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_to_boolean, boolean_enumerable_prop_value, enumerable_prop_value);
|
||||
ECMA_TRY_CATCH (enumerable_prop_value,
|
||||
ecma_op_object_get (obj_p, enumerable_magic_string_p),
|
||||
ret_value);
|
||||
ECMA_TRY_CATCH (boolean_enumerable_prop_value,
|
||||
ecma_op_to_boolean (enumerable_prop_value),
|
||||
ret_value);
|
||||
|
||||
prop_desc.is_enumerable_defined = true;
|
||||
if (ecma_is_value_true (boolean_enumerable_prop_value))
|
||||
@@ -634,8 +615,12 @@ ecma_op_to_property_descriptor (ecma_completion_value_t &ret_value, /**< out: co
|
||||
|
||||
if (ecma_op_object_get_property (obj_p, configurable_magic_string_p) != NULL)
|
||||
{
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_object_get, configurable_prop_value, obj_p, configurable_magic_string_p);
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_to_boolean, boolean_configurable_prop_value, configurable_prop_value);
|
||||
ECMA_TRY_CATCH (configurable_prop_value,
|
||||
ecma_op_object_get (obj_p, configurable_magic_string_p),
|
||||
ret_value);
|
||||
ECMA_TRY_CATCH (boolean_configurable_prop_value,
|
||||
ecma_op_to_boolean (configurable_prop_value),
|
||||
ret_value);
|
||||
|
||||
prop_desc.is_configurable_defined = true;
|
||||
if (ecma_is_value_true (boolean_configurable_prop_value))
|
||||
@@ -665,13 +650,12 @@ ecma_op_to_property_descriptor (ecma_completion_value_t &ret_value, /**< out: co
|
||||
|
||||
if (ecma_op_object_get_property (obj_p, value_magic_string_p) != NULL)
|
||||
{
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_object_get, value_prop_value, obj_p, value_magic_string_p);
|
||||
|
||||
ecma_value_t value_copy;
|
||||
ecma_copy_value (value_copy, value_prop_value, true);
|
||||
ECMA_TRY_CATCH (value_prop_value,
|
||||
ecma_op_object_get (obj_p, value_magic_string_p),
|
||||
ret_value);
|
||||
|
||||
prop_desc.is_value_defined = true;
|
||||
prop_desc.value = (ecma_value_packed_t) value_copy;
|
||||
prop_desc.value = ecma_copy_value (value_prop_value, true);
|
||||
|
||||
ECMA_FINALIZE (value_prop_value);
|
||||
}
|
||||
@@ -688,8 +672,12 @@ ecma_op_to_property_descriptor (ecma_completion_value_t &ret_value, /**< out: co
|
||||
|
||||
if (ecma_op_object_get_property (obj_p, writable_magic_string_p) != NULL)
|
||||
{
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_object_get, writable_prop_value, obj_p, writable_magic_string_p);
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_to_boolean, boolean_writable_prop_value, writable_prop_value);
|
||||
ECMA_TRY_CATCH (writable_prop_value,
|
||||
ecma_op_object_get (obj_p, writable_magic_string_p),
|
||||
ret_value);
|
||||
ECMA_TRY_CATCH (boolean_writable_prop_value,
|
||||
ecma_op_to_boolean (writable_prop_value),
|
||||
ret_value);
|
||||
|
||||
prop_desc.is_writable_defined = true;
|
||||
if (ecma_is_value_true (boolean_writable_prop_value))
|
||||
@@ -719,14 +707,14 @@ ecma_op_to_property_descriptor (ecma_completion_value_t &ret_value, /**< out: co
|
||||
|
||||
if (ecma_op_object_get_property (obj_p, get_magic_string_p) != NULL)
|
||||
{
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_object_get, get_prop_value, obj_p, get_magic_string_p);
|
||||
ECMA_TRY_CATCH (get_prop_value,
|
||||
ecma_op_object_get (obj_p, get_magic_string_p),
|
||||
ret_value);
|
||||
|
||||
if (!ecma_op_is_callable (get_prop_value)
|
||||
&& !ecma_is_value_undefined (get_prop_value))
|
||||
{
|
||||
ecma_object_ptr_t exception_obj_p;
|
||||
ecma_new_standard_error (exception_obj_p, ECMA_ERROR_TYPE);
|
||||
ecma_make_throw_obj_completion_value (ret_value, exception_obj_p);
|
||||
ret_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -740,11 +728,10 @@ ecma_op_to_property_descriptor (ecma_completion_value_t &ret_value, /**< out: co
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_object (get_prop_value));
|
||||
|
||||
ecma_object_ptr_t get_p;
|
||||
ecma_get_object_from_value (get_p, get_prop_value);
|
||||
ecma_object_t *get_p = ecma_get_object_from_value (get_prop_value);
|
||||
ecma_ref_object (get_p);
|
||||
|
||||
prop_desc.get_p = (ecma_object_t*) get_p;
|
||||
prop_desc.get_p = get_p;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -764,14 +751,14 @@ ecma_op_to_property_descriptor (ecma_completion_value_t &ret_value, /**< out: co
|
||||
|
||||
if (ecma_op_object_get_property (obj_p, set_magic_string_p) != NULL)
|
||||
{
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_object_get, set_prop_value, obj_p, set_magic_string_p);
|
||||
ECMA_TRY_CATCH (set_prop_value,
|
||||
ecma_op_object_get (obj_p, set_magic_string_p),
|
||||
ret_value);
|
||||
|
||||
if (!ecma_op_is_callable (set_prop_value)
|
||||
&& !ecma_is_value_undefined (set_prop_value))
|
||||
{
|
||||
ecma_object_ptr_t exception_obj_p;
|
||||
ecma_new_standard_error (exception_obj_p, ECMA_ERROR_TYPE);
|
||||
ecma_make_throw_obj_completion_value (ret_value, exception_obj_p);
|
||||
ret_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -785,11 +772,10 @@ ecma_op_to_property_descriptor (ecma_completion_value_t &ret_value, /**< out: co
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_object (set_prop_value));
|
||||
|
||||
ecma_object_ptr_t set_p;
|
||||
ecma_get_object_from_value (set_p, set_prop_value);
|
||||
ecma_object_t *set_p = ecma_get_object_from_value (set_prop_value);
|
||||
ecma_ref_object (set_p);
|
||||
|
||||
prop_desc.set_p = (ecma_object_t*) set_p;
|
||||
prop_desc.set_p = set_p;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -810,9 +796,7 @@ ecma_op_to_property_descriptor (ecma_completion_value_t &ret_value, /**< out: co
|
||||
if (prop_desc.is_value_defined
|
||||
|| prop_desc.is_writable_defined)
|
||||
{
|
||||
ecma_object_ptr_t exception_obj_p;
|
||||
ecma_new_standard_error (exception_obj_p, ECMA_ERROR_TYPE);
|
||||
ecma_make_throw_obj_completion_value (ret_value, exception_obj_p);
|
||||
ret_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -828,6 +812,8 @@ ecma_op_to_property_descriptor (ecma_completion_value_t &ret_value, /**< out: co
|
||||
|
||||
*out_prop_desc_p = prop_desc;
|
||||
}
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_op_to_property_descriptor */
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-value.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
@@ -38,35 +37,19 @@ typedef enum
|
||||
ECMA_PREFERRED_TYPE_STRING /**< String */
|
||||
} ecma_preferred_type_hint_t;
|
||||
|
||||
extern void
|
||||
ecma_op_check_object_coercible (ecma_completion_value_t &ret_value,
|
||||
const ecma_value_t& value);
|
||||
extern ecma_completion_value_t ecma_op_check_object_coercible (const ecma_value_t& value);
|
||||
extern bool ecma_op_same_value (const ecma_value_t& x,
|
||||
const ecma_value_t& y);
|
||||
extern void
|
||||
ecma_op_to_primitive (ecma_completion_value_t &ret_value,
|
||||
const ecma_value_t& value,
|
||||
ecma_preferred_type_hint_t preferred_type);
|
||||
extern void
|
||||
ecma_op_to_boolean (ecma_completion_value_t &ret_value,
|
||||
const ecma_value_t& value);
|
||||
extern void
|
||||
ecma_op_to_number (ecma_completion_value_t &ret_value,
|
||||
const ecma_value_t& value);
|
||||
extern void
|
||||
ecma_op_to_string (ecma_completion_value_t &ret_value,
|
||||
const ecma_value_t& value);
|
||||
extern void
|
||||
ecma_op_to_object (ecma_completion_value_t &ret_value,
|
||||
const ecma_value_t& value);
|
||||
extern ecma_completion_value_t ecma_op_to_primitive (const ecma_value_t& value,
|
||||
ecma_preferred_type_hint_t preferred_type);
|
||||
extern ecma_completion_value_t ecma_op_to_boolean (const ecma_value_t& value);
|
||||
extern ecma_completion_value_t ecma_op_to_number (const ecma_value_t& value);
|
||||
extern ecma_completion_value_t ecma_op_to_string (const ecma_value_t& value);
|
||||
extern ecma_completion_value_t ecma_op_to_object (const ecma_value_t& value);
|
||||
|
||||
extern void
|
||||
ecma_op_from_property_descriptor (ecma_object_ptr_t &ret_val,
|
||||
const ecma_property_descriptor_t* src_prop_desc_p);
|
||||
extern void
|
||||
ecma_op_to_property_descriptor (ecma_completion_value_t &ret_value,
|
||||
const ecma_value_t& obj_value,
|
||||
ecma_property_descriptor_t *out_prop_desc_p);
|
||||
extern ecma_object_t* ecma_op_from_property_descriptor (const ecma_property_descriptor_t* src_prop_desc_p);
|
||||
extern ecma_completion_value_t ecma_op_to_property_descriptor (const ecma_value_t& obj_value,
|
||||
ecma_property_descriptor_t *out_prop_desc_p);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -35,9 +35,8 @@
|
||||
* @return pointer to ecma-object representing specified error
|
||||
* with reference counter set to one.
|
||||
*/
|
||||
void
|
||||
ecma_new_standard_error (ecma_object_ptr_t &new_error_obj_p, /**< out: object pointer */
|
||||
ecma_standard_error_t error_type) /**< native error type */
|
||||
ecma_object_t*
|
||||
ecma_new_standard_error (ecma_standard_error_t error_type) /**< native error type */
|
||||
{
|
||||
#ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_ERROR_BUILTINS
|
||||
ecma_builtin_id_t prototype_id = ECMA_BUILTIN_ID__COUNT;
|
||||
@@ -87,20 +86,23 @@ ecma_new_standard_error (ecma_object_ptr_t &new_error_obj_p, /**< out: object po
|
||||
}
|
||||
}
|
||||
|
||||
ecma_object_ptr_t prototype_obj_p;
|
||||
ecma_builtin_get (prototype_obj_p, prototype_id);
|
||||
ecma_object_t *prototype_obj_p = ecma_builtin_get (prototype_id);
|
||||
|
||||
ecma_create_object (new_error_obj_p, prototype_obj_p, true, ECMA_OBJECT_TYPE_GENERAL);
|
||||
ecma_object_t *new_error_obj_p = ecma_create_object (prototype_obj_p,
|
||||
true,
|
||||
ECMA_OBJECT_TYPE_GENERAL);
|
||||
|
||||
ecma_deref_object (prototype_obj_p);
|
||||
|
||||
ecma_property_t *class_prop_p = ecma_create_internal_property (new_error_obj_p,
|
||||
ECMA_INTERNAL_PROPERTY_CLASS);
|
||||
class_prop_p->u.internal_property.value = ECMA_MAGIC_STRING_ERROR_UL;
|
||||
|
||||
return new_error_obj_p;
|
||||
#else /* !CONFIG_ECMA_COMPACT_PROFILE_DISABLE_ERROR_BUILTINS */
|
||||
(void) error_type;
|
||||
|
||||
ecma_builtin_get (new_error_obj_p, ECMA_BUILTIN_ID_COMPACT_PROFILE_ERROR);
|
||||
return ecma_builtin_get (ECMA_BUILTIN_ID_COMPACT_PROFILE_ERROR);
|
||||
#endif /* CONFIG_ECMA_COMPACT_PROFILE_DISABLE_ERROR_BUILTINS */
|
||||
} /* ecma_new_standard_error */
|
||||
|
||||
@@ -110,12 +112,11 @@ ecma_new_standard_error (ecma_object_ptr_t &new_error_obj_p, /**< out: object po
|
||||
* @return pointer to ecma-object representing specified error
|
||||
* with reference counter set to one.
|
||||
*/
|
||||
void
|
||||
ecma_new_standard_error_with_message (ecma_object_ptr_t &new_error_obj_p, /**< out: object pointer */
|
||||
ecma_standard_error_t error_type, /**< native error type */
|
||||
ecma_object_t*
|
||||
ecma_new_standard_error_with_message (ecma_standard_error_t error_type, /**< native error type */
|
||||
ecma_string_t* message_string_p) /**< message string */
|
||||
{
|
||||
ecma_new_standard_error (new_error_obj_p, error_type);
|
||||
ecma_object_t *new_error_obj_p = ecma_new_standard_error (error_type);
|
||||
|
||||
ecma_string_t *message_magic_string_p = ecma_get_magic_string (ECMA_MAGIC_STRING_MESSAGE);
|
||||
ecma_property_t *prop_p = ecma_create_named_data_property (new_error_obj_p,
|
||||
@@ -123,8 +124,10 @@ ecma_new_standard_error_with_message (ecma_object_ptr_t &new_error_obj_p, /**< o
|
||||
true, false, true);
|
||||
|
||||
ecma_set_named_data_property_value (prop_p,
|
||||
ecma_value_t (ecma_copy_or_ref_ecma_string (message_string_p)));
|
||||
ecma_make_string_value (ecma_copy_or_ref_ecma_string (message_string_p)));
|
||||
ecma_deref_ecma_string (message_magic_string_p);
|
||||
|
||||
return new_error_obj_p;
|
||||
} /* ecma_new_standard_error_with_message */
|
||||
|
||||
/**
|
||||
|
||||
@@ -44,13 +44,9 @@ typedef enum
|
||||
ECMA_ERROR_URI /**< URIError */
|
||||
} ecma_standard_error_t;
|
||||
|
||||
extern void
|
||||
ecma_new_standard_error (ecma_object_ptr_t &ret_val,
|
||||
ecma_standard_error_t error_type);
|
||||
extern void
|
||||
ecma_new_standard_error_with_message (ecma_object_ptr_t &ret_val,
|
||||
ecma_standard_error_t error_type,
|
||||
ecma_string_t *message_string_p);
|
||||
extern ecma_object_t *ecma_new_standard_error (ecma_standard_error_t error_type);
|
||||
extern ecma_object_t* ecma_new_standard_error_with_message (ecma_standard_error_t error_type,
|
||||
ecma_string_t *message_string_p);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -94,10 +94,9 @@ ecma_op_is_callable (const ecma_value_t& value) /**< ecma-value */
|
||||
return false;
|
||||
}
|
||||
|
||||
ecma_object_ptr_t obj_p;
|
||||
ecma_get_object_from_value (obj_p, value);
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (value);
|
||||
|
||||
JERRY_ASSERT(obj_p.is_not_null ());
|
||||
JERRY_ASSERT(obj_p != NULL);
|
||||
JERRY_ASSERT(!ecma_is_lexical_environment (obj_p));
|
||||
|
||||
return (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_FUNCTION
|
||||
@@ -119,10 +118,9 @@ ecma_is_constructor (const ecma_value_t& value) /**< ecma-value */
|
||||
return false;
|
||||
}
|
||||
|
||||
ecma_object_ptr_t obj_p;
|
||||
ecma_get_object_from_value (obj_p, value);
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (value);
|
||||
|
||||
JERRY_ASSERT(obj_p.is_not_null ());
|
||||
JERRY_ASSERT(obj_p != NULL);
|
||||
JERRY_ASSERT(!ecma_is_lexical_environment (obj_p));
|
||||
|
||||
return (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_FUNCTION
|
||||
@@ -136,19 +134,17 @@ ecma_is_constructor (const ecma_value_t& value) /**< ecma-value */
|
||||
*
|
||||
* @return pointer to newly created Function object
|
||||
*/
|
||||
void
|
||||
ecma_op_create_function_object (ecma_object_ptr_t &function_obj_p, /**< out: object pointer */
|
||||
ecma_string_t* formal_parameter_list_p[], /**< formal parameters list */
|
||||
ecma_object_t*
|
||||
ecma_op_create_function_object (ecma_string_t* formal_parameter_list_p[], /**< formal parameters list */
|
||||
ecma_length_t formal_parameters_number, /**< formal parameters list's length */
|
||||
const ecma_object_ptr_t& scope_p, /**< function's scope */
|
||||
ecma_object_t *scope_p, /**< function's scope */
|
||||
bool is_strict, /**< 'strict' flag */
|
||||
opcode_counter_t first_opcode_idx) /**< index of first opcode of function's body */
|
||||
{
|
||||
// 1., 4., 13.
|
||||
ecma_object_ptr_t prototype_obj_p;
|
||||
ecma_builtin_get (prototype_obj_p, ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE);
|
||||
ecma_object_t *prototype_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE);
|
||||
|
||||
ecma_create_object (function_obj_p, prototype_obj_p, true, ECMA_OBJECT_TYPE_FUNCTION);
|
||||
ecma_object_t *f = ecma_create_object (prototype_obj_p, true, ECMA_OBJECT_TYPE_FUNCTION);
|
||||
|
||||
ecma_deref_object (prototype_obj_p);
|
||||
|
||||
@@ -160,19 +156,16 @@ ecma_op_create_function_object (ecma_object_ptr_t &function_obj_p, /**< out: obj
|
||||
*/
|
||||
|
||||
// 3.
|
||||
ecma_property_t *class_prop_p = ecma_create_internal_property (function_obj_p, ECMA_INTERNAL_PROPERTY_CLASS);
|
||||
ecma_property_t *class_prop_p = ecma_create_internal_property (f, ECMA_INTERNAL_PROPERTY_CLASS);
|
||||
class_prop_p->u.internal_property.value = ECMA_MAGIC_STRING_FUNCTION_UL;
|
||||
|
||||
// 9.
|
||||
ecma_property_t *scope_prop_p = ecma_create_internal_property (function_obj_p, ECMA_INTERNAL_PROPERTY_SCOPE);
|
||||
{
|
||||
ecma_object_t *scope_tmp_p = (ecma_object_t*) scope_p;
|
||||
ECMA_SET_POINTER(scope_prop_p->u.internal_property.value, scope_tmp_p);
|
||||
}
|
||||
ecma_gc_update_may_ref_younger_object_flag_by_object (function_obj_p, scope_p);
|
||||
ecma_property_t *scope_prop_p = ecma_create_internal_property (f, ECMA_INTERNAL_PROPERTY_SCOPE);
|
||||
ECMA_SET_POINTER(scope_prop_p->u.internal_property.value, scope_p);
|
||||
ecma_gc_update_may_ref_younger_object_flag_by_object (f, scope_p);
|
||||
|
||||
// 10., 11.
|
||||
ecma_property_t *formal_parameters_prop_p = ecma_create_internal_property (function_obj_p,
|
||||
ecma_property_t *formal_parameters_prop_p = ecma_create_internal_property (f,
|
||||
ECMA_INTERNAL_PROPERTY_FORMAL_PARAMETERS);
|
||||
if (formal_parameters_number != 0)
|
||||
{
|
||||
@@ -186,7 +179,7 @@ ecma_op_create_function_object (ecma_object_ptr_t &function_obj_p, /**< out: obj
|
||||
}
|
||||
|
||||
// 12.
|
||||
ecma_property_t *code_prop_p = ecma_create_internal_property (function_obj_p, ECMA_INTERNAL_PROPERTY_CODE);
|
||||
ecma_property_t *code_prop_p = ecma_create_internal_property (f, ECMA_INTERNAL_PROPERTY_CODE);
|
||||
code_prop_p->u.internal_property.value = ecma_pack_code_internal_property_value (is_strict,
|
||||
first_opcode_idx);
|
||||
|
||||
@@ -197,15 +190,13 @@ ecma_op_create_function_object (ecma_object_ptr_t &function_obj_p, /**< out: obj
|
||||
// 15.
|
||||
ecma_property_descriptor_t length_prop_desc = ecma_make_empty_property_descriptor ();
|
||||
length_prop_desc.is_value_defined = true;
|
||||
length_prop_desc.value = (ecma_value_packed_t) ecma_value_t (len_p);
|
||||
length_prop_desc.value = ecma_make_number_value (len_p);
|
||||
|
||||
ecma_string_t* magic_string_length_p = ecma_get_magic_string (ECMA_MAGIC_STRING_LENGTH);
|
||||
ecma_completion_value_t completion;
|
||||
ecma_op_object_define_own_property (completion,
|
||||
function_obj_p,
|
||||
magic_string_length_p,
|
||||
&length_prop_desc,
|
||||
false);
|
||||
ecma_completion_value_t completion = ecma_op_object_define_own_property (f,
|
||||
magic_string_length_p,
|
||||
&length_prop_desc,
|
||||
false);
|
||||
ecma_deref_ecma_string (magic_string_length_p);
|
||||
|
||||
JERRY_ASSERT (ecma_is_completion_value_normal_true (completion)
|
||||
@@ -215,14 +206,13 @@ ecma_op_create_function_object (ecma_object_ptr_t &function_obj_p, /**< out: obj
|
||||
len_p = NULL;
|
||||
|
||||
// 16.
|
||||
ecma_object_ptr_t proto_p;
|
||||
ecma_op_create_object_object_noarg (proto_p);
|
||||
ecma_object_t *proto_p = ecma_op_create_object_object_noarg ();
|
||||
|
||||
// 17.
|
||||
ecma_property_descriptor_t prop_desc = ecma_make_empty_property_descriptor ();
|
||||
{
|
||||
prop_desc.is_value_defined = true;
|
||||
prop_desc.value = (ecma_value_packed_t) ecma_value_t (function_obj_p);
|
||||
prop_desc.value = ecma_make_object_value (f);
|
||||
|
||||
prop_desc.is_writable_defined = true;
|
||||
prop_desc.is_writable = true;
|
||||
@@ -235,28 +225,20 @@ ecma_op_create_function_object (ecma_object_ptr_t &function_obj_p, /**< out: obj
|
||||
}
|
||||
|
||||
ecma_string_t *magic_string_constructor_p = ecma_get_magic_string (ECMA_MAGIC_STRING_CONSTRUCTOR);
|
||||
ecma_op_object_define_own_property (completion,
|
||||
proto_p,
|
||||
ecma_op_object_define_own_property (proto_p,
|
||||
magic_string_constructor_p,
|
||||
&prop_desc,
|
||||
false);
|
||||
JERRY_ASSERT (ecma_is_completion_value_normal_true (completion)
|
||||
|| ecma_is_completion_value_normal_false (completion));
|
||||
|
||||
ecma_deref_ecma_string (magic_string_constructor_p);
|
||||
|
||||
// 18.
|
||||
prop_desc.value = (ecma_value_packed_t) ecma_value_t (proto_p);
|
||||
prop_desc.value = ecma_make_object_value (proto_p);
|
||||
prop_desc.is_configurable = false;
|
||||
ecma_string_t *magic_string_prototype_p = ecma_get_magic_string (ECMA_MAGIC_STRING_PROTOTYPE);
|
||||
ecma_op_object_define_own_property (completion,
|
||||
function_obj_p,
|
||||
ecma_op_object_define_own_property (f,
|
||||
magic_string_prototype_p,
|
||||
&prop_desc,
|
||||
false);
|
||||
JERRY_ASSERT (ecma_is_completion_value_normal_true (completion)
|
||||
|| ecma_is_completion_value_normal_false (completion));
|
||||
|
||||
ecma_deref_ecma_string (magic_string_prototype_p);
|
||||
|
||||
ecma_deref_object (proto_p);
|
||||
@@ -264,8 +246,7 @@ ecma_op_create_function_object (ecma_object_ptr_t &function_obj_p, /**< out: obj
|
||||
// 19.
|
||||
if (is_strict)
|
||||
{
|
||||
ecma_object_ptr_t thrower_p;
|
||||
ecma_builtin_get (thrower_p, ECMA_BUILTIN_ID_TYPE_ERROR_THROWER);
|
||||
ecma_object_t *thrower_p = ecma_builtin_get (ECMA_BUILTIN_ID_TYPE_ERROR_THROWER);
|
||||
|
||||
prop_desc = ecma_make_empty_property_descriptor ();
|
||||
{
|
||||
@@ -276,36 +257,30 @@ ecma_op_create_function_object (ecma_object_ptr_t &function_obj_p, /**< out: obj
|
||||
prop_desc.is_configurable = false;
|
||||
|
||||
prop_desc.is_get_defined = true;
|
||||
prop_desc.get_p = (ecma_object_t*) thrower_p;
|
||||
prop_desc.get_p = thrower_p;
|
||||
|
||||
prop_desc.is_set_defined = true;
|
||||
prop_desc.set_p = (ecma_object_t*) thrower_p;
|
||||
prop_desc.set_p = thrower_p;
|
||||
}
|
||||
|
||||
ecma_string_t *magic_string_caller_p = ecma_get_magic_string (ECMA_MAGIC_STRING_CALLER);
|
||||
ecma_op_object_define_own_property (completion,
|
||||
function_obj_p,
|
||||
ecma_op_object_define_own_property (f,
|
||||
magic_string_caller_p,
|
||||
&prop_desc,
|
||||
false);
|
||||
JERRY_ASSERT (ecma_is_completion_value_normal_true (completion)
|
||||
|| ecma_is_completion_value_normal_false (completion));
|
||||
|
||||
ecma_deref_ecma_string (magic_string_caller_p);
|
||||
|
||||
ecma_string_t *magic_string_arguments_p = ecma_get_magic_string (ECMA_MAGIC_STRING_ARGUMENTS);
|
||||
ecma_op_object_define_own_property (completion,
|
||||
function_obj_p,
|
||||
ecma_op_object_define_own_property (f,
|
||||
magic_string_arguments_p,
|
||||
&prop_desc,
|
||||
false);
|
||||
JERRY_ASSERT (ecma_is_completion_value_normal_true (completion)
|
||||
|| ecma_is_completion_value_normal_false (completion));
|
||||
|
||||
ecma_deref_ecma_string (magic_string_arguments_p);
|
||||
|
||||
ecma_deref_object (thrower_p);
|
||||
}
|
||||
|
||||
return f;
|
||||
} /* ecma_op_create_function_object */
|
||||
|
||||
/**
|
||||
@@ -317,10 +292,9 @@ ecma_op_create_function_object (ecma_object_ptr_t &function_obj_p, /**< out: obj
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
static void
|
||||
ecma_function_call_setup_args_variables (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_object_ptr_t& func_obj_p, /**< Function object */
|
||||
const ecma_object_ptr_t& env_p, /**< lexical environment */
|
||||
static ecma_completion_value_t
|
||||
ecma_function_call_setup_args_variables (ecma_object_t *func_obj_p, /**< Function object */
|
||||
ecma_object_t *env_p, /**< lexical environment */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len, /**< length of argument list */
|
||||
bool is_strict) /**< flag indicating strict mode */
|
||||
@@ -333,8 +307,7 @@ ecma_function_call_setup_args_variables (ecma_completion_value_t &ret_value, /**
|
||||
|
||||
if (formal_parameters_p == NULL)
|
||||
{
|
||||
ecma_make_empty_completion_value (ret_value);
|
||||
return;
|
||||
return ecma_make_empty_completion_value ();
|
||||
}
|
||||
|
||||
ecma_length_t formal_parameters_count = formal_parameters_p->unit_number;
|
||||
@@ -346,8 +319,12 @@ ecma_function_call_setup_args_variables (ecma_completion_value_t &ret_value, /**
|
||||
n < formal_parameters_count;
|
||||
n++)
|
||||
{
|
||||
ecma_value_t v (ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||
if (n < arguments_list_len)
|
||||
ecma_value_t v;
|
||||
if (n >= arguments_list_len)
|
||||
{
|
||||
v = ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||
}
|
||||
else
|
||||
{
|
||||
v = arguments_list_p[n];
|
||||
}
|
||||
@@ -355,43 +332,37 @@ ecma_function_call_setup_args_variables (ecma_completion_value_t &ret_value, /**
|
||||
bool is_moved = ecma_collection_iterator_next (&formal_params_iterator);
|
||||
JERRY_ASSERT (is_moved);
|
||||
|
||||
ecma_value_t formal_parameter_name_value (*formal_params_iterator.current_value_p);
|
||||
ecma_value_t formal_parameter_name_value = *formal_params_iterator.current_value_p;
|
||||
ecma_string_t *formal_parameter_name_string_p = ecma_get_string_from_value (formal_parameter_name_value);
|
||||
|
||||
bool arg_already_declared = ecma_op_has_binding (env_p, formal_parameter_name_string_p);
|
||||
if (!arg_already_declared)
|
||||
{
|
||||
ecma_completion_value_t completion;
|
||||
ecma_op_create_mutable_binding (completion,
|
||||
env_p,
|
||||
formal_parameter_name_string_p,
|
||||
false);
|
||||
ecma_completion_value_t completion = ecma_op_create_mutable_binding (env_p,
|
||||
formal_parameter_name_string_p,
|
||||
false);
|
||||
if (ecma_is_completion_value_throw (completion))
|
||||
{
|
||||
ret_value = completion;
|
||||
return;
|
||||
return completion;
|
||||
}
|
||||
|
||||
JERRY_ASSERT (ecma_is_completion_value_empty (completion));
|
||||
|
||||
ecma_op_set_mutable_binding (completion,
|
||||
env_p,
|
||||
formal_parameter_name_string_p,
|
||||
v,
|
||||
is_strict);
|
||||
completion = ecma_op_set_mutable_binding (env_p,
|
||||
formal_parameter_name_string_p,
|
||||
v,
|
||||
is_strict);
|
||||
|
||||
if (ecma_is_completion_value_throw (completion))
|
||||
{
|
||||
ret_value = completion;
|
||||
return;
|
||||
return completion;
|
||||
}
|
||||
|
||||
JERRY_ASSERT (ecma_is_completion_value_empty (completion));
|
||||
}
|
||||
}
|
||||
|
||||
ecma_make_empty_completion_value (ret_value);
|
||||
return;
|
||||
return ecma_make_empty_completion_value ();
|
||||
} /* ecma_function_call_setup_args_variables */
|
||||
|
||||
/**
|
||||
@@ -404,55 +375,52 @@ ecma_function_call_setup_args_variables (ecma_completion_value_t &ret_value, /**
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
ecma_op_function_has_instance (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_object_ptr_t& func_obj_p, /**< Function object */
|
||||
ecma_completion_value_t
|
||||
ecma_op_function_has_instance (ecma_object_t *func_obj_p, /**< Function object */
|
||||
const ecma_value_t& value) /**< argument 'V' */
|
||||
{
|
||||
JERRY_ASSERT(func_obj_p.is_not_null ()
|
||||
JERRY_ASSERT(func_obj_p != NULL
|
||||
&& !ecma_is_lexical_environment (func_obj_p));
|
||||
|
||||
if (ecma_get_object_type (func_obj_p) == ECMA_OBJECT_TYPE_FUNCTION)
|
||||
{
|
||||
if (!ecma_is_value_object (value))
|
||||
{
|
||||
ecma_make_simple_completion_value (ret_value, ECMA_SIMPLE_VALUE_FALSE);
|
||||
return;
|
||||
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE);
|
||||
}
|
||||
|
||||
ecma_object_ptr_t v_obj_p;
|
||||
ecma_get_object_from_value (v_obj_p, value);
|
||||
ecma_object_t* v_obj_p = ecma_get_object_from_value (value);
|
||||
|
||||
ecma_string_t *prototype_magic_string_p = ecma_get_magic_string (ECMA_MAGIC_STRING_PROTOTYPE);
|
||||
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_object_get, prototype_obj_value, func_obj_p, prototype_magic_string_p);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
ECMA_TRY_CATCH (prototype_obj_value,
|
||||
ecma_op_object_get (func_obj_p, prototype_magic_string_p),
|
||||
ret_value);
|
||||
|
||||
if (!ecma_is_value_object (prototype_obj_value))
|
||||
{
|
||||
ecma_object_ptr_t exception_obj_p;
|
||||
ecma_new_standard_error (exception_obj_p, ECMA_ERROR_TYPE);
|
||||
ecma_make_throw_obj_completion_value (ret_value, exception_obj_p);
|
||||
return;
|
||||
ret_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_object_ptr_t prototype_obj_p;
|
||||
ecma_get_object_from_value (prototype_obj_p, prototype_obj_value);
|
||||
JERRY_ASSERT (prototype_obj_p.is_not_null ());
|
||||
ecma_object_t *prototype_obj_p = ecma_get_object_from_value (prototype_obj_value);
|
||||
JERRY_ASSERT (prototype_obj_p != NULL);
|
||||
|
||||
do
|
||||
{
|
||||
ecma_get_object_prototype (v_obj_p, v_obj_p);
|
||||
v_obj_p = ecma_get_object_prototype (v_obj_p);
|
||||
|
||||
if (v_obj_p.is_null ())
|
||||
if (v_obj_p == NULL)
|
||||
{
|
||||
ecma_make_simple_completion_value (ret_value, ECMA_SIMPLE_VALUE_FALSE);
|
||||
ret_value = ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE);
|
||||
|
||||
break;
|
||||
}
|
||||
else if (v_obj_p == prototype_obj_p)
|
||||
{
|
||||
ecma_make_simple_completion_value (ret_value, ECMA_SIMPLE_VALUE_TRUE);
|
||||
ret_value = ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -462,12 +430,12 @@ ecma_op_function_has_instance (ecma_completion_value_t &ret_value, /**< out: com
|
||||
ECMA_FINALIZE (prototype_obj_value);
|
||||
|
||||
ecma_deref_ecma_string (prototype_magic_string_p);
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
else if (ecma_get_object_type (func_obj_p) == ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION)
|
||||
{
|
||||
ecma_object_ptr_t exception_obj_p;
|
||||
ecma_new_standard_error (exception_obj_p, ECMA_ERROR_TYPE);
|
||||
ecma_make_throw_obj_completion_value (ret_value, exception_obj_p);
|
||||
return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -487,33 +455,33 @@ ecma_op_function_has_instance (ecma_completion_value_t &ret_value, /**< out: com
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
ecma_op_function_call (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_object_ptr_t& func_obj_p, /**< Function object */
|
||||
ecma_completion_value_t
|
||||
ecma_op_function_call (ecma_object_t *func_obj_p, /**< Function object */
|
||||
const ecma_value_t& this_arg_value, /**< 'this' argument's value */
|
||||
const ecma_value_t* arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< length of arguments list */
|
||||
{
|
||||
JERRY_ASSERT(func_obj_p.is_not_null ()
|
||||
JERRY_ASSERT(func_obj_p != NULL
|
||||
&& !ecma_is_lexical_environment (func_obj_p));
|
||||
JERRY_ASSERT(ecma_op_is_callable (ecma_value_t (func_obj_p)));
|
||||
JERRY_ASSERT(ecma_op_is_callable (ecma_make_object_value (func_obj_p)));
|
||||
JERRY_ASSERT(arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
if (ecma_get_object_type (func_obj_p) == ECMA_OBJECT_TYPE_FUNCTION)
|
||||
{
|
||||
if (unlikely (ecma_get_object_is_builtin (func_obj_p)))
|
||||
{
|
||||
ecma_builtin_dispatch_call (ret_value, func_obj_p, this_arg_value, arguments_list_p, arguments_list_len);
|
||||
return;
|
||||
return ecma_builtin_dispatch_call (func_obj_p, this_arg_value, arguments_list_p, arguments_list_len);
|
||||
}
|
||||
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
/* Entering Function Code (ECMA-262 v5, 10.4.3) */
|
||||
|
||||
ecma_property_t *scope_prop_p = ecma_get_internal_property (func_obj_p, ECMA_INTERNAL_PROPERTY_SCOPE);
|
||||
ecma_property_t *code_prop_p = ecma_get_internal_property (func_obj_p, ECMA_INTERNAL_PROPERTY_CODE);
|
||||
|
||||
ecma_object_ptr_t scope_p;
|
||||
scope_p.unpack_from (scope_prop_p->u.internal_property.value);
|
||||
ecma_object_t *scope_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t,
|
||||
scope_prop_p->u.internal_property.value);
|
||||
uint32_t code_prop_value = code_prop_p->u.internal_property.value;
|
||||
|
||||
bool is_strict;
|
||||
@@ -524,61 +492,59 @@ ecma_op_function_call (ecma_completion_value_t &ret_value, /**< out: completion
|
||||
// 1.
|
||||
if (is_strict)
|
||||
{
|
||||
ecma_copy_value (this_binding, this_arg_value, true);
|
||||
this_binding = ecma_copy_value (this_arg_value, true);
|
||||
}
|
||||
else if (ecma_is_value_undefined (this_arg_value)
|
||||
|| ecma_is_value_null (this_arg_value))
|
||||
{
|
||||
// 2.
|
||||
ecma_object_ptr_t global_obj_p;
|
||||
ecma_builtin_get (global_obj_p, ECMA_BUILTIN_ID_GLOBAL);
|
||||
this_binding = global_obj_p;
|
||||
this_binding = ecma_make_object_value (ecma_builtin_get (ECMA_BUILTIN_ID_GLOBAL));
|
||||
}
|
||||
else
|
||||
{
|
||||
// 3., 4.
|
||||
ecma_completion_value_t to_obj_completion;
|
||||
ecma_op_to_object (to_obj_completion, this_arg_value);
|
||||
JERRY_ASSERT (ecma_is_completion_value_normal (to_obj_completion));
|
||||
ecma_completion_value_t completion = ecma_op_to_object (this_arg_value);
|
||||
JERRY_ASSERT (ecma_is_completion_value_normal (completion));
|
||||
|
||||
ecma_get_completion_value_value (this_binding, to_obj_completion);
|
||||
this_binding = ecma_get_completion_value_value (completion);
|
||||
}
|
||||
|
||||
// 5.
|
||||
ecma_object_ptr_t local_env_p;
|
||||
ecma_create_decl_lex_env (local_env_p, scope_p);
|
||||
ecma_object_t *local_env_p = ecma_create_decl_lex_env (scope_p);
|
||||
|
||||
// 9.
|
||||
ECMA_TRY_CATCH (ret_value, ecma_function_call_setup_args_variables, args_var_declaration_ret,
|
||||
func_obj_p, local_env_p, arguments_list_p, arguments_list_len, is_strict);
|
||||
ECMA_TRY_CATCH (args_var_declaration_ret,
|
||||
ecma_function_call_setup_args_variables (func_obj_p,
|
||||
local_env_p,
|
||||
arguments_list_p,
|
||||
arguments_list_len,
|
||||
is_strict),
|
||||
ret_value);
|
||||
|
||||
ecma_completion_value_t run_completion;
|
||||
run_int_from_pos (run_completion,
|
||||
code_first_opcode_idx,
|
||||
this_binding,
|
||||
local_env_p,
|
||||
is_strict,
|
||||
false);
|
||||
if (ecma_is_completion_value_return (run_completion))
|
||||
ecma_completion_value_t completion = run_int_from_pos (code_first_opcode_idx,
|
||||
this_binding,
|
||||
local_env_p,
|
||||
is_strict,
|
||||
false);
|
||||
if (ecma_is_completion_value_return (completion))
|
||||
{
|
||||
ecma_value_t value_to_ret;
|
||||
ecma_get_completion_value_value (value_to_ret, run_completion);
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, value_to_ret);
|
||||
ret_value = ecma_make_normal_completion_value (ecma_get_completion_value_value (completion));
|
||||
}
|
||||
else
|
||||
{
|
||||
ret_value = run_completion;
|
||||
ret_value = completion;
|
||||
}
|
||||
|
||||
ECMA_FINALIZE (args_var_declaration_ret);
|
||||
|
||||
ecma_deref_object (local_env_p);
|
||||
ecma_free_value (this_binding, true);
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
else if (ecma_get_object_type (func_obj_p) == ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION)
|
||||
{
|
||||
ecma_builtin_dispatch_call (ret_value, func_obj_p, this_arg_value, arguments_list_p, arguments_list_len);
|
||||
return ecma_builtin_dispatch_call (func_obj_p, this_arg_value, arguments_list_p, arguments_list_len);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -596,47 +562,48 @@ ecma_op_function_call (ecma_completion_value_t &ret_value, /**< out: completion
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
ecma_op_function_construct (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_object_ptr_t& func_obj_p, /**< Function object */
|
||||
ecma_completion_value_t
|
||||
ecma_op_function_construct (ecma_object_t *func_obj_p, /**< Function object */
|
||||
const ecma_value_t* arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< length of arguments list */
|
||||
{
|
||||
JERRY_ASSERT(func_obj_p.is_not_null ()
|
||||
JERRY_ASSERT(func_obj_p != NULL
|
||||
&& !ecma_is_lexical_environment (func_obj_p));
|
||||
JERRY_ASSERT(ecma_is_constructor (ecma_value_t (func_obj_p)));
|
||||
JERRY_ASSERT(ecma_is_constructor (ecma_make_object_value (func_obj_p)));
|
||||
JERRY_ASSERT(arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
if (ecma_get_object_type (func_obj_p) == ECMA_OBJECT_TYPE_FUNCTION)
|
||||
{
|
||||
if (unlikely (ecma_get_object_is_builtin (func_obj_p)))
|
||||
{
|
||||
ecma_builtin_dispatch_construct (ret_value, func_obj_p, arguments_list_p, arguments_list_len);
|
||||
return;
|
||||
return ecma_builtin_dispatch_construct (func_obj_p, arguments_list_p, arguments_list_len);
|
||||
}
|
||||
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
ecma_string_t *prototype_magic_string_p = ecma_get_magic_string (ECMA_MAGIC_STRING_PROTOTYPE);
|
||||
|
||||
// 5.
|
||||
ECMA_TRY_CATCH (ret_value,
|
||||
ecma_op_object_get, func_obj_prototype_prop_value, func_obj_p, prototype_magic_string_p);
|
||||
ECMA_TRY_CATCH (func_obj_prototype_prop_value,
|
||||
ecma_op_object_get (func_obj_p,
|
||||
prototype_magic_string_p),
|
||||
ret_value);
|
||||
|
||||
// 6.
|
||||
ecma_object_ptr_t prototype_p;
|
||||
ecma_object_t *prototype_p;
|
||||
if (ecma_is_value_object (func_obj_prototype_prop_value))
|
||||
{
|
||||
ecma_get_object_from_value (prototype_p, func_obj_prototype_prop_value);
|
||||
prototype_p = ecma_get_object_from_value (func_obj_prototype_prop_value);
|
||||
ecma_ref_object (prototype_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 7.
|
||||
ecma_builtin_get (prototype_p, ECMA_BUILTIN_ID_OBJECT_PROTOTYPE);
|
||||
prototype_p = ecma_builtin_get (ECMA_BUILTIN_ID_OBJECT_PROTOTYPE);
|
||||
}
|
||||
|
||||
// 1., 2., 4.
|
||||
ecma_object_ptr_t obj_p;
|
||||
ecma_create_object (obj_p, prototype_p, true, ECMA_OBJECT_TYPE_GENERAL);
|
||||
ecma_object_t *obj_p = ecma_create_object (prototype_p, true, ECMA_OBJECT_TYPE_GENERAL);
|
||||
|
||||
// 3.
|
||||
ecma_property_t *class_prop_p = ecma_create_internal_property (obj_p, ECMA_INTERNAL_PROPERTY_CLASS);
|
||||
@@ -645,9 +612,12 @@ ecma_op_function_construct (ecma_completion_value_t &ret_value, /**< out: comple
|
||||
ecma_deref_object (prototype_p);
|
||||
|
||||
// 8.
|
||||
ECMA_TRY_CATCH (ret_value,
|
||||
ecma_op_function_call, call_completion,
|
||||
func_obj_p, ecma_value_t (obj_p), arguments_list_p, arguments_list_len);
|
||||
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;
|
||||
|
||||
@@ -656,20 +626,22 @@ ecma_op_function_construct (ecma_completion_value_t &ret_value, /**< out: comple
|
||||
{
|
||||
ecma_deref_object (obj_p);
|
||||
|
||||
ecma_copy_value (obj_value, call_completion, true);
|
||||
obj_value = ecma_copy_value (call_completion, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 10.
|
||||
obj_value = obj_p;
|
||||
obj_value = ecma_make_object_value (obj_p);
|
||||
}
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, obj_value);
|
||||
ret_value = ecma_make_normal_completion_value (obj_value);
|
||||
|
||||
ECMA_FINALIZE (call_completion);
|
||||
ECMA_FINALIZE (func_obj_prototype_prop_value);
|
||||
|
||||
ecma_deref_ecma_string (prototype_magic_string_p);
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -686,9 +658,8 @@ ecma_op_function_construct (ecma_completion_value_t &ret_value, /**< out: comple
|
||||
* @return completion value
|
||||
* returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
void
|
||||
ecma_op_function_declaration (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_object_ptr_t& lex_env_p, /**< lexical environment */
|
||||
ecma_completion_value_t
|
||||
ecma_op_function_declaration (ecma_object_t *lex_env_p, /**< lexical environment */
|
||||
ecma_string_t *function_name_p, /**< function name */
|
||||
opcode_counter_t function_code_opcode_idx, /**< index of first opcode of function code */
|
||||
ecma_string_t* formal_parameter_list_p[], /**< formal parameters list */
|
||||
@@ -698,33 +669,30 @@ ecma_op_function_declaration (ecma_completion_value_t &ret_value, /**< out: comp
|
||||
is declared in eval code */
|
||||
{
|
||||
// b.
|
||||
ecma_object_ptr_t func_obj_p;
|
||||
ecma_op_create_function_object (func_obj_p,
|
||||
formal_parameter_list_p,
|
||||
formal_parameter_list_length,
|
||||
lex_env_p,
|
||||
is_strict,
|
||||
function_code_opcode_idx);
|
||||
ecma_object_t *func_obj_p = ecma_op_create_function_object (formal_parameter_list_p,
|
||||
formal_parameter_list_length,
|
||||
lex_env_p,
|
||||
is_strict,
|
||||
function_code_opcode_idx);
|
||||
|
||||
// c.
|
||||
bool func_already_declared = ecma_op_has_binding (lex_env_p, function_name_p);
|
||||
|
||||
// d.
|
||||
ecma_completion_value_t completion;
|
||||
ecma_completion_value_t completion = ecma_make_empty_completion_value ();
|
||||
|
||||
if (!func_already_declared)
|
||||
{
|
||||
ecma_op_create_mutable_binding (completion,
|
||||
lex_env_p,
|
||||
function_name_p,
|
||||
is_configurable_bindings);
|
||||
completion = ecma_op_create_mutable_binding (lex_env_p,
|
||||
function_name_p,
|
||||
is_configurable_bindings);
|
||||
|
||||
JERRY_ASSERT (ecma_is_completion_value_empty (completion));
|
||||
}
|
||||
else if (ecma_is_lexical_environment_global (lex_env_p))
|
||||
{
|
||||
// e.
|
||||
ecma_object_ptr_t glob_obj_p;
|
||||
ecma_builtin_get (glob_obj_p, ECMA_BUILTIN_ID_GLOBAL);
|
||||
ecma_object_t *glob_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_GLOBAL);
|
||||
|
||||
ecma_property_t *existing_prop_p = ecma_op_object_get_property (glob_obj_p, function_name_p);
|
||||
|
||||
@@ -733,7 +701,7 @@ ecma_op_function_declaration (ecma_completion_value_t &ret_value, /**< out: comp
|
||||
ecma_property_descriptor_t property_desc = ecma_make_empty_property_descriptor ();
|
||||
{
|
||||
property_desc.is_value_defined = true;
|
||||
property_desc.value = (ecma_value_packed_t) ecma_value_t (ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||
property_desc.value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||
|
||||
property_desc.is_writable_defined = true;
|
||||
property_desc.is_writable = true;
|
||||
@@ -745,17 +713,14 @@ ecma_op_function_declaration (ecma_completion_value_t &ret_value, /**< out: comp
|
||||
property_desc.is_configurable = is_configurable_bindings;
|
||||
}
|
||||
|
||||
ecma_op_object_define_own_property (completion,
|
||||
glob_obj_p,
|
||||
function_name_p,
|
||||
&property_desc,
|
||||
true);
|
||||
completion = ecma_op_object_define_own_property (glob_obj_p,
|
||||
function_name_p,
|
||||
&property_desc,
|
||||
true);
|
||||
}
|
||||
else if (existing_prop_p->type == ECMA_PROPERTY_NAMEDACCESSOR)
|
||||
{
|
||||
ecma_object_ptr_t exception_obj_p;
|
||||
ecma_new_standard_error (exception_obj_p, ECMA_ERROR_TYPE);
|
||||
ecma_make_throw_obj_completion_value (completion, exception_obj_p);
|
||||
completion = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -764,15 +729,15 @@ ecma_op_function_declaration (ecma_completion_value_t &ret_value, /**< out: comp
|
||||
if (!ecma_is_property_writable (existing_prop_p)
|
||||
|| !ecma_is_property_enumerable (existing_prop_p))
|
||||
{
|
||||
ecma_object_ptr_t exception_obj_p;
|
||||
ecma_new_standard_error (exception_obj_p, ECMA_ERROR_TYPE);
|
||||
ecma_make_throw_obj_completion_value (completion, exception_obj_p);
|
||||
completion = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||
}
|
||||
}
|
||||
|
||||
ecma_deref_object (glob_obj_p);
|
||||
}
|
||||
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
if (ecma_is_completion_value_throw (completion))
|
||||
{
|
||||
ret_value = completion;
|
||||
@@ -782,14 +747,15 @@ ecma_op_function_declaration (ecma_completion_value_t &ret_value, /**< out: comp
|
||||
JERRY_ASSERT (ecma_is_completion_value_empty (completion));
|
||||
|
||||
// f.
|
||||
ecma_op_set_mutable_binding (ret_value,
|
||||
lex_env_p,
|
||||
function_name_p,
|
||||
ecma_value_t (func_obj_p),
|
||||
is_strict);
|
||||
ret_value = ecma_op_set_mutable_binding (lex_env_p,
|
||||
function_name_p,
|
||||
ecma_make_object_value (func_obj_p),
|
||||
is_strict);
|
||||
}
|
||||
|
||||
ecma_deref_object (func_obj_p);
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_op_function_declaration */
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#define ECMA_FUNCTION_OBJECT_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-value.h"
|
||||
#include "interpreter.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -30,35 +29,30 @@
|
||||
extern bool ecma_op_is_callable (const ecma_value_t& value);
|
||||
extern bool ecma_is_constructor (const ecma_value_t& value);
|
||||
|
||||
extern void
|
||||
ecma_op_create_function_object (ecma_object_ptr_t &ret_val,
|
||||
ecma_string_t* formal_parameter_list_p[],
|
||||
extern ecma_object_t*
|
||||
ecma_op_create_function_object (ecma_string_t* formal_parameter_list_p[],
|
||||
ecma_length_t formal_parameters_number,
|
||||
const ecma_object_ptr_t& scope_p,
|
||||
ecma_object_t *scope_p,
|
||||
bool is_strict,
|
||||
opcode_counter_t first_opcode_idx);
|
||||
|
||||
extern void
|
||||
ecma_op_function_call (ecma_completion_value_t &ret_value,
|
||||
const ecma_object_ptr_t& func_obj_p,
|
||||
extern ecma_completion_value_t
|
||||
ecma_op_function_call (ecma_object_t *func_obj_p,
|
||||
const ecma_value_t& this_arg_value,
|
||||
const ecma_value_t* arguments_list_p,
|
||||
ecma_length_t arguments_list_len);
|
||||
|
||||
extern void
|
||||
ecma_op_function_construct (ecma_completion_value_t &ret_value,
|
||||
const ecma_object_ptr_t& func_obj_p,
|
||||
extern ecma_completion_value_t
|
||||
ecma_op_function_construct (ecma_object_t *func_obj_p,
|
||||
const ecma_value_t* arguments_list_p,
|
||||
ecma_length_t arguments_list_len);
|
||||
|
||||
extern void
|
||||
ecma_op_function_has_instance (ecma_completion_value_t &ret_value,
|
||||
const ecma_object_ptr_t& func_obj_p,
|
||||
extern ecma_completion_value_t
|
||||
ecma_op_function_has_instance (ecma_object_t *func_obj_p,
|
||||
const ecma_value_t& value);
|
||||
|
||||
extern void
|
||||
ecma_op_function_declaration (ecma_completion_value_t &ret_value,
|
||||
const ecma_object_ptr_t& lex_env_p,
|
||||
extern ecma_completion_value_t
|
||||
ecma_op_function_declaration (ecma_object_t *lex_env_p,
|
||||
ecma_string_t *function_name_p,
|
||||
opcode_counter_t function_code_opcode_idx,
|
||||
ecma_string_t* formal_parameter_list_p[],
|
||||
|
||||
@@ -43,33 +43,27 @@
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
void
|
||||
ecma_op_get_value_lex_env_base (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_object_ptr_t& ref_base_lex_env_p, /**< reference's base
|
||||
* (lexical environment) */
|
||||
ecma_completion_value_t
|
||||
ecma_op_get_value_lex_env_base (ecma_object_t *ref_base_lex_env_p, /**< reference's base (lexical environment) */
|
||||
ecma_string_t *var_name_string_p, /**< variable name */
|
||||
bool is_strict) /**< flag indicating strict mode */
|
||||
{
|
||||
const bool is_unresolvable_reference = (ref_base_lex_env_p.is_null ());
|
||||
const bool is_unresolvable_reference = (ref_base_lex_env_p == NULL);
|
||||
|
||||
// 3.
|
||||
if (unlikely (is_unresolvable_reference))
|
||||
{
|
||||
ecma_object_ptr_t exception_obj_p;
|
||||
ecma_new_standard_error (exception_obj_p, ECMA_ERROR_REFERENCE);
|
||||
ecma_make_throw_obj_completion_value (ret_value, exception_obj_p);
|
||||
return;
|
||||
return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_REFERENCE));
|
||||
}
|
||||
|
||||
// 5.
|
||||
JERRY_ASSERT(ref_base_lex_env_p.is_not_null ()
|
||||
JERRY_ASSERT(ref_base_lex_env_p != NULL
|
||||
&& ecma_is_lexical_environment (ref_base_lex_env_p));
|
||||
|
||||
// 5.a
|
||||
ecma_op_get_binding_value (ret_value,
|
||||
ref_base_lex_env_p,
|
||||
var_name_string_p,
|
||||
is_strict);
|
||||
return ecma_op_get_binding_value (ref_base_lex_env_p,
|
||||
var_name_string_p,
|
||||
is_strict);
|
||||
} /* ecma_op_get_value_lex_env_base */
|
||||
|
||||
/**
|
||||
@@ -80,23 +74,16 @@ ecma_op_get_value_lex_env_base (ecma_completion_value_t &ret_value, /**< out: co
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
void
|
||||
ecma_op_get_value_object_base (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_reference_t& ref) /**< ECMA-reference */
|
||||
ecma_completion_value_t
|
||||
ecma_op_get_value_object_base (ecma_reference_t ref) /**< ECMA-reference */
|
||||
{
|
||||
const ecma_value_t& base = ref.base;
|
||||
const ecma_value_t base = ref.base;
|
||||
const bool is_unresolvable_reference = ecma_is_value_undefined (base);
|
||||
const bool has_primitive_base = (ecma_is_value_boolean (base)
|
||||
|| ecma_is_value_number (base)
|
||||
|| ecma_is_value_string (base));
|
||||
bool has_object_base = false;
|
||||
if (ecma_is_value_object (base))
|
||||
{
|
||||
ecma_object_ptr_t base_obj_p;
|
||||
ecma_get_object_from_value (base_obj_p, base);
|
||||
|
||||
has_object_base = !ecma_is_lexical_environment (base_obj_p);
|
||||
}
|
||||
const bool has_object_base = (ecma_is_value_object (base)
|
||||
&& !(ecma_is_lexical_environment (ecma_get_object_from_value (base))));
|
||||
const bool is_property_reference = has_primitive_base || has_object_base;
|
||||
|
||||
JERRY_ASSERT (!is_unresolvable_reference);
|
||||
@@ -107,28 +94,30 @@ ecma_op_get_value_object_base (ecma_completion_value_t &ret_value, /**< out: com
|
||||
{
|
||||
// 4.b case 1
|
||||
|
||||
ecma_object_ptr_t obj_p;
|
||||
ecma_get_object_from_value (obj_p, base);
|
||||
JERRY_ASSERT(obj_p.is_not_null ()
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (base);
|
||||
JERRY_ASSERT(obj_p != NULL
|
||||
&& !ecma_is_lexical_environment (obj_p));
|
||||
|
||||
ecma_op_object_get (ret_value, obj_p, ECMA_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
ref.referenced_name_cp));
|
||||
return ecma_op_object_get (obj_p, ECMA_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
ref.referenced_name_cp));
|
||||
}
|
||||
else
|
||||
{
|
||||
// 4.b case 2
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_to_object, obj_base, base);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
ecma_object_ptr_t obj_p;
|
||||
ecma_get_object_from_value (obj_p, obj_base);
|
||||
JERRY_ASSERT (obj_p.is_not_null ()
|
||||
ECMA_TRY_CATCH (obj_base, ecma_op_to_object (base), ret_value);
|
||||
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (obj_base);
|
||||
JERRY_ASSERT (obj_p != NULL
|
||||
&& !ecma_is_lexical_environment (obj_p));
|
||||
|
||||
ecma_op_object_get (ret_value, obj_p, ECMA_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
ref.referenced_name_cp));
|
||||
ret_value = ecma_op_object_get (obj_p, ECMA_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
ref.referenced_name_cp));
|
||||
|
||||
ECMA_FINALIZE (obj_base);
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
} /* ecma_op_get_value_object_base */
|
||||
|
||||
@@ -140,15 +129,13 @@ ecma_op_get_value_object_base (ecma_completion_value_t &ret_value, /**< out: com
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
void
|
||||
ecma_op_put_value_lex_env_base (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_object_ptr_t& ref_base_lex_env_p, /**< reference's base
|
||||
* (lexical environment) */
|
||||
ecma_completion_value_t
|
||||
ecma_op_put_value_lex_env_base (ecma_object_t *ref_base_lex_env_p, /**< reference's base (lexical environment) */
|
||||
ecma_string_t *var_name_string_p, /**< variable name */
|
||||
bool is_strict, /**< flag indicating strict mode */
|
||||
const ecma_value_t& value) /**< ECMA-value */
|
||||
{
|
||||
const bool is_unresolvable_reference = (ref_base_lex_env_p.is_null ());
|
||||
const bool is_unresolvable_reference = (ref_base_lex_env_p == NULL);
|
||||
|
||||
// 3.
|
||||
if (unlikely (is_unresolvable_reference))
|
||||
@@ -156,44 +143,36 @@ ecma_op_put_value_lex_env_base (ecma_completion_value_t &ret_value, /**< out: co
|
||||
// 3.a.
|
||||
if (is_strict)
|
||||
{
|
||||
ecma_object_ptr_t exception_obj_p;
|
||||
ecma_new_standard_error (exception_obj_p, ECMA_ERROR_REFERENCE);
|
||||
ecma_make_throw_obj_completion_value (ret_value, exception_obj_p);
|
||||
return;
|
||||
return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_REFERENCE));
|
||||
}
|
||||
else
|
||||
{
|
||||
// 3.b.
|
||||
ecma_object_ptr_t global_object_p;
|
||||
ecma_builtin_get (global_object_p, ECMA_BUILTIN_ID_GLOBAL);
|
||||
ecma_object_t *global_object_p = ecma_builtin_get (ECMA_BUILTIN_ID_GLOBAL);
|
||||
|
||||
ecma_completion_value_t completion;
|
||||
ecma_op_object_put (completion,
|
||||
global_object_p,
|
||||
var_name_string_p,
|
||||
value,
|
||||
false);
|
||||
ecma_completion_value_t completion = ecma_op_object_put (global_object_p,
|
||||
var_name_string_p,
|
||||
value,
|
||||
false);
|
||||
|
||||
ecma_deref_object (global_object_p);
|
||||
|
||||
JERRY_ASSERT(ecma_is_completion_value_normal_true (completion)
|
||||
|| ecma_is_completion_value_normal_false (completion));
|
||||
|
||||
ecma_make_empty_completion_value (ret_value);
|
||||
return;
|
||||
return ecma_make_empty_completion_value ();
|
||||
}
|
||||
}
|
||||
|
||||
// 5.
|
||||
JERRY_ASSERT(ref_base_lex_env_p.is_not_null ()
|
||||
JERRY_ASSERT(ref_base_lex_env_p != NULL
|
||||
&& ecma_is_lexical_environment (ref_base_lex_env_p));
|
||||
|
||||
// 5.a
|
||||
ecma_op_set_mutable_binding (ret_value,
|
||||
ref_base_lex_env_p,
|
||||
var_name_string_p,
|
||||
value,
|
||||
is_strict);
|
||||
return ecma_op_set_mutable_binding (ref_base_lex_env_p,
|
||||
var_name_string_p,
|
||||
value,
|
||||
is_strict);
|
||||
} /* ecma_op_put_value_lex_env_base */
|
||||
|
||||
/**
|
||||
@@ -202,19 +181,16 @@ ecma_op_put_value_lex_env_base (ecma_completion_value_t &ret_value, /**< out: co
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
static void
|
||||
ecma_reject_put (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
bool is_throw) /**< Throw flag */
|
||||
static ecma_completion_value_t
|
||||
ecma_reject_put (bool is_throw) /**< Throw flag */
|
||||
{
|
||||
if (is_throw)
|
||||
{
|
||||
ecma_object_ptr_t exception_obj_p;
|
||||
ecma_new_standard_error (exception_obj_p, ECMA_ERROR_TYPE);
|
||||
ecma_make_throw_obj_completion_value (ret_value, exception_obj_p);
|
||||
return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_make_simple_completion_value (ret_value, ECMA_SIMPLE_VALUE_EMPTY);
|
||||
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_EMPTY);
|
||||
}
|
||||
} /* ecma_reject_put */
|
||||
|
||||
@@ -226,24 +202,17 @@ ecma_reject_put (ecma_completion_value_t &ret_value, /**< out: completion value
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
void
|
||||
ecma_op_put_value_object_base (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_reference_t& ref, /**< ECMA-reference */
|
||||
ecma_completion_value_t
|
||||
ecma_op_put_value_object_base (ecma_reference_t ref, /**< ECMA-reference */
|
||||
const ecma_value_t& value) /**< ECMA-value */
|
||||
{
|
||||
const ecma_value_t& base = ref.base;
|
||||
const ecma_value_t base = ref.base;
|
||||
const bool is_unresolvable_reference = ecma_is_value_undefined (base);
|
||||
const bool has_primitive_base = (ecma_is_value_boolean (base)
|
||||
|| ecma_is_value_number (base)
|
||||
|| ecma_is_value_string (base));
|
||||
bool has_object_base = false;
|
||||
if (ecma_is_value_object (base))
|
||||
{
|
||||
ecma_object_ptr_t base_obj_p;
|
||||
ecma_get_object_from_value (base_obj_p, base);
|
||||
|
||||
has_object_base = !ecma_is_lexical_environment (base_obj_p);
|
||||
}
|
||||
const bool has_object_base = (ecma_is_value_object (base)
|
||||
&& !(ecma_is_lexical_environment (ecma_get_object_from_value (base))));
|
||||
const bool is_property_reference = has_primitive_base || has_object_base;
|
||||
|
||||
JERRY_ASSERT (!is_unresolvable_reference);
|
||||
@@ -254,30 +223,36 @@ ecma_op_put_value_object_base (ecma_completion_value_t &ret_value, /**< out: com
|
||||
{
|
||||
// 4.b case 1
|
||||
|
||||
ecma_object_ptr_t obj_p;
|
||||
ecma_get_object_from_value (obj_p, base);
|
||||
JERRY_ASSERT (obj_p.is_not_null ()
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (base);
|
||||
JERRY_ASSERT (obj_p != NULL
|
||||
&& !ecma_is_lexical_environment (obj_p));
|
||||
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_object_put, put_ret_value, obj_p,
|
||||
ECMA_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
ref.referenced_name_cp),
|
||||
value, ref.is_strict);
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
ecma_make_empty_completion_value (ret_value);
|
||||
ECMA_TRY_CATCH (put_ret_value,
|
||||
ecma_op_object_put (obj_p,
|
||||
ECMA_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
ref.referenced_name_cp),
|
||||
value,
|
||||
ref.is_strict),
|
||||
ret_value);
|
||||
|
||||
ret_value = ecma_make_empty_completion_value ();
|
||||
|
||||
ECMA_FINALIZE (put_ret_value);
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 4.b case 2
|
||||
ecma_completion_value_t ret_value;
|
||||
|
||||
// sub_1.
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_to_object, obj_base, base);
|
||||
ECMA_TRY_CATCH (obj_base, ecma_op_to_object (base), ret_value);
|
||||
|
||||
ecma_object_ptr_t obj_p;
|
||||
ecma_get_object_from_value (obj_p, obj_base);
|
||||
JERRY_ASSERT (obj_p.is_not_null ()
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (obj_base);
|
||||
JERRY_ASSERT (obj_p != NULL
|
||||
&& !ecma_is_lexical_environment (obj_p));
|
||||
|
||||
ecma_string_t *referenced_name_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
@@ -286,7 +261,7 @@ ecma_op_put_value_object_base (ecma_completion_value_t &ret_value, /**< out: com
|
||||
// sub_2.
|
||||
if (!ecma_op_object_can_put (obj_p, referenced_name_p))
|
||||
{
|
||||
ecma_reject_put (ret_value, ref.is_strict);
|
||||
ret_value = ecma_reject_put (ref.is_strict);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -302,26 +277,30 @@ ecma_op_put_value_object_base (ecma_completion_value_t &ret_value, /**< out: com
|
||||
|| (prop_p == NULL)
|
||||
|| (prop_p->type != ECMA_PROPERTY_NAMEDACCESSOR))
|
||||
{
|
||||
ecma_reject_put (ret_value, ref.is_strict);
|
||||
ret_value = ecma_reject_put (ref.is_strict);
|
||||
}
|
||||
else
|
||||
{
|
||||
// sub_6.
|
||||
JERRY_ASSERT (prop_p != NULL && prop_p->type == ECMA_PROPERTY_NAMEDACCESSOR);
|
||||
|
||||
ecma_object_ptr_t setter_p;
|
||||
setter_p.unpack_from (prop_p->u.named_accessor_property.set_p);
|
||||
JERRY_ASSERT (setter_p.is_not_null ());
|
||||
ecma_object_t *setter_p = ECMA_GET_NON_NULL_POINTER(ecma_object_t,
|
||||
prop_p->u.named_accessor_property.set_p);
|
||||
JERRY_ASSERT (setter_p != NULL);
|
||||
|
||||
ECMA_TRY_CATCH (ret_value, ecma_op_function_call, call_ret, setter_p, base, &value, 1);
|
||||
ECMA_TRY_CATCH (call_ret,
|
||||
ecma_op_function_call (setter_p, base, &value, 1),
|
||||
ret_value);
|
||||
|
||||
ecma_make_empty_completion_value (ret_value);
|
||||
ret_value = ecma_make_empty_completion_value ();
|
||||
|
||||
ECMA_FINALIZE (call_ret);
|
||||
}
|
||||
}
|
||||
|
||||
ECMA_FINALIZE (obj_base);
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
} /* ecma_op_put_value_object_base */
|
||||
|
||||
|
||||
@@ -39,10 +39,10 @@
|
||||
* @return true / false
|
||||
*/
|
||||
bool
|
||||
ecma_op_has_binding (const ecma_object_ptr_t& lex_env_p, /**< lexical environment */
|
||||
ecma_op_has_binding (ecma_object_t *lex_env_p, /**< lexical environment */
|
||||
ecma_string_t *name_p) /**< argument N */
|
||||
{
|
||||
JERRY_ASSERT(lex_env_p.is_not_null ()
|
||||
JERRY_ASSERT(lex_env_p != NULL
|
||||
&& ecma_is_lexical_environment (lex_env_p));
|
||||
|
||||
if (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE)
|
||||
@@ -55,8 +55,7 @@ ecma_op_has_binding (const ecma_object_ptr_t& lex_env_p, /**< lexical environmen
|
||||
{
|
||||
JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND);
|
||||
|
||||
ecma_object_ptr_t binding_obj_p;
|
||||
ecma_get_lex_env_binding_object (binding_obj_p, lex_env_p);
|
||||
ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);
|
||||
|
||||
return (ecma_op_object_get_property (binding_obj_p, name_p) != NULL);
|
||||
}
|
||||
@@ -70,13 +69,12 @@ ecma_op_has_binding (const ecma_object_ptr_t& lex_env_p, /**< lexical environmen
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value
|
||||
*/
|
||||
void
|
||||
ecma_op_create_mutable_binding (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_object_ptr_t& lex_env_p, /**< lexical environment */
|
||||
ecma_completion_value_t
|
||||
ecma_op_create_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environment */
|
||||
ecma_string_t *name_p, /**< argument N */
|
||||
bool is_deletable) /**< argument D */
|
||||
{
|
||||
JERRY_ASSERT(lex_env_p.is_not_null ()
|
||||
JERRY_ASSERT(lex_env_p != NULL
|
||||
&& ecma_is_lexical_environment (lex_env_p));
|
||||
JERRY_ASSERT(name_p != NULL);
|
||||
|
||||
@@ -90,13 +88,12 @@ ecma_op_create_mutable_binding (ecma_completion_value_t &ret_value, /**< out: co
|
||||
{
|
||||
JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND);
|
||||
|
||||
ecma_object_ptr_t binding_obj_p;
|
||||
ecma_get_lex_env_binding_object (binding_obj_p, lex_env_p);
|
||||
ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);
|
||||
|
||||
ecma_property_descriptor_t prop_desc = ecma_make_empty_property_descriptor ();
|
||||
{
|
||||
prop_desc.is_value_defined = true;
|
||||
prop_desc.value = (ecma_value_packed_t) ecma_value_t (ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||
prop_desc.value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||
|
||||
prop_desc.is_writable_defined = true;
|
||||
prop_desc.is_writable = true;
|
||||
@@ -108,17 +105,14 @@ ecma_op_create_mutable_binding (ecma_completion_value_t &ret_value, /**< out: co
|
||||
prop_desc.is_configurable = is_deletable;
|
||||
}
|
||||
|
||||
ecma_completion_value_t completion;
|
||||
ecma_op_object_define_own_property (completion,
|
||||
binding_obj_p,
|
||||
name_p,
|
||||
&prop_desc,
|
||||
true);
|
||||
ecma_completion_value_t completion = ecma_op_object_define_own_property (binding_obj_p,
|
||||
name_p,
|
||||
&prop_desc,
|
||||
true);
|
||||
|
||||
if (ecma_is_completion_value_throw (completion))
|
||||
{
|
||||
ret_value = completion;
|
||||
return;
|
||||
return completion;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -127,7 +121,7 @@ ecma_op_create_mutable_binding (ecma_completion_value_t &ret_value, /**< out: co
|
||||
}
|
||||
}
|
||||
|
||||
ecma_make_empty_completion_value (ret_value);
|
||||
return ecma_make_empty_completion_value ();
|
||||
} /* ecma_op_create_mutable_binding */
|
||||
|
||||
/**
|
||||
@@ -138,14 +132,13 @@ ecma_op_create_mutable_binding (ecma_completion_value_t &ret_value, /**< out: co
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
void
|
||||
ecma_op_set_mutable_binding (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_object_ptr_t& lex_env_p, /**< lexical environment */
|
||||
ecma_completion_value_t
|
||||
ecma_op_set_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environment */
|
||||
ecma_string_t *name_p, /**< argument N */
|
||||
const ecma_value_t& value, /**< argument V */
|
||||
bool is_strict) /**< argument S */
|
||||
{
|
||||
JERRY_ASSERT(lex_env_p.is_not_null ()
|
||||
JERRY_ASSERT(lex_env_p != NULL
|
||||
&& ecma_is_lexical_environment (lex_env_p));
|
||||
JERRY_ASSERT(name_p != NULL);
|
||||
|
||||
@@ -166,10 +159,7 @@ ecma_op_set_mutable_binding (ecma_completion_value_t &ret_value, /**< out: compl
|
||||
|
||||
if (is_equal)
|
||||
{
|
||||
ecma_object_ptr_t cp_error_obj_p;
|
||||
ecma_builtin_get (cp_error_obj_p, ECMA_BUILTIN_ID_COMPACT_PROFILE_ERROR);
|
||||
ecma_make_throw_obj_completion_value (ret_value, cp_error_obj_p);
|
||||
return;
|
||||
return ecma_make_throw_obj_completion_value (ecma_builtin_get (ECMA_BUILTIN_ID_COMPACT_PROFILE_ERROR));
|
||||
}
|
||||
# endif /* CONFIG_ECMA_COMPACT_PROFILE */
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
@@ -182,30 +172,23 @@ ecma_op_set_mutable_binding (ecma_completion_value_t &ret_value, /**< out: compl
|
||||
}
|
||||
else if (is_strict)
|
||||
{
|
||||
ecma_object_ptr_t exception_obj_p;
|
||||
ecma_new_standard_error (exception_obj_p, ECMA_ERROR_TYPE);
|
||||
ecma_make_throw_obj_completion_value (ret_value, exception_obj_p);
|
||||
return;
|
||||
return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND);
|
||||
|
||||
ecma_object_ptr_t binding_obj_p;
|
||||
ecma_get_lex_env_binding_object (binding_obj_p, lex_env_p);
|
||||
ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);
|
||||
|
||||
ecma_completion_value_t completion;
|
||||
ecma_op_object_put (completion,
|
||||
binding_obj_p,
|
||||
name_p,
|
||||
value,
|
||||
is_strict);
|
||||
ecma_completion_value_t completion = ecma_op_object_put (binding_obj_p,
|
||||
name_p,
|
||||
value,
|
||||
is_strict);
|
||||
|
||||
if (ecma_is_completion_value_throw (completion))
|
||||
{
|
||||
ret_value = completion;
|
||||
return;
|
||||
return completion;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -214,7 +197,7 @@ ecma_op_set_mutable_binding (ecma_completion_value_t &ret_value, /**< out: compl
|
||||
}
|
||||
}
|
||||
|
||||
ecma_make_empty_completion_value (ret_value);
|
||||
return ecma_make_empty_completion_value ();
|
||||
} /* ecma_op_set_mutable_binding */
|
||||
|
||||
/**
|
||||
@@ -225,13 +208,12 @@ ecma_op_set_mutable_binding (ecma_completion_value_t &ret_value, /**< out: compl
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
void
|
||||
ecma_op_get_binding_value (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_object_ptr_t& lex_env_p, /**< lexical environment */
|
||||
ecma_completion_value_t
|
||||
ecma_op_get_binding_value (ecma_object_t *lex_env_p, /**< lexical environment */
|
||||
ecma_string_t *name_p, /**< argument N */
|
||||
bool is_strict) /**< argument S */
|
||||
{
|
||||
JERRY_ASSERT(lex_env_p.is_not_null ()
|
||||
JERRY_ASSERT(lex_env_p != NULL
|
||||
&& ecma_is_lexical_environment (lex_env_p));
|
||||
JERRY_ASSERT(name_p != NULL);
|
||||
|
||||
@@ -252,18 +234,14 @@ ecma_op_get_binding_value (ecma_completion_value_t &ret_value, /**< out: complet
|
||||
|
||||
if (is_equal)
|
||||
{
|
||||
ecma_object_ptr_t cp_error_obj_p;
|
||||
ecma_builtin_get (cp_error_obj_p, ECMA_BUILTIN_ID_COMPACT_PROFILE_ERROR);
|
||||
ecma_make_throw_obj_completion_value (ret_value, cp_error_obj_p);
|
||||
return;
|
||||
return ecma_make_throw_obj_completion_value (ecma_builtin_get (ECMA_BUILTIN_ID_COMPACT_PROFILE_ERROR));
|
||||
}
|
||||
# endif /* CONFIG_ECMA_COMPACT_PROFILE */
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
|
||||
ecma_property_t *property_p = ecma_get_named_data_property (lex_env_p, name_p);
|
||||
|
||||
ecma_value_t prop_value;
|
||||
ecma_get_named_data_property_value (prop_value, property_p);
|
||||
ecma_value_t prop_value = ecma_get_named_data_property_value (property_p);
|
||||
|
||||
/* is the binding mutable? */
|
||||
if (!ecma_is_property_writable (property_p)
|
||||
@@ -272,47 +250,35 @@ ecma_op_get_binding_value (ecma_completion_value_t &ret_value, /**< out: complet
|
||||
/* unitialized immutable binding */
|
||||
if (is_strict)
|
||||
{
|
||||
ecma_object_ptr_t exception_obj_p;
|
||||
ecma_new_standard_error (exception_obj_p, ECMA_ERROR_REFERENCE);
|
||||
ecma_make_throw_obj_completion_value (ret_value, exception_obj_p);
|
||||
return;
|
||||
return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_REFERENCE));
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_make_simple_completion_value (ret_value, ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||
return;
|
||||
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||
}
|
||||
}
|
||||
|
||||
ecma_value_t prop_value_copy;
|
||||
ecma_copy_value (prop_value_copy, prop_value, true);
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, prop_value_copy);
|
||||
return ecma_make_normal_completion_value (ecma_copy_value (prop_value, true));
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND);
|
||||
|
||||
ecma_object_ptr_t binding_obj_p;
|
||||
ecma_get_lex_env_binding_object (binding_obj_p, lex_env_p);
|
||||
ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);
|
||||
|
||||
if (ecma_op_object_get_property (binding_obj_p, name_p) == NULL)
|
||||
{
|
||||
if (is_strict)
|
||||
{
|
||||
ecma_object_ptr_t exception_obj_p;
|
||||
ecma_new_standard_error (exception_obj_p, ECMA_ERROR_REFERENCE);
|
||||
ecma_make_throw_obj_completion_value (ret_value, exception_obj_p);
|
||||
return;
|
||||
return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_REFERENCE));
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_make_simple_completion_value (ret_value, ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||
return;
|
||||
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||
}
|
||||
}
|
||||
|
||||
ecma_op_object_get (ret_value, binding_obj_p, name_p);
|
||||
return ecma_op_object_get (binding_obj_p, name_p);
|
||||
}
|
||||
} /* ecma_op_get_binding_value */
|
||||
|
||||
@@ -325,12 +291,11 @@ ecma_op_get_binding_value (ecma_completion_value_t &ret_value, /**< out: complet
|
||||
* Return value is simple and so need not be freed.
|
||||
* However, ecma_free_completion_value may be called for it, but it is a no-op.
|
||||
*/
|
||||
void
|
||||
ecma_op_delete_binding (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_object_ptr_t& lex_env_p, /**< lexical environment */
|
||||
ecma_completion_value_t
|
||||
ecma_op_delete_binding (ecma_object_t *lex_env_p, /**< lexical environment */
|
||||
ecma_string_t *name_p) /**< argument N */
|
||||
{
|
||||
JERRY_ASSERT(lex_env_p.is_not_null ()
|
||||
JERRY_ASSERT(lex_env_p != NULL
|
||||
&& ecma_is_lexical_environment (lex_env_p));
|
||||
JERRY_ASSERT(name_p != NULL);
|
||||
|
||||
@@ -360,16 +325,15 @@ ecma_op_delete_binding (ecma_completion_value_t &ret_value, /**< out: completion
|
||||
}
|
||||
}
|
||||
|
||||
ecma_make_simple_completion_value (ret_value, ret_val);
|
||||
return ecma_make_simple_completion_value (ret_val);
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND);
|
||||
|
||||
ecma_object_ptr_t binding_obj_p;
|
||||
ecma_get_lex_env_binding_object (binding_obj_p, lex_env_p);
|
||||
ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);
|
||||
|
||||
ecma_op_object_delete (ret_value, binding_obj_p, name_p, false);
|
||||
return ecma_op_object_delete (binding_obj_p, name_p, false);
|
||||
}
|
||||
} /* ecma_op_delete_binding */
|
||||
|
||||
@@ -381,16 +345,15 @@ ecma_op_delete_binding (ecma_completion_value_t &ret_value, /**< out: completion
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
void
|
||||
ecma_op_implicit_this_value (ecma_completion_value_t &ret_value, /**< out: completion value */
|
||||
const ecma_object_ptr_t& lex_env_p) /**< lexical environment */
|
||||
ecma_completion_value_t
|
||||
ecma_op_implicit_this_value (ecma_object_t *lex_env_p) /**< lexical environment */
|
||||
{
|
||||
JERRY_ASSERT(lex_env_p.is_not_null ()
|
||||
JERRY_ASSERT(lex_env_p != NULL
|
||||
&& ecma_is_lexical_environment (lex_env_p));
|
||||
|
||||
if (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE)
|
||||
{
|
||||
ecma_make_simple_completion_value (ret_value, ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -398,15 +361,14 @@ ecma_op_implicit_this_value (ecma_completion_value_t &ret_value, /**< out: compl
|
||||
|
||||
if (ecma_get_lex_env_provide_this (lex_env_p))
|
||||
{
|
||||
ecma_object_ptr_t binding_obj_p;
|
||||
ecma_get_lex_env_binding_object (binding_obj_p, lex_env_p);
|
||||
ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);
|
||||
ecma_ref_object (binding_obj_p);
|
||||
|
||||
ecma_make_normal_completion_value (ret_value, ecma_value_t (binding_obj_p));
|
||||
return ecma_make_normal_completion_value (ecma_make_object_value (binding_obj_p));
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_make_simple_completion_value (ret_value, ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||
}
|
||||
}
|
||||
} /* ecma_op_implicit_this_value */
|
||||
@@ -417,10 +379,10 @@ ecma_op_implicit_this_value (ecma_completion_value_t &ret_value, /**< out: compl
|
||||
* See also: ECMA-262 v5, 10.2.1
|
||||
*/
|
||||
void
|
||||
ecma_op_create_immutable_binding (const ecma_object_ptr_t& lex_env_p, /**< lexical environment */
|
||||
ecma_op_create_immutable_binding (ecma_object_t *lex_env_p, /**< lexical environment */
|
||||
ecma_string_t *name_p) /**< argument N */
|
||||
{
|
||||
JERRY_ASSERT(lex_env_p.is_not_null ()
|
||||
JERRY_ASSERT(lex_env_p != NULL
|
||||
&& ecma_is_lexical_environment (lex_env_p));
|
||||
JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE);
|
||||
|
||||
@@ -432,15 +394,10 @@ ecma_op_create_immutable_binding (const ecma_object_ptr_t& lex_env_p, /**< lexic
|
||||
name_p,
|
||||
false, false, false);
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
ecma_value_t prop_value;
|
||||
ecma_get_named_data_property_value (prop_value, prop_p);
|
||||
|
||||
JERRY_ASSERT(ecma_is_value_undefined (prop_value));
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
JERRY_ASSERT(ecma_is_value_undefined (ecma_get_named_data_property_value (prop_p)));
|
||||
|
||||
ecma_set_named_data_property_value (prop_p,
|
||||
ecma_value_t (ECMA_SIMPLE_VALUE_EMPTY));
|
||||
ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY));
|
||||
} /* ecma_op_create_immutable_binding */
|
||||
|
||||
/**
|
||||
@@ -449,22 +406,19 @@ ecma_op_create_immutable_binding (const ecma_object_ptr_t& lex_env_p, /**< lexic
|
||||
* See also: ECMA-262 v5, 10.2.1
|
||||
*/
|
||||
void
|
||||
ecma_op_initialize_immutable_binding (const ecma_object_ptr_t& lex_env_p, /**< lexical environment */
|
||||
ecma_op_initialize_immutable_binding (ecma_object_t *lex_env_p, /**< lexical environment */
|
||||
ecma_string_t *name_p, /**< argument N */
|
||||
const ecma_value_t& value) /**< argument V */
|
||||
{
|
||||
JERRY_ASSERT(lex_env_p.is_not_null ()
|
||||
JERRY_ASSERT(lex_env_p != NULL
|
||||
&& ecma_is_lexical_environment (lex_env_p));
|
||||
JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE);
|
||||
|
||||
ecma_property_t *prop_p = ecma_get_named_data_property (lex_env_p, name_p);
|
||||
|
||||
ecma_value_t prop_value;
|
||||
ecma_get_named_data_property_value (prop_value, prop_p);
|
||||
|
||||
/* The binding must be unitialized immutable binding */
|
||||
JERRY_ASSERT (!ecma_is_property_writable (prop_p)
|
||||
&& ecma_is_value_empty (prop_value));
|
||||
JERRY_ASSERT(!ecma_is_property_writable (prop_p)
|
||||
&& ecma_is_value_empty (ecma_get_named_data_property_value (prop_p)));
|
||||
|
||||
ecma_named_data_property_assign_value (lex_env_p, prop_p, value);
|
||||
} /* ecma_op_initialize_immutable_binding */
|
||||
@@ -476,18 +430,17 @@ ecma_op_initialize_immutable_binding (const ecma_object_ptr_t& lex_env_p, /**< l
|
||||
*
|
||||
* @return pointer to created lexical environment
|
||||
*/
|
||||
void
|
||||
ecma_op_create_global_environment (ecma_object_ptr_t &glob_env_p, /**< out: object pointer */
|
||||
const ecma_object_ptr_t& glob_obj_p) /**< the Global object */
|
||||
ecma_object_t*
|
||||
ecma_op_create_global_environment (ecma_object_t *glob_obj_p) /**< the Global object */
|
||||
{
|
||||
ecma_object_ptr_t null_pointer;
|
||||
|
||||
#ifdef CONFIG_ECMA_GLOBAL_ENVIRONMENT_DECLARATIVE
|
||||
(void) glob_obj_p;
|
||||
ecma_create_decl_lex_env (glob_env_p, null_pointer);
|
||||
ecma_object_t *glob_env_p = ecma_create_decl_lex_env (NULL);
|
||||
#else /* !CONFIG_ECMA_GLOBAL_ENVIRONMENT_DECLARATIVE */
|
||||
ecma_create_object_lex_env (glob_env_p, null_pointer, glob_obj_p, false);
|
||||
ecma_object_t *glob_env_p = ecma_create_object_lex_env (NULL, glob_obj_p, false);
|
||||
#endif /* !CONFIG_ECMA_GLOBAL_ENVIRONMENT_DECLARATIVE */
|
||||
|
||||
return glob_env_p;
|
||||
} /* ecma_op_create_global_environment */
|
||||
|
||||
/**
|
||||
@@ -497,17 +450,16 @@ ecma_op_create_global_environment (ecma_object_ptr_t &glob_env_p, /**< out: obje
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool
|
||||
ecma_is_lexical_environment_global (const ecma_object_ptr_t& lex_env_p) /**< lexical environment */
|
||||
ecma_is_lexical_environment_global (ecma_object_t *lex_env_p) /**< lexical environment */
|
||||
{
|
||||
JERRY_ASSERT(lex_env_p.is_not_null ()
|
||||
JERRY_ASSERT(lex_env_p != NULL
|
||||
&& ecma_is_lexical_environment (lex_env_p));
|
||||
|
||||
ecma_lexical_environment_type_t type = ecma_get_lex_env_type (lex_env_p);
|
||||
|
||||
if (type == ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND)
|
||||
{
|
||||
ecma_object_ptr_t binding_obj_p;
|
||||
ecma_get_lex_env_binding_object (binding_obj_p, lex_env_p);
|
||||
ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);
|
||||
|
||||
return ecma_builtin_is (binding_obj_p, ECMA_BUILTIN_ID_GLOBAL);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user