rocq/theories/Values.v
Run-time values, transcribed from interp.pl: capabilities, pointers and the words a temporary holds.
Words
Values are a sum type over classes (formal.md's decision): well classedness is a boolean fact about a word, not an index of its type.
| Gallina | interp.pl | Classes |
|---|---|---|
WIntn | an integer | w, l; also p, an integer argument with no pointer term |
WPtrp | ptr(Addr, Cap) | p, a, f |
WLimitc size | limit(Cap, Size) | l: a limit's opaque snapshot |
The integer at class p is interp.pl's defaulty case for main.pl's canonical arguments (class_arg/2): the model keeps it, and every operation that needs a pointer is stuck on it, as the interpreter fails there.
A capability, what a pointer carries beside its address: which object, if any, it may access. An object's is its identity, the base of its region, and holds no bounds of its own.
| | | CNone | none: no object, a null or forged pointer | |
| | | Obj | base : Z | obj(Base): the writable object of identity base |
| | | Ro | base : Z | ro(Base): the read-only object of identity base |
| | | Fn | f : name | fn(F): the function f of the module |
| | | External | n : name | ext(N): the symbol n, defined outside the module |
Equality of capabilities.
As ptr(Addr, Cap): a pointer, an address and its capability, which move together as one indivisible pair, the pair a flight builds.
A word, the value a temporary holds at run time; the table at the top of the page gives the classes each form is at.
| | | WInt | n : Z | an integer, or a float's bit pattern |
| | | WPtr | p : ptr | a pointer, or a proof of class a or f |
| | | WLimit | c : cap size : Z | limit(Cap, Size): a limit's opaque snapshot |
As word_at_class(K, X0, X): the word x taken at class k. An integer is cut to the low 32, 64 or 80 bits of the class (a float word is its bit pattern, an integer); a pointer or proof word is itself, and a limit stays a limit at l. Any other mismatch is the interpreter's type error, here no word.
As pointer_address(X, A): the address of a pointer word x, or the integer held at p itself; a limit has none.