Welcome! Log In Create A New Profile

Advanced

[njs] Printing AST before trying to generate code.

Dmitry Volyntsev
June 18, 2021 11:08AM
details: https://hg.nginx.org/njs/rev/d66e00e55b96
branches:
changeset: 1664:d66e00e55b96
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Fri Jun 18 15:01:12 2021 +0000
description:
Printing AST before trying to generate code.

diffstat:

src/njs_vm.c | 34 +++++++++++++++++-----------------
1 files changed, 17 insertions(+), 17 deletions(-)

diffs (51 lines):

diff -r 8d4bf6ec4002 -r d66e00e55b96 src/njs_vm.c
--- a/src/njs_vm.c Fri Jun 18 15:00:32 2021 +0000
+++ b/src/njs_vm.c Fri Jun 18 15:01:12 2021 +0000
@@ -150,6 +150,23 @@ njs_vm_compile(njs_vm_t *vm, u_char **st
return NJS_ERROR;
}

+ if (njs_slow_path(vm->options.ast)) {
+ njs_chb_init(&chain, vm->mem_pool);
+ ret = njs_parser_serialize_ast(parser.node, &chain);
+ if (njs_slow_path(ret == NJS_ERROR)) {
+ return ret;
+ }
+
+ if (njs_slow_path(njs_chb_join(&chain, &ast) != NJS_OK)) {
+ return NJS_ERROR;
+ }
+
+ njs_print(ast.start, ast.length);
+
+ njs_chb_destroy(&chain);
+ njs_mp_free(vm->mem_pool, ast.start);
+ }
+
*start = lexer.start;
scope = parser.scope;

@@ -209,23 +226,6 @@ njs_vm_compile(njs_vm_t *vm, u_char **st
njs_disassembler(vm);
}

- if (njs_slow_path(vm->options.ast)) {
- njs_chb_init(&chain, vm->mem_pool);
- ret = njs_parser_serialize_ast(parser.node, &chain);
- if (njs_slow_path(ret == NJS_ERROR)) {
- return ret;
- }
-
- if (njs_slow_path(njs_chb_join(&chain, &ast) != NJS_OK)) {
- return NJS_ERROR;
- }
-
- njs_print(ast.start, ast.length);
-
- njs_chb_destroy(&chain);
- njs_mp_free(vm->mem_pool, ast.start);
- }
-
return NJS_OK;
}

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

[njs] Printing AST before trying to generate code.

Dmitry Volyntsev 106 June 18, 2021 11:08AM



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

Online Users

Guests: 67
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready