diff --git a/main.cpp b/main.cpp index c2f791f..d5e3859 100644 --- a/main.cpp +++ b/main.cpp @@ -12,7 +12,7 @@ const uint32_t VM_OPTIMIZE =0x100; void help() { - std::cout + std::clog <<" ,--#-,\n" <<"<3 / \\____\\ <3\n" <<" |_|__A_|\n" @@ -47,7 +47,7 @@ void help() void logo() { - std::cout + std::clog <<" __ _\n" <<" /\\ \\ \\__ _ ___ __ _| |\n" <<" / \\/ / _` / __|/ _` | |\n" @@ -64,7 +64,7 @@ void logo() void err() { - std::cout + std::cerr <<"invalid argument(s).\n" <<"use to get help.\n"; std::exit(1); @@ -112,7 +112,7 @@ void execute(const std::string& file,const std::vector& argv,const auto start=std::chrono::high_resolution_clock::now(); vm.run(gen,linker,argv,cmd&VM_OPCALLNUM,cmd&VM_DBGINFO); auto end=std::chrono::high_resolution_clock::now(); - std::cout<<"process exited after "<<(end-start).count()*1.0/std::chrono::high_resolution_clock::duration::period::den<<"s.\n"; + std::clog<<"process exited after "<<(end-start).count()*1.0/std::chrono::high_resolution_clock::duration::period::den<<"s.\n"; } else if(cmd&VM_EXEC) vm.run(gen,linker,argv,cmd&VM_OPCALLNUM,cmd&VM_DBGINFO); diff --git a/nasal_gc.h b/nasal_gc.h index 102847b..a051106 100644 --- a/nasal_gc.h +++ b/nasal_gc.h @@ -1,7 +1,7 @@ #ifndef __NASAL_GC_H__ #define __NASAL_GC_H__ -enum vm_type:std::uint32_t{ +enum vm_type:std::uint8_t{ /* none-gc object */ vm_none=0, vm_cnt, @@ -76,12 +76,6 @@ struct nasal_ref // vm_addr nasal_ref(const uint8_t t,nasal_ref* n):type(t){val.addr=n;} nasal_ref(const nasal_ref& nr):type(nr.type),val(nr.val){} - nasal_ref& operator=(const nasal_ref& nr) - { - type=nr.type; - val=nr.val; - return *this; - } bool operator==(const nasal_ref& nr){return type==nr.type && val.gcobj==nr.val.gcobj;} bool operator!=(const nasal_ref& nr){return type!=nr.type || val.gcobj!=nr.val.gcobj;} // number and string can be translated to each other diff --git a/nasal_vm.h b/nasal_vm.h index f81e1aa..8c603bb 100644 --- a/nasal_vm.h +++ b/nasal_vm.h @@ -154,6 +154,10 @@ void nasal_vm::init( funcr=upvalr=nil; canary=stack+STACK_DEPTH-1; // stack[STACK_DEPTH-1] top=stack; + + /* clear main stack */ + for(uint32_t i=0;ib.second;} ); - std::cout<<"\noperands call info"; + std::clog<<"\noperands call info"; for(auto& i:opcall) { uint64_t rate=i.second*100/total; if(rate) - std::cout<<"\n "<