Nithin Sai K J
C11 · Interpreter

Vanta

Vanta is a statically typed language and tree-walk interpreter written in C11. Preconditions and postconditions are built into the language, with old(expr) preserving a value from when a function is entered.

Source code

Entry snapshots
During lowering, old(expr) nodes are moved ahead of the function body so their values are captured on entry, letting postconditions compare the final state against the initial state.
Build-mode stripping
Contracts marked with @debug are omitted during lowering in release builds, avoiding runtime flag checks on each call.
Static verification
Preconditions and postconditions pass through the same symbol table and type checker as function bodies, rejecting type mismatches and state mutations before execution.
Syntax
@debug @requires(s.size < s.capacity)
@debug @ensures(s.size == old(s.size) + 1)
fn push(s: *Stack, v: int) {
    s.data[s.size] = v;
    s.size += 1;
}