Skip to content

Commit

Permalink
Added njs_cnst.[ch]
Browse files Browse the repository at this point in the history
Introduced vm->shared->cnst_hash, populated by
njs_value_t for all predefined strings.
  • Loading branch information
VadimZhestikov committed Sep 23, 2024
1 parent d40d238 commit 3089c10
Show file tree
Hide file tree
Showing 7 changed files with 1,211 additions and 2 deletions.
1 change: 1 addition & 0 deletions auto/sources
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ NJS_LIB_SRCS=" \
src/njs_utils.c \
src/njs_chb.c \
src/njs_value.c \
src/njs_cnst.c \
src/njs_vm.c \
src/njs_vmcode.c \
src/njs_lexer.c \
Expand Down
10 changes: 10 additions & 0 deletions src/njs_builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ njs_builtin_objects_create(njs_vm_t *vm)
njs_object_prototype_t *prototype;
const njs_object_init_t *obj, **p;


shared = njs_mp_zalloc(vm->mem_pool, sizeof(njs_vm_shared_t));
if (njs_slow_path(shared == NULL)) {
return NJS_ERROR;
Expand All @@ -129,6 +130,15 @@ njs_builtin_objects_create(njs_vm_t *vm)
njs_lvlhsh_init(&shared->keywords_hash);
njs_lvlhsh_init(&shared->values_hash);


if (njs_cnst_hash_predefined.descr.elts_count == 0) {
ret = njs_cnst_hash_init(&shared->cnst_hash);
if (njs_slow_path(ret != NJS_OK)) {
return NJS_ERROR;
}
}


pattern = njs_regexp_pattern_create(vm, (u_char *) "(?:)",
njs_length("(?:)"), 0);
if (njs_slow_path(pattern == NULL)) {
Expand Down
Loading

0 comments on commit 3089c10

Please sign in to comment.