From ae5c76ecd5a4f1ff826c9cfaec0270c611b73b19 Mon Sep 17 00:00:00 2001 From: ValKmjolnir Date: Sun, 27 Aug 2023 00:25:49 +0800 Subject: [PATCH] :zap: maybe do not need o_intg anymore --- src/nasal_opcode.h | 2 +- src/nasal_vm.cpp | 12 ++++++------ src/nasal_vm.h | 5 +++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/nasal_opcode.h b/src/nasal_opcode.h index d7f93fc..2a4e4d5 100644 --- a/src/nasal_opcode.h +++ b/src/nasal_opcode.h @@ -7,7 +7,7 @@ enum op_code_type:u8 { op_exit, // stop the virtual machine - op_intg, // global scope size, set stack top + op_intg, // init global scope op_intl, // local scope size op_loadg, // load global value op_loadl, // load local value diff --git a/src/nasal_vm.cpp b/src/nasal_vm.cpp index 0bb57c0..caebcda 100644 --- a/src/nasal_vm.cpp +++ b/src/nasal_vm.cpp @@ -13,6 +13,7 @@ void vm::init( cstr = strs.data(); bytecode = code.data(); files = filenames.data(); + global_size = global_symbol.size(); /* set native functions */ native = natives; @@ -24,7 +25,7 @@ void vm::init( ctx.funcr = nil; ctx.upvalr = nil; ctx.canary = ctx.stack+STACK_DEPTH-1; // stack[STACK_DEPTH-1] - ctx.top = ctx.stack; + ctx.top = ctx.stack; // nothing is on stack /* clear main stack and global */ for(u32 i = 0; i=bottom; ++i, --top) { std::clog << " 0x" << std::hex << std::setw(6) << std::setfill('0') - << (u64)(top-ngc.rctx->stack) << std::dec + << (u64)(top-bottom) << std::dec << " "; valinfo(top[0]); } @@ -152,13 +153,12 @@ void vm::reginfo() { } void vm::gstate() { - // bytecode[0].op is op_intg - if (!bytecode[0].num || global[0].type==vm_none) { + if (!global_size || global[0].type==vm_none) { return; } std::clog << "global (0x" << std::hex << (u64)global << ")\n" << std::dec; - for(u32 i = 0; i