Repository: jerryscript-project/jerryscript
File: jerry-core/vm/vm-utils.c (C)

Code before:
 *         of built-in 'eval' routine of Global object
 *
 * @return true - currently performed call is performed through 'eval' identifier,
 *                without 'this' argument,
 *         false - otherwise
 */
inline bool JERRY_ATTR_ALWAYS_INLINE
vm_is_direct_eval_form_call (void)
{
  return (JERRY_CONTEXT (status_flags) & ECMA_STATUS_DIRECT_EVAL) != 0;
} /* vm_is_direct_eval_form_call */

/**
 * Get backtrace. The backtrace is an array of strings where
 * each string contains the position of the corresponding frame.
 * The array length is zero if the backtrace is not available.
 *
 * @return array ecma value
 */
ecma_value_t
vm_get_backtrace (uint32_t max_depth, /**< maximum backtrace depth, 0 = unlimited */
                  ecma_object_t *ignored_function_p) /**< ignore functions up to this function */
{
#if ENABLED (JERRY_LINE_INFO)
  vm_frame_ctx_t *context_p = JERRY_CONTEXT (vm_top_context_p);

  if (ignored_function_p != NULL)
  {
    while (true)
    {
      if (context_p == NULL)
      {
        context_p = JERRY_CONTEXT (vm_top_context_p);
        break;
      }

      if (context_p->shared_p->status_flags & VM_FRAME_CTX_SHARED_HAS_ARG_LIST)
      {
        vm_frame_ctx_shared_args_t *shared_args_p = (vm_frame_ctx_shared_args_t *) context_p->shared_p;

        if (shared_args_p->function_object_p == ignored_function_p)
        {
          context_p = context_p->prev_context_p;
          break;
        }
      }

      context_p = context_p->prev_context_p;
    }
  }


Review comment (suggestion):
I'd put here an assert, just in case if someone tries to call it from internal code rather than the new API function in the future. Something like: 
```
ecma_object_type_t type = ecma_get_object_type (ignored_function_p);
JERRY_ASSERT (type == ECMA_OBJECT_TYPE_FUNCTION || type == ECMA_OBJECT_TYPE_NATIVE_FUNCTION || type == ECMA_OBJECT_TYPE_BOUND_FUNCTION);
```

Code after:
 *         of built-in 'eval' routine of Global object
 *
 * @return true - currently performed call is performed through 'eval' identifier,
 *                without 'this' argument,
 *         false - otherwise
 */
inline bool JERRY_ATTR_ALWAYS_INLINE
vm_is_direct_eval_form_call (void)
{
  return (JERRY_CONTEXT (status_flags) & ECMA_STATUS_DIRECT_EVAL) != 0;
} /* vm_is_direct_eval_form_call */

/**
 * Get backtrace. The backtrace is an array of strings where
 * each string contains the position of the corresponding frame.
 * The array length is zero if the backtrace is not available.
 *
 * @return array ecma value
 */
ecma_value_t
vm_get_backtrace (uint32_t max_depth, /**< maximum backtrace depth, 0 = unlimited */
                  ecma_object_t *ignored_function_p) /**< ignore functions up to this function */
{
#if ENABLED (JERRY_LINE_INFO)
  vm_frame_ctx_t *context_p = JERRY_CONTEXT (vm_top_context_p);

  if (ignored_function_p != NULL)
  {
    JERRY_ASSERT (ecma_get_object_type (ignored_function_p) == ECMA_OBJECT_TYPE_FUNCTION
                  || ecma_get_object_type (ignored_function_p) == ECMA_OBJECT_TYPE_NATIVE_FUNCTION);

    while (true)
    {
      if (context_p == NULL)
      {
        context_p = JERRY_CONTEXT (vm_top_context_p);
        break;
      }

      if (context_p->shared_p->status_flags & VM_FRAME_CTX_SHARED_HAS_ARG_LIST)
      {
        vm_frame_ctx_shared_args_t *shared_args_p = (vm_frame_ctx_shared_args_t *) context_p->shared_p;

        if (shared_args_p->function_object_p == ignored_function_p)
        {
          context_p = context_p->prev_context_p;
          break;
        }
      }

      context_p = context_p->prev_context_p;