From ab49bb5d3db6149d4ace6e5501de5f13a1278d9b Mon Sep 17 00:00:00 2001 From: dzaima Date: Sun, 21 Nov 2021 22:54:07 +0200 Subject: [PATCH] =?UTF-8?q?native=20-=E2=81=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/builtins/arithm.c | 1 + src/builtins/fns.c | 2 ++ src/core.h | 1 + src/load.c | 6 +++--- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/builtins/arithm.c b/src/builtins/arithm.c index 46125ceb..fd8d9c0b 100644 --- a/src/builtins/arithm.c +++ b/src/builtins/arithm.c @@ -87,4 +87,5 @@ void arith_init() { c(BFn,bi_mul)->ident = c(BFn,bi_div)->ident = c(BFn,bi_and)->ident = c(BFn,bi_eq)->ident = c(BFn,bi_ge)->ident = c(BFn,bi_pow)->ident = c(BFn,bi_not)->ident = m_i32(1); c(BFn,bi_floor)->ident = m_f64(1.0/0.0); c(BFn,bi_ceil )->ident = m_f64(-1.0/0.0); + c(BFn, bi_sub)->im = sub_c1; } diff --git a/src/builtins/fns.c b/src/builtins/fns.c index e6424200..afbd8641 100644 --- a/src/builtins/fns.c +++ b/src/builtins/fns.c @@ -8,6 +8,7 @@ void print_funBI(B x) { printf("%s", pfn_repr(c(Fun,x)->extra)); } B funBI_uc1(B t, B o, B x) { return c(BFn,t)->uc1(t, o, x); } B funBI_ucw(B t, B o, B w, B x) { return c(BFn,t)->ucw(t, o, w, x); } +B funBI_im(B t, B x) { return c(BFn,t)->im(t, x); } B funBI_identity(B x) { return inc(c(BFn,x)->ident); } @@ -315,4 +316,5 @@ void fns_init() { TIi(t_funBI,identity) = funBI_identity; TIi(t_funBI,fn_uc1) = funBI_uc1; TIi(t_funBI,fn_ucw) = funBI_ucw; + TIi(t_funBI,fn_im) = funBI_im; } diff --git a/src/core.h b/src/core.h index ea543252..b68423ec 100644 --- a/src/core.h +++ b/src/core.h @@ -40,6 +40,7 @@ typedef struct BFn { B ident; BBB2B uc1; BBBB2B ucw; + BB2B im; } BFn; typedef struct BMd2 { struct Md2; diff --git a/src/load.c b/src/load.c index 41a6f219..00bb4ce7 100644 --- a/src/load.c +++ b/src/load.c @@ -468,9 +468,9 @@ void base_init() { // very first init function TIi(t_funBI,freeF) = TIi(t_md1BI,freeF) = TIi(t_md2BI,freeF) = builtin_free; assert((MD1_TAG>>1) == (MD2_TAG>>1)); // just to be sure it isn't changed incorrectly, `isMd` depends on this - #define FA(N,X) { BFn* f = mm_alloc(sizeof(BFn), t_funBI); f->c2=N##_c2; f->c1=N##_c1; f->extra=pf_##N; f->ident=bi_N; f->uc1=def_fn_uc1; f->ucw=def_fn_ucw; gc_add(bi_##N = tag(f,FUN_TAG)); } - #define FM(N,X) { BFn* f = mm_alloc(sizeof(BFn), t_funBI); f->c2=c2_bad; f->c1=N##_c1; f->extra=pf_##N; f->ident=bi_N; f->uc1=def_fn_uc1; f->ucw=def_fn_ucw; gc_add(bi_##N = tag(f,FUN_TAG)); } - #define FD(N,X) { BFn* f = mm_alloc(sizeof(BFn), t_funBI); f->c2=N##_c2; f->c1=c1_bad; f->extra=pf_##N; f->ident=bi_N; f->uc1=def_fn_uc1; f->ucw=def_fn_ucw; gc_add(bi_##N = tag(f,FUN_TAG)); } + #define FA(N,X) { BFn* f = mm_alloc(sizeof(BFn), t_funBI); f->c2=N##_c2; f->c1=N##_c1; f->extra=pf_##N; f->ident=bi_N; f->uc1=def_fn_uc1; f->ucw=def_fn_ucw; f->im=def_fn_im; gc_add(bi_##N = tag(f,FUN_TAG)); } + #define FM(N,X) { BFn* f = mm_alloc(sizeof(BFn), t_funBI); f->c2=c2_bad; f->c1=N##_c1; f->extra=pf_##N; f->ident=bi_N; f->uc1=def_fn_uc1; f->ucw=def_fn_ucw; f->im=def_fn_im; gc_add(bi_##N = tag(f,FUN_TAG)); } + #define FD(N,X) { BFn* f = mm_alloc(sizeof(BFn), t_funBI); f->c2=N##_c2; f->c1=c1_bad; f->extra=pf_##N; f->ident=bi_N; f->uc1=def_fn_uc1; f->ucw=def_fn_ucw; f->im=def_fn_im; gc_add(bi_##N = tag(f,FUN_TAG)); } FOR_PFN(FA,FM,FD) #undef FA #undef FM