[njs] Improved function naming in variable code.

Dmitry Volyntsev xeioex at nginx.com
Sun Dec 30 11:13:30 UTC 2018


details:   https://hg.nginx.org/njs/rev/74776ba6a1a2
branches:  
changeset: 712:74776ba6a1a2
user:      hongzhidao <hongzhidao at gmail.com>
date:      Sat Dec 29 22:35:31 2018 +0800
description:
Improved function naming in variable code.

Renaming:
1) njs_variable_get() to njs_variable_resolve().
2) njs_variable_find() to njs_variable_reference_resolve().

To better reflect what they do.

diffstat:

 njs/njs_generator.c |   4 ++--
 njs/njs_parser.h    |   2 +-
 njs/njs_variable.c  |  20 ++++++++++----------
 3 files changed, 13 insertions(+), 13 deletions(-)

diffs (112 lines):

diff -r 5cf68fb9152e -r 74776ba6a1a2 njs/njs_generator.c
--- a/njs/njs_generator.c	Sat Dec 29 16:03:57 2018 +0800
+++ b/njs/njs_generator.c	Sat Dec 29 22:35:31 2018 +0800
@@ -488,7 +488,7 @@ njs_generate_name(njs_vm_t *vm, njs_gene
     njs_variable_t            *var;
     njs_vmcode_object_copy_t  *copy;
 
-    var = njs_variable_get(vm, node);
+    var = njs_variable_resolve(vm, node);
     if (nxt_slow_path(var == NULL)) {
         return NXT_ERROR;
     }
@@ -2257,7 +2257,7 @@ njs_generate_function_declaration(njs_vm
     njs_variable_t         *var;
     njs_function_lambda_t  *lambda;
 
-    var = njs_variable_get(vm, node);
+    var = njs_variable_resolve(vm, node);
     if (nxt_slow_path(var == NULL)) {
         return NXT_ERROR;
     }
diff -r 5cf68fb9152e -r 74776ba6a1a2 njs/njs_parser.h
--- a/njs/njs_parser.h	Sat Dec 29 16:03:57 2018 +0800
+++ b/njs/njs_parser.h	Sat Dec 29 22:35:31 2018 +0800
@@ -324,7 +324,7 @@ njs_token_t njs_parser_property_name(njs
 njs_token_t njs_parser_property_token(njs_parser_t *parser);
 njs_token_t njs_parser_token(njs_parser_t *parser);
 nxt_int_t njs_parser_string_create(njs_vm_t *vm, njs_value_t *value);
-njs_variable_t *njs_variable_get(njs_vm_t *vm, njs_parser_node_t *node);
+njs_variable_t *njs_variable_resolve(njs_vm_t *vm, njs_parser_node_t *node);
 njs_index_t njs_variable_typeof(njs_vm_t *vm, njs_parser_node_t *node);
 njs_index_t njs_variable_index(njs_vm_t *vm, njs_parser_node_t *node);
 nxt_bool_t njs_parser_has_side_effect(njs_parser_node_t *node);
diff -r 5cf68fb9152e -r 74776ba6a1a2 njs/njs_variable.c
--- a/njs/njs_variable.c	Sat Dec 29 16:03:57 2018 +0800
+++ b/njs/njs_variable.c	Sat Dec 29 22:35:31 2018 +0800
@@ -9,8 +9,8 @@
 #include <string.h>
 
 
-static njs_ret_t njs_variable_find(njs_vm_t *vm, njs_parser_scope_t *node_scope,
-    njs_variable_reference_t *vr);
+static njs_ret_t njs_variable_reference_resolve(njs_vm_t *vm,
+    njs_variable_reference_t *vr, njs_parser_scope_t *node_scope);
 static njs_variable_t *njs_variable_alloc(njs_vm_t *vm, nxt_str_t *name,
     njs_variable_type_t type);
 
@@ -191,7 +191,7 @@ njs_variables_scope_resolve(njs_vm_t *vm
             vr = &node->u.reference;
 
             if (closure) {
-                ret = njs_variable_find(vm, node->scope, vr);
+                ret = njs_variable_reference_resolve(vm, vr, node->scope);
                 if (nxt_slow_path(ret != NXT_OK)) {
                     continue;
                 }
@@ -201,7 +201,7 @@ njs_variables_scope_resolve(njs_vm_t *vm
                 }
             }
 
-            var = njs_variable_get(vm, node);
+            var = njs_variable_resolve(vm, node);
 
             if (nxt_slow_path(var == NULL)) {
                 if (vr->type != NJS_TYPEOF) {
@@ -252,7 +252,7 @@ njs_variable_typeof(njs_vm_t *vm, njs_pa
 
     vr = &node->u.reference;
 
-    ret = njs_variable_find(vm, node->scope, vr);
+    ret = njs_variable_reference_resolve(vm, vr, node->scope);
 
     if (nxt_fast_path(ret == NXT_OK)) {
         return vr->variable->index;
@@ -271,7 +271,7 @@ njs_variable_index(njs_vm_t *vm, njs_par
         return node->index;
     }
 
-    var = njs_variable_get(vm, node);
+    var = njs_variable_resolve(vm, node);
 
     if (nxt_fast_path(var != NULL)) {
         return var->index;
@@ -282,7 +282,7 @@ njs_variable_index(njs_vm_t *vm, njs_par
 
 
 njs_variable_t *
-njs_variable_get(njs_vm_t *vm, njs_parser_node_t *node)
+njs_variable_resolve(njs_vm_t *vm, njs_parser_node_t *node)
 {
     nxt_int_t                 ret;
     nxt_uint_t                scope_index;
@@ -294,7 +294,7 @@ njs_variable_get(njs_vm_t *vm, njs_parse
 
     vr = &node->u.reference;
 
-    ret = njs_variable_find(vm, node->scope, vr);
+    ret = njs_variable_reference_resolve(vm, vr, node->scope);
 
     if (nxt_slow_path(ret != NXT_OK)) {
         goto not_found;
@@ -390,8 +390,8 @@ not_found:
 
 
 static njs_ret_t
-njs_variable_find(njs_vm_t *vm, njs_parser_scope_t *node_scope,
-    njs_variable_reference_t *vr)
+njs_variable_reference_resolve(njs_vm_t *vm, njs_variable_reference_t *vr,
+    njs_parser_scope_t *node_scope)
 {
     nxt_lvlhsh_query_t  lhq;
     njs_parser_scope_t  *scope, *parent, *previous;


More information about the nginx-devel mailing list