Improve the evaluate requests (#2583)

Currently it evaluates the given expression in the context of the top most stack frame.
The expression should access to any variables and arguments that are in the scope chain.
Implement the eval_at request with the level of the scope chain as a further argument.

JerryScript-DCO-1.0-Signed-off-by: Robert Sipka [email protected]
This commit is contained in:
Robert Sipka authored and GitHub committed 2018-11-15 15:53:10 +01:00
1 parent 6c4b316609
commit 47fa5904b1
10 files changed
+170 -13

No files matched your search

+10 -5
View File
@@ -40,7 +40,7 @@ typedef struct
*/
JERRY_STATIC_ASSERT (JERRY_DEBUGGER_MESSAGES_OUT_MAX_COUNT == 32
&& JERRY_DEBUGGER_MESSAGES_IN_MAX_COUNT == 21
&& JERRY_DEBUGGER_VERSION == 7,
&& JERRY_DEBUGGER_VERSION == 8,
debugger_version_correlates_to_message_type_count);
/**
@@ -529,12 +529,17 @@ jerry_debugger_send_eval (const lit_utf8_byte_t *eval_string_p, /**< evaluated s
JERRY_ASSERT (!(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_VM_IGNORE));
JERRY_DEBUGGER_SET_FLAGS (JERRY_DEBUGGER_VM_IGNORE);
ecma_value_t result = ecma_op_eval_chars_buffer (eval_string_p + 1, eval_string_size - 1, ECMA_PARSE_DIRECT_EVAL);
uint32_t chain_index;
memcpy (&chain_index, eval_string_p, sizeof (uint32_t));
uint32_t parse_opts = ECMA_PARSE_DIRECT_EVAL | (chain_index << ECMA_PARSE_CHAIN_INDEX_SHIFT);
ecma_value_t result = ecma_op_eval_chars_buffer (eval_string_p + 5, eval_string_size - 5, parse_opts);
JERRY_DEBUGGER_CLEAR_FLAGS (JERRY_DEBUGGER_VM_IGNORE);
if (!ECMA_IS_VALUE_ERROR (result))
{
if (eval_string_p[0] != JERRY_DEBUGGER_EVAL_EVAL)
if (eval_string_p[4] != JERRY_DEBUGGER_EVAL_EVAL)
{
JERRY_DEBUGGER_SET_FLAGS (JERRY_DEBUGGER_VM_EXCEPTION_THROWN);
JERRY_CONTEXT (error_value) = result;
@@ -543,7 +548,7 @@ jerry_debugger_send_eval (const lit_utf8_byte_t *eval_string_p, /**< evaluated s
JERRY_DEBUGGER_SET_FLAGS (JERRY_DEBUGGER_VM_STOP);
JERRY_CONTEXT (debugger_stop_context) = NULL;
if (eval_string_p[0] == JERRY_DEBUGGER_EVAL_THROW)
if (eval_string_p[4] == JERRY_DEBUGGER_EVAL_THROW)
{
JERRY_CONTEXT (status_flags) |= ECMA_STATUS_EXCEPTION;
}
@@ -918,7 +923,7 @@ jerry_debugger_process_message (const uint8_t *recv_buffer_p, /**< pointer to th
case JERRY_DEBUGGER_EVAL:
{
if (message_size < sizeof (jerry_debugger_receive_eval_first_t) + 1)
if (message_size < sizeof (jerry_debugger_receive_eval_first_t) + 5)
{
JERRY_ERROR_MSG ("Invalid message size\n");
jerry_debugger_transport_close ();