njs_value_t *args, **local, *value;
njs_value_t **cur_local, **cur_closures, **cur_temp;
njs_function_t *function;
+ njs_declaration_t *declr;
njs_function_lambda_t *lambda;
frame = (njs_frame_t *) vm->top_frame;
while (n != 0) {
n--;
- function = njs_function(lambda->declarations[n]);
+ declr = &lambda->declarations[n];
+ value = njs_scope_value(vm, declr->index);
+
+ *value = *declr->value;
+
+ function = njs_function_value_copy(vm, value);
+ if (njs_slow_path(function == NULL)) {
+ return NJS_ERROR;
+ }
ret = njs_function_capture_closure(vm, function, function->u.lambda);
if (njs_slow_path(ret != NJS_OK)) {
} njs_parser_rbtree_node_t;
+typedef struct {
+ njs_value_t *value;
+ njs_index_t index;
+} njs_declaration_t;
+
+
typedef njs_int_t (*njs_parser_traverse_cb_t)(njs_vm_t *vm,
njs_parser_node_t *node, void *ctx);
#include <njs_main.h>
-static njs_value_t **njs_variable_scope_function_add(njs_parser_t *parser,
+static njs_declaration_t *njs_variable_scope_function_add(njs_parser_t *parser,
njs_parser_scope_t *scope);
static njs_parser_scope_t *njs_variable_scope_find(njs_parser_t *parser,
njs_parser_scope_t *scope, uintptr_t unique_id, njs_variable_type_t type);
uintptr_t unique_id, njs_variable_type_t type)
{
njs_bool_t ctor;
- njs_value_t **declr;
njs_variable_t *var;
+ njs_declaration_t *declr;
njs_parser_scope_t *root;
njs_function_lambda_t *lambda;
return NULL;
}
- *declr = &var->value;
-
var->index = njs_scope_index(root->type, root->items, NJS_LEVEL_LOCAL,
type);
+
+ declr->value = &var->value;
+ declr->index = var->index;
+
root->items++;
}
}
-static njs_value_t **
+static njs_declaration_t *
njs_variable_scope_function_add(njs_parser_t *parser, njs_parser_scope_t *scope)
{
if (scope->declarations == NULL) {
scope->declarations = njs_arr_create(parser->vm->mem_pool, 1,
- sizeof(njs_value_t *));
+ sizeof(njs_declaration_t));
if (njs_slow_path(scope->declarations == NULL)) {
return NULL;
}