Welcome! Log In Create A New Profile

Advanced

[njs] A fix of function name usage.

October 18, 2016 09:02AM
details: http://hg.nginx.org/njs/rev/b2a23cf748f8
branches:
changeset: 206:b2a23cf748f8
user: Igor Sysoev <igor@sysoev.ru>
date: Tue Oct 18 15:48:19 2016 +0300
description:
A fix of function name usage.

diffstat:

njs/njs_generator.c | 9 ++-------
njs/njs_parser.c | 1 +
njs/njs_variable.h | 3 ++-
3 files changed, 5 insertions(+), 8 deletions(-)

diffs (52 lines):

diff -r 462f7d2113f9 -r b2a23cf748f8 njs/njs_generator.c
--- a/njs/njs_generator.c Tue Oct 18 15:48:13 2016 +0300
+++ b/njs/njs_generator.c Tue Oct 18 15:48:19 2016 +0300
@@ -333,14 +333,9 @@ njs_generator(njs_vm_t *vm, njs_parser_t
static nxt_int_t
njs_generate_name(njs_vm_t *vm, njs_parser_t *parser, njs_parser_node_t *node)
{
- njs_index_t index;
- njs_value_t *value;
njs_vmcode_object_copy_t *copy;

- index = node->u.variable->index;
- value = njs_variable_value(parser, index);
-
- if (value->type == NJS_FUNCTION) {
+ if (node->u.variable->function) {

node->index = njs_generator_dest_index(vm, parser, node);
if (nxt_slow_path(node->index == NJS_INDEX_ERROR)) {
@@ -352,7 +347,7 @@ njs_generate_name(njs_vm_t *vm, njs_pars
copy->code.operands = NJS_VMCODE_2OPERANDS;
copy->code.retval = NJS_VMCODE_RETVAL;
copy->retval = node->index;
- copy->object = index;
+ copy->object = node->u.variable->index;

return NXT_OK;
}
diff -r 462f7d2113f9 -r b2a23cf748f8 njs/njs_parser.c
--- a/njs/njs_parser.c Tue Oct 18 15:48:13 2016 +0300
+++ b/njs/njs_parser.c Tue Oct 18 15:48:19 2016 +0300
@@ -315,6 +315,7 @@ njs_parser_function_declaration(njs_vm_t
}

var->state = NJS_VARIABLE_DECLARED;
+ var->function = 1;
node->index = var->index;

token = njs_parser_token(parser);
diff -r 462f7d2113f9 -r b2a23cf748f8 njs/njs_variable.h
--- a/njs/njs_variable.h Tue Oct 18 15:48:13 2016 +0300
+++ b/njs/njs_variable.h Tue Oct 18 15:48:19 2016 +0300
@@ -20,7 +20,8 @@ typedef enum {
typedef struct {
u_char *name_start;
uint16_t name_len;
- njs_variable_state_t state:8; /* 3 bits */
+ njs_variable_state_t state:8; /* 3 bits */
+ uint8_t function; /* 1 bit */

njs_index_t index;
} njs_variable_t;

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] A fix of function name usage.

Igor Sysoev 579 October 18, 2016 09:02AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 274
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready