move random functions to stuff.c

This commit is contained in:
dzaima 2021-04-27 17:35:41 +03:00
parent f922aa2422
commit ca3ff89a4d
2 changed files with 19 additions and 17 deletions

19
src/h.h
View File

@ -365,23 +365,8 @@ TypeInfo ti[t_COUNT];
B bi_N, bi_noVar, bi_badHdr, bi_optOut, bi_noFill;
void do_nothing(B x) { }
void empty_free(B x) { err("FREEING EMPTY\n"); }
void builtin_free(B x) { err("FREEING BUILTIN\n"); }
void def_visit(B x) { printf("(no visit for %d=%s)\n", v(x)->type, format_type(v(x)->type)); }
void freed_visit(B x) {
#ifndef CATCH_ERRORS
err("visiting t_freed\n");
#endif
}
void def_print(B x) { printf("(%d=%s)", v(x)->type, format_type(v(x)->type)); }
B def_identity(B f) { return bi_N; }
B def_get (B x, usz n) { return inc(x); }
B def_getU(B x, usz n) { return x; }
B def_m1_d(B m, B f ) { return err("cannot derive this"); }
B def_m2_d(B m, B f, B g) { return err("cannot derive this"); }
B def_slice(B x, usz s) { return err("cannot slice non-array!"); }
B def_decompose(B x) { return m_v2(m_i32((isFun(x)|isMd(x))? 0 : -1),x); }
bool def_canStore(B x) { return false; }
B def_decompose(B x) { return m_v2(m_i32((isFun(x)|isMd(x))? 0 : -1),x); }
bool isNothing(B b) { return b.u==bi_N.u; }

View File

@ -154,6 +154,23 @@ usz arr_csz(B x) {
}
#endif
void empty_free(B x) { err("FREEING EMPTY\n"); }
void builtin_free(B x) { err("FREEING BUILTIN\n"); }
void def_visit(B x) { printf("(no visit for %d=%s)\n", v(x)->type, format_type(v(x)->type)); }
void freed_visit(B x) {
#ifndef CATCH_ERRORS
err("visiting t_freed\n");
#endif
}
void def_print(B x) { printf("(%d=%s)", v(x)->type, format_type(v(x)->type)); }
B def_identity(B f) { return bi_N; }
B def_get (B x, usz n) { return inc(x); }
B def_getU(B x, usz n) { return x; }
B def_m1_d(B m, B f ) { return err("cannot derive this"); }
B def_m2_d(B m, B f, B g) { return err("cannot derive this"); }
B def_slice(B x, usz s) { return err("cannot slice non-array!"); }
bool def_canStore(B x) { return false; }
static inline void hdr_init() {
for (i32 i = 0; i < t_COUNT; i++) {
ti[i].free = do_nothing;