[njs] Added the "name" property to the Function prototype object.

2019-05-04 Thread Valentin Bartenev
details:   https://hg.nginx.org/njs/rev/0c42e997371c
branches:  
changeset: 945:0c42e997371c
user:  Valentin Bartenev 
date:  Sat May 04 17:12:35 2019 +0300
description:
Added the "name" property to the Function prototype object.

Its value according to the ES6+ specification must be the empty String.

diffstat:

 njs/njs_function.c |  6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diffs (16 lines):

diff -r b7cdfafdc20b -r 0c42e997371c njs/njs_function.c
--- a/njs/njs_function.cSat May 04 16:59:24 2019 +0300
+++ b/njs/njs_function.cSat May 04 17:12:35 2019 +0300
@@ -1175,6 +1175,12 @@ static const njs_object_prop_t  njs_func
 {
 {
 .type = NJS_PROPERTY,
+.name = njs_string("name"),
+.value = njs_string(""),
+},
+
+{
+.type = NJS_PROPERTY,
 .name = njs_string("length"),
 .value = njs_value(NJS_NUMBER, 0, 0.0),
 },
___
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel


[njs] Style.

2019-05-04 Thread Valentin Bartenev
details:   https://hg.nginx.org/njs/rev/b7cdfafdc20b
branches:  
changeset: 944:b7cdfafdc20b
user:  Valentin Bartenev 
date:  Sat May 04 16:59:24 2019 +0300
description:
Style.

diffstat:

 njs/njs_disassembler.c   |   2 --
 njs/njs_function.c   |   1 -
 njs/njs_json.c   |   8 
 njs/njs_object.c |  10 +-
 njs/njs_parser.c |   7 +++
 njs/njs_string.c |   1 -
 njs/test/njs_unit_test.c |  10 +-
 7 files changed, 17 insertions(+), 22 deletions(-)

diffs (123 lines):

diff -r 551d173ab9ec -r b7cdfafdc20b njs/njs_disassembler.c
--- a/njs/njs_disassembler.cSat May 04 05:52:15 2019 +0300
+++ b/njs/njs_disassembler.cSat May 04 16:59:24 2019 +0300
@@ -295,7 +295,6 @@ njs_disassemble(u_char *start, u_char *e
(size_t) method->method, method->nargs,
method->code.ctor ? " CTOR" : "");
 
-
 p += sizeof(njs_vmcode_method_frame_t);
 continue;
 }
@@ -308,7 +307,6 @@ njs_disassemble(u_char *start, u_char *e
(size_t) prop_foreach->object,
(size_t) prop_foreach->offset);
 
-
 p += sizeof(njs_vmcode_prop_foreach_t);
 continue;
 }
diff -r 551d173ab9ec -r b7cdfafdc20b njs/njs_function.c
--- a/njs/njs_function.cSat May 04 05:52:15 2019 +0300
+++ b/njs/njs_function.cSat May 04 16:59:24 2019 +0300
@@ -31,7 +31,6 @@ njs_function_alloc(njs_vm_t *vm, njs_fun
 goto fail;
 }
 
