[njs] Added njs_vm_retval_dump().
Dmitry Volyntsev
xeioex at nginx.com
Wed Nov 7 15:41:48 UTC 2018
details: http://hg.nginx.org/njs/rev/f5ba2d1d3752
branches:
changeset: 641:f5ba2d1d3752
user: Dmitry Volyntsev <xeioex at nginx.com>
date: Wed Nov 07 18:41:28 2018 +0300
description:
Added njs_vm_retval_dump().
diffstat:
njs/njs.c | 18 ++++++++++++++++--
njs/njs.h | 10 ++++++----
njs/njs_shell.c | 2 +-
3 files changed, 23 insertions(+), 7 deletions(-)
diffs (74 lines):
diff -r f174a6ad9c3c -r f5ba2d1d3752 njs/njs.c
--- a/njs/njs.c Wed Nov 07 18:41:25 2018 +0300
+++ b/njs/njs.c Wed Nov 07 18:41:28 2018 +0300
@@ -671,7 +671,8 @@ njs_vm_memory_error(njs_vm_t *vm)
}
-njs_ret_t njs_vm_retval_to_ext_string(njs_vm_t *vm, nxt_str_t *retval)
+njs_ret_t
+njs_vm_retval_to_ext_string(njs_vm_t *vm, nxt_str_t *dst)
{
if (vm->top_frame == NULL) {
/* An exception was thrown during compilation. */
@@ -679,7 +680,20 @@ njs_ret_t njs_vm_retval_to_ext_string(nj
njs_vm_init(vm);
}
- return njs_vm_value_to_ext_string(vm, retval, &vm->retval, 1);
+ return njs_vm_value_to_ext_string(vm, dst, &vm->retval, 1);
+}
+
+
+njs_ret_t
+njs_vm_retval_dump(njs_vm_t *vm, nxt_str_t *dst, nxt_uint_t indent)
+{
+ if (vm->top_frame == NULL) {
+ /* An exception was thrown during compilation. */
+
+ njs_vm_init(vm);
+ }
+
+ return njs_vm_value_dump(vm, dst, &vm->retval, 1);
}
diff -r f174a6ad9c3c -r f5ba2d1d3752 njs/njs.h
--- a/njs/njs.h Wed Nov 07 18:41:25 2018 +0300
+++ b/njs/njs.h Wed Nov 07 18:41:28 2018 +0300
@@ -200,8 +200,12 @@ NXT_EXPORT nxt_int_t njs_value_string_co
NXT_EXPORT njs_ret_t njs_vm_value_to_ext_string(njs_vm_t *vm, nxt_str_t *dst,
const njs_value_t *src, nxt_uint_t handle_exception);
-NXT_EXPORT njs_ret_t njs_vm_retval_to_ext_string(njs_vm_t *vm,
- nxt_str_t *retval);
+NXT_EXPORT njs_ret_t njs_vm_retval_to_ext_string(njs_vm_t *vm, nxt_str_t *dst);
+
+NXT_EXPORT njs_ret_t njs_vm_value_dump(njs_vm_t *vm, nxt_str_t *dst,
+ const njs_value_t *value, nxt_uint_t indent);
+NXT_EXPORT njs_ret_t njs_vm_retval_dump(njs_vm_t *vm, nxt_str_t *dst,
+ nxt_uint_t indent);
NXT_EXPORT void njs_vm_memory_error(njs_vm_t *vm);
@@ -226,8 +230,6 @@ NXT_EXPORT nxt_int_t njs_value_is_string
NXT_EXPORT nxt_int_t njs_value_is_object(const njs_value_t *value);
NXT_EXPORT nxt_int_t njs_value_is_function(const njs_value_t *value);
-NXT_EXPORT njs_ret_t njs_vm_value_dump(njs_vm_t *vm, nxt_str_t *retval,
- const njs_value_t *value, nxt_uint_t indent);
NXT_EXPORT njs_ret_t njs_vm_object_alloc(njs_vm_t *vm, njs_value_t *retval,
...);
NXT_EXPORT njs_value_t *njs_vm_object_prop(njs_vm_t *vm,
diff -r f174a6ad9c3c -r f5ba2d1d3752 njs/njs_shell.c
--- a/njs/njs_shell.c Wed Nov 07 18:41:25 2018 +0300
+++ b/njs/njs_shell.c Wed Nov 07 18:41:28 2018 +0300
@@ -452,7 +452,7 @@ njs_process_script(njs_vm_t *vm, njs_opt
ret = njs_vm_run(vm);
}
- if (njs_vm_value_dump(vm, out, njs_vm_retval(vm), 1) != NXT_OK) {
+ if (njs_vm_retval_dump(vm, out, 1) != NXT_OK) {
*out = nxt_string_value("failed to get retval from VM");
return NXT_ERROR;
}
More information about the nginx-devel
mailing list