]> git.kaiwu.me - njs.git/commitdiff
Style and small miscellaneous fixes.
authorIgor Sysoev <igor@sysoev.ru>
Sun, 27 Dec 2015 12:26:04 +0000 (15:26 +0300)
committerIgor Sysoev <igor@sysoev.ru>
Sun, 27 Dec 2015 12:26:04 +0000 (15:26 +0300)
njs/njs_function.h
njs/njs_generator.c
njs/njs_vm.c
njs/test/njs_unit_test.c

index f30848bde22405f47ee3d4e3e77f5f89786e1944..1575bddd718367078ed21eb21ea43992e73af71a 100644 (file)
@@ -30,7 +30,7 @@ struct njs_function_lambda_s {
 #define NJS_FRAME_SIZE                                                        \
     nxt_align_size(sizeof(njs_frame_t), sizeof(njs_value_t))
 
-/* The retval and return_address fields are not used in the global frame. */
+/* The retval field are not used in the global frame. */
 #define NJS_GLOBAL_FRAME_SIZE                                                 \
     nxt_align_size(offsetof(njs_frame_t, retval), sizeof(njs_value_t))
 
index f40e493f97ec21d44951ce61cea005b745ffe9d2..25992f8f1cede2adff9594e97165b8e73b16deb2 100644 (file)
@@ -567,7 +567,7 @@ njs_generate_switch_statement(njs_vm_t *vm, njs_parser_t *parser,
             }
 
             patch = nxt_mem_cache_alloc(vm->mem_cache_pool,
-                                         sizeof(njs_parser_patch_t));
+                                        sizeof(njs_parser_patch_t));
             if (nxt_slow_path(patch == NULL)) {
                 return NXT_ERROR;
             }
index 27b781cd505f286f3442ebc0c14fcbf59af810a0..568dc9dd7b44ba66dfd6c6f5bf6046777d69d8f8 100644 (file)
@@ -2279,10 +2279,10 @@ njs_vmcode_function_call(njs_vm_t *vm, njs_value_t *invld, njs_value_t *retval)
         vm->scopes[NJS_SCOPE_CALLEE_ARGUMENTS] = vm->frame->arguments;
 
         retval = njs_vmcode_operand(vm, retval);
-         /*
-          * GC: value external/internal++ depending
-          * on vm->retval and retval type
-          */
+        /*
+         * GC: value external/internal++ depending
+         * on vm->retval and retval type
+         */
         *retval = vm->retval;
 
     } else if (ret == NJS_APPLIED) {
@@ -2496,7 +2496,7 @@ njs_vmcode_finally(njs_vm_t *vm, njs_value_t *invld, njs_value_t *retval)
 }
 
 
-njs_ret_t
+static njs_ret_t
 njs_vmcode_number_primitive(njs_vm_t *vm, njs_value_t *invld, njs_value_t *narg)
 {
     double       num;
@@ -2527,7 +2527,7 @@ njs_vmcode_number_primitive(njs_vm_t *vm, njs_value_t *invld, njs_value_t *narg)
 }
 
 
-njs_ret_t
+static njs_ret_t
 njs_vmcode_string_primitive(njs_vm_t *vm, njs_value_t *invld, njs_value_t *narg)
 {
     njs_ret_t          ret;
@@ -2713,10 +2713,10 @@ static const njs_vmcode_1addr_t  njs_trap_number[] = {
 
 static const njs_vm_trap_t  njs_vm_traps[] = {
     /* NJS_TRAP_PROPERTY */  { &njs_trap_strings[1], 0 },
-    /* NJS_TRAP_STRINGS */   { &njs_trap_strings[0], 0 },
-    /* NJS_TRAP_INCDEC */    { &njs_trap_numbers[1], 1 },
-    /* NJS_TRAP_NUMBERS */   { &njs_trap_numbers[0], 0 },
-    /* NJS_TRAP_NUMBER */    { &njs_trap_number[0],  0 },
+    /* NJS_TRAP_STRINGS  */  { &njs_trap_strings[0], 0 },
+    /* NJS_TRAP_INCDEC   */  { &njs_trap_numbers[1], 1 },
+    /* NJS_TRAP_NUMBERS  */  { &njs_trap_numbers[0], 0 },
+    /* NJS_TRAP_NUMBER   */  { &njs_trap_number[0],  0 },
 };
 
 
index 9371557e5288071a12be9251817939351922420b..3cfb91e0620a171ad5b9ef4fa7636c19c8ecf6b5 100644 (file)
@@ -2689,11 +2689,20 @@ static njs_unit_test_t  njs_test[] =
     { nxt_string("a = (function(a) { return a + 1 }(2)); a"),
       nxt_string("3") },
 
+    { nxt_string("a = +function(a) { return a + 1 }(2); a"),
+      nxt_string("3") },
+
+    { nxt_string("a = -function(a) { return a + 1 }(2); a"),
+      nxt_string("-3") },
+
     { nxt_string("a = !function(a) { return a + 1 }(2); a"),
       nxt_string("false") },
 
-    { nxt_string("a = +function(a) { return a + 1 }(2); a"),
-      nxt_string("3") },
+    { nxt_string("a = ~function(a) { return a + 1 }(2); a"),
+      nxt_string("-4") },
+
+    { nxt_string("a = void function(a) { return a + 1 }(2); a"),
+      nxt_string("undefined") },
 
     { nxt_string("a = true && function(a) { return a + 1 }(2); a"),
       nxt_string("3") },