Implement exponentiation operation. (#3692)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
@@ -74,6 +74,13 @@ do_number_arithmetic (number_arithmetic_op op, /**< number arithmetic operation
|
||||
result = ecma_op_number_remainder (num_left, num_right);
|
||||
break;
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
case NUMBER_ARITHMETIC_EXPONENTIATION:
|
||||
{
|
||||
result = ecma_number_pow (num_left, num_right);
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
}
|
||||
|
||||
ret_value = ecma_make_number_value (result);
|
||||
|
||||
@@ -35,6 +35,9 @@ typedef enum
|
||||
NUMBER_ARITHMETIC_MULTIPLICATION, /**< multiplication */
|
||||
NUMBER_ARITHMETIC_DIVISION, /**< division */
|
||||
NUMBER_ARITHMETIC_REMAINDER, /**< remainder calculation */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
NUMBER_ARITHMETIC_EXPONENTIATION, /**< exponentiation */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
} number_arithmetic_op;
|
||||
|
||||
/**
|
||||
|
||||
@@ -2815,6 +2815,22 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
*stack_top_p++ = result;
|
||||
goto free_both_values;
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
case VM_OC_EXP:
|
||||
{
|
||||
result = do_number_arithmetic (NUMBER_ARITHMETIC_EXPONENTIATION,
|
||||
left_value,
|
||||
right_value);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (result))
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
*stack_top_p++ = result;
|
||||
goto free_both_values;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
case VM_OC_EQUAL:
|
||||
{
|
||||
result = opfunc_equality (left_value, right_value);
|
||||
|
||||
@@ -182,6 +182,9 @@ typedef enum
|
||||
VM_OC_MUL, /**< mul */
|
||||
VM_OC_DIV, /**< div */
|
||||
VM_OC_MOD, /**< mod */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
VM_OC_EXP, /**< exponentiation */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
VM_OC_EQUAL, /**< equal */
|
||||
VM_OC_NOT_EQUAL, /**< not equal */
|
||||
@@ -276,6 +279,9 @@ typedef enum
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
#if !ENABLED (JERRY_ES2015)
|
||||
VM_OC_EXP = VM_OC_NONE, /**< exponentiation */
|
||||
#endif /* !ENABLED (JERRY_ES2015) */
|
||||
#if !ENABLED (JERRY_DEBUGGER)
|
||||
VM_OC_BREAKPOINT_ENABLED = VM_OC_NONE, /**< enabled breakpoint for debugger is unused */
|
||||
VM_OC_BREAKPOINT_DISABLED = VM_OC_NONE, /**< disabled breakpoint for debugger is unused */
|
||||
|
||||
Reference in New Issue
Block a user