1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-09 06:29:33 +00:00

Modifies contract again. This is why I'm doing this now.

This commit is contained in:
Thomas Harte 2021-01-02 21:19:45 -05:00
parent 32c942d154
commit 1a3effc692
2 changed files with 9 additions and 6 deletions

View File

@ -36,11 +36,13 @@ If instructions are a variable size, the decoder should maintain internal state
A sample interface:
size_t decode(Instruction &target, word_type *stream, size_t length) { ... }
Instruction decode(word_type *stream, size_t length) { ... }
Returns either the number of further words necessary fully to decode, if known, or a negative number to indicate a generic sense of 'more needed'. A value of `0` means 'an instruction was fully decoded', and the instruction itself should be able to report its size.
The returned instruction has a size that is one of:
* a positive number, indicating a successful decoding that consumed that many `word_type`s; or
* a negative number, indicating the [negatived] minimum number of `word_type`s that the caller should try to get hold of before calling `decode` again.
`target` is populated only if an instruction is decoded; `stream` and `length` provide as much further instruction stream data as the caller currently possesses.
A caller is permitted to react in any way it prefers to negative numbers; they're a hint potentially to reduce calling overhead only.
## Tying Decoders into Instruction Executors

View File

@ -101,9 +101,10 @@ struct Decoder {
/*!
@returns an @c Instruction with a positive size to indicate successful decoding; a
negative size specifies the number of further bytes required fully to decode, and
a zero size indicates that further bytes are required but the decoder does not yet
know exactly how many.
negative size specifies the [negatived] number of further bytes the caller should ideally
collect before calling again. The caller is free to call with fewer, but may not get a decoded
instruction in response, and the decoder may still not be able to complete decoding
even if given that number of bytes.
*/
Instruction decode(uint8_t *source, size_t length);