make functions in arith.c static

This commit is contained in:
dzaima 2021-05-24 00:32:59 +03:00
parent b724cbe1de
commit 6869c7d919

View File

@ -44,7 +44,7 @@ static inline B arith_recd(BBB2B f, B w, B x) {
dec(x); dec(x);
return r; return r;
} }
#define ffnx(NAME, EXPR, EXTRA) B NAME##_c2(B t, B w, B x) { \ #define ffnx(NAME, EXPR, EXTRA) static B NAME##_c2(B t, B w, B x) { \
if (isF64(w) & isF64(x)) return m_f64(EXPR); \ if (isF64(w) & isF64(x)) return m_f64(EXPR); \
EXTRA \ EXTRA \
if (isArr(w)|isArr(x)) { B ow=w; B ox=x; \ if (isArr(w)|isArr(x)) { B ow=w; B ox=x; \
@ -89,7 +89,7 @@ static inline B arith_recd(BBB2B f, B w, B x) {
thrM(#NAME ": invalid arithmetic"); \ thrM(#NAME ": invalid arithmetic"); \
} }
#else // if !TYPED_ARITH #else // if !TYPED_ARITH
#define ffnx(name, expr, extra) B name##_c2(B t, B w, B x) { \ #define ffnx(name, expr, extra) static B name##_c2(B t, B w, B x) { \
if (isF64(w) & isF64(x)) return m_f64(expr); \ if (isF64(w) & isF64(x)) return m_f64(expr); \
extra \ extra \
P2(name) \ P2(name) \
@ -98,7 +98,7 @@ static inline B arith_recd(BBB2B f, B w, B x) {
#endif // TYPED_ARITH #endif // TYPED_ARITH
#define ffn(name, op, extra) ffnx(name, w.f op x.f, extra) #define ffn(name, op, extra) ffnx(name, w.f op x.f, extra)
f64 pfmod(f64 a, f64 b) { static f64 pfmod(f64 a, f64 b) {
f64 r = fmod(a, b); f64 r = fmod(a, b);
if (a<0 != b<0 && r!=0) r+= b; if (a<0 != b<0 && r!=0) r+= b;
return r; return r;
@ -138,7 +138,7 @@ CMP(> , gt, 1)
#undef ffn #undef ffn
#undef ffnx #undef ffnx
B decp_c1(B t, B x); static B decp_c1(B t, B x);
#define CMP_IMPL(OP) \ #define CMP_IMPL(OP) \
if (isF64(w)&isF64(x)) return m_i32(w.f OP x.f); \ if (isF64(w)&isF64(x)) return m_i32(w.f OP x.f); \
bool wa = isArr(w); \ bool wa = isArr(w); \
@ -162,14 +162,14 @@ B decp_c1(B t, B x);
} \ } \
} }
B eq_c2(B t, B w, B x) { static B eq_c2(B t, B w, B x) {
CMP_IMPL(==) CMP_IMPL(==)
P2(eq); P2(eq);
B r = m_i32(atomEqual(w, x)); B r = m_i32(atomEqual(w, x));
dec(w); dec(x); dec(w); dec(x);
return r; return r;
} }
B ne_c2(B t, B w, B x) { static B ne_c2(B t, B w, B x) {
CMP_IMPL(!=) CMP_IMPL(!=)
P2(ne); P2(ne);
B r = m_i32(!atomEqual(w, x)); B r = m_i32(!atomEqual(w, x));
@ -178,28 +178,28 @@ B ne_c2(B t, B w, B x) {
} }
extern B rt_merge; extern B rt_merge;
B gt_c1(B t, B x) { static B gt_c1(B t, B x) {
if (isAtm(x)) return x; if (isAtm(x)) return x;
return bqn_merge(x); return bqn_merge(x);
} }
B add_c1(B t, B x) { return x; } static B add_c1(B t, B x) { return x; }
B sub_c1(B t, B x) { if (isF64(x)) return m_f64( -x.f ); P1( sub); thrM("-: Negating non-number"); } static B sub_c1(B t, B x) { if (isF64(x)) return m_f64( -x.f ); P1( sub); thrM("-: Negating non-number"); }
B not_c1(B t, B x) { if (isF64(x)) return m_f64( 1-x.f ); P1( not); thrM("¬: Argument was not a number"); } static B not_c1(B t, B x) { if (isF64(x)) return m_f64( 1-x.f ); P1( not); thrM("¬: Argument was not a number"); }
B mul_c1(B t, B x) { if (isF64(x)) return m_f64(x.f==0?0:x.f>0?1:-1); P1(mul); thrM("×: Getting sign of non-number"); } static B mul_c1(B t, B x) { if (isF64(x)) return m_f64(x.f==0?0:x.f>0?1:-1); P1(mul); thrM("×: Getting sign of non-number"); }
B div_c1(B t, B x) { if (isF64(x)) return m_f64( 1/x.f ); P1( div); thrM("÷: Getting reciprocal of non-number"); } static B div_c1(B t, B x) { if (isF64(x)) return m_f64( 1/x.f ); P1( div); thrM("÷: Getting reciprocal of non-number"); }
B pow_c1(B t, B x) { if (isF64(x)) return m_f64( exp(x.f)); P1( pow); thrM("⋆: Getting exp of non-number"); } static B pow_c1(B t, B x) { if (isF64(x)) return m_f64( exp(x.f)); P1( pow); thrM("⋆: Getting exp of non-number"); }
B floor_c1(B t, B x) { if (isF64(x)) return m_f64(floor(x.f)); P1(floor); thrM("⌊: Argument was not a number"); } static B floor_c1(B t, B x) { if (isF64(x)) return m_f64(floor(x.f)); P1(floor); thrM("⌊: Argument was not a number"); }
B ceil_c1(B t, B x) { if (isF64(x)) return m_f64( ceil(x.f)); P1( ceil); thrM("⌈: Argument was not a number"); } static B ceil_c1(B t, B x) { if (isF64(x)) return m_f64( ceil(x.f)); P1( ceil); thrM("⌈: Argument was not a number"); }
B stile_c1(B t, B x) { if (isF64(x)) return m_f64( fabs(x.f)); P1(stile); thrM("|: Argument was not a number"); } static B stile_c1(B t, B x) { if (isF64(x)) return m_f64( fabs(x.f)); P1(stile); thrM("|: Argument was not a number"); }
B log_c1(B t, B x) { if (isF64(x)) return m_f64( log(x.f)); P1( log); thrM("⋆⁼: Getting log of non-number"); } static B log_c1(B t, B x) { if (isF64(x)) return m_f64( log(x.f)); P1( log); thrM("⋆⁼: Getting log of non-number"); }
B lt_c1(B t, B x) { return m_unit(x); } static B lt_c1(B t, B x) { return m_unit(x); }
B eq_c1(B t, B x) { B r = m_i32(isArr(x)? rnk(x) : 0); decR(x); return r; } static B eq_c1(B t, B x) { B r = m_i32(isArr(x)? rnk(x) : 0); decR(x); return r; }
B ne_c1(B t, B x) { B r = m_f64(isArr(x)&&rnk(x)? *a(x)->sh : 1); decR(x); return r; } static B ne_c1(B t, B x) { B r = m_f64(isArr(x)&&rnk(x)? *a(x)->sh : 1); decR(x); return r; }
extern B rt_sortDsc; extern B rt_sortDsc;
B or_c1(B t, B x) { return c1(rt_sortDsc, x); } static B or_c1(B t, B x) { return c1(rt_sortDsc, x); }
B and_c1(B t, B x); // defined in sort.c B and_c1(B t, B x); // defined in sort.c
#undef P1 #undef P1