enable compiler compilation with a define

This commit is contained in:
dzaima 2021-05-12 11:54:41 +03:00
parent f13c0e9969
commit 3609c1ecdd

View File

@ -61,27 +61,29 @@
int main() {
cbqn_init();
// uncomment to self-compile and use that for the REPL
// expects a copy of mlochbaum/BQN/src/c.bqn to be at the execution directory (with •args replaced with the array in glyphs.bqn)
// char* c_src = NULL;
// u64 c_len;
// FILE* f = fopen("c.bqn", "rb");
// if (f) {
// fseek(f, 0, SEEK_END); c_len = ftell(f);
// fseek(f, 0, SEEK_SET); c_src = malloc(c_len);
// if (c_src) fread(c_src, 1, c_len, f);
// fclose(f);
// } else {
// c_src = NULL;
// }
// if (c_src) {
// bqn_setComp(bqn_exec(fromUTF8(c_src, c_len)));
// // for (i32 i = 0; i < 100; i++) { dec(bqn_exec(fromUTF8(c_src, c_len))); gc_maybeGC(); } rtPerf_print(); exit(0);
// } else {
// printf("couldn't read c.bqn\n");
// exit(1);
// }
#if defined(COMP_COMP) || defined(COMP_COMP_TIME)
char* c_src = NULL;
u64 c_len;
FILE* f = fopen("c.bqn", "rb");
if (f) {
fseek(f, 0, SEEK_END); c_len = ftell(f);
fseek(f, 0, SEEK_SET); c_src = malloc(c_len);
if (c_src) fread(c_src, 1, c_len, f);
fclose(f);
} else {
c_src = NULL;
}
if (c_src) {
#ifdef COMP_COMP_TIME
for (i32 i = 0; i < 100; i++) { dec(bqn_exec(fromUTF8(c_src, c_len))); gc_maybeGC(); } rtPerf_print(); exit(0);
#endif
bqn_setComp(bqn_exec(fromUTF8(c_src, c_len)));
} else {
printf("couldn't read c.bqn\n");
exit(1);
}
#endif
while (CATCH) {