Welcome! Log In Create A New Profile

Advanced

[njs] Fixed vmcode function call.

Dmitry Volyntsev
January 09, 2019 10:24AM
details: https://hg.nginx.org/njs/rev/d0ba2a63eb5a
branches:
changeset: 714:d0ba2a63eb5a
user: hongzhidao <hongzhidao@gmail.com>
date: Mon Jan 07 17:40:48 2019 +0800
description:
Fixed vmcode function call.

This closes #82 issue on Github.

diffstat:

njs/njs_vm.c | 10 ++++++++--
njs/test/njs_unit_test.c | 3 +++
2 files changed, 11 insertions(+), 2 deletions(-)

diffs (33 lines):

diff -r fd135f1b18bb -r d0ba2a63eb5a njs/njs_vm.c
--- a/njs/njs_vm.c Wed Jan 09 18:21:31 2019 +0300
+++ b/njs/njs_vm.c Mon Jan 07 17:40:48 2019 +0800
@@ -2086,8 +2086,14 @@ njs_vmcode_function_call(njs_vm_t *vm, n
* If a retval is in a callee arguments scope it
* must be in the previous callee arguments scope.
*/
- vm->scopes[NJS_SCOPE_CALLEE_ARGUMENTS] =
- vm->top_frame->arguments + function->args_offset;
+ args = vm->top_frame->arguments;
+ function = vm->top_frame->function;
+
+ if (function != NULL) {
+ args += function->args_offset;
+ }
+
+ vm->scopes[NJS_SCOPE_CALLEE_ARGUMENTS] = args;

retval = njs_vmcode_operand(vm, retval);
/*
diff -r fd135f1b18bb -r d0ba2a63eb5a njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c Wed Jan 09 18:21:31 2019 +0300
+++ b/njs/test/njs_unit_test.c Mon Jan 07 17:40:48 2019 +0800
@@ -4017,6 +4017,9 @@ static njs_unit_test_t njs_test[] =
{ nxt_string("var f = ''.concat.bind(0, 1, 2, 3, 4); f(5, 6, 7, 8, 9)"),
nxt_string("0123456789") },

+ { nxt_string("var f = ''.concat.bind(0, 1, 2, 3, 4); f(Math.sqrt(25))"),
+ nxt_string("012345") },
+
{ nxt_string("var f = String.prototype.concat.bind(0, 1); f(2)"),
nxt_string("012") },

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

[njs] Fixed vmcode function call.

Dmitry Volyntsev 301 January 09, 2019 10:24AM



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

Online Users

Guests: 145
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