]> git.kaiwu.me - njs.git/commitdiff
VM: removed vm->variables_hash.
authorDmitry Volyntsev <xeioex@nginx.com>
Wed, 5 Apr 2023 05:19:48 +0000 (22:19 -0700)
committerDmitry Volyntsev <xeioex@nginx.com>
Wed, 5 Apr 2023 05:19:48 +0000 (22:19 -0700)
src/njs_builtin.c
src/njs_shell.c
src/njs_vm.c
src/njs_vm.h

index bcffed9a5c71bf04460e25d1587620cac78fb2c5..50a53532ba77bd8470e31e47a663942dabdb67f0 100644 (file)
@@ -588,7 +588,7 @@ njs_vm_expression_completions(njs_vm_t *vm, njs_str_t *expression)
 
     var_node.key = (uintptr_t) lhq.value;
 
-    node = njs_rbtree_find(vm->variables_hash, &var_node.node);
+    node = njs_rbtree_find(&vm->global_scope->variables, &var_node.node);
     if (njs_slow_path(node == NULL)) {
         return NULL;
     }
@@ -1018,7 +1018,7 @@ njs_global_this_prop_handler(njs_vm_t *vm, njs_object_prop_t *prop,
 
     var_node.key = (uintptr_t) lhq.value;
 
-    rb_node = njs_rbtree_find(vm->variables_hash, &var_node.node);
+    rb_node = njs_rbtree_find(&vm->global_scope->variables, &var_node.node);
     if (rb_node == NULL) {
         return NJS_DECLINED;
     }
index 256657957e2f824bc586ddcd0d7780c4a26335f6..4b4cedf2c9347d1ac0ffc620abf946cd685990bd 100644 (file)
@@ -1205,8 +1205,8 @@ njs_completion_generator(const char *text, int state)
         cmpl->length = njs_strlen(text);
         cmpl->suffix_completions = NULL;
 
-        if (vm->variables_hash != NULL) {
-            cmpl->node = njs_rbtree_min(vm->variables_hash);
+        if (vm->global_scope != NULL) {
+            cmpl->node = njs_rbtree_min(&vm->global_scope->variables);
         }
     }
 
@@ -1214,7 +1214,8 @@ next:
 
     switch (cmpl->phase) {
     case NJS_COMPLETION_VAR:
-        variables = vm->variables_hash;
+        variables = (vm->global_scope != NULL) ? &vm->global_scope->variables
+                                               : NULL;
 
         if (variables == NULL) {
             njs_next_phase(cmpl);
index 2f684e56fdd099091310ed19d6bf6326accf941d..6e2840101a16f0591dee8cf42ea6fa714801cd88 100644 (file)
@@ -228,7 +228,6 @@ njs_vm_compile(njs_vm_t *vm, u_char **start, u_char *end)
     njs_scope_value_set(vm, njs_scope_global_this_index(), &vm->global_value);
 
     vm->start = generator.code_start;
-    vm->variables_hash = &scope->variables;
     vm->global_scope = scope;
 
     if (vm->options.disassemble) {
index d2b9a1d148228ee030ff281ad2609759c87edd63..4ab3fbadf3557721076859d407ae53ae71626349 100644 (file)
@@ -132,7 +132,6 @@ struct njs_vm_s {
     njs_native_frame_t       *top_frame;
     njs_frame_t              *active_frame;
 
-    njs_rbtree_t             *variables_hash;
     njs_lvlhsh_t             keywords_hash;
     njs_lvlhsh_t             values_hash;