From cc5a5752bf6b9dfe1c5757cd9628d8e1834405df Mon Sep 17 00:00:00 2001 From: dzaima Date: Thu, 26 Jan 2023 01:53:09 +0200 Subject: [PATCH] =?UTF-8?q?add=20=E2=80=A2CompObj=20to=20NATIVE=5FCOMPILER?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/builtins.h | 4 ++-- src/builtins/sysfn.c | 11 +++++++---- src/load.c | 6 ++++++ src/opt/comp.c | 4 +--- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/builtins.h b/src/builtins.h index 30ae59ad..a85244cf 100644 --- a/src/builtins.h +++ b/src/builtins.h @@ -8,8 +8,8 @@ /* sfns.c*/A(shifta,"«") A(take,"↑") A(drop,"↓") A(group,"⊔") A(reverse,"⌽") A(transp,"⍉") \ /* sort.c*/A(gradeUp,"⍋") A(gradeDown,"⍒") \ /* everything before the definition of •Type is defined to be pure, and everything after is not */ \ -/* sysfn.c*/A(invalidFn, "(invalid fn)") M(type,"•Type") M(decp,"•Decompose") M(primInd,"•PrimInd") M(glyph,"•Glyph") A(fill,"•FillFn") M(sys,"•getsys") A(grLen,"•GroupLen") \ -/* sysfn.c*/D(grOrd,"•GroupOrd") M(repr,"•Repr") M(parseFloat,"•ParseFloat") M(fmt,"•Fmt") A(asrt,"!") A(casrt,"!") M(out,"•Out") M(show,"•Show") A(bqn,"•BQN") \ +/* sysfn.c*/A(invalidFn, "(invalid fn)") A(grLen,"•GroupLen") D(grOrd,"•GroupOrd") M(compObj, "•CompObj") A(fill,"•FillFn") M(sys,"•getsys") M(primInd,"•PrimInd") M(glyph,"•Glyph") \ +/* sysfn.c*/M(type,"•Type") M(decp,"•Decompose") M(repr,"•Repr") M(parseFloat,"•ParseFloat") M(fmt,"•Fmt") A(asrt,"!") A(casrt,"!") M(out,"•Out") M(show,"•Show") A(bqn,"•BQN") \ /* sysfn.c*/A(sh,"•SH") M(fromUtf8,"•FromUTF8") M(toUtf8,"•ToUTF8") M(currentError,"•CurrentError") D(cmp,"•Cmp") A(hash,"•Hash") M(unixTime,"•UnixTime")\ /* sysfn.c*/M(monoTime,"•MonoTime") M(delay,"•Delay") M(makeRand,"•MakeRand") M(reBQN,"•ReBQN") M(exit,"•Exit") M(getLine,"•GetLine") \ /* sysfn.c*/M(fName,"•file.Name") M(fParent,"•file.Parent") \ diff --git a/src/builtins/sysfn.c b/src/builtins/sysfn.c index eba82543..4c52c726 100644 --- a/src/builtins/sysfn.c +++ b/src/builtins/sysfn.c @@ -1420,6 +1420,9 @@ static Body* file_nsGen; #else #define FFIOPT 0 #endif +#if !NATIVE_COMPILER +#define NATIVE_COMPILER 0 +#endif #define OPTSYS_0(X) #define OPTSYS_1(X) X @@ -1468,7 +1471,8 @@ static Body* file_nsGen; F("file", U"•file", tag(14,VAR_TAG)) \ F("state", U"•state", tag(15,VAR_TAG)) \ F("args", U"•args", tag(16,VAR_TAG)) \ - F("listsys", U"•listsys", tag(17,VAR_TAG)) + F("listsys", U"•listsys", tag(17,VAR_TAG)) \ + OPTSYS(NATIVE_COMPILER)(F("compobj", U"•CompObj", tag(18,VAR_TAG))) NFnDesc* ffiloadDesc; B ffiload_c2(B t, B w, B x); @@ -1570,9 +1574,8 @@ B sys_c1(B t, B x) { cr = inc(comp_currArgs); break; } - case 17: { // •listsys - cr = incG(curr_ns); - } + case 17: cr = incG(curr_ns); break; // •listsys + case 18: cr = incG(bi_compObj); break; // •CompObj } HARR_ADD(r, i, cr); } diff --git a/src/load.c b/src/load.c index 50ee4521..b8ca1a22 100644 --- a/src/load.c +++ b/src/load.c @@ -147,6 +147,12 @@ void switchComp() { load_comp = load_comp.u==load_rtComp.u? native_comp : load_rtComp; } #endif +B compObj_c1(B t, B x) { + Block* block = load_compObj(x, bi_N, bi_N, NULL); + B res = evalFunBlock(block, 0); + ptr_dec(block); + return res; +} #if FORMATTER B load_fmt, load_repr; diff --git a/src/opt/comp.c b/src/opt/comp.c index a9ff7f06..d4d81e27 100644 --- a/src/opt/comp.c +++ b/src/opt/comp.c @@ -124,9 +124,7 @@ usz addObj(B* objs, B val) { // consumes val return IA(*objs)-1; } -i32 nc_ty(B x) { - assert(o2iG(IGetU(x, 0))<10); - return o2iG(IGetU(x, 0)); } +i32 nc_ty(B x) { return o2iG(IGetU(x, 0)); } B nc_generate(B p1) { // consumes // printf("p1: "); printI(p1); putchar('\n');