From: hongzhidao Date: Sat, 29 Dec 2018 14:35:31 +0000 (+0800) Subject: Improved function naming in variable code. X-Git-Tag: 0.2.8~90 X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=1471808fa95961de28487b894ecf00231a379636;p=njs.git 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. --- diff --git a/njs/njs_generator.c b/njs/njs_generator.c index a75e2b8a..575f2aa9 100644 --- a/njs/njs_generator.c +++ b/njs/njs_generator.c @@ -488,7 +488,7 @@ njs_generate_name(njs_vm_t *vm, njs_generator_t *generator, 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_t *vm, njs_generator_t *generator, 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 --git a/njs/njs_parser.h b/njs/njs_parser.h index cf903162..d8780e1e 100644 --- a/njs/njs_parser.h +++ b/njs/njs_parser.h @@ -324,7 +324,7 @@ njs_token_t njs_parser_property_name(njs_vm_t *vm, njs_parser_t *parser, 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 --git a/njs/njs_variable.c b/njs/njs_variable.c index ce60fd3a..c7549da4 100644 --- a/njs/njs_variable.c +++ b/njs/njs_variable.c @@ -9,8 +9,8 @@ #include -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, njs_parser_scope_t *scope, 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, njs_parser_scope_t *scope, } } - 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_parser_node_t *node) 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_parser_node_t *node) 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_parser_node_t *node) 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_parser_node_t *node) 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;