a couple random c tweaks
authorcassowarii <2374677+cassowarii@users.noreply.github.com>
Sun, 19 Jul 2026 05:18:25 +0000 (22:18 -0700)
committercassowarii <2374677+cassowarii@users.noreply.github.com>
Sun, 19 Jul 2026 05:18:25 +0000 (22:18 -0700)
src/global.h
src/vm/exec.c

index 4f7c920..b4adf4b 100644 (file)
@@ -3,10 +3,10 @@
 
 #ifdef DEBUG
 #define PANIC(...) do { fprintf(stderr, "PANIC: " __VA_ARGS__); fprintf(stderr, "\n       at " __FILE__ ":%d\n", __LINE__); abort(); } while (0)
-#define CHECK(...) do { fprintf(stderr, "PANIC: " __VA_ARGS__); fprintf(stderr, "\n       at " __FILE__ ":%d\n", __LINE__); abort(); } while (0)
+#define CHECK(...) do { fprintf(stderr, "BUGCHECK: " __VA_ARGS__); fprintf(stderr, "\n       at " __FILE__ ":%d\n", __LINE__); abort(); } while (0)
 #define debug(...) printf(__VA_ARGS__)
 #else
-#define PANIC(...) do { fprintf(stderr, "BUGCHECK: " __VA_ARGS__); fprintf(stderr, "\n"); abort(); } while (0)
+#define PANIC(...) do { fprintf(stderr, "PANIC: " __VA_ARGS__); fprintf(stderr, "\n"); abort(); } while (0)
 #define CHECK(...) ((void)0)
 #define debug(...) ((void)0)
 #endif
index 6b1dad0..84568ba 100644 (file)
@@ -20,13 +20,15 @@ void swap_stack_top(hVm vm);
 void print_stack(hVm vm);
 
 void sbVm_initialize(hVm vm, usize stacksize, usize rstacksize, flag debugmode) {
-  *vm = (sbVm) {0};
-  vm->vstack = malloc(stacksize);
-  vm->stacksize = stacksize;
-  vm->rstack = malloc(rstacksize);
-  vm->rstacksize = rstacksize;
+  *vm = (sbVm) {
+    .stacksize = stacksize,
+    .rstacksize = rstacksize,
+    .debugmode = debugmode,
+  };
 
+  vm->vstack = malloc(stacksize);
   vm->vsp = vm->vstack;
+  vm->rstack = malloc(rstacksize);
   vm->rsp = vm->rstack;
   vm->fp = (sbVmStackFrame*)vm->rstack;