Implement missing async function and async iterator prototypes. (#3962)

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2020-07-03 11:04:27 +02:00
committed by GitHub
parent f86b78a886
commit 80716cca90
22 changed files with 509 additions and 72 deletions
+13 -4
View File
@@ -846,7 +846,7 @@ typedef enum
CBC_CODE_FLAGS_HAS_TAGGED_LITERALS = (1u << 9), /**< this function has tagged template literal list */
CBC_CODE_FLAGS_LEXICAL_BLOCK_NEEDED = (1u << 10), /**< compiled code needs a lexical block */
/* Bits from bit 13 is reserved for function types (see CBC_FUNCTION_TYPE_SHIFT).
/* Bits from bit 12 is reserved for function types (see CBC_FUNCTION_TYPE_SHIFT).
* Note: the last bits are used for type flags because < and >= operators can be used to
check a range of types without decoding the actual type. */
} cbc_code_flags_t;
@@ -867,14 +867,17 @@ typedef enum
CBC_FUNCTION_ASYNC_GENERATOR, /**< async generator function */
/* The following functions has no prototype (see CBC_FUNCTION_HAS_PROTOTYPE) */
CBC_FUNCTION_ARROW, /**< arrow function */
CBC_FUNCTION_ACCESSOR, /**< property accessor function */
/* The following functions are arrow function (see CBC_FUNCTION_IS_ARROW) */
CBC_FUNCTION_ARROW, /**< arrow function */
CBC_FUNCTION_ASYNC_ARROW, /**< arrow function */
} cbc_code_function_types_t;
/**
* Shift for getting / setting the function type of a byte code.
*/
#define CBC_FUNCTION_TYPE_SHIFT 13
#define CBC_FUNCTION_TYPE_SHIFT 12
/**
* Compute function type bits in code flags.
@@ -904,7 +907,13 @@ typedef enum
* Checks whether the function has prototype property.
*/
#define CBC_FUNCTION_HAS_PROTOTYPE(flags) \
((flags) < (CBC_FUNCTION_ARROW << CBC_FUNCTION_TYPE_SHIFT))
((flags) < (CBC_FUNCTION_ACCESSOR << CBC_FUNCTION_TYPE_SHIFT))
/**
* Checks whether the function is an arrow function.
*/
#define CBC_FUNCTION_IS_ARROW(flags) \
((flags) >= (CBC_FUNCTION_ARROW << CBC_FUNCTION_TYPE_SHIFT))
/**
* Any arguments object is needed
+15 -3
View File
@@ -713,14 +713,19 @@ parse_print_final_cbc (ecma_compiled_code_t *compiled_code_p, /**< compiled code
JERRY_DEBUG_MSG (",async_generator");
break;
}
case CBC_FUNCTION_ACCESSOR:
{
JERRY_DEBUG_MSG (",accessor");
break;
}
case CBC_FUNCTION_ARROW:
{
JERRY_DEBUG_MSG (",arrow");
break;
}
case CBC_FUNCTION_ACCESSOR:
case CBC_FUNCTION_ASYNC_ARROW:
{
JERRY_DEBUG_MSG (",accessor");
JERRY_DEBUG_MSG (",async_arrow");
break;
}
}
@@ -1372,7 +1377,14 @@ parser_post_processing (parser_context_t *context_p) /**< context */
}
else if (context_p->status_flags & PARSER_IS_ARROW_FUNCTION)
{
function_type = CBC_FUNCTION_TO_TYPE_BITS (CBC_FUNCTION_ARROW);
if (context_p->status_flags & PARSER_IS_ASYNC_FUNCTION)
{
function_type = CBC_FUNCTION_TO_TYPE_BITS (CBC_FUNCTION_ASYNC_ARROW);
}
else
{
function_type = CBC_FUNCTION_TO_TYPE_BITS (CBC_FUNCTION_ARROW);
}
}
else if (context_p->status_flags & PARSER_IS_GENERATOR_FUNCTION)
{