summaryrefslogtreecommitdiff
path: root/pit/src/runtime/eval.c
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2026-09-25 17:36:15 -0400
committerLLLL Colonq <llll@colonq>2026-09-25 17:36:15 -0400
commit17df4b1ff7f4cbcf3b3218fea68f65d3cb60c984 (patch)
tree5e0b2b81a3ac9c7e506303e8570c16c742072d5d /pit/src/runtime/eval.c
parentc1a6dfb43efca52cacae738ce3d9648c4981906e (diff)
pit: Add fuel economy
Diffstat (limited to 'pit/src/runtime/eval.c')
-rw-r--r--pit/src/runtime/eval.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/pit/src/runtime/eval.c b/pit/src/runtime/eval.c
index eba9715..a2ed166 100644
--- a/pit/src/runtime/eval.c
+++ b/pit/src/runtime/eval.c
@@ -155,6 +155,8 @@ bool pit_vm_run_one(pit_runtime *rt) {
if (rt->callstack->next < 1 || rt->error != PIT_NIL) return false;
pit_callstack_entry *ent = pit_vec_get(pit_callstack_entry)(rt->callstack, rt->callstack->next - 1);
if (ent == NULL) { pit_error(rt, "malformed call stack"); return false; }
+ if (rt->fuel == 0) { pit_error(rt, "out of fuel"); return false; }
+ rt->fuel -= 1;
pit_value ins = pit_value_cons_car(rt, ent->code);
if (ins == PIT_NIL) { pit_error(rt, "malformed vm instruction: %v %v", ins); return false; }
ent->code = pit_value_cons_cdr(rt, ent->code);