Lines Matching refs:scope

17 #include "handle-scope-internal.h"
20 * Opens a new handle scope and attach it to current global scope as a child scope.
22 * @param result - [out value] opened scope.
33 * Release all jerry values attached to given scope
35 * @param scope - the scope of handles to be released.
38 jerryx_handle_scope_release_handles (jerryx_handle_scope scope)
40 size_t prelist_handle_count = scope->prelist_handle_count;
41 if (prelist_handle_count == JERRYX_HANDLE_PRELIST_SIZE && scope->handle_ptr != NULL)
43 jerryx_handle_t *a_handle = scope->handle_ptr;
51 scope->handle_ptr = NULL;
57 jerry_release_value (scope->handle_prelist[idx]);
59 scope->prelist_handle_count = 0;
63 * Close the scope and its child scopes and release all jerry values that
67 * @param scope - the scope closed.
71 jerryx_close_handle_scope (jerryx_handle_scope scope)
74 * Release all handles related to given scope and its child scopes
76 jerryx_handle_scope a_scope = scope;
90 * Opens a new handle scope from which one object can be promoted to the outer scope
91 * and attach it to current global scope as a child scope.
93 * @param result - [out value] opened escapable handle scope.
103 * Close the scope and its child scopes and release all jerry values that
107 * @param scope - the one to be closed.
111 jerryx_close_escapable_handle_scope (jerryx_handle_scope scope)
113 return jerryx_close_handle_scope (scope);
118 * Escape a jerry value from the scope, yet did not promote it to outer scope.
121 * @param scope - scope of the handle added to.
122 * @param idx - expected index of the handle in the scope's prelist.
126 jerryx_hand_scope_escape_handle_from_prelist (jerryx_handle_scope scope, size_t idx)
128 jerry_value_t jval = scope->handle_prelist[idx];
129 if (scope->prelist_handle_count == JERRYX_HANDLE_PRELIST_SIZE && scope->handle_ptr != NULL)
131 jerryx_handle_t *handle = scope->handle_ptr;
132 scope->handle_ptr = handle->sibling;
133 scope->handle_prelist[idx] = handle->jval;
140 scope->handle_prelist[idx] = scope->handle_prelist[scope->prelist_handle_count - 1];
147 * Escape a jerry value from the given escapable handle scope.
149 * @param scope - the expected scope to be escaped from.
153 * scope after escaped from the given handle scope.
157 jerryx_escape_handle_internal (jerryx_escapable_handle_scope scope,
162 if (scope->escaped)
167 jerryx_handle_scope parent = jerryx_handle_scope_get_parent (scope);
176 size_t prelist_count = scope->prelist_handle_count;
183 if (escapee == scope->handle_prelist[idx_plus_1 - 1])
193 *result = jerryx_hand_scope_escape_handle_from_prelist (scope, found_idx);
195 --scope->prelist_handle_count;
198 scope->escaped = true;
200 * Escape handle to parent scope
202 jerryx_create_handle_in_scope (*result, jerryx_handle_scope_get_parent (scope));
208 if (scope->prelist_handle_count <= JERRYX_HANDLE_PRELIST_SIZE && scope->handle_ptr == NULL)
217 jerryx_handle_t *handle = scope->handle_ptr;
233 * Remove found handle from current scope's handle chain
240 scope->handle_ptr = found_handle->sibling;
251 * Escape handle to parent scope
258 scope->escaped = true;
265 * the outer scope. It can only be called once per scope. If it is called more than
268 * @param scope - the expected scope to be escaped from.
274 jerryx_escape_handle (jerryx_escapable_handle_scope scope,
278 return jerryx_escape_handle_internal (scope, escapee, result, true);
282 * Escape a handle from scope yet do not promote it to the outer scope.
285 * @param scope - the expected scope to be removed from.
291 jerryx_remove_handle (jerryx_escapable_handle_scope scope,
295 return jerryx_escape_handle_internal (scope, escapee, result, false);
299 * Try to reuse given handle if possible while adding to the scope.
301 * @param handle - the one to be added to the scope.
302 * @param scope - the scope of handle to be added to.
306 jerryx_handle_scope_add_handle_to (jerryx_handle_t *handle, jerryx_handle_scope scope)
308 size_t prelist_handle_count = scope->prelist_handle_count;
311 ++scope->prelist_handle_count;
314 scope->handle_prelist[prelist_handle_count] = jval;
318 handle->sibling = scope->handle_ptr;
319 scope->handle_ptr = handle;
324 * Add given jerry value to the scope.
326 * @param jval - jerry value to be added to scope.
327 * @param scope - the scope of the jerry value been expected to be added to.
328 * @return jerry value that added to scope.
331 jerryx_create_handle_in_scope (jerry_value_t jval, jerryx_handle_scope scope)
333 size_t prelist_handle_count = scope->prelist_handle_count;
336 scope->handle_prelist[prelist_handle_count] = jval;
338 ++scope->prelist_handle_count;
345 handle->sibling = scope->handle_ptr;
346 scope->handle_ptr = handle;
352 * Add given jerry value to current top scope.
354 * @param jval - jerry value to be added to scope.
355 * @return jerry value that added to scope.