little update

This commit is contained in:
ValKmjolnir 2022-02-10 22:20:18 +08:00
parent a176022840
commit 3e7ba4d774
4 changed files with 44 additions and 45 deletions

35
lib.nas
View File

@ -263,23 +263,6 @@ var math=
isnan: func(x) {return __builtin_isnan(x); }
};
var D2R=math.pi/180;
var FPS2KT=0.5925;
var FT2M=0.3048;
var GAL2L=3.7854;
var IN2M=0.0254;
var KG2LB=2.2046;
var KT2FPS=1.6878;
var KT2MPS=0.5144;
var L2GAL=0.2642;
var LB2KG=0.4536;
var M2FT=3.2808;
var M2IN=39.3701;
var M2NM=0.00054;
var MPS2KT=1.9438;
var NM2M=1852;
var R2D=180/math.pi;
var unix=
{
pipe: func(){die("not supported yet");},
@ -328,3 +311,21 @@ var runtime=
# carefully use it because using it frequently may make program running slower.
gc: func(){return __builtin_gc;}
};
# important global constants
var D2R=math.pi/180;
var FPS2KT=0.5925;
var FT2M=0.3048;
var GAL2L=3.7854;
var IN2M=0.0254;
var KG2LB=2.2046;
var KT2FPS=1.6878;
var KT2MPS=0.5144;
var L2GAL=0.2642;
var LB2KG=0.4536;
var M2FT=3.2808;
var M2IN=39.3701;
var M2NM=0.00054;
var MPS2KT=1.9438;
var NM2M=1852;
var R2D=180/math.pi;

View File

@ -20,7 +20,7 @@ test:nasal
./nasal -op -e -d test/lexer.nas
./nasal -op -e -d test/life.nas
./nasal -op -t test/loop.nas
./nasal -op -c test/mandel.nas
./nasal -op -t -d test/mandel.nas
./nasal -op -t -d test/mandelbrot.nas
./nasal -op -c test/module_test.nas
./nasal -op -e test/nasal_test.nas

View File

@ -322,7 +322,7 @@ struct nasal_gc
std::vector<nasal_val*> memory; // gc memory
std::queue<nasal_val*> free_list[vm_type_size]; // gc free list
std::vector<nasal_ref> local;
size_t size[vm_type_size];
uint64_t size[vm_type_size];
uint64_t count[vm_type_size];
void mark();
void sweep();
@ -390,10 +390,7 @@ void nasal_gc::sweep()
void nasal_gc::init(const std::vector<std::string>& s)
{
for(uint8_t i=0;i<vm_type_size;++i)
{
size[i]=increment[i];
count[i]=0;
}
size[i]=count[i]=0;
for(uint8_t i=vm_str;i<vm_type_size;++i)
for(uint32_t j=0;j<increment[i];++j)
{
@ -436,7 +433,7 @@ void nasal_gc::info()
std::cout<<name[i]<<" | "<<count[i]<<"\n";
std::cout<<"\nmemory allocator info(max size):\n";
for(uint8_t i=vm_str;i<vm_type_size;++i)
std::cout<<name[i]<<" | "<<size[i]<<"(+"<<size[i]/increment[i]-1<<")\n";
std::cout<<name[i]<<" | "<<(size[i]+1)*increment[i]<<"(+"<<size[i]<<")\n";
}
nasal_ref nasal_gc::alloc(uint8_t type)
{
@ -448,7 +445,7 @@ nasal_ref nasal_gc::alloc(uint8_t type)
}
if(free_list[type].empty())
{
size[type]+=increment[type];
++size[type];
for(uint32_t i=0;i<increment[type];++i)
{
nasal_val* tmp=new nasal_val(type);
@ -469,7 +466,7 @@ nasal_ref nasal_gc::builtin_alloc(uint8_t type)
// so use builtin_alloc in builtin functions if this function uses alloc more then one time
if(free_list[type].empty())
{
size[type]+=increment[type];
++size[type];
for(uint32_t i=0;i<increment[type];++i)
{
nasal_val* tmp=new nasal_val(type);

View File

@ -263,23 +263,6 @@ var math=
isnan: func(x) {return __builtin_isnan(x); }
};
var D2R=math.pi/180;
var FPS2KT=0.5925;
var FT2M=0.3048;
var GAL2L=3.7854;
var IN2M=0.0254;
var KG2LB=2.2046;
var KT2FPS=1.6878;
var KT2MPS=0.5144;
var L2GAL=0.2642;
var LB2KG=0.4536;
var M2FT=3.2808;
var M2IN=39.3701;
var M2NM=0.00054;
var MPS2KT=1.9438;
var NM2M=1852;
var R2D=180/math.pi;
var unix=
{
pipe: func(){die("not supported yet");},
@ -328,3 +311,21 @@ var runtime=
# carefully use it because using it frequently may make program running slower.
gc: func(){return __builtin_gc;}
};
# important global constants
var D2R=math.pi/180;
var FPS2KT=0.5925;
var FT2M=0.3048;
var GAL2L=3.7854;
var IN2M=0.0254;
var KG2LB=2.2046;
var KT2FPS=1.6878;
var KT2MPS=0.5144;
var L2GAL=0.2642;
var LB2KG=0.4536;
var M2FT=3.2808;
var M2IN=39.3701;
var M2NM=0.00054;
var MPS2KT=1.9438;
var NM2M=1852;
var R2D=180/math.pi;