update
This commit is contained in:
parent
6175e274c6
commit
11e36ba29f
|
@ -0,0 +1,14 @@
|
|||
# nasal lib bits.nas
|
||||
# 2020/2/6
|
||||
# this file is used to avoid name confliction
|
||||
# and is used to avoid name undefined
|
||||
# before running this file will be translated to abstract syntax tree
|
||||
# and this ast will be linked before main ast as main-ast's beginning
|
||||
|
||||
var bits=
|
||||
{
|
||||
fld:func(){},
|
||||
sfld:func(){},
|
||||
setfld:func(){},
|
||||
buf:func(){},
|
||||
};
|
|
@ -1,10 +1,22 @@
|
|||
# nasal lib io.nas
|
||||
# 2020/2/4
|
||||
# 2020/2/6
|
||||
# this file is used to avoid name confliction
|
||||
# and is used to avoid name undefined
|
||||
# before running this file will be translated to abstract syntax tree
|
||||
# and this ast will be linked before main ast as main-ast's beginning
|
||||
|
||||
var io=
|
||||
{
|
||||
open:func(){},
|
||||
close:func(){},
|
||||
read:func(){},
|
||||
write:func(){},
|
||||
seek:func(){},
|
||||
tell:func(){},
|
||||
readln:func(){},
|
||||
stat:func(){},
|
||||
};
|
||||
|
||||
var input=func(filename="")
|
||||
{
|
||||
if(filename=="")
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# nasal lib math.nas
|
||||
# 2020/2/4
|
||||
# 2020/2/6
|
||||
# this file is used to avoid name confliction
|
||||
# and is used to avoid name undefined
|
||||
# before running this file will be translated to abstract syntax tree
|
||||
|
@ -24,74 +24,8 @@ var math=
|
|||
{
|
||||
var call_inline_pow=func(num,x){};
|
||||
return call_inline_pow(me.e,x);
|
||||
}
|
||||
},
|
||||
ln:func(){},
|
||||
sqrt:func(){},
|
||||
atan2:func(){},
|
||||
};
|
||||
var __e=2.7182818284590452354;
|
||||
var __pi=3.14159265358979323846;
|
||||
var __ln_2=0.69314718055994530942;
|
||||
var __ln_10=2.30258509299404568402;
|
||||
|
||||
var abs=func(number)
|
||||
{
|
||||
if(number>0)
|
||||
return number;
|
||||
else
|
||||
return -1*number;
|
||||
}
|
||||
|
||||
var sin=func(number)
|
||||
{
|
||||
return number;
|
||||
}
|
||||
|
||||
var cos=func(number)
|
||||
{
|
||||
return number;
|
||||
}
|
||||
|
||||
var tan=func(number)
|
||||
{
|
||||
return sin(number)/cos(number);
|
||||
}
|
||||
|
||||
var cot=func(number)
|
||||
{
|
||||
return cos(number)/sin(number);
|
||||
}
|
||||
|
||||
var exp=func(number)
|
||||
{
|
||||
var int_num=int(number);
|
||||
var f_num=number-int_num;
|
||||
var __res_exp=exp(int_num);
|
||||
var pw=1;
|
||||
for(var i=1;i<6;i+=1)
|
||||
{
|
||||
__res_exp+=pw/i;
|
||||
pw*=f_num;
|
||||
}
|
||||
return __res_exp;
|
||||
}
|
||||
|
||||
var ln=func(number)
|
||||
{
|
||||
return number;
|
||||
}
|
||||
|
||||
var sqrt=func(number)
|
||||
{
|
||||
var temp = number/8 + 0.5 + 2*number/(4+number);
|
||||
var cnt = 10;
|
||||
while(cnt!=0)
|
||||
{
|
||||
cnt-=1;
|
||||
temp = (temp+number/temp)/2;
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
var atan2=func(x,y)
|
||||
{
|
||||
return y/x;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
# nasal lib readline.nas
|
||||
# 2020/2/6
|
||||
# this file is used to avoid name confliction
|
||||
# and is used to avoid name undefined
|
||||
# before running this file will be translated to abstract syntax tree
|
||||
# and this ast will be linked before main ast as main-ast's beginning
|
||||
|
||||
# GNU Readline Library
|
||||
var readline=func(prompt="> ")
|
||||
{
|
||||
return;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
# nasal lib regex.nas
|
||||
# 2020/2/6
|
||||
# this file is used to avoid name confliction
|
||||
# and is used to avoid name undefined
|
||||
# before running this file will be translated to abstract syntax tree
|
||||
# and this ast will be linked before main ast as main-ast's beginning
|
||||
|
||||
var regex=
|
||||
{
|
||||
comp:func(){},
|
||||
exec:func(){},
|
||||
};
|
|
@ -0,0 +1,15 @@
|
|||
# nasal lib sqlite.nas
|
||||
# 2020/2/6
|
||||
# this file is used to avoid name confliction
|
||||
# and is used to avoid name undefined
|
||||
# before running this file will be translated to abstract syntax tree
|
||||
# and this ast will be linked before main ast as main-ast's beginning
|
||||
|
||||
var sqlite=
|
||||
{
|
||||
open:func(){},
|
||||
close:func(){},
|
||||
prepare:func(){},
|
||||
exec:func(){},
|
||||
finalize:func(){},
|
||||
};
|
|
@ -1,7 +1,17 @@
|
|||
#nasal-strict-lib thread
|
||||
# nasal lib thread.nas
|
||||
# 2020/2/6
|
||||
# this file is used to avoid name confliction
|
||||
# and is used to avoid name undefined
|
||||
# before running this file will be translated to abstract syntax tree
|
||||
# and this ast will be linked before main ast as main-ast's beginning
|
||||
|
||||
var thread=func(__function)
|
||||
var thread=
|
||||
{
|
||||
__system_call_cpp_new_thread(__function);
|
||||
return 0;
|
||||
}
|
||||
newthread:func(){},
|
||||
newlock:func(){},
|
||||
lock:func(){},
|
||||
unlock:func(){},
|
||||
newsem:func(){},
|
||||
semdown:func(){},
|
||||
semup:func(){},
|
||||
};
|
|
@ -0,0 +1,22 @@
|
|||
# nasal lib unix.nas
|
||||
# 2020/2/6
|
||||
# this file is used to avoid name confliction
|
||||
# and is used to avoid name undefined
|
||||
# before running this file will be translated to abstract syntax tree
|
||||
# and this ast will be linked before main ast as main-ast's beginning
|
||||
|
||||
var unix=
|
||||
{
|
||||
pipe:func(){},
|
||||
fork:func(){},
|
||||
dup2:func(){},
|
||||
exec:func(){},
|
||||
waitpid:func(){},
|
||||
opendir:func(){},
|
||||
readdir:func(){},
|
||||
closedir:func(){},
|
||||
time:func(){},
|
||||
chdir:func(){},
|
||||
environ:func(){},
|
||||
sleep:func(){},
|
||||
};
|
|
@ -0,0 +1,15 @@
|
|||
# nasal lib utf8.nas
|
||||
# 2020/2/6
|
||||
# this file is used to avoid name confliction
|
||||
# and is used to avoid name undefined
|
||||
# before running this file will be translated to abstract syntax tree
|
||||
# and this ast will be linked before main ast as main-ast's beginning
|
||||
|
||||
var utf8=
|
||||
{
|
||||
chstr:func(){},
|
||||
strc:func(){},
|
||||
substr:func(){},
|
||||
size:func(){},
|
||||
validate:func(){},
|
||||
};
|
|
@ -32,13 +32,14 @@
|
|||
others: __unknown_operator
|
||||
*/
|
||||
|
||||
const std::string lib_filename[9]=
|
||||
const std::string lib_filename[10]=
|
||||
{
|
||||
"lib/base.nas",
|
||||
"lib/bits.nas",
|
||||
"lib/io.nas",
|
||||
"lib/math.nas",
|
||||
"lib/readline.nas",
|
||||
"lib/regex.nas",
|
||||
"lib/sqlite.nas",
|
||||
"lib/thread.nas",
|
||||
"lib/unix.nas",
|
||||
|
@ -112,7 +113,7 @@ class resource_file
|
|||
void load_lib_file()
|
||||
{
|
||||
resource.clear();
|
||||
for(int i=0;i<9;++i)
|
||||
for(int i=0;i<10;++i)
|
||||
{
|
||||
std::ifstream fin(lib_filename[i],std::ios::binary);
|
||||
if(fin.fail())
|
||||
|
|
Loading…
Reference in New Issue