mirror of
https://github.com/TomHarte/CLK.git
synced 2024-09-06 05:54:28 +00:00
Modifies contract again. This is why I'm doing this now.
This commit is contained in:
parent
32c942d154
commit
1a3effc692
@ -36,11 +36,13 @@ If instructions are a variable size, the decoder should maintain internal state
|
|||||||
|
|
||||||
A sample interface:
|
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
|
## Tying Decoders into Instruction Executors
|
||||||
|
|
||||||
|
@ -101,9 +101,10 @@ struct Decoder {
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
@returns an @c Instruction with a positive size to indicate successful decoding; a
|
@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
|
negative size specifies the [negatived] number of further bytes the caller should ideally
|
||||||
a zero size indicates that further bytes are required but the decoder does not yet
|
collect before calling again. The caller is free to call with fewer, but may not get a decoded
|
||||||
know exactly how many.
|
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);
|
Instruction decode(uint8_t *source, size_t length);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user