[njs] Renaming void to undefined.

Dmitry Volyntsev xeioex at nginx.com
Tue Mar 19 13:20:38 UTC 2019


details:   https://hg.nginx.org/njs/rev/e9fd5b21f08d
branches:  
changeset: 834:e9fd5b21f08d
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Tue Mar 19 16:02:07 2019 +0300
description:
Renaming void to undefined.

diffstat:

 njs/njs.c                |   6 ++--
 njs/njs.h                |   7 +++--
 njs/njs_array.c          |  26 +++++++++---------
 njs/njs_builtin.c        |   4 +-
 njs/njs_error.c          |   2 +-
 njs/njs_fs.c             |  14 +++++-----
 njs/njs_function.c       |  14 +++++-----
 njs/njs_generator.c      |   6 ++--
 njs/njs_json.c           |  22 ++++++++--------
 njs/njs_object.c         |  42 ++++++++++++++++---------------
 njs/njs_parser.c         |   2 +-
 njs/njs_regexp.c         |  14 +++++-----
 njs/njs_shell.c          |  14 +++++-----
 njs/njs_string.c         |  26 +++++++++---------
 njs/njs_time.c           |   4 +-
 njs/njs_variable.c       |   3 +-
 njs/njs_vm.c             |  63 ++++++++++++++++++++++++++---------------------
 njs/njs_vm.h             |  21 ++++++++-------
 njs/test/njs_unit_test.c |   2 +-
 19 files changed, 152 insertions(+), 140 deletions(-)

diffs (truncated from 1160 to 1000 lines):

diff -r 2037b3ccd677 -r e9fd5b21f08d njs/njs.c
--- a/njs/njs.c	Mon Mar 18 19:20:02 2019 +0300
+++ b/njs/njs.c	Tue Mar 19 16:02:07 2019 +0300
@@ -245,7 +245,7 @@ njs_vm_compile(njs_vm_t *vm, u_char **st
         nxt_array_reset(vm->backtrace);
     }
 
-    vm->retval = njs_value_void;
+    vm->retval = njs_value_undefined;
 
     ret = njs_parser(vm, parser, prev);
     if (nxt_slow_path(ret != NXT_OK)) {
@@ -439,7 +439,7 @@ njs_vm_init(njs_vm_t *vm)
     }
 
     if (njs_is_null(&vm->retval)) {
-        vm->retval = njs_value_void;
+        vm->retval = njs_value_undefined;
     }
 
     return NXT_OK;
