njs_variable_t *var;
njs_parser_scope_t *scope;
- scope = parser->scope;
-
- while (scope->type != NJS_SCOPE_GLOBAL) {
- scope = scope->parent;
- }
+ scope = njs_parser_global_scope(vm);
var = njs_variable_add(vm, scope, name, hash, NJS_VARIABLE_VAR);
if (nxt_slow_path(var == NULL)) {
}
+nxt_inline njs_parser_scope_t *
+njs_parser_global_scope(njs_vm_t *vm)
+{
+ njs_parser_scope_t *scope;
+
+ scope = vm->parser->scope;
+
+ while (scope->type != NJS_SCOPE_GLOBAL) {
+ scope = scope->parent;
+ }
+
+ return scope;
+}
+
+
extern const nxt_lvlhsh_proto_t njs_keyword_hash_proto;
njs_parser_scope_t *node_scope)
{
nxt_lvlhsh_query_t lhq;
- njs_parser_scope_t *scope, *parent, *previous;
+ njs_parser_scope_t *scope, *previous;
lhq.key_hash = vr->hash;
lhq.key = vr->name;
return NXT_OK;
}
- parent = scope->parent;
-
- if (parent == NULL) {
+ if (scope->parent == NULL) {
/* A global scope. */
vr->scope = scope;
}
previous = scope;
- scope = parent;
+ scope = scope->parent;
}
}