Add iterator close support for for-of statement (#3401)

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
Robert Fancsik
2020-01-13 17:38:47 +01:00
committed by GitHub
parent f1dd59e4bd
commit be8ae3aae8
5 changed files with 290 additions and 6 deletions
+9 -1
View File
@@ -18,6 +18,7 @@
#include "ecma-helpers.h"
#include "vm-defines.h"
#include "vm-stack.h"
#include "ecma-iterator-object.h"
/** \addtogroup vm Virtual machine
* @{
@@ -79,8 +80,15 @@ vm_stack_context_abort (vm_frame_ctx_t *frame_ctx_p, /**< frame context */
#if ENABLED (JERRY_ES2015)
case VM_CONTEXT_FOR_OF:
{
ecma_value_t iterator = vm_stack_top_p[-3];
if (context_info & VM_CONTEXT_CLOSE_ITERATOR)
{
ecma_op_iterator_close (iterator);
}
ecma_free_value (iterator);
ecma_free_value (vm_stack_top_p[-2]);
ecma_free_value (vm_stack_top_p[-3]);
VM_MINUS_EQUAL_U16 (frame_ctx_p->context_depth, PARSER_FOR_OF_CONTEXT_STACK_ALLOCATION);
vm_stack_top_p -= PARSER_FOR_OF_CONTEXT_STACK_ALLOCATION;
break;