Welcome! Log In Create A New Profile

Advanced

[njs] Removed obsolete function call interface.

January 27, 2017 08:36AM
details: http://hg.nginx.org/njs/rev/fb2ec3176a14
branches:
changeset: 306:fb2ec3176a14
user: Igor Sysoev <igor@sysoev.ru>
date: Fri Jan 27 16:01:31 2017 +0300
description:
Removed obsolete function call interface.

diffstat:

nginx/ngx_http_js_module.c | 2 +-
nginx/ngx_stream_js_module.c | 2 +-
njs/njs_generator.c | 3 ---
njs/njs_parser.c | 9 +--------
njs/njs_parser.h | 1 -
njs/njscript.c | 18 +-----------------
njs/njscript.h | 2 +-
njs/test/njs_unit_test.c | 29 ++++-------------------------
8 files changed, 9 insertions(+), 57 deletions(-)

diffs (197 lines):

diff -r f136239eebff -r fb2ec3176a14 nginx/ngx_http_js_module.c
--- a/nginx/ngx_http_js_module.c Tue Jan 24 14:38:59 2017 +0300
+++ b/nginx/ngx_http_js_module.c Fri Jan 27 16:01:31 2017 +0300
@@ -1322,7 +1322,7 @@ ngx_http_js_include(ngx_conf_t *cf, ngx_
return NGX_CONF_ERROR;
}

- rc = njs_vm_compile(jlcf->vm, &start, end, NULL, &export);
+ rc = njs_vm_compile(jlcf->vm, &start, end, &export);

