diff --git a/nasal.h b/nasal.h index 30ac547..0c2ebfd 100644 --- a/nasal.h +++ b/nasal.h @@ -50,7 +50,7 @@ using usize=std::size_t; using f64=double; using std::string; -const u32 STACK_DEPTH=2048; +const u32 STACK_DEPTH=1024; inline f64 hex_to_double(const char* str) { diff --git a/nasal_vm.h b/nasal_vm.h index 67a0a67..3d2a183 100644 --- a/nasal_vm.h +++ b/nasal_vm.h @@ -203,14 +203,12 @@ void nasal_vm::bytecodeinfo(const char* header,const u32 p) } void nasal_vm::traceback() { - const u32 global_size=bytecode[0].num; // bytecode[0] is op_intg - nas_ref* t=top; - nas_ref* bottom=stack+global_size; + nas_ref* bottom=stack+bytecode[0].num; // bytecode[0] is op_intg std::stack ret; - for(nas_ref* i=bottom;i<=t;++i) + for(nas_ref* i=bottom;i<=top;++i) if(i->type==vm_ret) ret.push(i->ret()); - // push pc to ret stack to store the position program crashed + // push pc to stack to store the position program crashed ret.push(pc); std::cout<<"trace back:\n"; u32 same=0,last=0xffffffff; @@ -222,14 +220,13 @@ void nasal_vm::traceback() continue; } if(same) - std::cout<<" 0x"<