-
 /*
  * nxt_mp_zalloc() does also:
  *   nxt_lvlhsh_init(>object.hash);
diff -r 551d173ab9ec -r b7cdfafdc20b njs/njs_json.c
--- a/njs/njs_json.cSat May 04 05:52:15 2019 +0300
+++ b/njs/njs_json.cSat May 04 16:59:24 2019 +0300
@@ -1916,10 +1916,10 @@ njs_json_append_number(njs_json_stringif
 static njs_value_t *
 njs_json_wrap_value(njs_vm_t *vm, const njs_value_t *value)
 {
-nxt_int_t ret;
-njs_value_t   *wrapper;
-njs_object_prop_t *prop;
-nxt_lvlhsh_query_tlhq;
+nxt_int_t   ret;
+njs_value_t *wrapper;
+njs_object_prop_t   *prop;
+nxt_lvlhsh_query_t  lhq;
 
 wrapper = nxt_mp_alloc(vm->mem_pool, sizeof(njs_value_t));
 if (nxt_slow_path(wrapper == NULL)) {
diff -r 551d173ab9ec -r b7cdfafdc20b njs/njs_object.c
--- a/njs/njs_object.c  Sat May 04 05:52:15 2019 +0300
+++ b/njs/njs_object.c  Sat May 04 16:59:24 2019 +0300
@@ -2619,11 +2619,11 @@ njs_value_t *
 njs_property_prototype_create(njs_vm_t *vm, nxt_lvlhsh_t *hash,
 njs_object_t *prototype)
 {
-nxt_int_t  ret;
-njs_object_prop_t  *prop;
-nxt_lvlhsh_query_t lhq;
-
-static const njs_value_t   proto_string = njs_string("prototype");
+nxt_int_t ret;
+njs_object_prop_t *prop;
+nxt_lvlhsh_query_tlhq;
+
+static const njs_value_t  proto_string = njs_string("prototype");
 
 prop = njs_object_prop_alloc(vm, _string, _value_undefined, 0);
 if (nxt_slow_path(prop == NULL)) {
diff -r 551d173ab9ec -r b7cdfafdc20b njs/njs_parser.c
--- a/njs/njs_parser.c  Sat May 04 05:52:15 2019 +0300
+++ b/njs/njs_parser.c  Sat May 04 16:59:24 2019 +0300
@@ -1064,7 +1064,6 @@ njs_parser_var_statement(njs_vm_t *vm, n
 return NJS_TOKEN_ILLEGAL;
 }
 
-
 name = njs_parser_variable_node(vm, parser,
 njs_parser_text(parser),
 njs_parser_key_hash(parser),
@@ -2179,9 +2178,9 @@ njs_token_t
 njs_parser_arrow_expression(njs_vm_t *vm, njs_parser_t *parser,
 njs_token_t token)
 {
-njs_ret_t   ret;
-njs_index_t index;
-njs_parser_node_t   *node, *body, *parent;
+njs_ret_t  ret;
+njs_index_tindex;
+njs_parser_node_t  *node, *body, *parent;
 njs_function_lambda_t  *lambda;
 
 node = njs_parser_node_new(vm, parser, NJS_TOKEN_FUNCTION_EXPRESSION);
diff -r 551d173ab9ec -r b7cdfafdc20b njs/njs_string.c
--- a/njs/njs_string.c  Sat May 04 05:52:15 2019 +0300
+++ b/njs/njs_string.c  Sat May 04 16:59:24 2019 +0300
@@ -598,7 +598,6 @@ static const njs_object_prop_t  njs_stri
  NJS_SKIP_ARG, NJS_STRING_ARG),
 },
 
-
 /* String.fromCharCode(). */
 {
 .type = NJS_METHOD,
diff -r 551d173ab9ec -r b7cdfafdc20b njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c  Sat May 04 05:52:15 2019 +0300
+++ b/njs/test/njs_unit_test.c  Sat May 04 16:59:24 2019 +0300
@@ -13104,11 +13104,11 @@ done:
 static nxt_int_t
 njs_timezone_optional_test(nxt_bool_t disassemble, nxt_bool_t verbose)
 {
-size_t  size;
-u_char  buf[16];
-time_t  clock;
-struct tm   tm;
-nxt_int_t   ret;
+size_t size;
+u_char buf[16];
+time_t clock;
+struct tm  tm;
+nxt_int_t  ret;
 
 /*
  * Chatham Islands NZ-CHAT 

[njs] Simplified condition in njs_function_alloc().

2019-05-04 Thread Valentin Bartenev
details:   https://hg.nginx.org/njs/rev/551d173ab9ec
branches:  
changeset: 943:551d173ab9ec
user:  Valentin Bartenev 
date:  Sat May 04 05:52:15 2019 +0300
description:
Simplified condition in njs_function_alloc().

There's no reason to check both flags when one depends on another.
See just a few lines above: function->ctor = !lambda->arrow.

Now the condition is made similar to the one in njs_method_private_copy().

diffstat:

 njs/njs_function.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (18 lines):

diff -r fe74f3c7863a -r 551d173ab9ec njs/njs_function.c
--- a/njs/njs_function.cSat May 04 00:56:39 2019 +0300
+++ b/njs/njs_function.cSat May 04 05:52:15 2019 +0300
@@ -42,11 +42,11 @@ njs_function_alloc(njs_vm_t *vm, njs_fun
 function->args_offset = 1;
 function->u.lambda = lambda;
 
-if (lambda->arrow || !function->ctor) {
-function->object.shared_hash = vm->shared->arrow_instance_hash;
+if (function->ctor) {
+function->object.shared_hash = vm->shared->function_instance_hash;
 
 } else {
-function->object.shared_hash = vm->shared->function_instance_hash;
+function->object.shared_hash = vm->shared->arrow_instance_hash;
 }
 
 function->object.__proto__ = 
>prototypes[NJS_PROTOTYPE_FUNCTION].object;
___
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel