⚡ visual update
This commit is contained in:
parent
bd12fe917a
commit
7cdc5e40af
10
makefile
10
makefile
|
@ -33,10 +33,7 @@ clean:
|
|||
|
||||
test:nasal
|
||||
@ ./nasal -e test/ascii-art.nas
|
||||
@ ./nasal -c test/auto_crash.nas
|
||||
@ ./nasal -a -c test/bf.nas
|
||||
@ ./nasal -a -c test/bfconvertor.nas
|
||||
@ ./nasal -d test/bfs.nas
|
||||
@ ./nasal -t -d test/bfs.nas
|
||||
@ ./nasal -t test/bigloop.nas
|
||||
@ ./nasal -t test/bp.nas
|
||||
@ ./nasal -d test/calc.nas
|
||||
|
@ -51,7 +48,6 @@ test:nasal
|
|||
@ ./nasal -t -d test/fib.nas
|
||||
@ ./nasal -e test/filesystem.nas
|
||||
@ ./nasal -d test/hexdump.nas
|
||||
@ ./nasal -c test/httptest.nas
|
||||
@ ./nasal -e test/json.nas
|
||||
@ ./nasal -e test/leetcode1319.nas
|
||||
@ ./nasal -d test/lexer.nas
|
||||
|
@ -63,11 +59,9 @@ test:nasal
|
|||
@ ./nasal -t -d test/md5compare.nas
|
||||
-@ ./nasal -d test/module_test.nas
|
||||
@ ./nasal -e test/nasal_test.nas
|
||||
@ ./nasal test/occupation.nas 2
|
||||
@ ./nasal -t -d test/occupation.nas 2
|
||||
@ ./nasal -t -d test/pi.nas
|
||||
@ ./nasal -c test/ppmgen.nas
|
||||
@ ./nasal -t -d test/prime.nas
|
||||
@ ./nasal -c test/push.nas
|
||||
@ ./nasal -e test/qrcode.nas
|
||||
@ ./nasal -t -d test/quick_sort.nas
|
||||
@ ./nasal -e test/scalar.nas hello world
|
||||
|
|
|
@ -147,12 +147,11 @@ public:
|
|||
u8 op=ins.code.op;
|
||||
u32 num=ins.code.num;
|
||||
out<<std::hex<<"0x"
|
||||
<<std::setw(6)<<std::setfill('0')<<ins.index<<" "
|
||||
<<std::setw(6)<<std::setfill('0')<<ins.index<<" "
|
||||
<<std::setw(2)<<std::setfill('0')<<(u32)op<<" "
|
||||
<<std::setw(2)<<std::setfill('0')<<((num>>24)&0xff)<<" "
|
||||
<<std::setw(2)<<std::setfill('0')<<((num>>16)&0xff)<<" "
|
||||
<<std::setw(2)<<std::setfill('0')<<((num>>8)&0xff)<<" "
|
||||
<<std::setw(2)<<std::setfill('0')<<(num&0xff)<<" "
|
||||
<<std::setw(2)<<std::setfill('0')<<(num&0xff)<<" "
|
||||
<<opname[op]<<" "<<std::dec;
|
||||
switch(op) {
|
||||
case op_addeq: case op_subeq: case op_muleq: case op_diveq:
|
||||
|
|
|
@ -836,9 +836,9 @@ ast parse::definition() {
|
|||
if (lookahead(tok::var)) {
|
||||
match(tok::var);
|
||||
switch(toks[ptr].type) {
|
||||
case tok::id: node.add(id());break;
|
||||
case tok::id: node.add(id());break;
|
||||
case tok::lcurve: node.add(outcurve_def());break;
|
||||
default: die(thisspan,"expected identifier");break;
|
||||
default: die(thisspan,"expected identifier");break;
|
||||
}
|
||||
} else if (lookahead(tok::lcurve)) {
|
||||
node.add(incurve_def());
|
||||
|
|
133
nasal_vm.h
133
nasal_vm.h
|
@ -9,35 +9,39 @@
|
|||
|
||||
class vm {
|
||||
protected:
|
||||
|
||||
/* registers and constants of vm */
|
||||
u32 pc; // program counter
|
||||
var* localr; // local scope register
|
||||
var* memr; // used for mem_call
|
||||
var funcr; // function register
|
||||
var upvalr; // upvalue register
|
||||
var* canary; // avoid stackoverflow
|
||||
var* top; // stack top
|
||||
u32 pc; // program counter
|
||||
var* localr; // local frame pointer
|
||||
var* memr; // store address got by memory call
|
||||
var funcr; // function register
|
||||
var upvalr; // upvalue register
|
||||
var* canary; // avoid stack overflow, at the top of main stack
|
||||
var* top; // stack top pointer
|
||||
|
||||
/* constants */
|
||||
const f64* cnum; // const numbers
|
||||
const string* cstr; // const symbols
|
||||
std::vector<u32> imm; // immediate number
|
||||
const f64* cnum; // constant numbers
|
||||
const string* cstr; // constant symbols and strings
|
||||
std::vector<u32> imm; // immediate number table
|
||||
|
||||
/* garbage collector */
|
||||
gc ngc;
|
||||
gc ngc;
|
||||
|
||||
/* main stack */
|
||||
var stack[STACK_DEPTH];
|
||||
|
||||
/* values used for debugger */
|
||||
const string* files;
|
||||
const opcode* bytecode;
|
||||
const string* files; // file name list
|
||||
const opcode* bytecode; // bytecode buffer address
|
||||
|
||||
/* vm initializing function */
|
||||
void init(
|
||||
const std::vector<string>&,
|
||||
const std::vector<f64>&,
|
||||
const std::vector<opcode>&,
|
||||
const std::vector<string>&,
|
||||
const std::vector<string>&);
|
||||
|
||||
/* debug functions */
|
||||
bool verbose;
|
||||
void valinfo(var&);
|
||||
|
@ -49,8 +53,10 @@ protected:
|
|||
void ustate();
|
||||
void detail();
|
||||
void die(const string&);
|
||||
|
||||
/* vm calculation functions*/
|
||||
bool cond(var&);
|
||||
|
||||
/* vm operands */
|
||||
void o_intg();
|
||||
void o_intl();
|
||||
|
@ -139,12 +145,16 @@ protected:
|
|||
void o_mcallh();
|
||||
void o_ret();
|
||||
public:
|
||||
|
||||
/* constructor of vm instance */
|
||||
vm():
|
||||
pc(0),localr(nullptr),memr(nullptr),funcr(nil),
|
||||
upvalr(nil),canary(nullptr),top(stack),
|
||||
cnum(nullptr),cstr(nullptr),
|
||||
ngc(pc,localr,memr,funcr,upvalr,canary,top,stack),
|
||||
files(nullptr),bytecode(nullptr),verbose(false) {}
|
||||
|
||||
/* execution entry */
|
||||
void run(
|
||||
const codegen&,
|
||||
const linker&,
|
||||
|
@ -179,39 +189,38 @@ void vm::init(
|
|||
|
||||
void vm::valinfo(var& val) {
|
||||
const nas_val* p=val.val.gcobj;
|
||||
std::cout<<"\t";
|
||||
switch(val.type) {
|
||||
case vm_none: std::cout<<"| null |";break;
|
||||
case vm_ret: std::cout<<"| pc | 0x"<<std::hex
|
||||
case vm_none: std::clog<<"| null |";break;
|
||||
case vm_ret: std::clog<<"| pc | 0x"<<std::hex
|
||||
<<val.ret()<<std::dec;break;
|
||||
case vm_addr: std::cout<<"| addr | 0x"<<std::hex
|
||||
case vm_addr: std::clog<<"| addr | 0x"<<std::hex
|
||||
<<(u64)val.addr()<<std::dec;break;
|
||||
case vm_cnt: std::cout<<"| cnt | "<<val.cnt();break;
|
||||
case vm_nil: std::cout<<"| nil |";break;
|
||||
case vm_num: std::cout<<"| num | "<<val.num();break;
|
||||
case vm_str: std::cout<<"| str | <0x"<<std::hex<<(u64)p
|
||||
case vm_cnt: std::clog<<"| cnt | "<<val.cnt();break;
|
||||
case vm_nil: std::clog<<"| nil |";break;
|
||||
case vm_num: std::clog<<"| num | "<<val.num();break;
|
||||
case vm_str: std::clog<<"| str | <0x"<<std::hex<<(u64)p
|
||||
<<"> "<<rawstr(val.str(),16)<<std::dec;break;
|
||||
case vm_func: std::cout<<"| func | <0x"<<std::hex<<(u64)p
|
||||
case vm_func: std::clog<<"| func | <0x"<<std::hex<<(u64)p
|
||||
<<"> entry:0x"<<val.func().entry
|
||||
<<std::dec;break;
|
||||
case vm_upval:std::cout<<"| upval| <0x"<<std::hex<<(u64)p
|
||||
case vm_upval:std::clog<<"| upval| <0x"<<std::hex<<(u64)p
|
||||
<<std::dec<<"> ["<<val.upval().size
|
||||
<<" val]";break;
|
||||
case vm_vec: std::cout<<"| vec | <0x"<<std::hex<<(u64)p
|
||||
case vm_vec: std::clog<<"| vec | <0x"<<std::hex<<(u64)p
|
||||
<<std::dec<<"> ["<<val.vec().size()
|
||||
<<" val]";break;
|
||||
case vm_hash: std::cout<<"| hash | <0x"<<std::hex<<(u64)p
|
||||
case vm_hash: std::clog<<"| hash | <0x"<<std::hex<<(u64)p
|
||||
<<std::dec<<"> {"<<val.hash().size()
|
||||
<<" val}";break;
|
||||
case vm_obj: std::cout<<"| obj | <0x"<<std::hex<<(u64)p
|
||||
case vm_obj: std::clog<<"| obj | <0x"<<std::hex<<(u64)p
|
||||
<<"> obj:0x"<<(u64)val.obj().ptr
|
||||
<<std::dec;break;
|
||||
case vm_co: std::cout<<"| co | <0x"<<std::hex<<(u64)p
|
||||
case vm_co: std::clog<<"| co | <0x"<<std::hex<<(u64)p
|
||||
<<std::dec<<"> coroutine";break;
|
||||
default: std::cout<<"| err | <0x"<<std::hex<<(u64)p
|
||||
default: std::clog<<"| err | <0x"<<std::hex<<(u64)p
|
||||
<<std::dec<<"> unknown object";break;
|
||||
}
|
||||
std::cout<<"\n";
|
||||
std::clog<<"\n";
|
||||
}
|
||||
|
||||
void vm::traceback() {
|
||||
|
@ -225,19 +234,19 @@ void vm::traceback() {
|
|||
}
|
||||
}
|
||||
ret.push(pc); // store the position program crashed
|
||||
std::cout<<"trace back ("<<(ngc.stack==stack?"main":"coroutine")<<")\n";
|
||||
std::clog<<"trace back ("<<(ngc.stack==stack?"main":"coroutine")<<")\n";
|
||||
for(u32 p=0,same=0,prev=0xffffffff;!ret.empty();prev=p,ret.pop()) {
|
||||
if ((p=ret.top())==prev) {
|
||||
++same;
|
||||
continue;
|
||||
}
|
||||
if (same) {
|
||||
std::cout
|
||||
<<" 0x"<<std::hex<<std::setw(8)<<std::setfill('0')
|
||||
<<prev<<std::dec<<" "<<same<<" same call(s)\n";
|
||||
std::clog
|
||||
<<" 0x"<<std::hex<<std::setw(6)<<std::setfill('0')
|
||||
<<prev<<std::dec<<" "<<same<<" same call(s)\n";
|
||||
}
|
||||
same=0;
|
||||
std::cout<<" "<<codestream(bytecode[p],p,cnum,cstr,files)<<"\n";
|
||||
std::clog<<" "<<codestream(bytecode[p],p,cnum,cstr,files)<<"\n";
|
||||
}
|
||||
// the first called place has no same calls
|
||||
}
|
||||
|
@ -247,38 +256,40 @@ void vm::stackinfo(const u32 limit=10) {
|
|||
const u32 gsize=ngc.stack==stack?bytecode[0].num:0;
|
||||
var* t=top;
|
||||
var* bottom=ngc.stack+gsize;
|
||||
std::cout<<"vm stack (0x"<<std::hex<<(u64)bottom<<std::dec
|
||||
<<" <sp+"<<gsize<<">, limit "<<limit<<", total "
|
||||
std::clog<<"stack (0x"<<std::hex<<(u64)bottom<<std::dec
|
||||
<<" <+"<<gsize<<">, limit "<<limit<<", total "
|
||||
<<(t<bottom? 0:(i64)(t-bottom+1))<<")\n";
|
||||
for(u32 i=0;i<limit && t>=bottom;++i,--t) {
|
||||
std::cout<<" 0x"<<std::hex
|
||||
<<std::setw(8)<<std::setfill('0')
|
||||
<<(u64)(t-ngc.stack)<<std::dec;
|
||||
std::clog<<" 0x"<<std::hex
|
||||
<<std::setw(6)<<std::setfill('0')
|
||||
<<(u64)(t-ngc.stack)<<std::dec
|
||||
<<" ";
|
||||
valinfo(t[0]);
|
||||
}
|
||||
}
|
||||
|
||||
void vm::reginfo() {
|
||||
std::cout<<"registers ("<<(ngc.cort?"coroutine":"main")<<")\n"<<std::hex
|
||||
<<" [ pc ] | pc | 0x"<<pc<<"\n"
|
||||
<<" [ global ] | addr | 0x"<<(u64)stack<<"\n"
|
||||
<<" [ localr ] | addr | 0x"<<(u64)localr<<"\n"
|
||||
<<" [ memr ] | addr | 0x"<<(u64)memr<<"\n"
|
||||
<<" [ canary ] | addr | 0x"<<(u64)canary<<"\n"
|
||||
<<" [ top ] | addr | 0x"<<(u64)top<<"\n"
|
||||
std::clog<<"registers ("<<(ngc.cort?"coroutine":"main")<<")\n"<<std::hex
|
||||
<<" [pc ] | pc | 0x"<<pc<<"\n"
|
||||
<<" [global] | addr | 0x"<<(u64)stack<<"\n"
|
||||
<<" [local ] | addr | 0x"<<(u64)localr<<"\n"
|
||||
<<" [memr ] | addr | 0x"<<(u64)memr<<"\n"
|
||||
<<" [canary] | addr | 0x"<<(u64)canary<<"\n"
|
||||
<<" [top ] | addr | 0x"<<(u64)top<<"\n"
|
||||
<<std::dec;
|
||||
std::cout<<" [ funcr ]";valinfo(funcr);
|
||||
std::cout<<" [ upvalr ]";valinfo(upvalr);
|
||||
std::clog<<" [funcr ] ";valinfo(funcr);
|
||||
std::clog<<" [upval ] ";valinfo(upvalr);
|
||||
}
|
||||
|
||||
void vm::gstate() {
|
||||
if (!bytecode[0].num || stack[0].type==vm_none) { // bytecode[0].op is op_intg
|
||||
return;
|
||||
}
|
||||
std::cout<<"global (0x"<<std::hex<<(u64)stack<<" <sp+0>)\n"<<std::dec;
|
||||
std::clog<<"global (0x"<<std::hex<<(u64)stack<<" <+0>)\n"<<std::dec;
|
||||
for(u32 i=0;i<bytecode[0].num;++i) {
|
||||
std::cout<<" 0x"<<std::hex<<std::setw(8)
|
||||
<<std::setfill('0')<<i<<std::dec;
|
||||
std::clog<<" 0x"<<std::hex<<std::setw(6)
|
||||
<<std::setfill('0')<<i<<std::dec
|
||||
<<" ";
|
||||
valinfo(stack[i]);
|
||||
}
|
||||
}
|
||||
|
@ -288,11 +299,12 @@ void vm::lstate() {
|
|||
return;
|
||||
}
|
||||
const u32 lsize=funcr.func().lsize;
|
||||
std::cout<<"local (0x"<<std::hex<<(u64)localr
|
||||
<<" <sp+"<<(u64)(localr-ngc.stack)<<">)\n"<<std::dec;
|
||||
std::clog<<"local (0x"<<std::hex<<(u64)localr
|
||||
<<" <+"<<(u64)(localr-ngc.stack)<<">)\n"<<std::dec;
|
||||
for(u32 i=0;i<lsize;++i) {
|
||||
std::cout<<" 0x"<<std::hex<<std::setw(8)
|
||||
<<std::setfill('0')<<i<<std::dec;
|
||||
std::clog<<" 0x"<<std::hex<<std::setw(6)
|
||||
<<std::setfill('0')<<i<<std::dec
|
||||
<<" ";
|
||||
valinfo(localr[i]);
|
||||
}
|
||||
}
|
||||
|
@ -301,14 +313,15 @@ void vm::ustate() {
|
|||
if (funcr.type==vm_nil || funcr.func().upval.empty()) {
|
||||
return;
|
||||
}
|
||||
std::cout<<"upvalue\n";
|
||||
std::clog<<"upvalue\n";
|
||||
auto& upval=funcr.func().upval;
|
||||
for(u32 i=0;i<upval.size();++i) {
|
||||
std::cout<<" -> upval["<<i<<"]:\n";
|
||||
std::clog<<" -> upval["<<i<<"]:\n";
|
||||
auto& uv=upval[i].upval();
|
||||
for(u32 j=0;j<uv.size;++j) {
|
||||
std::cout<<" 0x"<<std::hex<<std::setw(8)
|
||||
<<std::setfill('0')<<j<<std::dec;
|
||||
std::clog<<" 0x"<<std::hex<<std::setw(6)
|
||||
<<std::setfill('0')<<j<<std::dec
|
||||
<<" ";
|
||||
valinfo(uv[j]);
|
||||
}
|
||||
}
|
||||
|
@ -322,7 +335,7 @@ void vm::detail() {
|
|||
}
|
||||
|
||||
void vm::die(const string& str) {
|
||||
std::cout<<"[vm] error: "<<str<<"\n";
|
||||
std::cerr<<"[vm] error: "<<str<<"\n";
|
||||
traceback();
|
||||
stackinfo();
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ var prt=func(){
|
|||
}
|
||||
s~='+--------------------+\n';
|
||||
print(s);
|
||||
unix.sleep(1/200);
|
||||
unix.sleep(1/800);
|
||||
}
|
||||
|
||||
var bfs=func(begin,end){
|
||||
|
|
|
@ -104,14 +104,14 @@ for(var t=0;t<10;t+=1){
|
|||
counter+=1;
|
||||
for(var i=0;i<t+1;i+=1)
|
||||
coroutine.resume(co);
|
||||
if(counter-int(counter/5000)*5000==0){
|
||||
if(counter-int(counter/1000)*1000==0){
|
||||
var rate=counter/2e5;
|
||||
print(" ",bar.bar(rate)," ",leftpad(str(int(rate*100)),3),"% | ",str(1e3*int(counter/tm.elapsedMSec()))," tasks/s \r");
|
||||
}
|
||||
}
|
||||
|
||||
tm.stamp();
|
||||
for(var i=0;i<2e5;i+=1)
|
||||
for(var i=0;i<1e5;i+=1)
|
||||
consumer();
|
||||
println(" ",bar.bar(1)," 100% | ",str(int(1e3*counter/tm.elapsedMSec()))," tasks/s ");
|
||||
}
|
|
@ -102,6 +102,6 @@ for(var i=10;i<1e6;i*=10) {
|
|||
project(i);
|
||||
}
|
||||
println("select");
|
||||
for(var i=100;i<1e7;i*=10) {
|
||||
for(var i=10;i<1e6;i*=10) {
|
||||
select(i);
|
||||
}
|
|
@ -37,12 +37,14 @@ println(JSON.parse(ss),"\n");
|
|||
func {
|
||||
var bar=process_bar.high_resolution_bar(30);
|
||||
var tmp=[
|
||||
{t0:nil},
|
||||
{t1:nil},
|
||||
{t2:nil},
|
||||
{t3:nil},
|
||||
{t4:nil},
|
||||
{t5:nil},
|
||||
{t6:nil}
|
||||
{t6:nil},
|
||||
{t7:nil}
|
||||
];
|
||||
|
||||
srand();
|
||||
|
@ -50,14 +52,14 @@ func {
|
|||
var name=keys(h)[0];
|
||||
h[name]=[];
|
||||
print("\e[1000D",bar.bar(0));
|
||||
for(var i=0;i<1e3;i+=1) {
|
||||
for(var i=0;i<500;i+=1) {
|
||||
append(h[name],{id:i,content:int(rand()*1e7)});
|
||||
print("\e[1000D",bar.bar((i+1)/1e3));
|
||||
print("\e[1000D",bar.bar((i+1)/500));
|
||||
}
|
||||
print("\e[1000D",bar.bar(1)," executing...\n");
|
||||
}
|
||||
print("\e[1000D","\e["~str(size(tmp))~"A");
|
||||
foreach(var h;JSON.parse(JSON.stringify(tmp))) {
|
||||
println("\e[1000D",bar.bar(1)," done ",keys(h)[0]," ",size(h[keys(h)[0]])," ");
|
||||
println("\e[1000D",bar.bar(1)," parse done ",keys(h)[0]," ",size(h[keys(h)[0]]));
|
||||
}
|
||||
}();
|
|
@ -1,80 +1,66 @@
|
|||
import.test.md5;
|
||||
import.stl.process_bar;
|
||||
import.stl.file;
|
||||
srand();
|
||||
|
||||
var compare=func(){
|
||||
var compare=func() {
|
||||
var ch=[
|
||||
"0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","+",
|
||||
"_","*","/","\'","\"",".",",",";",":","<",">","!","@","#","$","%",
|
||||
"^","&","*","(",")","-","=","\\","|","[","]","{","}","`"," ","\t","?"
|
||||
];
|
||||
return func(begin,end){
|
||||
return func(begin,end) {
|
||||
var byte=0;
|
||||
var total=end-begin;
|
||||
var timestamp=maketimestamp();
|
||||
timestamp.stamp();
|
||||
var bar=process_bar.high_resolution_bar(40);
|
||||
for(var i=begin;i<end;i+=1){
|
||||
for(var i=begin;i<end;i+=1) {
|
||||
var s="";
|
||||
for(var j=0;j<i;j+=1){
|
||||
for(var j=0;j<i;j+=1) {
|
||||
s~=ch[rand()*size(ch)];
|
||||
}
|
||||
byte+=size(s);
|
||||
var res=md5(s);
|
||||
if(cmp(res,_md5(s))){
|
||||
if(cmp(res,_md5(s))) {
|
||||
die("error: "~str(i));
|
||||
}
|
||||
print(" ",bar.bar((i-begin+1)/total)," (",i-begin+1,"/",total,")\t",res," byte: ",int(byte/1024),"k time: ",timestamp.elapsedMSec()," \r");
|
||||
if (i-begin-int((i-begin)/4)*4==0) {
|
||||
print(
|
||||
"\e[1000D ",bar.bar((i-begin+1)/total),
|
||||
" (",i-begin+1,"/",total,")\t",
|
||||
res," byte: ",int(byte/1024),"k"
|
||||
);
|
||||
}
|
||||
}
|
||||
print(
|
||||
"\e[1000D ",bar.bar((i-begin)/total),
|
||||
" (",i-begin,"/",total,")\t",
|
||||
res," byte: ",int(byte/1024),"k",
|
||||
" time: ",timestamp.elapsedMSec()
|
||||
);
|
||||
print("\n");
|
||||
};
|
||||
}();
|
||||
|
||||
var filechecksum=func(){
|
||||
var files=[
|
||||
"./stl/fg_env.nas", "./stl/file.nas",
|
||||
"./stl/json.nas", "./stl/lib.nas",
|
||||
"./stl/list.nas", "./stl/log.nas",
|
||||
"./stl/mat.nas", "./stl/module.nas",
|
||||
"./stl/padding.nas", "./stl/process_bar.nas",
|
||||
"./stl/queue.nas", "./stl/result.nas",
|
||||
"./stl/sort.nas", "./stl/stack.nas",
|
||||
"./stl/string.nas",
|
||||
"./test/ascii-art.nas", "./test/auto_crash.nas",
|
||||
"./test/bf.nas", "./test/bfconvertor.nas",
|
||||
"./test/bfs.nas", "./test/bigloop.nas",
|
||||
"./test/bp.nas", "./test/calc.nas",
|
||||
"./test/choice.nas", "./test/class.nas",
|
||||
"./test/console3D.nas",
|
||||
"./test/coroutine.nas", "./test/datalog.nas",
|
||||
"./test/diff.nas", "./test/donuts.nas",
|
||||
"./test/exception.nas", "./test/fib.nas",
|
||||
"./test/filesystem.nas", "./test/hexdump.nas",
|
||||
"./test/httptest.nas", "./test/json.nas",
|
||||
"./test/leetcode1319.nas", "./test/lexer.nas",
|
||||
"./test/life.nas", "./test/loop.nas",
|
||||
"./test/mandel.nas", "./test/mandelbrot.nas",
|
||||
"./test/mcpu.nas",
|
||||
"./test/md5.nas", "./test/md5compare.nas",
|
||||
"./test/module_test.nas", "./test/nasal_test.nas",
|
||||
"./test/occupation.nas", "./test/pi.nas",
|
||||
"./test/ppmgen.nas", "./test/prime.nas",
|
||||
"./test/qrcode.nas", "./test/quick_sort.nas",
|
||||
"./test/scalar.nas", "./test/snake.nas",
|
||||
"./test/tetris.nas", "./test/trait.nas",
|
||||
"./test/turingmachine.nas", "./test/utf8chk.nas",
|
||||
"./test/watchdog.nas", "./test/wavecollapse.nas",
|
||||
"./test/word_collector.nas",
|
||||
"./test/ycombinator.nas", "LICENSE",
|
||||
"main.cpp", "makefile",
|
||||
"nasal_ast.h", "nasal_builtin.h",
|
||||
"nasal_codegen.h", "nasal_dbg.h",
|
||||
"nasal_err.h", "nasal_gc.h",
|
||||
"nasal_import.h", "nasal_lexer.h",
|
||||
"nasal_opt.h", "nasal_parse.h",
|
||||
"nasal_vm.h", "nasal.ebnf",
|
||||
"nasal.h", "README.md"
|
||||
];
|
||||
var files=[];
|
||||
foreach(var p;find_all_files_with_extension("./test","nas")) {
|
||||
append(files,"./test/"~p);
|
||||
}
|
||||
foreach(var p;find_all_files_with_extension("./stl","nas")) {
|
||||
append(files,"./stl/"~p);
|
||||
}
|
||||
foreach(var p;find_all_files_with_extension("./module","nas","cpp")) {
|
||||
append(files,"./module/"~p);
|
||||
}
|
||||
foreach(var p;find_all_files_with_extension(".","cpp","h","md")) {
|
||||
append(files,"./"~p);
|
||||
}
|
||||
foreach(var p;find_all_files_with_extension("./doc","md")) {
|
||||
append(files,"./doc/"~p);
|
||||
}
|
||||
|
||||
var byte=0;
|
||||
var total=size(files);
|
||||
var timestamp=maketimestamp();
|
||||
|
@ -87,14 +73,19 @@ var filechecksum=func(){
|
|||
if(cmp(res,_md5(f))){
|
||||
die("error: "~files[i]);
|
||||
}
|
||||
print(" ",bar.bar((i+1)/total)," (",i+1,"/",total,")\t",res," byte: ",int(byte/1024),"k time: ",timestamp.elapsedMSec()," \r");
|
||||
print(
|
||||
"\e[1000D ",bar.bar((i+1)/total),
|
||||
" (",i+1,"/",total,")\t",res,
|
||||
" byte: ",int(byte/1024),"k",
|
||||
" time: ",timestamp.elapsedMSec()
|
||||
);
|
||||
}
|
||||
print("\n");
|
||||
}
|
||||
|
||||
var randomchecksum=func(){
|
||||
for(var i=0;i<4096;i+=512)
|
||||
compare(i,i+512);
|
||||
for(var i=0;i<2048;i+=256)
|
||||
compare(i,i+256);
|
||||
}
|
||||
|
||||
if(os.platform()=="windows")
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
import.stl.sort;
|
||||
|
||||
var vec=[];
|
||||
rand(time(0));
|
||||
for(var i=0;i<1e4;i+=1)
|
||||
append(vec,int(rand()*1e5));
|
||||
sort(vec);
|
||||
println(vec);
|
||||
for(var i=1;i<1e4;i+=1) {
|
||||
if (vec[i]<vec[i-1]) {
|
||||
die("incorrect sort result");
|
||||
}
|
||||
}
|
||||
|
||||
var test=func(n){
|
||||
var a=[];
|
||||
|
@ -27,6 +32,6 @@ var test=func(n){
|
|||
println("[time] ",str(n)," in ",ts.elapsedMSec()/1000," sec (lambda)");
|
||||
}
|
||||
|
||||
for(var i=1000;i<1e7;i*=10){
|
||||
for(var i=1000;i<1e6;i*=10){
|
||||
test(i);
|
||||
}
|
Loading…
Reference in New Issue