access function/modifier native ID through macro

This commit is contained in:
dzaima 2024-10-10 02:37:08 +03:00
parent ddb0e09d08
commit d4b36b3017
6 changed files with 11 additions and 9 deletions

View File

@ -75,9 +75,9 @@ static const i32 firstImpurePM1 = pm1_timed;
static const i32 firstImpurePM2 = pm2_while;
static inline bool isImpureBuiltin(B x) {
if (isFun(x)) return !v(x)->extra || v(x)->extra>=firstImpurePFN;
if (isMd1(x)) return !v(x)->extra || v(x)->extra>=firstImpurePM1;
if (isMd2(x)) return !v(x)->extra || v(x)->extra>=firstImpurePM2;
if (isFun(x)) { u8 nid = NID(v(x)); return nid==0 || nid>=firstImpurePFN; }
if (isMd1(x)) { u8 nid = NID(v(x)); return nid==0 || nid>=firstImpurePM1; }
if (isMd2(x)) { u8 nid = NID(v(x)); return nid==0 || nid>=firstImpurePM2; }
return false;
}

View File

@ -385,7 +385,7 @@ B tack_uc1(B t, B o, B x) {
void fun_gcFn(void) {
if (globalNames!=NULL) mm_visitP(globalNames);
}
static void print_funBI(FILE* f, B x) { fprintf(f, "%s", pfn_repr(c(Fun,x)->extra)); }
static void print_funBI(FILE* f, B x) { fprintf(f, "%s", pfn_repr(NID(c(BFn,x)))); }
static B funBI_uc1(B t, B o, B x) { return c(BFn,t)->uc1(t, o, x); }
static B funBI_ucw(B t, B o, B w, B x) { return c(BFn,t)->ucw(t, o, w, x); }
static B funBI_im(B t, B x) { return c(BFn,t)->im(t, x); }

View File

@ -169,7 +169,7 @@ B timed_c1(Md1D* d, B x) { B f = d->f;
return m_f64((ens-sns)*1e-9);
}
static void print_md1BI(FILE* f, B x) { fprintf(f, "%s", pm1_repr(c(Md1,x)->extra)); }
static void print_md1BI(FILE* f, B x) { fprintf(f, "%s", pm1_repr(NID(c(BMd1,x)))); }
static B md1BI_im(Md1D* d, B x) { return ((BMd1*)d->m1)->im(d, x); }
static B md1BI_iw(Md1D* d, B w, B x) { return ((BMd1*)d->m1)->iw(d, w, x); }
static B md1BI_ix(Md1D* d, B w, B x) { return ((BMd1*)d->m1)->ix(d, w, x); }

View File

@ -243,7 +243,7 @@ B depth_c2(Md2D* d, B w, B x) {
}
static void print_md2BI(FILE* f, B x) { fprintf(f, "%s", pm2_repr(c(Md1,x)->extra)); }
static void print_md2BI(FILE* f, B x) { fprintf(f, "%s", pm2_repr(NID(c(BMd2,x)))); }
static B md2BI_im(Md2D* d, B x) { return ((BMd2*)d->m2)->im(d, x); }
static B md2BI_iw(Md2D* d, B w, B x) { return ((BMd2*)d->m2)->iw(d, w, x); }
static B md2BI_ix(Md2D* d, B w, B x) { return ((BMd2*)d->m2)->ix(d, w, x); }

View File

@ -73,9 +73,9 @@ B glyph_c1(B t, B x) {
return r;
}
u8 ty = TY(x);
if (ty==t_funBI) { B r = utf8Decode0(pfn_repr(c(Fun,x)->extra)); decG(x); return r; }
if (ty==t_md1BI) { B r = utf8Decode0(pm1_repr(c(Md1,x)->extra)); decG(x); return r; }
if (ty==t_md2BI) { B r = utf8Decode0(pm2_repr(c(Md2,x)->extra)); decG(x); return r; }
if (ty==t_funBI) { B r = utf8Decode0(pfn_repr(NID(c(BFn, x)))); decG(x); return r; }
if (ty==t_md1BI) { B r = utf8Decode0(pm1_repr(NID(c(BMd1,x)))); decG(x); return r; }
if (ty==t_md2BI) { B r = utf8Decode0(pm2_repr(NID(c(BMd2,x)))); decG(x); return r; }
if (ty==t_nfn) { B r = nfn_name(x); decG(x); return r; }
if (ty==t_funBl) { decG(x); return m_c8vec_0("(function block)"); }
if (ty==t_md1Bl) { decG(x); return m_c8vec_0("(1-modifier block)"); }

View File

@ -424,6 +424,8 @@ void freeThrown(void);
#define TY(X) PTY(v(X))
#define RNK(X) PRNK(v(X))
#define NID(X) ((X)->extra)
#define VTY(X,T) assert(isVal(X) && TY(X)==(T))
#if DEBUG