[njs] Removed unnecessary njs_parser_var_expression().

Dmitry Volyntsev xeioex at nginx.com
Fri Apr 5 14:16:57 UTC 2019


details:   https://hg.nginx.org/njs/rev/5224c5969233
branches:  
changeset: 870:5224c5969233
user:      hongzhidao <hongzhidao at gmail.com>
date:      Fri Apr 05 20:59:15 2019 +0800
description:
Removed unnecessary njs_parser_var_expression().

diffstat:

 njs/njs_parser.c            |   4 +-
 njs/njs_parser.h            |   2 -
 njs/njs_parser_expression.c |  53 ---------------------------------------------
 3 files changed, 2 insertions(+), 57 deletions(-)

diffs (96 lines):

diff -r 38262ccd9571 -r 5224c5969233 njs/njs_parser.c
--- a/njs/njs_parser.c	Fri Apr 05 16:49:21 2019 +0300
+++ b/njs/njs_parser.c	Fri Apr 05 20:59:15 2019 +0800
@@ -1055,7 +1055,7 @@ njs_parser_var_statement(njs_vm_t *vm, n
                 return token;
             }
 
-            token = njs_parser_var_expression(vm, parser, token);
+            token = njs_parser_assignment_expression(vm, parser, token);
             if (nxt_slow_path(token <= NJS_TOKEN_ILLEGAL)) {
                 return token;
             }
@@ -1501,7 +1501,7 @@ njs_parser_for_var_statement(njs_vm_t *v
                 return token;
             }
 
-            token = njs_parser_var_expression(vm, parser, token);
+            token = njs_parser_assignment_expression(vm, parser, token);
             if (nxt_slow_path(token <= NJS_TOKEN_ILLEGAL)) {
                 return token;
             }
diff -r 38262ccd9571 -r 5224c5969233 njs/njs_parser.h
--- a/njs/njs_parser.h	Fri Apr 05 16:49:21 2019 +0300
+++ b/njs/njs_parser.h	Fri Apr 05 20:59:15 2019 +0800
@@ -78,8 +78,6 @@ nxt_int_t njs_parser(njs_vm_t *vm, njs_p
     njs_parser_t *prev);
 njs_token_t njs_parser_expression(njs_vm_t *vm, njs_parser_t *parser,
     njs_token_t token);
-njs_token_t njs_parser_var_expression(njs_vm_t *vm, njs_parser_t *parser,
-    njs_token_t token);
 njs_token_t njs_parser_assignment_expression(njs_vm_t *vm,
     njs_parser_t *parser, njs_token_t token);
 njs_token_t njs_parser_function_expression(njs_vm_t *vm, njs_parser_t *parser);
diff -r 38262ccd9571 -r 5224c5969233 njs/njs_parser_expression.c
--- a/njs/njs_parser_expression.c	Fri Apr 05 16:49:21 2019 +0300
+++ b/njs/njs_parser_expression.c	Fri Apr 05 20:59:15 2019 +0800
@@ -210,59 +210,6 @@ njs_parser_expression(njs_vm_t *vm, njs_
 }
 
 
-njs_token_t
-njs_parser_var_expression(njs_vm_t *vm, njs_parser_t *parser, njs_token_t token)
-{
-    njs_parser_node_t       *node;
-    njs_vmcode_operation_t  operation;
-
-    token = njs_parser_assignment_expression(vm, parser, token);
-    if (nxt_slow_path(token <= NJS_TOKEN_ILLEGAL)) {
-        return token;
-    }
-
-    for ( ;; ) {
-        switch (token) {
-
-        case NJS_TOKEN_ASSIGNMENT:
-            nxt_thread_log_debug("JS: =");
-            operation = njs_vmcode_move;
-            break;
-
-        default:
-            return token;
-        }
-
-        if (!njs_parser_is_lvalue(parser->node)) {
-            njs_parser_ref_error(vm, parser,
-                                 "Invalid left-hand side in assignment");
-            return NJS_TOKEN_ILLEGAL;
-        }
-
-        node = njs_parser_node_new(vm, parser, token);
-        if (nxt_slow_path(node == NULL)) {
-            return NJS_TOKEN_ERROR;
-        }
-
-        node->u.operation = operation;
-        node->left = parser->node;
-
-        token = njs_parser_token(vm, parser);
-        if (nxt_slow_path(token <= NJS_TOKEN_ILLEGAL)) {
-            return token;
-        }
-
-        token = njs_parser_var_expression(vm, parser, token);
-        if (nxt_slow_path(token <= NJS_TOKEN_ILLEGAL)) {
-            return token;
-        }
-
-        node->right = parser->node;
-        parser->node = node;
-    }
-}
-
-
 static njs_token_t
 njs_parser_any_expression(njs_vm_t *vm, njs_parser_t *parser,
     const njs_parser_expression_t *expr, njs_token_t token)


More information about the nginx-devel mailing list