Lines Matching refs:scope
17 #include "handle-scope-internal.h"
34 #define JERRYX_HANDLE_SCOPE_PRELIST_IDX(scope) (scope - jerryx_handle_scope_pool.prelist)
37 * Get current handle scope top of stack.
46 * Get root handle scope.
55 * Determines if given handle scope is located in pre-allocated list.
57 * @param scope - the one to be determined.
60 jerryx_handle_scope_is_in_prelist (jerryx_handle_scope_t *scope)
62 return (jerryx_handle_scope_pool.prelist <= scope)
63 && (scope <= (jerryx_handle_scope_pool.prelist + JERRYX_SCOPE_PRELIST_SIZE - 1));
67 * Get the parent of given handle scope.
68 * If given handle scope is in prelist, the parent must be in prelist too;
72 * @param scope - the one to be permformed on.
73 * @returns - the parent of the given scope.
76 jerryx_handle_scope_get_parent (jerryx_handle_scope_t *scope)
78 if (scope == &jerryx_handle_scope_root)
82 if (!jerryx_handle_scope_is_in_prelist (scope))
84 jerryx_handle_scope_dynamic_t *dy_scope = (jerryx_handle_scope_dynamic_t *) scope;
92 if (scope == jerryx_handle_scope_pool.prelist)
96 return jerryx_handle_scope_pool.prelist + JERRYX_HANDLE_SCOPE_PRELIST_IDX (scope) - 1;
100 * Get the child of given handle scope.
101 * If the given handle scope is in heap chain list, its child must be in heap chain list too;
102 * if the given handle scope is the last one of prelist, its child must be the first item of chain list;
105 * @param scope - the one to be permformed on.
106 * @returns the child of the given scope.
109 jerryx_handle_scope_get_child (jerryx_handle_scope_t *scope)
111 if (scope == &jerryx_handle_scope_root)
119 if (!jerryx_handle_scope_is_in_prelist (scope))
121 jerryx_handle_scope_dynamic_t *child = ((jerryx_handle_scope_dynamic_t *) scope)->child;
124 if (scope == JERRYX_HANDLE_SCOPE_POOL_PRELIST_LAST)
128 long idx = (long)(JERRYX_HANDLE_SCOPE_PRELIST_IDX (scope));
141 * Claims a handle scope either from prelist or allocating a new memory block,
142 * and increment pool's scope count by 1, and set current scope to the newly claimed one.
145 * and link it to previously dynamically allocated scope, or link it to pool's start pointer.
147 * @returns the newly claimed handle scope pointer.
152 jerryx_handle_scope_t *scope;
155 scope = jerryx_handle_scope_pool.prelist + jerryx_handle_scope_pool.count;
175 scope = (jerryx_handle_scope_t *) dy_scope;
178 scope->prelist_handle_count = 0;
179 scope->escaped = false;
180 scope->handle_ptr = NULL;
182 jerryx_handle_scope_current = scope;
184 return (jerryx_handle_scope_t *) scope;
188 * Deannounce a previously claimed handle scope, return it to pool
191 * @param scope - the one to be freed.
194 jerryx_handle_scope_free (jerryx_handle_scope_t *scope)
196 if (scope == &jerryx_handle_scope_root)
202 if (scope == jerryx_handle_scope_current)
204 jerryx_handle_scope_current = jerryx_handle_scope_get_parent (scope);
207 if (!jerryx_handle_scope_is_in_prelist (scope))
209 jerryx_handle_scope_dynamic_t *dy_scope = (jerryx_handle_scope_dynamic_t *) scope;