Implement nullish coalescing operator (#3997)
JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
This commit is contained in:
@@ -2922,6 +2922,20 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
ecma_fast_free_value (value);
|
||||
continue;
|
||||
}
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
case VM_OC_BRANCH_IF_NULLISH:
|
||||
{
|
||||
left_value = stack_top_p[-1];
|
||||
|
||||
if (!ecma_is_value_null (left_value) && !ecma_is_value_undefined (left_value))
|
||||
{
|
||||
byte_code_p = byte_code_start_p + branch_offset;
|
||||
continue;
|
||||
}
|
||||
--stack_top_p;
|
||||
continue;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
case VM_OC_PLUS:
|
||||
case VM_OC_MINUS:
|
||||
{
|
||||
|
||||
@@ -161,6 +161,9 @@ typedef enum
|
||||
VM_OC_ERROR, /**< error while the vm_loop is suspended */
|
||||
|
||||
VM_OC_JUMP, /**< jump */
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
VM_OC_BRANCH_IF_NULLISH, /** branch if undefined or null */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
VM_OC_BRANCH_IF_STRICT_EQUAL, /**< branch if strict equal */
|
||||
|
||||
/* These four opcodes must be in this order. */
|
||||
@@ -296,6 +299,7 @@ typedef enum
|
||||
{
|
||||
#if !ENABLED (JERRY_ESNEXT)
|
||||
VM_OC_EXP = VM_OC_NONE, /**< exponentiation */
|
||||
VM_OC_BRANCH_IF_NULLISH = VM_OC_NONE, /** branch if undefined or null */
|
||||
#endif /* !ENABLED (JERRY_ESNEXT) */
|
||||
#if !ENABLED (JERRY_DEBUGGER)
|
||||
VM_OC_BREAKPOINT_ENABLED = VM_OC_NONE, /**< enabled breakpoint for debugger is unused */
|
||||
|
||||
Reference in New Issue
Block a user