From 17df4b1ff7f4cbcf3b3218fea68f65d3cb60c984 Mon Sep 17 00:00:00 2001 From: LLLL Colonq Date: Fri, 25 Sep 2026 17:36:15 -0400 Subject: pit: Add fuel economy --- pit/src/runtime/eval.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'pit/src/runtime') 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); -- cgit v1.3.1