if (rc != NJS_OK) {
njs_vm_exception(jlcf->vm, &text);
diff -r f136239eebff -r fb2ec3176a14 nginx/ngx_stream_js_module.c
--- a/nginx/ngx_stream_js_module.c Tue Jan 24 14:38:59 2017 +0300
+++ b/nginx/ngx_stream_js_module.c Fri Jan 27 16:01:31 2017 +0300
@@ -1030,7 +1030,7 @@ ngx_stream_js_include(ngx_conf_t *cf, ng
return NGX_CONF_ERROR;
}

- rc = njs_vm_compile(jscf->vm, &start, end, NULL, &export);
+ rc = njs_vm_compile(jscf->vm, &start, end, &export);

if (rc != NJS_OK) {
njs_vm_exception(jscf->vm, &text);
diff -r f136239eebff -r fb2ec3176a14 njs/njs_generator.c
--- a/njs/njs_generator.c Tue Jan 24 14:38:59 2017 +0300
+++ b/njs/njs_generator.c Fri Jan 27 16:01:31 2017 +0300
@@ -170,9 +170,6 @@ njs_generator(njs_vm_t *vm, njs_parser_t
case NJS_TOKEN_END:
return njs_generate_stop_statement(vm, parser, node);

- case NJS_TOKEN_CALL:
- return njs_generate_children(vm, parser, node);
-
case NJS_TOKEN_COMMA:
return njs_generate_comma_expression(vm, parser, node);

diff -r f136239eebff -r fb2ec3176a14 njs/njs_parser.c
--- a/njs/njs_parser.c Tue Jan 24 14:38:59 2017 +0300
+++ b/njs/njs_parser.c Fri Jan 27 16:01:31 2017 +0300
@@ -123,14 +123,7 @@ njs_parser(njs_vm_t *vm, njs_parser_t *p

node = parser->node;

- if (node != NULL && node->right != NULL) {
- if (node->right->token == NJS_TOKEN_FUNCTION) {
- node->token = NJS_TOKEN_CALL;
- node->scope = parser->scope;
- return node;
- }
-
- } else {
+ if (node == NULL) {
/* Empty string, just semicolons or variables declarations. */

node = njs_parser_node_alloc(vm);
diff -r f136239eebff -r fb2ec3176a14 njs/njs_parser.h
--- a/njs/njs_parser.h Tue Jan 24 14:38:59 2017 +0300
+++ b/njs/njs_parser.h Fri Jan 27 16:01:31 2017 +0300
@@ -14,7 +14,6 @@ typedef enum {
NJS_TOKEN_ILLEGAL = 0,

NJS_TOKEN_END,
- NJS_TOKEN_CALL,
NJS_TOKEN_SPACE,
NJS_TOKEN_LINE_END,

diff -r f136239eebff -r fb2ec3176a14 njs/njscript.c
--- a/njs/njscript.c Tue Jan 24 14:38:59 2017 +0300
+++ b/njs/njscript.c Fri Jan 27 16:01:31 2017 +0300
@@ -184,13 +184,11 @@ njs_vm_destroy(njs_vm_t *vm)


nxt_int_t
-njs_vm_compile(njs_vm_t *vm, u_char **start, u_char *end,
- njs_function_t **function, nxt_str_t **export)
+njs_vm_compile(njs_vm_t *vm, u_char **start, u_char *end, nxt_str_t **export)
{
nxt_int_t ret;
njs_lexer_t *lexer;
njs_parser_t *parser;
- njs_variable_t *var;
njs_parser_node_t *node;

parser = nxt_mem_cache_zalloc(vm->mem_cache_pool, sizeof(njs_parser_t));
@@ -219,20 +217,6 @@ njs_vm_compile(njs_vm_t *vm, u_char **st
return NJS_ERROR;
}

- if (function != NULL) {
- if (node->token == NJS_TOKEN_CALL) {
- var = njs_variable_get(vm, node->right, NJS_NAME_DECLARATION);
- if (nxt_slow_path(var == NULL)) {
- return NJS_ERROR;
- }
-
- *function = var->value.data.u.function;
-
- } else {
- *function = NULL;
- }
- }
-
*start = parser->lexer->start;

ret = njs_generate_scope(vm, parser, node);
diff -r f136239eebff -r fb2ec3176a14 njs/njscript.h
--- a/njs/njscript.h Tue Jan 24 14:38:59 2017 +0300
+++ b/njs/njscript.h Fri Jan 27 16:01:31 2017 +0300
@@ -84,7 +84,7 @@ NXT_EXPORT njs_vm_t *njs_vm_create(nxt_m
NXT_EXPORT void njs_vm_destroy(njs_vm_t *vm);

NXT_EXPORT nxt_int_t njs_vm_compile(njs_vm_t *vm, u_char **start, u_char *end,
- njs_function_t **function, nxt_str_t **export);
+ nxt_str_t **export);
NXT_EXPORT njs_vm_t *njs_vm_clone(njs_vm_t *vm, nxt_mem_cache_pool_t *mcp,
void **external);
NXT_EXPORT nxt_int_t njs_vm_call(njs_vm_t *vm, njs_function_t *function,
diff -r f136239eebff -r fb2ec3176a14 njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c Tue Jan 24 14:38:59 2017 +0300
+++ b/njs/test/njs_unit_test.c Fri Jan 27 16:01:31 2017 +0300
@@ -6758,11 +6758,6 @@ static njs_unit_test_t njs_test[] =
{ nxt_string("parseFloat('12345abc')"),
nxt_string("12345") },

- /* External interface. */
-
- { nxt_string("function f(req) { return req.uri }"),
- nxt_string("АБВ") },
-
/* Trick: number to boolean. */

{ nxt_string("var a = 0; !!a"),
@@ -7056,14 +7051,12 @@ njs_unit_test(nxt_bool_t disassemble)
u_char *start;
njs_vm_t *vm, *nvm;
nxt_int_t ret;
- nxt_str_t s, r_name, *export;
+ nxt_str_t s, *export;
nxt_uint_t i;
nxt_bool_t success;
nxt_lvlhsh_t externals;
- njs_function_t *function;
njs_vm_shared_t *shared;
njs_unit_test_req r;
- njs_opaque_value_t value;
nxt_mem_cache_pool_t *mcp;

/*
@@ -7105,7 +7098,7 @@ njs_unit_test(nxt_bool_t disassemble)
start = njs_test[i].script.start;

ret = njs_vm_compile(vm, &start, start + njs_test[i].script.length,
- &function, &export);
+ &export);

if (ret == NXT_OK) {
if (disassemble) {
@@ -7121,20 +7114,7 @@ njs_unit_test(nxt_bool_t disassemble)
r.uri.length = 6;
r.uri.start = (u_char *) "АБВ";

- if (function != NULL) {
- r_name.length = 2;
- r_name.start = (u_char *) "$r";
-
- ret = njs_vm_external(nvm, NULL, &r_name, &value);
- if (ret != NXT_OK) {
- return NXT_ERROR;
- }
-
- ret = njs_vm_call(nvm, function, &value, 1);
-
- } else {
- ret = njs_vm_run(nvm);
- }
+ ret = njs_vm_run(nvm);

if (ret == NXT_OK) {
if (njs_vm_retval(nvm, &s) != NXT_OK) {
@@ -7219,7 +7199,7 @@ njs_unit_test_benchmark(nxt_str_t *scrip

start = script->start;

- ret = njs_vm_compile(vm, &start, start + script->length, NULL, &export);
+ ret = njs_vm_compile(vm, &start, start + script->length, &export);
if (ret != NXT_OK) {
return NXT_ERROR;
}
@@ -7232,7 +7212,6 @@ njs_unit_test_benchmark(nxt_str_t *scrip
}

if (njs_vm_run(nvm) == NXT_OK) {
-
if (njs_vm_retval(nvm, &s) != NXT_OK) {
return NXT_ERROR;
}
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Removed obsolete function call interface.

Igor Sysoev 777 January 27, 2017 08:36AM



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

Online Users

Guests: 70
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready