mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Introducing type argument in 'assignment' opcode handler.
This commit is contained in:
parent
123df0f185
commit
98a0c0f933
@ -238,8 +238,9 @@ OP_CODE_DECL (greater_or_equal_than, T_IDX_IDX_IDX,
|
||||
// Assign value to LEFT operand based on value of RIGHT operand.
|
||||
|
||||
/** L = R */
|
||||
OP_CODE_DECL (assignment, T_IDX_IDX,
|
||||
value_left,
|
||||
OP_CODE_DECL (assignment, T_IDX_IDX_IDX,
|
||||
var_left,
|
||||
type_value_right,
|
||||
value_right)
|
||||
|
||||
// Functions calls, declarations and argument handling
|
||||
|
||||
@ -278,7 +278,7 @@ GETOP_IMPL_3 (less_than, dst, var_left, var_right)
|
||||
GETOP_IMPL_3 (greater_than, dst, var_left, var_right)
|
||||
GETOP_IMPL_3 (less_or_equal_than, dst, var_left, var_right)
|
||||
GETOP_IMPL_3 (greater_or_equal_than, dst, var_left, var_right)
|
||||
GETOP_IMPL_2 (assignment, value_left, value_right)
|
||||
GETOP_IMPL_3 (assignment, var_left, type_value_right, value_right)
|
||||
GETOP_IMPL_2 (call_1, name_lit_idx, arg1_lit_idx)
|
||||
GETOP_IMPL_3 (call_2, name_lit_idx, arg1_lit_idx, arg2_lit_idx)
|
||||
GETOP_IMPL_3 (call_n, name_lit_idx, arg1_lit_idx, arg2_lit_idx)
|
||||
|
||||
@ -141,5 +141,18 @@ OPCODE
|
||||
}
|
||||
__packed;
|
||||
|
||||
/**
|
||||
* Descriptor of assignment's second argument
|
||||
* that specifies type of third argument.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
OPCODE_ARG_TYPE_SIMPLE, /**< ecma_SimpleValue_t */
|
||||
OPCODE_ARG_TYPE_SMALLINT, /**< small integer: from -128 to 127 */
|
||||
OPCODE_ARG_TYPE_NUMBER, /**< index of number literal */
|
||||
OPCODE_ARG_TYPE_STRING, /**< index of string literal */
|
||||
OPCODE_ARG_TYPE_VARIABLE /**< index of variable name */
|
||||
} opcode_arg_type_operand;
|
||||
|
||||
#endif /* OPCODES_H */
|
||||
|
||||
|
||||
@ -131,6 +131,33 @@ first_operand_as_literal (statement stmt)
|
||||
return oper.data.lit;
|
||||
}
|
||||
|
||||
static opcode_arg_type_operand
|
||||
first_operand_type (statement stmt)
|
||||
{
|
||||
JERRY_ASSERT (expression_has_operands (stmt));
|
||||
if (!first_operand (stmt).is_literal)
|
||||
{
|
||||
return OPCODE_ARG_TYPE_VARIABLE;
|
||||
}
|
||||
|
||||
literal lit = first_operand(stmt).data.lit;
|
||||
|
||||
TODO( Small integer -> OPCODE_ARG_TYPE_SMALLINT );
|
||||
|
||||
switch ( lit.type )
|
||||
{
|
||||
case LIT_NULL:
|
||||
case LIT_BOOL:
|
||||
return OPCODE_ARG_TYPE_SIMPLE;
|
||||
case LIT_INT:
|
||||
return OPCODE_ARG_TYPE_NUMBER;
|
||||
case LIT_STR:
|
||||
return OPCODE_ARG_TYPE_STRING;
|
||||
}
|
||||
|
||||
JERRY_UNREACHABLE();
|
||||
}
|
||||
|
||||
static uint8_t
|
||||
first_operand_id (statement stmt)
|
||||
{
|
||||
@ -378,7 +405,9 @@ generator_dump_statement (statement stmt)
|
||||
break;
|
||||
|
||||
case AO_EQ:
|
||||
opcode = getop_assignment (lhs (stmt), first_operand_id (stmt));
|
||||
opcode = getop_assignment (lhs (stmt),
|
||||
first_operand_type(stmt),
|
||||
first_operand_id (stmt));
|
||||
dump_opcode (&opcode);
|
||||
return;
|
||||
|
||||
@ -415,4 +444,4 @@ generator_dump_statement (statement stmt)
|
||||
__printf (" generator_dump_statement: %d ", stmt.type);
|
||||
JERRY_UNREACHABLE ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user