GaloisInc / cryptol

Cryptol: The Language of Cryptography
https://galoisinc.github.io/cryptol/master/RefMan.html
BSD 3-Clause "New" or "Revised" License
1.14k stars 126 forks source link

Start on a mechanism to build Cryptol values from outside Cryptol #1739

Open yav opened 2 months ago

yav commented 2 months ago

The plan here is to add a mechanism that allows the Cryptol interpreter to cooperate with an external function to build Cryptol values, which would help support more forms of FFI.

Our current FFI to C assumes a fixed data layout for values, and it is the job of Cryptol to parse the values back into Cryptol values, when results a returned by a foreign function.

The new approach exposes a "Cryptol value builder" object to the foreign function, so that the foreign function can build the Cryptol values itself. The benefit of this is that we only need to impose representation constraints on primitve types (e.g., bool, integer, word), while the representation of compound values types (e.g., vectors, tuples, sums) is unrestricted.