summaryrefslogtreecommitdiff
path: root/pit/src/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'pit/src/runtime')
-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);