🔥 delete `--opcnt` and replace the function of `-o` by `--optimize`.
This commit is contained in:
parent
5be6351b60
commit
24ba300f3c
26
main.cpp
26
main.cpp
|
@ -12,15 +12,14 @@
|
|||
#include "nasal_dbg.h"
|
||||
#include <unordered_map>
|
||||
|
||||
const u32 VM_LEXINFO =0x01;
|
||||
const u32 VM_ASTINFO =0x02;
|
||||
const u32 VM_CODEINFO =0x04;
|
||||
const u32 VM_EXECTIME =0x08;
|
||||
const u32 VM_OPCALLNUM=0x10;
|
||||
const u32 VM_EXEC =0x20;
|
||||
const u32 VM_DETAIL =0x40;
|
||||
const u32 VM_DEBUG =0x80;
|
||||
const u32 VM_OPTIMIZE =0x100;
|
||||
const u32 VM_LEXINFO =0x01;
|
||||
const u32 VM_ASTINFO =0x02;
|
||||
const u32 VM_CODEINFO=0x04;
|
||||
const u32 VM_EXECTIME=0x08;
|
||||
const u32 VM_EXEC =0x10;
|
||||
const u32 VM_DETAIL =0x20;
|
||||
const u32 VM_DEBUG =0x40;
|
||||
const u32 VM_OPTIMIZE=0x80;
|
||||
|
||||
void help()
|
||||
{
|
||||
|
@ -42,12 +41,10 @@ void help()
|
|||
<<" -c, --code | view bytecode.\n"
|
||||
<<" -e, --exec | execute.\n"
|
||||
<<" -t, --time | get the running time.\n"
|
||||
<<" -o, --opcnt | count used operands.\n"
|
||||
<<" | available in debug mode.\n"
|
||||
<<" -d, --detail | get detail runtime crash info.\n"
|
||||
<<" | get detail linker path-not-found info.\n"
|
||||
<<" | get garbage collector info if didn't crash.\n"
|
||||
<<" -op, --optimize| use optimizer(beta).\n"
|
||||
<<" -o, --optimize | use optimizer(beta).\n"
|
||||
<<" | if want to use -op and run, please use -op -e/-t/-d.\n"
|
||||
<<" -dbg, --debug | debug mode (this will ignore -t -d).\n"
|
||||
<<"file:\n"
|
||||
|
@ -115,7 +112,7 @@ void execute(const string& file,const std::vector<string>& argv,const u32 cmd)
|
|||
|
||||
// run
|
||||
if(cmd&VM_DEBUG)
|
||||
nasal_dbg(nerr).run(gen,linker,argv,cmd&VM_OPCALLNUM);
|
||||
nasal_dbg(nerr).run(gen,linker,argv);
|
||||
else if(cmd&VM_EXECTIME)
|
||||
{
|
||||
auto start=std::chrono::high_resolution_clock::now();
|
||||
|
@ -152,10 +149,9 @@ i32 main(i32 argc,const char* argv[])
|
|||
{"--ast",VM_ASTINFO},{"-a",VM_ASTINFO},
|
||||
{"--code",VM_CODEINFO},{"-c",VM_CODEINFO},
|
||||
{"--exec",VM_EXEC},{"-e",VM_EXEC},
|
||||
{"--opcnt",VM_OPCALLNUM},{"-o",VM_OPCALLNUM},
|
||||
{"--time",VM_EXECTIME|VM_EXEC},{"-t",VM_EXECTIME|VM_EXEC},
|
||||
{"--detail",VM_DETAIL|VM_EXEC},{"-d",VM_DETAIL|VM_EXEC},
|
||||
{"--optimize",VM_OPTIMIZE},{"-op",VM_OPTIMIZE},
|
||||
{"--optimize",VM_OPTIMIZE},{"-o",VM_OPTIMIZE},
|
||||
{"--debug",VM_DEBUG},{"-dbg",VM_DEBUG}
|
||||
};
|
||||
u32 cmd=0;
|
||||
|
|
13
nasal_dbg.h
13
nasal_dbg.h
|
@ -17,7 +17,7 @@ private:
|
|||
u16 fileindex(const string&);
|
||||
void err();
|
||||
void help();
|
||||
void opcallsort(const u64*);
|
||||
void callsort(const u64*);
|
||||
void stepinfo();
|
||||
void interact();
|
||||
public:
|
||||
|
@ -28,8 +28,7 @@ public:
|
|||
void run(
|
||||
const nasal_codegen&,
|
||||
const nasal_import&,
|
||||
const std::vector<string>&,
|
||||
bool
|
||||
const std::vector<string>&
|
||||
);
|
||||
};
|
||||
|
||||
|
@ -83,7 +82,7 @@ void nasal_dbg::help()
|
|||
<<"\tbk, break | set break point\n";
|
||||
}
|
||||
|
||||
void nasal_dbg::opcallsort(const u64* arr)
|
||||
void nasal_dbg::callsort(const u64* arr)
|
||||
{
|
||||
typedef std::pair<u32,u64> op;
|
||||
std::vector<op> opcall;
|
||||
|
@ -207,8 +206,7 @@ void nasal_dbg::interact()
|
|||
void nasal_dbg::run(
|
||||
const nasal_codegen& gen,
|
||||
const nasal_import& linker,
|
||||
const std::vector<string>& argv,
|
||||
bool opcnt)
|
||||
const std::vector<string>& argv)
|
||||
{
|
||||
detail_info=true;
|
||||
fsize=linker.filelist().size();
|
||||
|
@ -307,8 +305,7 @@ void nasal_dbg::run(
|
|||
vmexit:
|
||||
if(top>=canary)
|
||||
die("stack overflow");
|
||||
if(opcnt)
|
||||
opcallsort(count);
|
||||
callsort(count);
|
||||
gc.clear();
|
||||
imm.clear();
|
||||
std::cout<<"[debug] debugger exited\n";
|
||||
|
|
|
@ -17,7 +17,7 @@ var width=1280;
|
|||
var height=720;
|
||||
var bar=process_bar.bar(front:os.platform()=="windows"?"sharp":"block",back:"point",sep:"line",length:50);
|
||||
var f=func(i,j){
|
||||
var (yMin,yMax,xMin,xMax)=(-0.9,0.9,-2.2,1);
|
||||
var (yMin,yMax,xMin,xMax)=(-1.35,1.35,-3.3,1.5);
|
||||
var (yDel,xDel)=(yMax-yMin,xMax-xMin);
|
||||
var (y,x)=((i/height)*yDel+yMin,(j/width)*xDel+xMin);
|
||||
var (x0,y0)=(x,y);
|
||||
|
@ -30,7 +30,7 @@ var f=func(i,j){
|
|||
}
|
||||
var progress=(i*width+j+1)/(width*height);
|
||||
print(bar.bar(progress)," ",progress*100,"% \r");
|
||||
iter=int(iter/25*255);
|
||||
iter=iter==25?255:int(iter/25*255);
|
||||
return iter~" "~iter~" "~iter~" ";
|
||||
}
|
||||
ppm("a.ppm",width,height,f);
|
||||
|
|
Loading…
Reference in New Issue