Skip to main content

Module interp

Module interp 

Source
Expand description

The MVP tree-walking interpreter.

The interpreter is an ordinary evaluator over cove_syntax::ast plus the five rules that make Cove Cove:

  • assignment and ordinary argument passing clone a Value, and Clone already encodes field-wise shallow copy, so there is no deep-copy path;
  • mutation resolves an lvalue down to a slot the caller owns. Which lvalues source may write — let binds a read-only place and var a mutable one — is checked before the run, by cove-sema, since ADR 0021;
  • var self and var parameters bind the caller’s place instead of a copy;
  • Host API calls go through HostRegistry::call, which enforces grants;
  • concurrent work belongs to a task scope, and leaving the scope waits for or cancels the tasks spawned into it.

Static checking (types, exhaustiveness, uniqueness) is future work; the interpreter enforces the same rules dynamically and says which rule it enforced. Two families of rule are no longer among them, because cove check decides them from the source and a program it refuses never reaches here: which places source may write, and whether a labelled argument stands in declaration order. ADR 0021 says why they went, and what is left in their place is a guard rather than a diagnostic — var_self_needs_place and Interpreter::resolve_place’s last arm are this evaluator saying it was handed something it cannot address, not the language saying a program is wrong.

Structs§

Interpreter
Executes a resolved program.

Constants§

SAFEPOINT_FUEL
Fuel charged at every safepoint: a loop back edge, a function call, or an await.
STACK_SIZE
How much stack the runtime gives every thread it runs Cove on.

Functions§

on_cove_stack
Runs body on a thread the runtime sized, and hands back what it produced.