Implement eval check for ECMAScript code (#4788)

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2021-10-15 22:25:20 +02:00
committed by GitHub
parent fe3a5c08b2
commit b52c114423
7 changed files with 196 additions and 2 deletions
+22
View File
@@ -5565,6 +5565,28 @@ jerry_get_user_value (const jerry_value_t value) /**< jerry api value */
return ecma_copy_value (CBC_SCRIPT_GET_USER_VALUE (script_p));
} /* jerry_get_user_value */
/**
* Checks whether an ECMAScript code is compiled by eval
* like (eval, new Function, jerry_eval, etc.) command.
*
* @return true, if code is compiled by eval like command
* false, otherwise
*/
bool
jerry_is_eval_code (const jerry_value_t value) /**< jerry api value */
{
ecma_value_t script_value = ecma_script_get_from_value (value);
if (script_value == JMEM_CP_NULL)
{
return false;
}
const cbc_script_t *script_p = ECMA_GET_INTERNAL_VALUE_POINTER (cbc_script_t, script_value);
return (script_p->refs_and_type & CBC_SCRIPT_IS_EVAL_CODE) != 0;
} /* jerry_is_eval_code */
/**
* Returns a newly created source info structure corresponding to the passed script/module/function.
*