The vm->main_index was only needed for the disassembler in the
accumulative mode. It was used to prevent from disassembling the code
from the previous iterations in the CLI.
The same result can be achieved without introducing the VM level field.
njs_vm_code_t *code;
code = vm->codes->start;
- code += vm->main_index;
- n = vm->codes->items - vm->main_index;
+ n = vm->codes->items;
+
+ while (n != 0) {
+ if (code->start == vm->start) {
+ break;
+ }
+
+ code++;
+ n--;
+ }
while (n != 0) {
njs_printf("%V:%V\n", &code->file, &code->name);
return NJS_ERROR;
}
- vm->main_index = code - (njs_vm_code_t *) vm->codes->start;
vm->start = generator.code_start;
vm->global_scope = generator.local_scope;
vm->scope_size = generator.scope_size;
njs_object_t string_object;
njs_object_t global_object;
- njs_uint_t main_index;
njs_arr_t *codes; /* of njs_vm_code_t */
-
njs_arr_t *functions_name_cache;
njs_trace_t trace;