]> git.kaiwu.me - njs.git/commit
Decoupling parser structure from the main VM structure.
authorDmitry Volyntsev <xeioex@nginx.com>
Wed, 24 Feb 2021 14:48:20 +0000 (14:48 +0000)
committerDmitry Volyntsev <xeioex@nginx.com>
Wed, 24 Feb 2021 14:48:20 +0000 (14:48 +0000)
commitfbdfaa23b3a2a62757e85592b6090e8c88475ac6
tree0c2ae2f03f34edde921566f16cc5d45c9093d973
parent8761ae6e8593b30b88e580c5f038980daffb16e7
Decoupling parser structure from the main VM structure.

vm->parser is only needed during parsing phase, so it can be eliminated.
This improves dependencies tracking and readability.

As a side effect it fixes #372 issue on Github: previously, Function
constructor left VM context in inconsistent state if compilation failed.
The direct root cause was that a function object was created, but
because Function constructor ended prematurely the object was not fully
initialized. This is not a problem by itself because usually this
partially created object cannot be referenced. In the accumulative mode,
which is only enabled in CLI, vm->parser was used to store the references
to the variables from the previous iteration.
12 files changed:
src/njs_builtin.c
src/njs_function.c
src/njs_module.c
src/njs_parser.c
src/njs_parser.h
src/njs_regexp.c
src/njs_shell.c
src/njs_variable.c
src/njs_variable.h
src/njs_vm.c
src/njs_vm.h
src/test/njs_unit_test.c