@@ -462,7 +462,7 @@ njs_vm_invoke(njs_vm_t *vm, njs_function
     njs_ret_t    ret;
     njs_value_t  *this;
 
-    this = (njs_value_t *) &njs_value_void;
+    this = (njs_value_t *) &njs_value_undefined;
 
     current = vm->current;
 
diff -r 2037b3ccd677 -r e9fd5b21f08d njs/njs.h
--- a/njs/njs.h	Mon Mar 18 19:20:02 2019 +0300
+++ b/njs/njs.h	Tue Mar 19 16:02:07 2019 +0300
@@ -45,10 +45,10 @@ typedef struct {
     (njs_value_t *) ((u_char *) args + n * 16)
 
 
-extern const njs_value_t            njs_value_void;
+extern const njs_value_t            njs_value_undefined;
 
 #define njs_arg(args, nargs, n)                                               \
-    ((n < nargs) ? njs_argument(args, n) : &njs_value_void)
+    ((n < nargs) ? njs_argument(args, n) : &njs_value_undefined)
 
 #define njs_value_assign(dst, src)                                            \
     *((njs_opaque_value_t *) dst) = *((njs_opaque_value_t *) src);
@@ -265,7 +265,8 @@ NXT_EXPORT void *njs_value_data(const nj
 NXT_EXPORT njs_function_t *njs_value_function(const njs_value_t *value);
 
 NXT_EXPORT nxt_int_t njs_value_is_null(const njs_value_t *value);
-NXT_EXPORT nxt_int_t njs_value_is_void(const njs_value_t *value);
+NXT_EXPORT nxt_int_t njs_value_is_undefined(const njs_value_t *value);
+NXT_EXPORT nxt_int_t njs_value_is_null_or_undefined(const njs_value_t *value);
 NXT_EXPORT nxt_int_t njs_value_is_boolean(const njs_value_t *value);
 NXT_EXPORT nxt_int_t njs_value_is_number(const njs_value_t *value);
 NXT_EXPORT nxt_int_t njs_value_is_valid_number(const njs_value_t *value);
diff -r 2037b3ccd677 -r e9fd5b21f08d njs/njs_array.c
--- a/njs/njs_array.c	Mon Mar 18 19:20:02 2019 +0300
+++ b/njs/njs_array.c	Tue Mar 19 16:02:07 2019 +0300
@@ -509,7 +509,7 @@ njs_array_prototype_slice_continuation(n
         length = 0;
 
     } else {
-        if (!njs_is_void(njs_arg(args, nargs, 2))) {
+        if (!njs_is_undefined(njs_arg(args, nargs, 2))) {
             end = (int32_t) njs_primitive_value_to_integer(&args[2]);
 
         } else {
@@ -664,7 +664,7 @@ njs_array_prototype_pop(njs_vm_t *vm, nj
     njs_array_t        *array;
     const njs_value_t  *retval, *value;
 
-    retval = &njs_value_void;
+    retval = &njs_value_undefined;
 
     if (njs_is_array(&args[0])) {
         array = args[0].data.u.array;
@@ -730,7 +730,7 @@ njs_array_prototype_shift(njs_vm_t *vm, 
     njs_array_t        *array;
     const njs_value_t  *retval, *value;
 
-    retval = &njs_value_void;
+    retval = &njs_value_undefined;
 
     if (njs_is_array(&args[0])) {
         array = args[0].data.u.array;
@@ -963,7 +963,7 @@ njs_array_prototype_join(njs_vm_t *vm, n
 
         if (!njs_is_string(value)
             && njs_is_valid(value)
-            && !njs_is_null_or_void(value))
+            && !njs_is_null_or_undefined(value))
         {
             max++;
         }
@@ -989,7 +989,7 @@ njs_array_prototype_join(njs_vm_t *vm, n
 
             if (!njs_is_string(value)
                 && njs_is_valid(value)
-                && !njs_is_null_or_void(value))
+                && !njs_is_null_or_undefined(value))
             {
                 values[n++] = *value;
 
@@ -1037,7 +1037,7 @@ njs_array_prototype_join_continuation(nj
     for (i = 0; i < array->length; i++) {
         value = &array->start[i];
 
-        if (njs_is_valid(value) && !njs_is_null_or_void(value)) {
+        if (njs_is_valid(value) && !njs_is_null_or_undefined(value)) {
 
             if (!njs_is_string(value)) {
                 value = &values[n++];
@@ -1084,7 +1084,7 @@ njs_array_prototype_join_continuation(nj
     for (i = 0; i < array->length; i++) {
         value = &array->start[i];
 
-        if (njs_is_valid(value) && !njs_is_null_or_void(value)) {
+        if (njs_is_valid(value) && !njs_is_null_or_undefined(value)) {
             if (!njs_is_string(value)) {
                 value = &values[n++];
             }
@@ -1465,7 +1465,7 @@ njs_array_prototype_for_each_continuatio
     index = njs_array_iterator_index(args[0].data.u.array, iter);
 
     if (index == NJS_ARRAY_INVALID_INDEX) {
-        vm->retval = njs_value_void;
+        vm->retval = njs_value_undefined;
         return NXT_OK;
     }
 
@@ -1660,7 +1660,7 @@ njs_array_prototype_find_continuation(nj
     njs_array_find_t   *find;
     const njs_value_t  *retval;
 
-    retval = &njs_value_void;
+    retval = &njs_value_undefined;
 
     find = njs_vm_continuation(vm);
     iter = &find->iter;
@@ -1752,7 +1752,7 @@ njs_array_prototype_find_apply(njs_vm_t 
     value = &args[0].data.u.array->start[n];
 
     if (!njs_is_valid(value)) {
-        value = &njs_value_void;
+        value = &njs_value_undefined;
     }
 
     arguments[1] = *value;
@@ -1899,7 +1899,7 @@ njs_array_prototype_reduce_continuation(
         return NXT_OK;
     }
 
-    arguments[0] = njs_value_void;
+    arguments[0] = njs_value_undefined;
 
     /* GC: array elt, array */
     arguments[1] = iter->retval;
@@ -2036,7 +2036,7 @@ njs_array_prototype_reduce_right_continu
         return NXT_OK;
     }
 
-    arguments[0] = njs_value_void;
+    arguments[0] = njs_value_undefined;
 
     /* GC: array elt, array */
     arguments[1] = iter->retval;
@@ -2177,7 +2177,7 @@ njs_array_prototype_sort_continuation(nj
                 if (njs_is_valid(&start[n])) {
 
                     if (njs_is_valid(&start[n - 1])) {
-                        arguments[0] = njs_value_void;
+                        arguments[0] = njs_value_undefined;
 
                         /* GC: array elt, array */
                         arguments[1] = start[n - 1];
diff -r 2037b3ccd677 -r e9fd5b21f08d njs/njs_builtin.c
--- a/njs/njs_builtin.c	Mon Mar 18 19:20:02 2019 +0300
+++ b/njs/njs_builtin.c	Tue Mar 19 16:02:07 2019 +0300
@@ -403,7 +403,7 @@ static njs_ret_t
 njs_prototype_function(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs,
     njs_index_t unused)
 {
-    vm->retval = njs_value_void;
+    vm->retval = njs_value_undefined;
 
     return NXT_OK;
 }
@@ -1105,7 +1105,7 @@ static const njs_object_prop_t  njs_glob
     {
         .type = NJS_PROPERTY,
         .name = njs_string("undefined"),
-        .value = njs_value(NJS_VOID, 0, NAN),
+        .value = njs_value(NJS_UNDEFINED, 0, NAN),
     },
 };
 
diff -r 2037b3ccd677 -r e9fd5b21f08d njs/njs_error.c
--- a/njs/njs_error.c	Mon Mar 18 19:20:02 2019 +0300
+++ b/njs/njs_error.c	Tue Mar 19 16:02:07 2019 +0300
@@ -538,7 +538,7 @@ njs_memory_error_prototype_create(njs_vm
     proto = njs_property_prototype_create(vm, &function->object.hash,
                                           &vm->prototypes[index].object);
     if (proto == NULL) {
-        proto = (njs_value_t *) &njs_value_void;
+        proto = (njs_value_t *) &njs_value_undefined;
     }
 
     *retval = *proto;
diff -r 2037b3ccd677 -r e9fd5b21f08d njs/njs_fs.c
--- a/njs/njs_fs.c	Mon Mar 18 19:20:02 2019 +0300
+++ b/njs/njs_fs.c	Tue Mar 19 16:02:07 2019 +0300
@@ -279,13 +279,13 @@ done:
             return NJS_ERROR;
         }
 
-        arguments[2] = njs_value_void;
+        arguments[2] = njs_value_undefined;
 
     } else {
-        arguments[1] = njs_value_void;
+        arguments[1] = njs_value_undefined;
     }
 
-    arguments[0] = njs_value_void;
+    arguments[0] = njs_value_undefined;
 
     cont = njs_vm_continuation(vm);
     cont->u.cont.function = njs_fs_done;
@@ -702,10 +702,10 @@ done:
         }
 
     } else {
-        arguments[1] = njs_value_void;
+        arguments[1] = njs_value_undefined;
     }
 
-    arguments[0] = njs_value_void;
+    arguments[0] = njs_value_undefined;
 
     cont = njs_vm_continuation(vm);
     cont->u.cont.function = njs_fs_done;
@@ -874,7 +874,7 @@ done:
         }
 
     } else {
-        vm->retval = njs_value_void;
+        vm->retval = njs_value_undefined;
     }
 
     return NJS_OK;
@@ -884,7 +884,7 @@ done:
 static njs_ret_t njs_fs_done(njs_vm_t *vm, njs_value_t *args,
     nxt_uint_t nargs, njs_index_t unused)
 {
-    vm->retval = njs_value_void;
+    vm->retval = njs_value_undefined;
 
     return NJS_OK;
 }
diff -r 2037b3ccd677 -r e9fd5b21f08d njs/njs_function.c
--- a/njs/njs_function.c	Mon Mar 18 19:20:02 2019 +0300
+++ b/njs/njs_function.c	Tue Mar 19 16:02:07 2019 +0300
@@ -330,7 +330,7 @@ njs_function_lambda_frame(njs_vm_t *vm, 
     }
 
     while (max_args != 0) {
-        *value++ = njs_value_void;
+        *value++ = njs_value_undefined;
         max_args--;
     }
 
@@ -575,7 +575,7 @@ njs_normalize_args(njs_vm_t *vm, njs_val
 
         case NJS_STRING_OBJECT_ARG:
 
-            if (njs_is_null_or_void(args)) {
+            if (njs_is_null_or_undefined(args)) {
                 goto type_error;
             }
 
@@ -638,7 +638,7 @@ njs_normalize_args(njs_vm_t *vm, njs_val
         case NJS_REGEXP_ARG:
 
             switch (args->type) {
-            case NJS_VOID:
+            case NJS_UNDEFINED:
             case NJS_STRING:
             case NJS_REGEXP:
                 break;
@@ -659,7 +659,7 @@ njs_normalize_args(njs_vm_t *vm, njs_val
 
         case NJS_OBJECT_ARG:
 
-            if (njs_is_null_or_void(args)) {
+            if (njs_is_null_or_undefined(args)) {
                 goto type_error;
             }
 
@@ -876,7 +876,7 @@ njs_function_prototype_call(njs_vm_t *vm
         nargs -= 2;
 
     } else {
-        this = (njs_value_t *) &njs_value_void;
+        this = (njs_value_t *) &njs_value_undefined;
         nargs = 0;
     }
 
@@ -924,7 +924,7 @@ njs_function_prototype_apply(njs_vm_t *v
 
     } else {
         if (nargs == 1) {
-            this = (njs_value_t *) &njs_value_void;
+            this = (njs_value_t *) &njs_value_undefined;
         }
 
         nargs = 0;
@@ -1007,7 +1007,7 @@ njs_function_prototype_bind(njs_vm_t *vm
     function->object.extensible = 1;
 
     if (nargs == 1) {
-        args = (njs_value_t *) &njs_value_void;
+        args = (njs_value_t *) &njs_value_undefined;
 
     } else {
         nargs--;
diff -r 2037b3ccd677 -r e9fd5b21f08d njs/njs_generator.c
--- a/njs/njs_generator.c	Mon Mar 18 19:20:02 2019 +0300
+++ b/njs/njs_generator.c	Tue Mar 19 16:02:07 2019 +0300
@@ -1606,7 +1606,7 @@ njs_generate_stop_statement(njs_vm_t *vm
         }
 
         if (index == NJS_INDEX_NONE) {
-            index = njs_value_index(vm, &njs_value_void, generator->runtime);
+            index = njs_value_index(vm, &njs_value_undefined, generator->runtime);
         }
 
         stop->retval = index;
@@ -2377,7 +2377,7 @@ njs_generate_scope(njs_vm_t *vm, njs_gen
     value = (njs_value_t *) (p + size);
 
     for (n = scope_size - size; n != 0; n -= sizeof(njs_value_t)) {
-        *value++ = njs_value_void;
+        *value++ = njs_value_undefined;
     }
 
     if (vm->code == NULL) {
@@ -2459,7 +2459,7 @@ njs_generate_return_statement(njs_vm_t *
         index = node->right->index;
 
     } else {
-        index = njs_value_index(vm, &njs_value_void, generator->runtime);
+        index = njs_value_index(vm, &njs_value_undefined, generator->runtime);
     }
 
     immediate = njs_generate_lookup_block(generator->block, NJS_GENERATOR_TRY,
diff -r 2037b3ccd677 -r e9fd5b21f08d njs/njs_json.c
--- a/njs/njs_json.c	Mon Mar 18 19:20:02 2019 +0300
+++ b/njs/njs_json.c	Tue Mar 19 16:02:07 2019 +0300
@@ -176,7 +176,7 @@ njs_json_parse(njs_vm_t *vm, njs_value_t
     }
 
     if (nargs < 2) {
-        arg = njs_string_void;
+        arg = njs_string_undefined;
     } else {
         arg = args[1];
     }
@@ -256,7 +256,7 @@ njs_json_stringify(njs_vm_t *vm, njs_val
     njs_json_stringify_t  *stringify;
 
     if (nargs < 2) {
-        vm->retval = njs_value_void;
+        vm->retval = njs_value_undefined;
         return NXT_OK;
     }
 
@@ -277,7 +277,7 @@ njs_json_stringify(njs_vm_t *vm, njs_val
         }
 
     } else {
-        stringify->replacer = njs_value_void;
+        stringify->replacer = njs_value_undefined;
     }
 
     stringify->space.length = 0;
@@ -975,7 +975,7 @@ njs_json_parse_continuation(njs_vm_t *vm
             lhq.proto = &njs_object_hash_proto;
             lhq.pool = vm->mem_pool;
 
-            if (njs_is_void(&parse->retval)) {
+            if (njs_is_undefined(&parse->retval)) {
                 ret = nxt_lvlhsh_delete(&state->value.data.u.object->hash,
                                         &lhq);
 
@@ -1244,7 +1244,7 @@ njs_json_stringify_continuation(njs_vm_t
             prop = lhq.value;
 
             if (!prop->enumerable
-                || njs_is_void(&prop->value)
+                || njs_is_undefined(&prop->value)
                 || !njs_is_valid(&prop->value)
                 || njs_is_function(&prop->value))
             {
@@ -1282,7 +1282,7 @@ njs_json_stringify_continuation(njs_vm_t
             break;
 
         case NJS_JSON_OBJECT_TO_JSON_REPLACED:
-            if (njs_is_void(&stringify->retval)) {
+            if (njs_is_undefined(&stringify->retval)) {
                 state->type = NJS_JSON_OBJECT_CONTINUE;
                 break;
             }
@@ -1298,7 +1298,7 @@ njs_json_stringify_continuation(njs_vm_t
         case NJS_JSON_OBJECT_REPLACED:
             state->type = NJS_JSON_OBJECT_CONTINUE;
 
-            if (njs_is_void(&stringify->retval)) {
+            if (njs_is_undefined(&stringify->retval)) {
                 break;
             }
 
@@ -1372,7 +1372,7 @@ njs_json_stringify_continuation(njs_vm_t
             break;
 
         case NJS_JSON_ARRAY_TO_JSON_REPLACED:
-            if (!njs_is_void(&stringify->retval)
+            if (!njs_is_undefined(&stringify->retval)
                 && njs_is_function(&stringify->replacer))
             {
                 return njs_json_stringify_replacer(vm, stringify, NULL,
@@ -1412,7 +1412,7 @@ done:
      * An empty object means empty result.
      */
     if (str.length <= nxt_length("{\n\n}")) {
-        vm->retval = njs_value_void;
+        vm->retval = njs_value_undefined;
         goto release;
     }
 
@@ -1735,7 +1735,7 @@ njs_json_append_value(njs_json_stringify
             return njs_json_buf_append(stringify, "false", 5);
         }
 
-    case NJS_VOID:
+    case NJS_UNDEFINED:
     case NJS_NULL:
     case NJS_INVALID:
     case NJS_FUNCTION:
@@ -2150,7 +2150,7 @@ njs_dump_value(njs_json_stringify_t *str
 
         break;
 
-    case NJS_VOID:
+    case NJS_UNDEFINED:
         njs_dump("undefined");
         break;
 
diff -r 2037b3ccd677 -r e9fd5b21f08d njs/njs_object.c
--- a/njs/njs_object.c	Mon Mar 18 19:20:02 2019 +0300
+++ b/njs/njs_object.c	Tue Mar 19 16:02:07 2019 +0300
@@ -286,7 +286,7 @@ njs_property_query(njs_vm_t *vm, njs_pro
         break;
 
     case NJS_STRING:
-        if (nxt_fast_path(!njs_is_null_or_void_or_boolean(property))) {
+        if (nxt_fast_path(!njs_is_null_or_undefined_or_boolean(property))) {
             index = njs_value_to_index(property);
 
             if (nxt_fast_path(index < NJS_STRING_MAX_LENGTH)) {
@@ -298,7 +298,7 @@ njs_property_query(njs_vm_t *vm, njs_pro
         break;
 
     case NJS_OBJECT_STRING:
-        if (nxt_fast_path(!njs_is_null_or_void_or_boolean(property))) {
+        if (nxt_fast_path(!njs_is_null_or_undefined_or_boolean(property))) {
             index = njs_value_to_index(property);
 
             if (nxt_fast_path(index < NJS_STRING_MAX_LENGTH)) {
@@ -316,7 +316,7 @@ njs_property_query(njs_vm_t *vm, njs_pro
         break;
 
     case NJS_ARRAY:
-        if (nxt_fast_path(!njs_is_null_or_void_or_boolean(property))) {
+        if (nxt_fast_path(!njs_is_null_or_undefined_or_boolean(property))) {
             index = njs_value_to_index(property);
 
             if (nxt_fast_path(index < NJS_ARRAY_MAX_LENGTH)) {
@@ -357,7 +357,7 @@ njs_property_query(njs_vm_t *vm, njs_pro
         obj = NULL;
         break;
 
-    case NJS_VOID:
+    case NJS_UNDEFINED:
     case NJS_NULL:
     default:
         ret = njs_primitive_value_to_string(vm, &pq->value, property);
@@ -434,7 +434,9 @@ njs_object_property_query(njs_vm_t *vm, 
                 goto next;
             }
 
-            if (proto != object && !njs_is_null_or_void_or_boolean(property)) {
+            if (proto != object
+                && !njs_is_null_or_undefined_or_boolean(property))
+            {
                 switch (proto->type) {
                 case NJS_ARRAY:
                     index = njs_value_to_index(property);
@@ -776,7 +778,7 @@ njs_object_constructor(njs_vm_t *vm, njs
     value = njs_arg(args, nargs, 1);
     type = value->type;
 
-    if (njs_is_null_or_void(value)) {
+    if (njs_is_null_or_undefined(value)) {
 
         object = njs_object_alloc(vm);
         if (nxt_slow_path(object == NULL)) {
@@ -865,7 +867,7 @@ njs_object_keys(njs_vm_t *vm, njs_value_
 
     value = njs_arg(args, nargs, 1);
 
-    if (njs_is_null_or_void(value)) {
+    if (njs_is_null_or_undefined(value)) {
         njs_type_error(vm, "cannot convert %s argument to object",
                        njs_type_string(value->type));
 
@@ -894,7 +896,7 @@ njs_object_values(njs_vm_t *vm, njs_valu
 
     value = njs_arg(args, nargs, 1);
 
-    if (njs_is_null_or_void(value)) {
+    if (njs_is_null_or_undefined(value)) {
         njs_type_error(vm, "cannot convert %s argument to object",
                        njs_type_string(value->type));
 
@@ -923,7 +925,7 @@ njs_object_entries(njs_vm_t *vm, njs_val
 
     value = njs_arg(args, nargs, 1);
 
-    if (njs_is_null_or_void(value)) {
+    if (njs_is_null_or_undefined(value)) {
         njs_type_error(vm, "cannot convert %s argument to object",
                        njs_type_string(value->type));
 
@@ -1366,7 +1368,7 @@ njs_descriptor_prop(njs_vm_t *vm, const 
     njs_object_prop_t   *prop, *pr;
     nxt_lvlhsh_query_t  pq;
 
-    value = unset ? &njs_value_invalid : &njs_value_void;
+    value = unset ? &njs_value_invalid : &njs_value_undefined;
     prop = njs_object_prop_alloc(vm, name, value, 0);
     if (nxt_slow_path(prop == NULL)) {
         return NULL;
@@ -1465,7 +1467,7 @@ njs_define_property(njs_vm_t *vm, njs_va
         if (njs_is_valid(&desc->value)) {
             *current->value.data.u.value = desc->value;
         } else {
-            *current->value.data.u.value = njs_value_void;
+            *current->value.data.u.value = njs_value_undefined;
         }
 
         return NXT_OK;
@@ -1563,7 +1565,7 @@ njs_object_get_own_property_descriptor(n
 
     value = njs_arg(args, nargs, 1);
 
-    if (njs_is_null_or_void(value)) {
+    if (njs_is_null_or_undefined(value)) {
         njs_type_error(vm, "cannot convert %s argument to object",
                        njs_type_string(value->type));
         return NXT_ERROR;
@@ -1580,7 +1582,7 @@ njs_object_get_own_property_descriptor(n
         break;
 
     case NXT_DECLINED:
-        vm->retval = njs_value_void;
+        vm->retval = njs_value_undefined;
         return NXT_OK;
 
     case NJS_TRAP:
@@ -1747,7 +1749,7 @@ njs_object_freeze(njs_vm_t *vm, njs_valu
     value = njs_arg(args, nargs, 1);
 
     if (!njs_is_object(value)) {
-        vm->retval = njs_value_void;
+        vm->retval = njs_value_undefined;
         return NXT_OK;
     }
 
@@ -2015,7 +2017,7 @@ njs_object_prototype_create(njs_vm_t *vm
     }
 
     if (proto == NULL) {
-        proto = &njs_value_void;
+        proto = &njs_value_undefined;
     }
 
     *retval = *proto;
@@ -2032,9 +2034,9 @@ njs_property_prototype_create(njs_vm_t *
     njs_object_prop_t          *prop;
     nxt_lvlhsh_query_t         lhq;
 
-    static const njs_value_t   prototype_string = njs_string("prototype");
-
-    prop = njs_object_prop_alloc(vm, &prototype_string, &njs_value_void, 0);
+    static const njs_value_t   proto_string = njs_string("prototype");
+
+    prop = njs_object_prop_alloc(vm, &proto_string, &njs_value_undefined, 0);
     if (nxt_slow_path(prop == NULL)) {
         return NULL;
     }
@@ -2428,7 +2430,7 @@ njs_object_prototype_has_own_property(nj
 
     value = njs_arg(args, nargs, 0);
 
-    if (njs_is_null_or_void(value)) {
+    if (njs_is_null_or_undefined(value)) {
         njs_type_error(vm, "cannot convert %s argument to object",
                        njs_type_string(value->type));
         return NXT_ERROR;
@@ -2468,7 +2470,7 @@ njs_object_prototype_prop_is_enumerable(
 
     value = njs_arg(args, nargs, 0);
 
-    if (njs_is_null_or_void(value)) {
+    if (njs_is_null_or_undefined(value)) {
         njs_type_error(vm, "cannot convert %s argument to object",
                        njs_type_string(value->type));
         return NXT_ERROR;
diff -r 2037b3ccd677 -r e9fd5b21f08d njs/njs_parser.c
--- a/njs/njs_parser.c	Mon Mar 18 19:20:02 2019 +0300
+++ b/njs/njs_parser.c	Tue Mar 19 16:02:07 2019 +0300
@@ -2128,7 +2128,7 @@ njs_parser_reference(njs_vm_t *vm, njs_p
     case NJS_TOKEN_UNDEFINED:
         nxt_thread_log_debug("JS: undefined");
 
-        node->u.value = njs_value_void;
+        node->u.value = njs_value_undefined;
         break;
 
     case NJS_TOKEN_THIS:
diff -r 2037b3ccd677 -r e9fd5b21f08d njs/njs_regexp.c
--- a/njs/njs_regexp.c	Mon Mar 18 19:20:02 2019 +0300
+++ b/njs/njs_regexp.c	Tue Mar 19 16:02:07 2019 +0300
@@ -589,7 +589,7 @@ njs_regexp_prototype_test(njs_vm_t *vm, 
         value = &args[1];
 
     } else {
-        value = (njs_value_t *) &njs_string_void;
+        value = (njs_value_t *) &njs_string_undefined;
     }
 
     (void) njs_string_prop(&string, value);
@@ -637,7 +637,7 @@ njs_regexp_prototype_exec(njs_vm_t *vm, 
         value = &args[1];
 
     } else {
-        value = (njs_value_t *) &njs_string_void;
+        value = (njs_value_t *) &njs_string_undefined;
     }
 
     regexp = args[0].data.u.regexp;
@@ -706,8 +706,8 @@ njs_regexp_exec_result(njs_vm_t *vm, njs
     njs_object_prop_t   *prop;
     nxt_lvlhsh_query_t  lhq;
 
-    static const njs_value_t  njs_string_index = njs_string("index");
-    static const njs_value_t  njs_string_input = njs_string("input");
+    static const njs_value_t  string_index = njs_string("index");
+    static const njs_value_t  string_input = njs_string("input");
 
     array = njs_array_alloc(vm, regexp->pattern->ncaptures, 0);
     if (nxt_slow_path(array == NULL)) {
@@ -732,11 +732,11 @@ njs_regexp_exec_result(njs_vm_t *vm, njs
             }
 
         } else {
-            array->start[i] = njs_value_void;
+            array->start[i] = njs_value_undefined;
         }
     }
 
-    prop = njs_object_prop_alloc(vm, &njs_string_index, &njs_value_void, 1);
+    prop = njs_object_prop_alloc(vm, &string_index, &njs_value_undefined, 1);
     if (nxt_slow_path(prop == NULL)) {
         goto fail;
     }
@@ -762,7 +762,7 @@ njs_regexp_exec_result(njs_vm_t *vm, njs
         goto fail;
     }
 
-    prop = njs_object_prop_alloc(vm, &njs_string_input, &regexp->string, 1);
+    prop = njs_object_prop_alloc(vm, &string_input, &regexp->string, 1);
     if (nxt_slow_path(prop == NULL)) {
         goto fail;
     }
diff -r 2037b3ccd677 -r e9fd5b21f08d njs/njs_shell.c
--- a/njs/njs_shell.c	Mon Mar 18 19:20:02 2019 +0300
+++ b/njs/njs_shell.c	Tue Mar 19 16:02:07 2019 +0300
@@ -847,7 +847,7 @@ njs_ext_console_log(njs_vm_t *vm, njs_va
         printf("\n");
     }
 
-    vm->retval = njs_value_void;
+    vm->retval = njs_value_undefined;
 
     return NJS_OK;
 }
@@ -878,7 +878,7 @@ njs_ext_console_dump(njs_vm_t *vm, njs_v
         printf("\n");
     }
 
-    vm->retval = njs_value_void;
+    vm->retval = njs_value_undefined;
 
     return NJS_OK;
 }
@@ -909,7 +909,7 @@ njs_ext_console_help(njs_vm_t *vm, njs_v
 
     printf("\n");
 
-    vm->retval = njs_value_void;
+    vm->retval = njs_value_undefined;
 
     return NJS_OK;
 }
@@ -921,7 +921,7 @@ njs_ext_console_time(njs_vm_t *vm, njs_v
 {
     njs_console_t  *console;
 
-    if (!njs_value_is_void(njs_arg(args, nargs, 1))) {
+    if (!njs_value_is_undefined(njs_arg(args, nargs, 1))) {
         njs_vm_error(vm, "labels not implemented");
         return NJS_ERROR;
     }
@@ -933,7 +933,7 @@ njs_ext_console_time(njs_vm_t *vm, njs_v
 
     console->time = nxt_time();
 
-    vm->retval = njs_value_void;
+    vm->retval = njs_value_undefined;
 
     return NJS_OK;
 }
@@ -948,7 +948,7 @@ njs_ext_console_time_end(njs_vm_t *vm, n
 
     ns = nxt_time();
 
-    if (!njs_value_is_void(njs_arg(args, nargs, 1))) {
+    if (!njs_value_is_undefined(njs_arg(args, nargs, 1))) {
         njs_vm_error(vm, "labels not implemented");
         return NJS_ERROR;
     }
@@ -973,7 +973,7 @@ njs_ext_console_time_end(njs_vm_t *vm, n
         printf("Timer \"default\" doesn’t exist.\n");
     }
 
-    vm->retval = njs_value_void;
+    vm->retval = njs_value_undefined;
 
     return NJS_OK;
 }
diff -r 2037b3ccd677 -r e9fd5b21f08d njs/njs_string.c
--- a/njs/njs_string.c	Mon Mar 18 19:20:02 2019 +0300
+++ b/njs/njs_string.c	Tue Mar 19 16:02:07 2019 +0300
@@ -829,7 +829,7 @@ njs_string_prototype_concat(njs_vm_t *vm
     nxt_uint_t         i;
     njs_string_prop_t  string;
 
-    if (njs_is_null_or_void(&args[0])) {
+    if (njs_is_null_or_undefined(&args[0])) {
         njs_type_error(vm, "\"this\" argument is null or undefined");
         return NXT_ERROR;
     }
@@ -1249,7 +1249,7 @@ njs_string_slice_args(njs_slice_prop_t *
         length = 0;
 
     } else {
-        if (!njs_is_void(njs_arg(args, nargs, 2))) {
+        if (!njs_is_undefined(njs_arg(args, nargs, 2))) {
             value = njs_arg(args, nargs, 2);
             end = value->data.u.number;
 
@@ -2540,7 +2540,7 @@ njs_string_prototype_search(njs_vm_t *vm
 
             goto done;
 
-        case NJS_VOID:
+        case NJS_UNDEFINED:
         default:
             goto done;
         }
@@ -2860,7 +2860,7 @@ found:
 
             goto done;
 
-        case NJS_VOID:
+        case NJS_UNDEFINED:
         default:
             break;
         }
@@ -2958,7 +2958,7 @@ njs_string_prototype_replace(njs_vm_t *v
     /* A literal replacement is stored in the second part. */
 
     if (nargs == 2) {
-        njs_string_replacement_copy(&r->part[1], &njs_string_void);
+        njs_string_replacement_copy(&r->part[1], &njs_string_undefined);
 
     } else if (njs_is_string(&args[2])) {
         njs_string_replacement_copy(&r->part[1], &args[2]);
@@ -3122,7 +3122,7 @@ njs_string_replace_regexp_function(njs_v
         return NXT_ERROR;
     }
 
-    arguments[0] = njs_value_void;
+    arguments[0] = njs_value_undefined;
 
     /* Matched substring and parenthesized submatch strings. */
     for (k = 0, i = 1; i <= n; i++) {
@@ -3261,7 +3261,7 @@ njs_string_replace_search_function(njs_v
 
     r->u.cont.function = njs_string_replace_search_continuation;
 
-    arguments[0] = njs_value_void;
+    arguments[0] = njs_value_undefined;
 
     /* GC, args[0], args[1] */
 
@@ -3560,8 +3560,8 @@ njs_primitive_value_to_string(njs_vm_t *
         value = &njs_string_null;
         break;
 
-    case NJS_VOID:
-        value = &njs_string_void;
+    case NJS_UNDEFINED:
+        value = &njs_string_undefined;
         break;
 
     case NJS_BOOLEAN:
@@ -4003,7 +4003,7 @@ njs_string_encode_uri(njs_vm_t *vm, njs_
         return njs_string_encode(vm, &args[1], escape);
     }
 
-    vm->retval = njs_string_void;
+    vm->retval = njs_string_undefined;
 
     return NXT_OK;
 }
@@ -4039,7 +4039,7 @@ njs_string_encode_uri_component(njs_vm_t
         return njs_string_encode(vm, &args[1], escape);
     }
 
-    vm->retval = njs_string_void;
+    vm->retval = njs_string_undefined;
 
     return NXT_OK;
 }
@@ -4134,7 +4134,7 @@ njs_string_decode_uri(njs_vm_t *vm, njs_
         return njs_string_decode(vm, &args[1], reserve);
     }
 
-    vm->retval = njs_string_void;
+    vm->retval = njs_string_undefined;
 
     return NXT_OK;
 }
@@ -4170,7 +4170,7 @@ njs_string_decode_uri_component(njs_vm_t
         return njs_string_decode(vm, &args[1], reserve);
     }
 
-    vm->retval = njs_string_void;
+    vm->retval = njs_string_undefined;
 
     return NXT_OK;
 }
diff -r 2037b3ccd677 -r e9fd5b21f08d njs/njs_time.c
--- a/njs/njs_time.c	Mon Mar 18 19:20:02 2019 +0300
+++ b/njs/njs_time.c	Tue Mar 19 16:02:07 2019 +0300
@@ -106,7 +106,7 @@ njs_clear_timeout(njs_vm_t *vm, njs_valu
     nxt_lvlhsh_query_t  lhq;
 
     if (nxt_fast_path(nargs < 2) || !njs_is_number(&args[1])) {
-        vm->retval = njs_value_void;
+        vm->retval = njs_value_undefined;
         return NJS_OK;
     }
 
@@ -125,7 +125,7 @@ njs_clear_timeout(njs_vm_t *vm, njs_valu
         njs_del_event(vm, event, NJS_EVENT_RELEASE | NJS_EVENT_DELETE);
     }
 
-    vm->retval = njs_value_void;
+    vm->retval = njs_value_undefined;
 
     return NJS_OK;
 }
diff -r 2037b3ccd677 -r e9fd5b21f08d njs/njs_variable.c
--- a/njs/njs_variable.c	Mon Mar 18 19:20:02 2019 +0300
+++ b/njs/njs_variable.c	Tue Mar 19 16:02:07 2019 +0300
@@ -397,7 +397,8 @@ njs_variable_resolve(njs_vm_t *vm, njs_p
         goto not_found;
     }
 
-    default_value = njs_is_object(&var->value) ? &var->value : &njs_value_void;
+    default_value = njs_is_object(&var->value) ? &var->value :
+                                                 &njs_value_undefined;
 
     index = njs_scope_next_index(vm, vr->scope, scope_index, default_value);
 
diff -r 2037b3ccd677 -r e9fd5b21f08d njs/njs_vm.c
--- a/njs/njs_vm.c	Mon Mar 18 19:20:02 2019 +0300
+++ b/njs/njs_vm.c	Tue Mar 19 16:02:07 2019 +0300
@@ -66,7 +66,7 @@ void njs_debug(njs_index_t index, njs_va
 
 
 const njs_value_t  njs_value_null =         njs_value(NJS_NULL, 0, 0.0);
-const njs_value_t  njs_value_void =         njs_value(NJS_VOID, 0, NAN);
+const njs_value_t  njs_value_undefined =    njs_value(NJS_UNDEFINED, 0, NAN);
 const njs_value_t  njs_value_false =        njs_value(NJS_BOOLEAN, 0, 0.0);
 const njs_value_t  njs_value_true =         njs_value(NJS_BOOLEAN, 1, 1.0);
 const njs_value_t  njs_value_zero =         njs_value(NJS_NUMBER, 0, 0.0);
@@ -77,7 +77,7 @@ const njs_value_t  njs_value_invalid =  
 const njs_value_t  njs_string_empty =       njs_string("");
 const njs_value_t  njs_string_comma =       njs_string(",");
 const njs_value_t  njs_string_null =        njs_string("null");
-const njs_value_t  njs_string_void =        njs_string("undefined");
+const njs_value_t  njs_string_undefined =   njs_string("undefined");
 const njs_value_t  njs_string_boolean =     njs_string("boolean");
 const njs_value_t  njs_string_false =       njs_string("false");
 const njs_value_t  njs_string_true =        njs_string("true");
@@ -591,7 +591,7 @@ njs_vmcode_property_set(njs_vm_t *vm, nj
             }
         }
 
-        prop = njs_object_prop_alloc(vm, &pq.value, &njs_value_void, 1);
+        prop = njs_object_prop_alloc(vm, &pq.value, &njs_value_undefined, 1);
         if (nxt_slow_path(prop == NULL)) {
             return NXT_ERROR;
         }
@@ -897,7 +897,7 @@ njs_vmcode_instance_of(njs_vm_t *vm, njs
     retval = &njs_value_false;
 
     if (njs_is_object(object)) {
-        value = njs_value_void;
+        value = njs_value_undefined;
         ret = njs_value_property(vm, constructor, &prototype_string, &value);
 
         if (nxt_fast_path(ret == NXT_OK)) {
@@ -1026,21 +1026,21 @@ njs_vmcode_typeof(njs_vm_t *vm, njs_valu
 
     static const njs_value_t  *types[NJS_TYPE_MAX] = {
         &njs_string_object,
-        &njs_string_void,
+        &njs_string_undefined,
         &njs_string_boolean,
         &njs_string_number,
         &njs_string_string,
-        &njs_string_void,
-        &njs_string_void,
-        &njs_string_void,
-        &njs_string_void,
-        &njs_string_void,
-        &njs_string_void,
-        &njs_string_void,
-        &njs_string_void,
-        &njs_string_void,
-        &njs_string_void,
-        &njs_string_void,
+        &njs_string_undefined,
+        &njs_string_undefined,
+        &njs_string_undefined,
+        &njs_string_undefined,
+        &njs_string_undefined,
+        &njs_string_undefined,
+        &njs_string_undefined,
+        &njs_string_undefined,
+        &njs_string_undefined,
+        &njs_string_undefined,
+        &njs_string_undefined,
 
         &njs_string_object,
         &njs_string_object,
@@ -1062,7 +1062,7 @@ njs_vmcode_typeof(njs_vm_t *vm, njs_valu
     };
 
     /* A zero index means non-declared variable. */
-    type = (value != NULL) ? value->type : NJS_VOID;
+    type = (value != NULL) ? value->type : NJS_UNDEFINED;
 
     vm->retval = *types[type];
 
@@ -1073,7 +1073,7 @@ njs_vmcode_typeof(njs_vm_t *vm, njs_valu
 njs_ret_t
 njs_vmcode_void(njs_vm_t *vm, njs_value_t *invld1, njs_value_t *invld2)
 {
-    vm->retval = njs_value_void;
+    vm->retval = njs_value_undefined;
 
     return sizeof(njs_vmcode_2addr_t);
 }


More information about the nginx-devel mailing list