stdlib tester, fixes, switch to builtins as pseudo functions (use call), remove negative closure offset possibility

This commit is contained in:
ProgramSnail 2025-03-30 09:34:50 +03:00
parent 905632aab6
commit 43088ec9f9
10 changed files with 321 additions and 131 deletions

View file

@ -11,47 +11,47 @@ Bytefile *run_with_imports(Bytefile *root, int argc, char **argv,
// ---
enum BUILTIN : uint {
BUILTIN_Luppercase,
BUILTIN_Llowercase,
BUILTIN_Lassert,
BUILTIN_Lstring,
BUILTIN_Llength,
BUILTIN_LstringInt,
BUILTIN_Lread,
BUILTIN_Lwrite,
BUILTIN_LmakeArray,
BUILTIN_LmakeString,
BUILTIN_Lstringcat,
BUILTIN_LmatchSubString,
BUILTIN_Lsprintf,
BUILTIN_Lsubstring,
BUILTIN_Li__Infix_4343, // ++
BUILTIN_Lclone,
BUILTIN_Lhash,
BUILTIN_LtagHash,
BUILTIN_Lcompare,
BUILTIN_LflatCompare,
BUILTIN_Lfst,
BUILTIN_Lsnd,
BUILTIN_Lhd,
BUILTIN_Ltl,
BUILTIN_Lprintf,
BUILTIN_LreadLine,
BUILTIN_Lfopen,
BUILTIN_Lfclose,
BUILTIN_Lfread,
BUILTIN_Lfwrite,
BUILTIN_Lfexists,
BUILTIN_Lfprintf,
BUILTIN_Lregexp,
BUILTIN_LregexpMatch,
BUILTIN_Lfailure,
BUILTIN_Lsystem,
BUILTIN_LgetEnv,
BUILTIN_Lrandom,
BUILTIN_Ltime,
BUILTIN_Barray, // can't be run with run_stdlib_func
BUILTIN_NONE,
BUILTIN_Luppercase, // 0
BUILTIN_Llowercase, // 1
BUILTIN_Lassert, // 2
BUILTIN_Lstring, // 3
BUILTIN_Llength, // 4
BUILTIN_LstringInt, // 5
BUILTIN_Lread, // 6
BUILTIN_Lwrite, // 7
BUILTIN_LmakeArray, // 8
BUILTIN_LmakeString, // 9
BUILTIN_Lstringcat, // 10
BUILTIN_LmatchSubString, // 11
BUILTIN_Lsprintf, // 12
BUILTIN_Lsubstring, // 13
BUILTIN_Li__Infix_4343, // 14 // ++
BUILTIN_Lclone, // 15
BUILTIN_Lhash, // 16
BUILTIN_LtagHash, // 17
BUILTIN_Lcompare, // 18
BUILTIN_LflatCompare, // 19
BUILTIN_Lfst, // 20
BUILTIN_Lsnd, // 21
BUILTIN_Lhd, // 22
BUILTIN_Ltl, // 23
BUILTIN_Lprintf, // 24
BUILTIN_LreadLine, // 25
BUILTIN_Lfopen, // 26
BUILTIN_Lfclose, // 27
BUILTIN_Lfread, // 28
BUILTIN_Lfwrite, // 29
BUILTIN_Lfexists, // 30
BUILTIN_Lfprintf, // 31
BUILTIN_Lregexp, // 32
BUILTIN_LregexpMatch, // 33
BUILTIN_Lfailure, // 34
BUILTIN_Lsystem, // 35
BUILTIN_LgetEnv, // 36
BUILTIN_Lrandom, // 37
BUILTIN_Ltime, // 38
BUILTIN_Barray, // 39 // can't be run with run_stdlib_func
BUILTIN_NONE, // 40
};
enum BUILTIN id_by_builtin(const char *name);

View file

@ -125,6 +125,14 @@ static inline void s_popn(size_t n) {
// ------ complex operations ------
static inline void s_swap_tops() {
// NOTE: can be optimized
void *x = s_pop();
void *y = s_pop();
s_push(x);
s_push(y);
}
// for some reason does not work in sexp constructor, probably connected with gc
// behaviour
static inline void s_put_nth(size_t n, void *val) {

View file

@ -16,7 +16,7 @@
// CLOJURE_T = CLOSURE_TAG,
// };
#define STACK_SIZE 128 * 1024
#define STACK_SIZE 512 * 1024
static const size_t MAX_ARRAY_SIZE = 0x11111110;