summaryrefslogtreecommitdiff
path: root/pit/src/native.c
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2026-09-24 16:40:51 -0400
committerLLLL Colonq <llll@colonq>2026-09-24 16:41:00 -0400
commit394757c770ec871bdaf9d532940a575606ae3318 (patch)
tree4064f3f0653bb66e0509c519d8f8c2082b73435f /pit/src/native.c
parentd7f85e314f40548c6840d987a3f4b556f2b7b7ff (diff)
pit: Add comments
Diffstat (limited to 'pit/src/native.c')
-rw-r--r--pit/src/native.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/pit/src/native.c b/pit/src/native.c
index 2d28679..d0989a5 100644
--- a/pit/src/native.c
+++ b/pit/src/native.c
@@ -98,16 +98,26 @@ pit_value pit_value_bytes_new_file(pit_runtime *rt, char *path) {
return ret;
}
+/* check invariants - these should always hold between top-level evaluations! */
static void check_invariants(pit_runtime *rt) {
+ if (rt->saved_bindings->next != 0) {
+ pit_error(rt, "leaked saved_bindings memory! %ld", rt->result_stack->next);
+ }
if (rt->expr_stack->next != 0) {
pit_error(rt, "leaked expr_stack memory! %ld", rt->expr_stack->next);
}
if (rt->result_stack->next != 0) {
pit_error(rt, "leaked result_stack memory! %ld", rt->result_stack->next);
}
+ if (rt->compilation_stack->next != 0) {
+ pit_error(rt, "leaked compilation_stack memory! %ld", rt->result_stack->next);
+ }
if (rt->traversal->next != 0) {
pit_error(rt, "leaked traversal memory! %ld", rt->traversal->next);
}
+ if (rt->callstack->next != 0) {
+ pit_error(rt, "leaked callstack memory! %ld", rt->result_stack->next);
+ }
}
pit_value pit_load_file(pit_runtime *rt, char *path) {
pit_lexer lex;
@@ -127,8 +137,6 @@ pit_value pit_load_file(pit_runtime *rt, char *path) {
check_invariants(rt); if (pit_runtime_print_error(rt)) return PIT_NIL;
ret = pit_vm_eval(rt, compiled);
check_invariants(rt); if (pit_runtime_print_error(rt)) return PIT_NIL;
- // pit_gc(rt);
- // check_invariants(rt); if (pit_runtime_print_error(rt)) return PIT_NIL;
}
check_invariants(rt); if (pit_runtime_print_error(rt)) return PIT_NIL;
return ret;