From 2ed20f636272cd4700a9edde92898b7db370eb23 Mon Sep 17 00:00:00 2001 From: ValKmjolnir Date: Sat, 9 Jul 2022 16:24:58 +0800 Subject: [PATCH] :memo: change some identifiers' name. --- README.md | 48 +++--- doc/README_zh.md | 46 +++--- lib.nas | 184 +++++++++++----------- nasal_builtin.h | 375 ++++++++++++++++++++++----------------------- nasal_dbg.h | 31 ++-- nasal_import.h | 2 +- nasal_opt.h | 20 ++- nasal_vm.h | 17 +- stl/lib.nas | 184 +++++++++++----------- stl/module.nas | 2 +- test/coroutine.nas | 4 +- 11 files changed, 453 insertions(+), 460 deletions(-) diff --git a/README.md b/README.md index 68394db..18e565b 100644 --- a/README.md +++ b/README.md @@ -331,7 +331,7 @@ You could see how to write your own native-functions below. ```javascript var my_new_obj=func(){ - return __builtin_my_obj(); + return __my_obj(); } var obj=my_new_obj(); ``` @@ -652,25 +652,25 @@ struct func nasal_ref (*func)(nasal_ref*,nasal_gc&); } builtin[]= { - {"__builtin_print",builtin_print}, + {"__print",builtin_print}, {nullptr, nullptr } }; ``` -At last,warp the `__builtin_print` in a nasal file: +At last,warp the `__print` in a nasal file: ```javascript var print=func(elems...){ - return __builtin_print(elems); + return __print(elems); }; ``` -In fact the arguments that `__builtin_print` uses are not necessary. +In fact the arguments that `__print` uses are not necessary. So writting it like this is also right: ```javascript var print=func(elems...){ - return __builtin_print; + return __print; }; ``` @@ -719,10 +719,10 @@ After 2021/12/3, there are some new functions added to `lib.nas`: ```javascript var dylib= { - dlopen: func(libname){return __builtin_dlopen;}, - dlsym: func(lib,sym){return __builtin_dlsym; }, - dlclose: func(lib){return __builtin_dlclose; }, - dlcall: func(funcptr,args...){return __builtin_dlcall} + dlopen: func(libname){return __dlopen;}, + dlsym: func(lib,sym){return __dlsym; }, + dlclose: func(lib){return __dlclose; }, + dlcall: func(funcptr,args...){return __dlcall} }; ``` @@ -1334,7 +1334,7 @@ func <0x29c>: 0x0000029d: 02 00 00 00 02 intl 0x2 0x0000029e: 0d 00 00 00 66 para 0x66 ("libname") 0x0000029f: 32 00 00 02 a2 jmp 0x2a2 - 0x000002a0: 40 00 00 00 42 callb 0x42 <__builtin_dlopen@0x41dc40> + 0x000002a0: 40 00 00 00 42 callb 0x42 <__dlopen@0x41dc40> 0x000002a1: 4a 00 00 00 00 ret <0x29c>; @@ -1346,7 +1346,7 @@ func <0x2a3>: 0x000002a5: 0d 00 00 00 68 para 0x68 ("lib") 0x000002a6: 0d 00 00 00 69 para 0x69 ("sym") 0x000002a7: 32 00 00 02 aa jmp 0x2aa - 0x000002a8: 40 00 00 00 43 callb 0x43 <__builtin_dlsym@0x41df00> + 0x000002a8: 40 00 00 00 43 callb 0x43 <__dlsym@0x41df00> 0x000002a9: 4a 00 00 00 00 ret <0x2a3>; @@ -1357,7 +1357,7 @@ func <0x2ab>: 0x000002ac: 02 00 00 00 02 intl 0x2 0x000002ad: 0d 00 00 00 68 para 0x68 ("lib") 0x000002ae: 32 00 00 02 b1 jmp 0x2b1 - 0x000002af: 40 00 00 00 44 callb 0x44 <__builtin_dlclose@0x41e2a0> + 0x000002af: 40 00 00 00 44 callb 0x44 <__dlclose@0x41e2a0> 0x000002b0: 4a 00 00 00 00 ret <0x2ab>; @@ -1369,7 +1369,7 @@ func <0x2b2>: 0x000002b4: 0d 00 00 00 6c para 0x6c ("funcptr") 0x000002b5: 0f 00 00 00 6d dyn 0x6d ("args") 0x000002b6: 32 00 00 02 b9 jmp 0x2b9 - 0x000002b7: 40 00 00 00 45 callb 0x45 <__builtin_dlcall@0x41e3d0> + 0x000002b7: 40 00 00 00 45 callb 0x45 <__dlcall@0x41e3d0> 0x000002b8: 4a 00 00 00 00 ret <0x2b2>; @@ -1381,7 +1381,7 @@ func <0x2bc>: 0x000002bc: 0b 00 00 02 bf newf 0x2bf 0x000002bd: 02 00 00 00 01 intl 0x1 0x000002be: 32 00 00 02 c1 jmp 0x2c1 - 0x000002bf: 40 00 00 00 46 callb 0x46 <__builtin_platform@0x41e4f0> + 0x000002bf: 40 00 00 00 46 callb 0x46 <__platform@0x41e4f0> 0x000002c0: 4a 00 00 00 00 ret <0x2bc>; @@ -1393,7 +1393,7 @@ func <0x2c4>: 0x000002c4: 0b 00 00 02 c7 newf 0x2c7 0x000002c5: 02 00 00 00 01 intl 0x1 0x000002c6: 32 00 00 02 c9 jmp 0x2c9 - 0x000002c7: 40 00 00 00 47 callb 0x47 <__builtin_gc@0x41e530> + 0x000002c7: 40 00 00 00 47 callb 0x47 <__gc@0x41e530> 0x000002c8: 4a 00 00 00 00 ret <0x2c4>; @@ -1409,11 +1409,11 @@ Now we add coroutine in this runtime: ```javascript var coroutine={ - create: func(function){return __builtin_cocreate;}, - resume: func(co) {return __builtin_coresume;}, - yield: func(args...) {return __builtin_coyield; }, - status: func(co) {return __builtin_costatus;}, - running:func() {return __builtin_corun; } + create: func(function){return __cocreate;}, + resume: func(co) {return __coresume;}, + yield: func(args...) {return __coyield; }, + status: func(co) {return __costatus;}, + running:func() {return __corun; } }; ``` @@ -1748,7 +1748,7 @@ hello [vm] error: error occurred this line [vm] native function error. trace back: - 0x000000ac: 40 00 00 00 25 callb 0x25 <__builtin_die@0x41afc0> (lib.nas:131) + 0x000000ac: 40 00 00 00 25 callb 0x25 <__die@0x41afc0> (lib.nas:131) 0x000004f6: 3e 00 00 00 01 callfv 0x1 (a.nas:4) 0x000004fa: 3e 00 00 00 00 callfv 0x0 (a.nas:6) vm stack(0x7fffcd21bc68, limit 10, total 12): @@ -1825,7 +1825,7 @@ hello [vm] error: error occurred this line [vm] native function error. trace back: - 0x000000ac: 40 00 00 00 25 callb 0x25 <__builtin_die@0x41afc0> (lib.nas:131) + 0x000000ac: 40 00 00 00 25 callb 0x25 <__die@0x41afc0> (lib.nas:131) 0x000004f6: 3e 00 00 00 01 callfv 0x1 (a.nas:4) 0x000004fa: 3e 00 00 00 00 callfv 0x0 (a.nas:6) vm stack(0x7ffff42f3d08, limit 10, total 12): @@ -1961,7 +1961,7 @@ next bytecode: 0x00000002: 02 00 00 00 02 intl 0x2 (lib.nas:5) 0x00000003: 0d 00 00 00 00 para 0x0 ("filename") (lib.nas:5) 0x00000004: 32 00 00 00 07 jmp 0x7 (lib.nas:5) - 0x00000005: 40 00 00 00 24 callb 0x24 <__builtin_import@0x419b20> (lib.nas:6) + 0x00000005: 40 00 00 00 24 callb 0x24 <__import@0x419b20> (lib.nas:6) 0x00000006: 4a 00 00 00 00 ret 0x0 (lib.nas:6) 0x00000007: 03 00 00 00 00 loadg 0x0 (lib.nas:5) vm stack(0x7fffe05e3190, limit 5, total 0) diff --git a/doc/README_zh.md b/doc/README_zh.md index befd863..d966a6d 100644 --- a/doc/README_zh.md +++ b/doc/README_zh.md @@ -309,7 +309,7 @@ __`vm_obj`__ 是一种用来存储用户自定义数据的特别类型。这意 ```javascript var my_new_obj=func(){ - return __builtin_my_obj(); + return __my_obj(); } var obj=my_new_obj(); ``` @@ -618,7 +618,7 @@ struct func nasal_ref (*func)(nasal_ref*,nasal_gc&); } builtin[]= { - {"__builtin_print",builtin_print}, + {"__print",builtin_print}, {nullptr, nullptr } }; ``` @@ -627,15 +627,15 @@ struct func ```javascript var print=func(elems...){ - return __builtin_print(elems); + return __print(elems); }; ``` -事实上`__builtin_print`后面跟着的传参列表不是必须要写的。所以这样写也对: +事实上`__print`后面跟着的传参列表不是必须要写的。所以这样写也对: ```javascript var print=func(elems...){ - return __builtin_print; + return __print; }; ``` @@ -679,10 +679,10 @@ nasal_ref builtin_keys(nasal_ref* local,nasal_gc& gc) ```javascript var dylib= { - dlopen: func(libname){return __builtin_dlopen;}, - dlsym: func(lib,sym){return __builtin_dlsym; }, - dlclose: func(lib){return __builtin_dlclose; }, - dlcall: func(funcptr,args...){return __builtin_dlcall} + dlopen: func(libname){return __dlopen;}, + dlsym: func(lib,sym){return __dlsym; }, + dlclose: func(lib){return __dlclose; }, + dlcall: func(funcptr,args...){return __dlcall} }; ``` @@ -1235,7 +1235,7 @@ func <0x29c>: 0x0000029d: 02 00 00 00 02 intl 0x2 0x0000029e: 0d 00 00 00 66 para 0x66 ("libname") 0x0000029f: 32 00 00 02 a2 jmp 0x2a2 - 0x000002a0: 40 00 00 00 42 callb 0x42 <__builtin_dlopen@0x41dc40> + 0x000002a0: 40 00 00 00 42 callb 0x42 <__dlopen@0x41dc40> 0x000002a1: 4a 00 00 00 00 ret <0x29c>; @@ -1247,7 +1247,7 @@ func <0x2a3>: 0x000002a5: 0d 00 00 00 68 para 0x68 ("lib") 0x000002a6: 0d 00 00 00 69 para 0x69 ("sym") 0x000002a7: 32 00 00 02 aa jmp 0x2aa - 0x000002a8: 40 00 00 00 43 callb 0x43 <__builtin_dlsym@0x41df00> + 0x000002a8: 40 00 00 00 43 callb 0x43 <__dlsym@0x41df00> 0x000002a9: 4a 00 00 00 00 ret <0x2a3>; @@ -1258,7 +1258,7 @@ func <0x2ab>: 0x000002ac: 02 00 00 00 02 intl 0x2 0x000002ad: 0d 00 00 00 68 para 0x68 ("lib") 0x000002ae: 32 00 00 02 b1 jmp 0x2b1 - 0x000002af: 40 00 00 00 44 callb 0x44 <__builtin_dlclose@0x41e2a0> + 0x000002af: 40 00 00 00 44 callb 0x44 <__dlclose@0x41e2a0> 0x000002b0: 4a 00 00 00 00 ret <0x2ab>; @@ -1270,7 +1270,7 @@ func <0x2b2>: 0x000002b4: 0d 00 00 00 6c para 0x6c ("funcptr") 0x000002b5: 0f 00 00 00 6d dyn 0x6d ("args") 0x000002b6: 32 00 00 02 b9 jmp 0x2b9 - 0x000002b7: 40 00 00 00 45 callb 0x45 <__builtin_dlcall@0x41e3d0> + 0x000002b7: 40 00 00 00 45 callb 0x45 <__dlcall@0x41e3d0> 0x000002b8: 4a 00 00 00 00 ret <0x2b2>; @@ -1282,7 +1282,7 @@ func <0x2bc>: 0x000002bc: 0b 00 00 02 bf newf 0x2bf 0x000002bd: 02 00 00 00 01 intl 0x1 0x000002be: 32 00 00 02 c1 jmp 0x2c1 - 0x000002bf: 40 00 00 00 46 callb 0x46 <__builtin_platform@0x41e4f0> + 0x000002bf: 40 00 00 00 46 callb 0x46 <__platform@0x41e4f0> 0x000002c0: 4a 00 00 00 00 ret <0x2bc>; @@ -1294,7 +1294,7 @@ func <0x2c4>: 0x000002c4: 0b 00 00 02 c7 newf 0x2c7 0x000002c5: 02 00 00 00 01 intl 0x1 0x000002c6: 32 00 00 02 c9 jmp 0x2c9 - 0x000002c7: 40 00 00 00 47 callb 0x47 <__builtin_gc@0x41e530> + 0x000002c7: 40 00 00 00 47 callb 0x47 <__gc@0x41e530> 0x000002c8: 4a 00 00 00 00 ret <0x2c4>; @@ -1310,11 +1310,11 @@ func <0x2c4>: ```javascript var coroutine={ - create: func(function){return __builtin_cocreate;}, - resume: func(co) {return __builtin_coresume;}, - yield: func(args...) {return __builtin_coyield; }, - status: func(co) {return __builtin_costatus;}, - running:func() {return __builtin_corun; } + create: func(function){return __cocreate;}, + resume: func(co) {return __coresume;}, + yield: func(args...) {return __coyield; }, + status: func(co) {return __costatus;}, + running:func() {return __corun; } }; ``` @@ -1609,7 +1609,7 @@ hello [vm] error: error occurred this line [vm] native function error. trace back: - 0x000000ac: 40 00 00 00 25 callb 0x25 <__builtin_die@0x41afc0> (lib.nas:131) + 0x000000ac: 40 00 00 00 25 callb 0x25 <__die@0x41afc0> (lib.nas:131) 0x000004f6: 3e 00 00 00 01 callfv 0x1 (a.nas:4) 0x000004fa: 3e 00 00 00 00 callfv 0x0 (a.nas:6) vm stack(0x7fffcd21bc68, limit 10, total 12): @@ -1686,7 +1686,7 @@ hello [vm] error: error occurred this line [vm] native function error. trace back: - 0x000000ac: 40 00 00 00 25 callb 0x25 <__builtin_die@0x41afc0> (lib.nas:131) + 0x000000ac: 40 00 00 00 25 callb 0x25 <__die@0x41afc0> (lib.nas:131) 0x000004f6: 3e 00 00 00 01 callfv 0x1 (a.nas:4) 0x000004fa: 3e 00 00 00 00 callfv 0x0 (a.nas:6) vm stack(0x7ffff42f3d08, limit 10, total 12): @@ -1820,7 +1820,7 @@ next bytecode: 0x00000002: 02 00 00 00 02 intl 0x2 (lib.nas:5) 0x00000003: 0d 00 00 00 00 para 0x0 ("filename") (lib.nas:5) 0x00000004: 32 00 00 00 07 jmp 0x7 (lib.nas:5) - 0x00000005: 40 00 00 00 24 callb 0x24 <__builtin_import@0x419b20> (lib.nas:6) + 0x00000005: 40 00 00 00 24 callb 0x24 <__import@0x419b20> (lib.nas:6) 0x00000006: 4a 00 00 00 00 ret 0x0 (lib.nas:6) 0x00000007: 03 00 00 00 00 loadg 0x0 (lib.nas:5) vm stack(0x7fffe05e3190, limit 5, total 0) diff --git a/lib.nas b/lib.nas index b09f175..d517ad7 100644 --- a/lib.nas +++ b/lib.nas @@ -3,66 +3,66 @@ # print is used to print all things in nasal, try and see how it works. # this function uses std::cout/printf to output logs. var print=func(elems...){ - return __builtin_print(elems); + return __print(elems); } # append is used to add values into a vector. var append=func(vec,elems...){ - return __builtin_append(vec,elems); + return __append(vec,elems); } # setsize is used to change the size of vector. # if the size is larger than before, # this function will fill vm_nil into uninitialized space. var setsize=func(vec,size){ - return __builtin_setsize(vec,size); + return __setsize(vec,size); } # system has the same use in C. var system=func(str){ - return __builtin_system(str); + return __system(str); } # input uses std::cin and returns what we input. var input=func(){ - return __builtin_input(); + return __input(); } # split a string by separator for example: # split("ll","hello world") -> ["he","o world"] # this function will return a vector. var split=func(separator,str){ - return __builtin_split(separator,str); + return __split(separator,str); } # rand has the same function as the rand in C # if seed is nil, it will return the random number. # if seed is not nil, it will be initialized by this seed. var rand=func(seed=nil){ - return __builtin_rand(seed); + return __rand(seed); } # id will return the pointer of an gc-object. # if this object is not managed by gc, it will return 0. var id=func(object){ - return __builtin_id(object); + return __id(object); } # int will get the integer of input number. # but carefully use it, because int has range between -2147483648~2147483647 var int=func(val){ - return __builtin_int(val); + return __int(val); } # floor will get the integral number of input argument # which is less than or equal to this argument var floor=func(val){ - return __builtin_floor(val); + return __floor(val); } # abort using std::abort var abort=func(){ - __builtin_abort(); + __abort(); } # abs gets absolute number. @@ -73,47 +73,47 @@ var abs=func(n){ # num will change all the other types into number. # mostly used to change a numerable string. var num=func(val){ - return __builtin_num(val); + return __num(val); } # pop used to pop the last element in a vector. # this function will return the value that poped if vector has element(s). # if the vector is empty, it will return nil. var pop=func(vec){ - return __builtin_pop(vec); + return __pop(vec); } # str is used to change number into string. var str=func(num){ - return __builtin_str(num); + return __str(num); } # size can get the size of a string/vector/hashmap. # in fact it can also get the size of number, and the result is the number itself. # so don't do useless things, though it really works. var size=func(object){ - return __builtin_size(object); + return __size(object); } # contains is used to check if a key exists in a hashmap/dict. var contains=func(hash,key){ - return __builtin_contains(hash,key); + return __contains(hash,key); } # delete is used to delete a pair in a hashmap/dict by key. var delete=func(hash,key){ - return __builtin_delete(hash,key); + return __delete(hash,key); } # keys is used to get all keys in a hashmap/dict. # this function will return a vector. var keys=func(hash){ - return __builtin_keys(hash); + return __keys(hash); } # time has the same function in C. var time=func(begin){ - return __builtin_time(begin); + return __time(begin); } var systime=func(){ return time(0); @@ -122,18 +122,18 @@ var systime=func(){ # die is a special native function. # use it at where you want the program to crash immediately. var die=func(str){ - return __builtin_die(str); + return __die(str); } # find will give the first position of the needle in haystack var find=func(needle,haystack){ - return __builtin_find(needle,haystack); + return __find(needle,haystack); } # typeof is used to get the type of an object. # this function returns a string. var typeof=func(object){ - return __builtin_type(object); + return __type(object); } # subvec is used to get part of a vector @@ -144,37 +144,37 @@ var subvec=func(vec,begin,length=nil){ # substr will get the sub-string. # it gets the string, the begin index and sub-string's length as arguments. var substr=func(str,begin,len){ - return __builtin_substr(str,begin,len); + return __substr(str,begin,len); } # streq is used to compare if two strings are the same. var streq=func(a,b){ - return __builtin_streq(a,b); + return __streq(a,b); } # left is used to get the sub-string like substr. # but the begin index is 0. var left=func(str,len){ - return __builtin_left(str,len); + return __left(str,len); } # right i used to get the sub-string like substr. # but the begin index is strlen-len. var right=func(str,len){ - return __builtin_right(str,len); + return __right(str,len); } # cmp is used to compare two strings. # normal string will not be correctly compared by operators < > <= >= # because these operators will turn strings into numbers then compare. var cmp=func(a,b){ - return __builtin_cmp(a,b); + return __cmp(a,b); } # chr is used to get the character by ascii-number. # for example chr(65) -> 'A' var chr=func(code){ - return __builtin_chr(code); + return __chr(code); } # mut is used to change unmutable strings to mutable. @@ -190,13 +190,13 @@ var srand=func(){ # values() gets all values in a hash. var values=func(hash){ - return __builtin_values(hash); + return __values(hash); } # println has the same function as print. # but it will output a '\n' after using print. var println=func(elems...){ - return __builtin_println(elems); + return __println(elems); } var isfunc=func(f){ @@ -263,7 +263,7 @@ var assert=func(condition,message="assertion failed!"){ var maketimestamp=func(){ var t=0; var millisec=func(){ - return __builtin_millisec; + return __millisec; } return { stamp:func(){t=millisec();}, @@ -274,7 +274,7 @@ var maketimestamp=func(){ # md5 var md5=func(str){ - return __builtin_md5(str); + return __md5(str); } var io= @@ -283,29 +283,29 @@ var io= SEEK_CUR:1, SEEK_END:2, # get content of a file by filename. returns a string. - fin: func(filename){return __builtin_fin(filename);}, + fin: func(filename){return __fin(filename);}, # input a string as the content of a file. - fout: func(filename,str){return __builtin_fout(filename,str);}, + fout: func(filename,str){return __fout(filename,str);}, # same as C fopen. open file and get the FILE*. - open: func(filename,mode="r"){return __builtin_open(filename,mode);}, + open: func(filename,mode="r"){return __open(filename,mode);}, # same as C fclose. close file by FILE*. - close: func(filehandle){return __builtin_close(filehandle);}, + close: func(filehandle){return __close(filehandle);}, # same as C fread. read file by FILE*. # caution: buf must be a mutable string.use mut("") to get an empty mutable string. - read: func(filehandle,buf,len){return __builtin_read(filehandle,buf,len);}, + read: func(filehandle,buf,len){return __read(filehandle,buf,len);}, # same as C fwrite. write file by FILE*. - write: func(filehandle,str){return __builtin_write(filehandle,str);}, + write: func(filehandle,str){return __write(filehandle,str);}, # same as C fseek. seek place by FILE*. - seek: func(filehandle,pos,whence){return __builtin_seek(filehandle,pos,whence);}, + seek: func(filehandle,pos,whence){return __seek(filehandle,pos,whence);}, # same as C ftell. - tell: func(filehandle){return __builtin_tell(filehandle);}, + tell: func(filehandle){return __tell(filehandle);}, # read file by lines. use FILE*. # get nil if EOF - readln:func(filehandle){return __builtin_readln(filehandle);}, + readln:func(filehandle){return __readln(filehandle);}, # same as C stat. - stat: func(filename){return __builtin_stat(filename);}, + stat: func(filename){return __stat(filename);}, # same as C feof. check if FILE* gets the end of file(EOF). - eof: func(filehandle){return __builtin_eof(filehandle);} + eof: func(filehandle){return __eof(filehandle);} }; # get file status. using data from io.stat @@ -331,45 +331,45 @@ var fstat=func(filename){ var bits= { # i32 xor - i32_xor: func(a,b){return __builtin_i32xor(a,b); }, + i32_xor: func(a,b){return __i32xor(a,b); }, # i32 and - i32_and: func(a,b){return __builtin_i32and(a,b); }, + i32_and: func(a,b){return __i32and(a,b); }, # i32 or - i32_or: func(a,b){return __builtin_i32or(a,b); }, + i32_or: func(a,b){return __i32or(a,b); }, # i32 nand - i32_nand:func(a,b){return __builtin_i32nand(a,b);}, + i32_nand:func(a,b){return __i32nand(a,b);}, # i32 not - i32_not: func(a) {return __builtin_i32not(a); }, + i32_not: func(a) {return __i32not(a); }, # u32 xor - u32_xor: func(a,b){return __builtin_u32xor(a,b); }, + u32_xor: func(a,b){return __u32xor(a,b); }, # u32 and - u32_and: func(a,b){return __builtin_u32and(a,b); }, + u32_and: func(a,b){return __u32and(a,b); }, # u32 or - u32_or: func(a,b){return __builtin_u32or(a,b); }, + u32_or: func(a,b){return __u32or(a,b); }, # u32 nand - u32_nand:func(a,b){return __builtin_u32nand(a,b);}, + u32_nand:func(a,b){return __u32nand(a,b);}, # u32 not - u32_not: func(a) {return __builtin_u32not(a); }, + u32_not: func(a) {return __u32not(a); }, # get bit data from a special string. for example: # bits.fld(s,0,3); # if s stores 10100010(162) # will get 101(5). - fld: func(str,startbit,len){return __builtin_fld;}, + fld: func(str,startbit,len){return __fld;}, # get sign-extended data from a special string. for example: # bits.sfld(s,0,3); # if s stores 10100010(162) # will get 101(5) then this will be signed extended to # 11111101(-3). - sfld: func(str,startbit,len){return __builtin_sfld;}, + sfld: func(str,startbit,len){return __sfld;}, # set value into a special string to store it. little-endian, for example: # bits.setfld(s,0,8,69); # set 01000101(69) to string will get this: # 10100010(162) # so s[0]=162. - setfld: func(str,startbit,len,val){return __builtin_setfld;}, + setfld: func(str,startbit,len,val){return __setfld;}, # get a special string filled by '\0' to use in setfld. - buf: func(len){return __builtin_buf;} + buf: func(len){return __buf;} }; # mostly used math functions and special constants, you know. @@ -380,39 +380,39 @@ var math= inf: 1/0, nan: 0/0, abs: func(x) {return x>0?x:-x; }, - floor: func(x) {return __builtin_floor(x); }, - pow: func(x,y){return __builtin_pow(x,y); }, - sin: func(x) {return __builtin_sin(x); }, - cos: func(x) {return __builtin_cos(x); }, - tan: func(x) {return __builtin_tan(x); }, - exp: func(x) {return __builtin_exp(x); }, - lg: func(x) {return __builtin_lg(x); }, - ln: func(x) {return __builtin_ln(x); }, - sqrt: func(x) {return __builtin_sqrt(x); }, - atan2: func(x,y){return __builtin_atan2(x,y);}, - isnan: func(x) {return __builtin_isnan(x); }, + floor: func(x) {return __floor(x); }, + pow: func(x,y){return __pow(x,y); }, + sin: func(x) {return __sin(x); }, + cos: func(x) {return __cos(x); }, + tan: func(x) {return __tan(x); }, + exp: func(x) {return __exp(x); }, + lg: func(x) {return __lg(x); }, + ln: func(x) {return __ln(x); }, + sqrt: func(x) {return __sqrt(x); }, + atan2: func(x,y){return __atan2(x,y);}, + isnan: func(x) {return __isnan(x); }, max: func(x,y){return x>y?x:y; }, min: func(x,y){return x"){ } var coroutine={ - create: func(function){return __builtin_cocreate;}, - resume: func(co) {return __builtin_coresume;}, - yield: func(args...) {return __builtin_coyield; }, - status: func(co) {return __builtin_costatus;}, - running:func() {return __builtin_corun; } + create: func(function){return __cocreate;}, + resume: func(co) {return __coresume;}, + yield: func(args...) {return __coyield; }, + status: func(co) {return __costatus;}, + running:func() {return __corun; } }; \ No newline at end of file diff --git a/nasal_builtin.h b/nasal_builtin.h index 7bcb1ee..306119d 100644 --- a/nasal_builtin.h +++ b/nasal_builtin.h @@ -7,103 +7,102 @@ #endif // declaration of builtin functions -// to add new builtin function, declare it here and write the definition below -#define nas_native(name) nasal_ref name(nasal_ref*,nasal_gc&) -nas_native(builtin_print); -nas_native(builtin_println); -nas_native(builtin_abort); -nas_native(builtin_append); -nas_native(builtin_setsize); -nas_native(builtin_system); -nas_native(builtin_input); -nas_native(builtin_fin); -nas_native(builtin_fout); -nas_native(builtin_split); -nas_native(builtin_rand); -nas_native(builtin_id); -nas_native(builtin_int); -nas_native(builtin_floor); -nas_native(builtin_num); -nas_native(builtin_pop); -nas_native(builtin_str); -nas_native(builtin_size); -nas_native(builtin_i32xor); -nas_native(builtin_i32and); -nas_native(builtin_i32or); -nas_native(builtin_i32nand); -nas_native(builtin_i32not); -nas_native(builtin_u32xor); -nas_native(builtin_u32and); -nas_native(builtin_u32or); -nas_native(builtin_u32nand); -nas_native(builtin_u32not); -nas_native(builtin_pow); -nas_native(builtin_sin); -nas_native(builtin_cos); -nas_native(builtin_tan); -nas_native(builtin_exp); -nas_native(builtin_lg); -nas_native(builtin_ln); -nas_native(builtin_sqrt); -nas_native(builtin_atan2); -nas_native(builtin_isnan); -nas_native(builtin_time); -nas_native(builtin_contains); -nas_native(builtin_delete); -nas_native(builtin_keys); -nas_native(builtin_die); -nas_native(builtin_find); -nas_native(builtin_type); -nas_native(builtin_substr); -nas_native(builtin_streq); -nas_native(builtin_left); -nas_native(builtin_right); -nas_native(builtin_cmp); -nas_native(builtin_chr); -nas_native(builtin_values); -nas_native(builtin_open); -nas_native(builtin_close); -nas_native(builtin_read); -nas_native(builtin_write); -nas_native(builtin_seek); -nas_native(builtin_tell); -nas_native(builtin_readln); -nas_native(builtin_stat); -nas_native(builtin_eof); -nas_native(builtin_fld); -nas_native(builtin_sfld); -nas_native(builtin_setfld); -nas_native(builtin_buf); -nas_native(builtin_sleep); -nas_native(builtin_pipe); -nas_native(builtin_fork); -nas_native(builtin_waitpid); -nas_native(builtin_opendir); -nas_native(builtin_readdir); -nas_native(builtin_closedir); -nas_native(builtin_chdir); -nas_native(builtin_environ); -nas_native(builtin_getcwd); -nas_native(builtin_getenv); -nas_native(builtin_dlopen); -nas_native(builtin_dlsym); -nas_native(builtin_dlclose); -nas_native(builtin_dlcall); -nas_native(builtin_platform); -nas_native(builtin_gc); -nas_native(builtin_md5); -nas_native(builtin_cocreate); -nas_native(builtin_coresume); -nas_native(builtin_coyield); -nas_native(builtin_costatus); -nas_native(builtin_corun); -nas_native(builtin_millisec); -nas_native(builtin_sysargv); -nas_native(builtin_logtime); +#define native(name) nasal_ref name(nasal_ref*,nasal_gc&) +native(builtin_print); +native(builtin_println); +native(builtin_abort); +native(builtin_append); +native(builtin_setsize); +native(builtin_system); +native(builtin_input); +native(builtin_fin); +native(builtin_fout); +native(builtin_split); +native(builtin_rand); +native(builtin_id); +native(builtin_int); +native(builtin_floor); +native(builtin_num); +native(builtin_pop); +native(builtin_str); +native(builtin_size); +native(builtin_i32xor); +native(builtin_i32and); +native(builtin_i32or); +native(builtin_i32nand); +native(builtin_i32not); +native(builtin_u32xor); +native(builtin_u32and); +native(builtin_u32or); +native(builtin_u32nand); +native(builtin_u32not); +native(builtin_pow); +native(builtin_sin); +native(builtin_cos); +native(builtin_tan); +native(builtin_exp); +native(builtin_lg); +native(builtin_ln); +native(builtin_sqrt); +native(builtin_atan2); +native(builtin_isnan); +native(builtin_time); +native(builtin_contains); +native(builtin_delete); +native(builtin_keys); +native(builtin_die); +native(builtin_find); +native(builtin_type); +native(builtin_substr); +native(builtin_streq); +native(builtin_left); +native(builtin_right); +native(builtin_cmp); +native(builtin_chr); +native(builtin_values); +native(builtin_open); +native(builtin_close); +native(builtin_read); +native(builtin_write); +native(builtin_seek); +native(builtin_tell); +native(builtin_readln); +native(builtin_stat); +native(builtin_eof); +native(builtin_fld); +native(builtin_sfld); +native(builtin_setfld); +native(builtin_buf); +native(builtin_sleep); +native(builtin_pipe); +native(builtin_fork); +native(builtin_waitpid); +native(builtin_opendir); +native(builtin_readdir); +native(builtin_closedir); +native(builtin_chdir); +native(builtin_environ); +native(builtin_getcwd); +native(builtin_getenv); +native(builtin_dlopen); +native(builtin_dlsym); +native(builtin_dlclose); +native(builtin_dlcall); +native(builtin_platform); +native(builtin_gc); +native(builtin_md5); +native(builtin_cocreate); +native(builtin_coresume); +native(builtin_coyield); +native(builtin_costatus); +native(builtin_corun); +native(builtin_millisec); +native(builtin_sysargv); +native(builtin_logtime); -nasal_ref builtin_err(const char* func_name,const std::string& info) +nasal_ref builtin_err(const std::string& errfunc,const std::string& info) { - std::cerr<<"[vm] "<& elems) @@ -347,7 +346,7 @@ nasal_ref builtin_split(nasal_ref* local,nasal_gc& gc) pos=s.find(deli,last); } if(last!=s.length()) - vec.push_back(gc.newstr(s.substr(last,s.length()-1))); + vec.push_back(gc.newstr(s.substr(last))); gc.temp=nil; return res; } diff --git a/nasal_dbg.h b/nasal_dbg.h index 346d781..f7af91b 100644 --- a/nasal_dbg.h +++ b/nasal_dbg.h @@ -7,12 +7,13 @@ class nasal_dbg:public nasal_vm { private: bool next_step; + size_t fsize; uint16_t bk_fidx; uint32_t bk_line; fstreamline src; std::vector parse(const std::string&); - uint16_t get_fileindex(const std::string&); + uint16_t fileindex(const std::string&); void err(); void help(); void stepinfo(); @@ -31,25 +32,22 @@ public: std::vector nasal_dbg::parse(const std::string& cmd) { std::vector res; - std::string tmp=""; - for(uint32_t i=0;ilast) + res.push_back(cmd.substr(last,pos-last)); + last=pos+1; + pos=cmd.find(" ",last); } - if(tmp.length()) - res.push_back(tmp); + if(last& argv) { detail_info=true; + fsize=linker.get_file().size(); init(gen.get_strs(),gen.get_nums(),gen.get_code(),linker.get_file(),argv); const void* oprs[]= { diff --git a/nasal_import.h b/nasal_import.h index 926e62c..cf1ab04 100644 --- a/nasal_import.h +++ b/nasal_import.h @@ -39,7 +39,7 @@ nasal_import::nasal_import(nasal_err& e):lib_loaded(false),nerr(e){ pos=PATH.find(sep,last); } if(last!=PATH.length()) - envpath.push_back(PATH.substr(last,pos-last)); + envpath.push_back(PATH.substr(last)); } std::string nasal_import::path(const nasal_ast& node) diff --git a/nasal_opt.h b/nasal_opt.h index cd27acc..d1020bc 100644 --- a/nasal_opt.h +++ b/nasal_opt.h @@ -47,19 +47,17 @@ void calc_const(nasal_ast& root) } if(vec.size()!=2) return; - if(root.type()!=ast_add && - root.type()!=ast_sub && - root.type()!=ast_mult && - root.type()!=ast_div && - root.type()!=ast_link && - root.type()!=ast_less && - root.type()!=ast_leq && - root.type()!=ast_grt && - root.type()!=ast_geq) + if(root.type()!=ast_add && root.type()!=ast_sub && + root.type()!=ast_mult && root.type()!=ast_div && + root.type()!=ast_link && root.type()!=ast_less && + root.type()!=ast_leq && root.type()!=ast_grt && + root.type()!=ast_geq) return; - if(root.type()==ast_link && vec[0].type()==ast_str && vec[1].type()==ast_str) + if(root.type()==ast_link && + vec[0].type()==ast_str && vec[1].type()==ast_str) const_str(root); - else if(root.type()!=ast_link && vec[0].type()==ast_num && vec[1].type()==ast_num) + else if(root.type()!=ast_link && + vec[0].type()==ast_num && vec[1].type()==ast_num) const_num(root); } void optimize(nasal_ast& root) diff --git a/nasal_vm.h b/nasal_vm.h index 2dda8a4..3dcb5c6 100644 --- a/nasal_vm.h +++ b/nasal_vm.h @@ -22,7 +22,6 @@ protected: nasal_ref stack[STACK_DEPTH]; /* values used for debugger */ - size_t files_size; const std::string* files; // ref from nasal_import const opcode* bytecode; // ref from nasal_codegen @@ -144,7 +143,6 @@ void nasal_vm::init( str_table=strs.data(); bytecode=code.data(); files=filenames.data(); - files_size=filenames.size(); /* set canary and program counter */ pc=0; @@ -340,18 +338,17 @@ void nasal_vm::opcallsort(const uint64_t* arr) { typedef std::pair op; std::vector opcall; - for(uint32_t i=0;i<=op_ret;++i) + uint64_t total=0; + for(uint32_t i=0;ib.second;} + } + std::sort(opcall.begin(),opcall.end(), + [](const op& a,const op& b){return a.second>b.second;} ); std::cout<<"\noperands call info"; - uint64_t total=0; - for(auto& i:opcall) - total+=i.second; for(auto& i:opcall) { uint64_t rate=i.second*100/total; diff --git a/stl/lib.nas b/stl/lib.nas index b09f175..d517ad7 100644 --- a/stl/lib.nas +++ b/stl/lib.nas @@ -3,66 +3,66 @@ # print is used to print all things in nasal, try and see how it works. # this function uses std::cout/printf to output logs. var print=func(elems...){ - return __builtin_print(elems); + return __print(elems); } # append is used to add values into a vector. var append=func(vec,elems...){ - return __builtin_append(vec,elems); + return __append(vec,elems); } # setsize is used to change the size of vector. # if the size is larger than before, # this function will fill vm_nil into uninitialized space. var setsize=func(vec,size){ - return __builtin_setsize(vec,size); + return __setsize(vec,size); } # system has the same use in C. var system=func(str){ - return __builtin_system(str); + return __system(str); } # input uses std::cin and returns what we input. var input=func(){ - return __builtin_input(); + return __input(); } # split a string by separator for example: # split("ll","hello world") -> ["he","o world"] # this function will return a vector. var split=func(separator,str){ - return __builtin_split(separator,str); + return __split(separator,str); } # rand has the same function as the rand in C # if seed is nil, it will return the random number. # if seed is not nil, it will be initialized by this seed. var rand=func(seed=nil){ - return __builtin_rand(seed); + return __rand(seed); } # id will return the pointer of an gc-object. # if this object is not managed by gc, it will return 0. var id=func(object){ - return __builtin_id(object); + return __id(object); } # int will get the integer of input number. # but carefully use it, because int has range between -2147483648~2147483647 var int=func(val){ - return __builtin_int(val); + return __int(val); } # floor will get the integral number of input argument # which is less than or equal to this argument var floor=func(val){ - return __builtin_floor(val); + return __floor(val); } # abort using std::abort var abort=func(){ - __builtin_abort(); + __abort(); } # abs gets absolute number. @@ -73,47 +73,47 @@ var abs=func(n){ # num will change all the other types into number. # mostly used to change a numerable string. var num=func(val){ - return __builtin_num(val); + return __num(val); } # pop used to pop the last element in a vector. # this function will return the value that poped if vector has element(s). # if the vector is empty, it will return nil. var pop=func(vec){ - return __builtin_pop(vec); + return __pop(vec); } # str is used to change number into string. var str=func(num){ - return __builtin_str(num); + return __str(num); } # size can get the size of a string/vector/hashmap. # in fact it can also get the size of number, and the result is the number itself. # so don't do useless things, though it really works. var size=func(object){ - return __builtin_size(object); + return __size(object); } # contains is used to check if a key exists in a hashmap/dict. var contains=func(hash,key){ - return __builtin_contains(hash,key); + return __contains(hash,key); } # delete is used to delete a pair in a hashmap/dict by key. var delete=func(hash,key){ - return __builtin_delete(hash,key); + return __delete(hash,key); } # keys is used to get all keys in a hashmap/dict. # this function will return a vector. var keys=func(hash){ - return __builtin_keys(hash); + return __keys(hash); } # time has the same function in C. var time=func(begin){ - return __builtin_time(begin); + return __time(begin); } var systime=func(){ return time(0); @@ -122,18 +122,18 @@ var systime=func(){ # die is a special native function. # use it at where you want the program to crash immediately. var die=func(str){ - return __builtin_die(str); + return __die(str); } # find will give the first position of the needle in haystack var find=func(needle,haystack){ - return __builtin_find(needle,haystack); + return __find(needle,haystack); } # typeof is used to get the type of an object. # this function returns a string. var typeof=func(object){ - return __builtin_type(object); + return __type(object); } # subvec is used to get part of a vector @@ -144,37 +144,37 @@ var subvec=func(vec,begin,length=nil){ # substr will get the sub-string. # it gets the string, the begin index and sub-string's length as arguments. var substr=func(str,begin,len){ - return __builtin_substr(str,begin,len); + return __substr(str,begin,len); } # streq is used to compare if two strings are the same. var streq=func(a,b){ - return __builtin_streq(a,b); + return __streq(a,b); } # left is used to get the sub-string like substr. # but the begin index is 0. var left=func(str,len){ - return __builtin_left(str,len); + return __left(str,len); } # right i used to get the sub-string like substr. # but the begin index is strlen-len. var right=func(str,len){ - return __builtin_right(str,len); + return __right(str,len); } # cmp is used to compare two strings. # normal string will not be correctly compared by operators < > <= >= # because these operators will turn strings into numbers then compare. var cmp=func(a,b){ - return __builtin_cmp(a,b); + return __cmp(a,b); } # chr is used to get the character by ascii-number. # for example chr(65) -> 'A' var chr=func(code){ - return __builtin_chr(code); + return __chr(code); } # mut is used to change unmutable strings to mutable. @@ -190,13 +190,13 @@ var srand=func(){ # values() gets all values in a hash. var values=func(hash){ - return __builtin_values(hash); + return __values(hash); } # println has the same function as print. # but it will output a '\n' after using print. var println=func(elems...){ - return __builtin_println(elems); + return __println(elems); } var isfunc=func(f){ @@ -263,7 +263,7 @@ var assert=func(condition,message="assertion failed!"){ var maketimestamp=func(){ var t=0; var millisec=func(){ - return __builtin_millisec; + return __millisec; } return { stamp:func(){t=millisec();}, @@ -274,7 +274,7 @@ var maketimestamp=func(){ # md5 var md5=func(str){ - return __builtin_md5(str); + return __md5(str); } var io= @@ -283,29 +283,29 @@ var io= SEEK_CUR:1, SEEK_END:2, # get content of a file by filename. returns a string. - fin: func(filename){return __builtin_fin(filename);}, + fin: func(filename){return __fin(filename);}, # input a string as the content of a file. - fout: func(filename,str){return __builtin_fout(filename,str);}, + fout: func(filename,str){return __fout(filename,str);}, # same as C fopen. open file and get the FILE*. - open: func(filename,mode="r"){return __builtin_open(filename,mode);}, + open: func(filename,mode="r"){return __open(filename,mode);}, # same as C fclose. close file by FILE*. - close: func(filehandle){return __builtin_close(filehandle);}, + close: func(filehandle){return __close(filehandle);}, # same as C fread. read file by FILE*. # caution: buf must be a mutable string.use mut("") to get an empty mutable string. - read: func(filehandle,buf,len){return __builtin_read(filehandle,buf,len);}, + read: func(filehandle,buf,len){return __read(filehandle,buf,len);}, # same as C fwrite. write file by FILE*. - write: func(filehandle,str){return __builtin_write(filehandle,str);}, + write: func(filehandle,str){return __write(filehandle,str);}, # same as C fseek. seek place by FILE*. - seek: func(filehandle,pos,whence){return __builtin_seek(filehandle,pos,whence);}, + seek: func(filehandle,pos,whence){return __seek(filehandle,pos,whence);}, # same as C ftell. - tell: func(filehandle){return __builtin_tell(filehandle);}, + tell: func(filehandle){return __tell(filehandle);}, # read file by lines. use FILE*. # get nil if EOF - readln:func(filehandle){return __builtin_readln(filehandle);}, + readln:func(filehandle){return __readln(filehandle);}, # same as C stat. - stat: func(filename){return __builtin_stat(filename);}, + stat: func(filename){return __stat(filename);}, # same as C feof. check if FILE* gets the end of file(EOF). - eof: func(filehandle){return __builtin_eof(filehandle);} + eof: func(filehandle){return __eof(filehandle);} }; # get file status. using data from io.stat @@ -331,45 +331,45 @@ var fstat=func(filename){ var bits= { # i32 xor - i32_xor: func(a,b){return __builtin_i32xor(a,b); }, + i32_xor: func(a,b){return __i32xor(a,b); }, # i32 and - i32_and: func(a,b){return __builtin_i32and(a,b); }, + i32_and: func(a,b){return __i32and(a,b); }, # i32 or - i32_or: func(a,b){return __builtin_i32or(a,b); }, + i32_or: func(a,b){return __i32or(a,b); }, # i32 nand - i32_nand:func(a,b){return __builtin_i32nand(a,b);}, + i32_nand:func(a,b){return __i32nand(a,b);}, # i32 not - i32_not: func(a) {return __builtin_i32not(a); }, + i32_not: func(a) {return __i32not(a); }, # u32 xor - u32_xor: func(a,b){return __builtin_u32xor(a,b); }, + u32_xor: func(a,b){return __u32xor(a,b); }, # u32 and - u32_and: func(a,b){return __builtin_u32and(a,b); }, + u32_and: func(a,b){return __u32and(a,b); }, # u32 or - u32_or: func(a,b){return __builtin_u32or(a,b); }, + u32_or: func(a,b){return __u32or(a,b); }, # u32 nand - u32_nand:func(a,b){return __builtin_u32nand(a,b);}, + u32_nand:func(a,b){return __u32nand(a,b);}, # u32 not - u32_not: func(a) {return __builtin_u32not(a); }, + u32_not: func(a) {return __u32not(a); }, # get bit data from a special string. for example: # bits.fld(s,0,3); # if s stores 10100010(162) # will get 101(5). - fld: func(str,startbit,len){return __builtin_fld;}, + fld: func(str,startbit,len){return __fld;}, # get sign-extended data from a special string. for example: # bits.sfld(s,0,3); # if s stores 10100010(162) # will get 101(5) then this will be signed extended to # 11111101(-3). - sfld: func(str,startbit,len){return __builtin_sfld;}, + sfld: func(str,startbit,len){return __sfld;}, # set value into a special string to store it. little-endian, for example: # bits.setfld(s,0,8,69); # set 01000101(69) to string will get this: # 10100010(162) # so s[0]=162. - setfld: func(str,startbit,len,val){return __builtin_setfld;}, + setfld: func(str,startbit,len,val){return __setfld;}, # get a special string filled by '\0' to use in setfld. - buf: func(len){return __builtin_buf;} + buf: func(len){return __buf;} }; # mostly used math functions and special constants, you know. @@ -380,39 +380,39 @@ var math= inf: 1/0, nan: 0/0, abs: func(x) {return x>0?x:-x; }, - floor: func(x) {return __builtin_floor(x); }, - pow: func(x,y){return __builtin_pow(x,y); }, - sin: func(x) {return __builtin_sin(x); }, - cos: func(x) {return __builtin_cos(x); }, - tan: func(x) {return __builtin_tan(x); }, - exp: func(x) {return __builtin_exp(x); }, - lg: func(x) {return __builtin_lg(x); }, - ln: func(x) {return __builtin_ln(x); }, - sqrt: func(x) {return __builtin_sqrt(x); }, - atan2: func(x,y){return __builtin_atan2(x,y);}, - isnan: func(x) {return __builtin_isnan(x); }, + floor: func(x) {return __floor(x); }, + pow: func(x,y){return __pow(x,y); }, + sin: func(x) {return __sin(x); }, + cos: func(x) {return __cos(x); }, + tan: func(x) {return __tan(x); }, + exp: func(x) {return __exp(x); }, + lg: func(x) {return __lg(x); }, + ln: func(x) {return __ln(x); }, + sqrt: func(x) {return __sqrt(x); }, + atan2: func(x,y){return __atan2(x,y);}, + isnan: func(x) {return __isnan(x); }, max: func(x,y){return x>y?x:y; }, min: func(x,y){return x"){ } var coroutine={ - create: func(function){return __builtin_cocreate;}, - resume: func(co) {return __builtin_coresume;}, - yield: func(args...) {return __builtin_coyield; }, - status: func(co) {return __builtin_costatus;}, - running:func() {return __builtin_corun; } + create: func(function){return __cocreate;}, + resume: func(co) {return __coresume;}, + yield: func(args...) {return __coyield; }, + status: func(co) {return __costatus;}, + running:func() {return __corun; } }; \ No newline at end of file diff --git a/stl/module.nas b/stl/module.nas index 7ac7815..ce6834c 100644 --- a/stl/module.nas +++ b/stl/module.nas @@ -6,7 +6,7 @@ # all the invalid functions cannot be called var module_call_func=func(fptr,args){ - return __builtin_dlcall; + return __dlcall; } var extern={ new: func(fptr){ diff --git a/test/coroutine.nas b/test/coroutine.nas index d314fe8..52baa1f 100644 --- a/test/coroutine.nas +++ b/test/coroutine.nas @@ -37,7 +37,7 @@ var productor=func(){ for(var i=0;;i+=1) coroutine.yield(i); } -var total=10000; # ms +var total=4000; # ms var co=coroutine.create(productor); var tm=maketimestamp(); @@ -54,4 +54,4 @@ var consumer=func(){ tm.stamp(); while(tm.elapsedMSec()