/** * Perform 'eval' with code stored in continuous character buffer * * See also: * ecma_op_eval * ECMA-262 v5, 15.1.2.1 (steps 2 to 8) * * @return ecma value */ ecma_value_t ecma_op_eval_chars_buffer (const jerry_api_char_t *code_p, /**< code characters buffer */ size_t code_buffer_size, /**< size of the buffer */ bool is_direct, /**< is eval called directly (ECMA-262 v5, 15.1.2.1.1) */ bool is_called_from_strict_mode_code) /**< is eval is called from strict mode code */ { JERRY_ASSERT (code_p != NULL); ecma_value_t ret_value; ecma_compiled_code_t *bytecode_data_p; jsp_status_t parse_status; bool is_strict_call = (is_direct && is_called_from_strict_mode_code); jerry_api_object_t *error_obj_p = NULL; parse_status = parser_parse_eval (code_p, code_buffer_size, is_strict_call, &bytecode_data_p, &error_obj_p); if (parse_status == JSP_STATUS_OK) { ret_value = vm_run_eval (bytecode_data_p, is_direct); } else { JERRY_ASSERT (parse_status == JSP_STATUS_SYNTAX_ERROR); ret_value = ecma_make_error_obj_value (error_obj_p); } return ret_value; } /* ecma_op_eval_chars_buffer */
/** * Raise a standard ecma-error with the given type and message. * * @return ecma value * Returned value must be freed with ecma_free_value */ ecma_value_t ecma_raise_standard_error (ecma_standard_error_t error_type, /**< error type */ const lit_utf8_byte_t *msg_p) /**< error message */ { ecma_object_t *error_obj_p; if (msg_p != NULL) { ecma_string_t *error_msg_p = ecma_new_ecma_string_from_utf8 (msg_p, lit_zt_utf8_string_size (msg_p)); error_obj_p = ecma_new_standard_error_with_message (error_type, error_msg_p); ecma_deref_ecma_string (error_msg_p); } else { error_obj_p = ecma_new_standard_error (error_type); } return ecma_make_error_obj_value (error_obj_p); } /* ecma_raise_standard_error */