mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Add in opcode handler. Untested.
This commit is contained in:
parent
b822c704e5
commit
3dc1f8df77
@ -33,6 +33,7 @@
|
|||||||
#include "actuators.h"
|
#include "actuators.h"
|
||||||
#include "common-io.h"
|
#include "common-io.h"
|
||||||
#include "sensors.h"
|
#include "sensors.h"
|
||||||
|
#include "ecma-objects.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Note:
|
* Note:
|
||||||
@ -470,7 +471,6 @@ do_number_bitwise_logic (struct __int_data *int_data, /**< interpreter context *
|
|||||||
op (logical_and) \
|
op (logical_and) \
|
||||||
op (logical_or) \
|
op (logical_or) \
|
||||||
op (instanceof) \
|
op (instanceof) \
|
||||||
op (in) \
|
|
||||||
op (meta) \
|
op (meta) \
|
||||||
static char __unused unimplemented_list_end
|
static char __unused unimplemented_list_end
|
||||||
|
|
||||||
@ -2179,6 +2179,56 @@ opfunc_exitval (OPCODE opdata, /**< operation data */
|
|||||||
exit_status,
|
exit_status,
|
||||||
ECMA_TARGET_ID_RESERVED);
|
ECMA_TARGET_ID_RESERVED);
|
||||||
} /* opfunc_exitval */
|
} /* opfunc_exitval */
|
||||||
|
/**
|
||||||
|
* 'in' opcode handler.
|
||||||
|
*
|
||||||
|
* See also: ECMA-262 v5, 11.8.6
|
||||||
|
*
|
||||||
|
* @return completion value
|
||||||
|
* returned value must be freed with ecma_free_completion_value.
|
||||||
|
*/
|
||||||
|
ecma_completion_value_t
|
||||||
|
opfunc_in (OPCODE opdata __unused, /**< operation data */
|
||||||
|
struct __int_data *int_data __unused) /**< interpreter context */
|
||||||
|
{
|
||||||
|
const T_IDX dst_idx = opdata.data.in.dst;
|
||||||
|
const T_IDX left_var_idx = opdata.data.in.var_left;
|
||||||
|
const T_IDX right_var_idx = opdata.data.in.var_right;
|
||||||
|
|
||||||
|
ecma_completion_value_t ret_value;
|
||||||
|
|
||||||
|
ECMA_TRY_CATCH (right_value, get_variable_value (int_data, right_var_idx, false), ret_value);
|
||||||
|
|
||||||
|
if (right_value.value.value_type != ECMA_TYPE_OBJECT)
|
||||||
|
{
|
||||||
|
ret_value = ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ecma_simple_value_t is_in = ECMA_SIMPLE_VALUE_UNDEFINED;
|
||||||
|
ecma_string_t *to_string_lval = ecma_new_ecma_string_from_lit_index (left_var_idx);
|
||||||
|
ecma_object_t *right_value_obj_p = ECMA_GET_POINTER (right_value.value.value);
|
||||||
|
|
||||||
|
if (ecma_op_object_has_property (right_value_obj_p, to_string_lval))
|
||||||
|
{
|
||||||
|
is_in = ECMA_SIMPLE_VALUE_TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
is_in = ECMA_SIMPLE_VALUE_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ecma_deref_ecma_string (to_string_lval);
|
||||||
|
|
||||||
|
ret_value = set_variable_value (int_data,
|
||||||
|
dst_idx,
|
||||||
|
ecma_make_simple_value (is_in));
|
||||||
|
}
|
||||||
|
|
||||||
|
ECMA_FINALIZE (right_value);
|
||||||
|
|
||||||
|
return ret_value;
|
||||||
|
} /* opfunc_in */
|
||||||
|
|
||||||
|
|
||||||
/** Opcode generators. */
|
/** Opcode generators. */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user