🐛 fix bug in test/calc.nas
This commit is contained in:
parent
84f9280cb4
commit
79c1e27027
1
makefile
1
makefile
|
@ -67,6 +67,7 @@ test:nasal
|
||||||
@ ./nasal -t -d test/pi.nas
|
@ ./nasal -t -d test/pi.nas
|
||||||
@ ./nasal -c test/ppmgen.nas
|
@ ./nasal -c test/ppmgen.nas
|
||||||
@ ./nasal -t -d test/prime.nas
|
@ ./nasal -t -d test/prime.nas
|
||||||
|
@ ./nasal -c test/push.nas
|
||||||
@ ./nasal -e test/qrcode.nas
|
@ ./nasal -e test/qrcode.nas
|
||||||
@ ./nasal -t -d test/quick_sort.nas
|
@ ./nasal -t -d test/quick_sort.nas
|
||||||
@ ./nasal -e test/scalar.nas hello world
|
@ ./nasal -e test/scalar.nas hello world
|
||||||
|
|
|
@ -115,13 +115,7 @@ struct opcode {
|
||||||
u32 line;// line of source code
|
u32 line;// line of source code
|
||||||
opcode(u8 o=op_exit,u16 f=0,u32 n=0,u32 l=0):
|
opcode(u8 o=op_exit,u16 f=0,u32 n=0,u32 l=0):
|
||||||
op(o),fidx(f),num(n),line(l) {}
|
op(o),fidx(f),num(n),line(l) {}
|
||||||
opcode& operator=(const opcode& tmp) {
|
opcode& operator=(const opcode& tmp) = default;
|
||||||
op=tmp.op;
|
|
||||||
fidx=tmp.fidx;
|
|
||||||
num=tmp.num;
|
|
||||||
line=tmp.line;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class codestream {
|
class codestream {
|
||||||
|
|
|
@ -35,7 +35,7 @@ var blank=func(s){
|
||||||
flag=1;
|
flag=1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(flag){
|
if(!flag){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ var calc=func(codetype,files,path=""){
|
||||||
println(rightpad(files[i],padding_length),'|',
|
println(rightpad(files[i],padding_length),'|',
|
||||||
column(line_cnt),' line |',
|
column(line_cnt),' line |',
|
||||||
column(semi_cnt),' semi |',
|
column(semi_cnt),' semi |',
|
||||||
leftpad(str(int(size(s)/1024)),3),' kb | ',
|
leftpad(str(int(size(s)/1024)),4),' kb | ',
|
||||||
md5(s),' |');
|
md5(s),' |');
|
||||||
bytes+=size(s);
|
bytes+=size(s);
|
||||||
ctx~=s;
|
ctx~=s;
|
||||||
|
@ -73,7 +73,7 @@ var calc=func(codetype,files,path=""){
|
||||||
println(rightpad("total:",padding_length),'|',
|
println(rightpad("total:",padding_length),'|',
|
||||||
column(line),' line |',
|
column(line),' line |',
|
||||||
column(semi),' semi |',
|
column(semi),' semi |',
|
||||||
leftpad(str(int(bytes/1024)),3),' kb | ',
|
leftpad(str(int(bytes/1024)),4),' kb | ',
|
||||||
md5(ctx),' |\n');
|
md5(ctx),' |\n');
|
||||||
return int(bytes/1024);
|
return int(bytes/1024);
|
||||||
}
|
}
|
||||||
|
@ -82,4 +82,4 @@ var all=calc("source code:",source)
|
||||||
+calc("lib:",lib,"stl/")
|
+calc("lib:",lib,"stl/")
|
||||||
+calc("test file:",testfile,"test/")
|
+calc("test file:",testfile,"test/")
|
||||||
+calc("module:",module,"module/");
|
+calc("module:",module,"module/");
|
||||||
println(rightpad("total:",padding_length),'| ',rightpad(str(all),6),'kb');
|
println(rightpad("total:",padding_length),'|',leftpad(str(all),6),' kb |');
|
|
@ -1,6 +1,7 @@
|
||||||
# coroutine.nas by ValKmjolnir
|
# coroutine.nas by ValKmjolnir
|
||||||
# 2022/5/19
|
# 2022/5/19
|
||||||
import.stl.process_bar;
|
import.stl.process_bar;
|
||||||
|
import.stl.padding;
|
||||||
|
|
||||||
if(os.platform()=="windows"){
|
if(os.platform()=="windows"){
|
||||||
system("chcp 65001");
|
system("chcp 65001");
|
||||||
|
@ -105,7 +106,7 @@ for(var t=0;t<10;t+=1){
|
||||||
coroutine.resume(co);
|
coroutine.resume(co);
|
||||||
if(counter-int(counter/1000)*1000==0){
|
if(counter-int(counter/1000)*1000==0){
|
||||||
var rate=counter/4e5;
|
var rate=counter/4e5;
|
||||||
print(" ",bar.bar(rate)," ",int(rate*100),"% | ",str(1e3*int(counter/tm.elapsedMSec()))," tasks/s \r");
|
print(" ",bar.bar(rate)," ",leftpad(str(int(rate*100)),3),"% | ",str(1e3*int(counter/tm.elapsedMSec()))," tasks/s \r");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,10 +27,10 @@ var project=func(n) {
|
||||||
# generate process bar, every 0.2%
|
# generate process bar, every 0.2%
|
||||||
if((i-last_step)/n>1/500) {
|
if((i-last_step)/n>1/500) {
|
||||||
last_step=i;
|
last_step=i;
|
||||||
print(" ",bar.bar((i+1)/n)~" \r");
|
print(" ",bar.bar((i+1)/n)," ",leftpad(str(int((i+1)/n*100)),3),"% | \r");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print(" ",bar.bar(1)~" ",rightpad(str(ts.elapsedMSec()/1000),5)," s | ");
|
print(" ",bar.bar(1)~" 100% | ",rightpad(str(ts.elapsedMSec()/1000),5)," s | ");
|
||||||
|
|
||||||
mess(color);
|
mess(color);
|
||||||
|
|
||||||
|
@ -63,10 +63,10 @@ var select=func(n) {
|
||||||
# generate process bar, every 0.2%
|
# generate process bar, every 0.2%
|
||||||
if((i-last_step)/n>1/500) {
|
if((i-last_step)/n>1/500) {
|
||||||
last_step=i;
|
last_step=i;
|
||||||
print(" ",bar.bar((i+1)/n)~" \r");
|
print(" ",bar.bar((i+1)/n)," ",leftpad(str(int((i+1)/n*100)),3),"% | \r");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print(" ",bar.bar(1)~" ",rightpad(str(ts.elapsedMSec()/1000),5)," s | ");
|
print(" ",bar.bar(1)~" 100% | ",rightpad(str(ts.elapsedMSec()/1000),5)," s | ");
|
||||||
|
|
||||||
mess(color);
|
mess(color);
|
||||||
mess(message);
|
mess(message);
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
|
|
||||||
|
println("[",os.time(),"] auto push, please wait...");
|
||||||
|
|
||||||
while(system("git push")!=0) {
|
while(system("git push")!=0) {
|
||||||
println("[",os.time(),"] failed to push, retrying...");
|
println("[",os.time(),"] failed to push, retrying...");
|
||||||
unix.sleep(0.5);
|
unix.sleep(0.5);
|
Loading…
Reference in New Issue