Ivan Enderlin
e4921bd496
feat(interface-types) Use Vec::last_mut
to simplify code.
2020-04-03 16:20:22 +02:00
Ivan Enderlin
398d791c9f
fix(interface-types) Also apply another lazy evaluation in the deserializer.
2020-04-03 16:19:07 +02:00
Ivan Enderlin
e160feb99a
fix(interface-types) Use lazy evaluation in the deserializer.
2020-04-03 16:18:24 +02:00
Ivan Enderlin
d186142507
doc(interface-types) Fix a typo.
2020-04-03 16:16:53 +02:00
Ivan Enderlin
3159da5bfe
feat(interface-types) Add the Vec1
type to represent a non-empty vector.
...
`Vec1` is used by `RecordType` to ensure that a record have at least 1
field. Then an `InterfaceValue::Record` is ensured to get at least one
value with the type-checking pass.
2020-04-03 16:13:44 +02:00
Ivan Enderlin
6cef1c244a
doc(interface-types) Fix typos.
2020-04-03 14:46:59 +02:00
Ivan Enderlin
2011fda31d
chore(interface-types) Split the serde
module…
...
… into `serde/ser.rs` and `serde/de.rs`. I like smaller files.
2020-04-02 16:46:23 +02:00
Ivan Enderlin
be66ac8aa4
doc(interface-types) Improve serde
module documentation.
2020-04-02 16:41:03 +02:00
Ivan Enderlin
e385bf66c7
feat(interface-types) Make unwrap
s safe by introducing more errors.
2020-04-02 16:38:40 +02:00
Ivan Enderlin
b0af014339
doc(interface-types) Update an example.
2020-04-02 16:29:52 +02:00
Ivan Enderlin
ee0596d2c3
feat(interface-types) Restrict supported type in the Deserializer
.
...
`seq`, `map` and `tuple` for instance are not supported officially. It
was fun to play with it at the beginning, but it is time to remove it
to match the `Serializer` implementation.
2020-04-02 16:26:24 +02:00
Ivan Enderlin
d6f7e3ff02
doc(interface-types) Describe to_interface_value
.
2020-04-02 15:59:07 +02:00
Ivan Enderlin
f9832fecaf
feat(interface-types) Implement a serializer for WIT values.
2020-04-02 15:54:39 +02:00
Ivan Enderlin
8868d640fa
feat(interface-types) Rename from_values
to from_interface_values
.
2020-04-02 13:56:20 +02:00
Ivan Enderlin
7b182416df
feat(interface-types) Make serde
optional behind a feature flag.
2020-04-02 13:53:10 +02:00
Ivan Enderlin
f8507533fb
fix(interface-types) Fix a git-merge
issue.
2020-04-02 12:16:30 +02:00
Ivan Enderlin
bac56a6e0b
Merge branch 'master' into feat-interface-types-record-instructions
2020-04-02 12:10:01 +02:00
Ivan Enderlin
8f8c5f1bc8
chore(interface-types) Improve code readabilit of the record.lift
instruction.
2020-04-02 12:06:54 +02:00
Ivan Enderlin
0023eea275
feat(interface-types) Implement the record.lower
instruction.
2020-04-02 12:06:27 +02:00
Ivan Enderlin
11687c57ca
feat(interface-types) Encodes/decodes the record.lower
instruction.
2020-04-02 12:05:22 +02:00
Ivan Enderlin
b8ef82d1d0
test(interface-types) Rename test cases.
2020-04-02 11:59:35 +02:00
Ivan Enderlin
a1551b52af
test(interface-types) Rename a test case.
2020-04-02 11:58:05 +02:00
Ivan Enderlin
aab82c122d
feat(interface-types) Implement From<&Vec<InterfaceValue>>
for RecordType
.
2020-04-02 11:55:54 +02:00
Ivan Enderlin
3411ac7a1c
feat(interface-types) Move serde::InterfaceTypeIterator
into values::FlattenInterfaceValueIterator
.
2020-04-02 11:55:20 +02:00
Ivan Enderlin
5ba6fda1c9
chore(interface-types) Improve code readibility of string
instructions.
2020-04-02 11:51:34 +02:00
Ivan Enderlin
1a17cbb17e
test(interface-types) Deserialize WIT record to Rust struct.
2020-03-31 14:44:04 +02:00
Ivan Enderlin
02b7e21345
feat(interface-types) Implement the record.lift
instruction.
2020-03-31 12:34:32 +02:00
Ivan Enderlin
0af1076eee
feat(interface-types) Encodes/decodes the record.lift
instruction.
2020-03-31 08:17:52 +02:00
Ivan Enderlin
3655ef8bb7
chore(interface-types) Reorganize the serde module.
2020-03-31 08:02:46 +02:00
Ivan Enderlin
ee57b47770
feat(interface-types) Improve the Deserializer
API.
2020-03-31 07:47:54 +02:00
Ivan Enderlin
c87c2ef33b
feat(interface-values) Improve the TypeMismatch
error.
2020-03-31 07:47:15 +02:00
Ivan Enderlin
154dcba42c
feat(interface-types) Implement Serde deserializing for WIT records to Rust values.
...
WIT values are native Rust values. But records are represented as a
vector of WIT values. In order to provide a super neat API to the
user, Serde is used to deserialize this vector of WIT values to a
large variety of Rust values.
2020-03-30 15:42:35 +02:00
Ivan Enderlin
a99ae6bdb2
feat(interface-types) Add the Record
WIT value.
2020-03-30 08:32:31 +02:00
Ivan Enderlin
bd9226eb68
feat(interface-types) Introduce RecordType
for InterfaceType
and Type
.
...
The `Type::Record` variant now is defined by `RecordType`. In
addition, `InterfaceType` has a new variant: `Record`, that is also
defined by `RecordType`. Encoders and decoders are updated to consider
`RecordType`, which removes code duplication and simplify code.
2020-03-26 13:35:24 +01:00
Ivan Enderlin
3c02c501ed
chore(interface-types) Move the instruction.rs
module in instructions/mod.rs
.
2020-03-26 11:24:10 +01:00
Ivan Enderlin
734795c1f4
test(interface-types) Test Type::Record
.
2020-03-26 11:18:24 +01:00
Ivan Enderlin
bbb4f1fc0f
feat(interface-types) Introduce the record type.
...
This patch updates the `Type` type to be an enum with 2 variants:
`Function` and `Record`, resp. to represent:
1. `(@interface type (func (param i32 i32) (result string)))`
2. `(@interface type (record string i32))`
This patch updates the binary encoder and decoder, along with the WAT
encoder and decoder.
2020-03-26 10:54:58 +01:00
Ivan Enderlin
6e5d9624f1
feat(interface-types) Simplify code by implementing From<TryFromIntError>
.
2020-03-26 10:49:49 +01:00
Ivan Enderlin
25cd6cd24a
feat(interface-types) Add the NegativeValue
instruction error.
2020-03-26 08:31:06 +01:00
Ivan Enderlin
f3be7981d2
test(interface-types) Test negative pointer or length in string.lift_memory
.
2020-03-26 08:30:32 +01:00
Ivan Enderlin
86b545fd49
fix(interface-types) Avoid integer overflows in string instructions.
2020-03-26 08:27:51 +01:00
Ivan Enderlin
0e70e538cc
fix(interface-types) Instruction::CallCore.function_index
is a u32
.
2020-03-26 07:53:44 +01:00
Ivan Enderlin
b0879d1d12
fix(interface-types) Cast index to usize
to compare index to length.
...
The index is bound to `u32::max_value()`. The invocation inputs'
length is bound to `usize::max_value()`, which can be
`u64::max_value`. Consequently, casting the invocation inputs' length
to `u32` can lead to an integer overflow. It is better to cast `index`
to `usize` when comparing with the invocation inputs' length.
2020-03-26 07:46:59 +01:00
Ivan Enderlin
ffe7f765a2
doc(interface-types) Add strign.size
in the list of supported instructions.
2020-03-24 15:35:01 +01:00
Ivan Enderlin
38f62392ff
feat(interface-types) Implement the string.size
instruction.
2020-03-24 15:33:42 +01:00
Ivan Enderlin
daef7b0bfd
feat(interface-types) Add the Stackable::peek1
method.
...
This method allows to peek the last item on the stack (if any) by
reference.
2020-03-24 15:32:54 +01:00
Ivan Enderlin
7f2273b32b
doc(interface-types) Add string.*
instructions.
2020-03-24 13:29:38 +01:00
Ivan Enderlin
ec7aebe7e1
feat(interface-types) Implement the string.(lift|lower)_memory
instructions.
...
The `string.lift_memory` instruction replaces `memory-to-string`, and
`string.lower_memory` replaces `string-to-memory`.
2020-03-24 13:25:06 +01:00
Ivan Enderlin
afbeb5d230
feat(interface-types) Rename lowering_lifting
module to numbers
.
2020-03-24 13:10:21 +01:00
Ivan Enderlin
6fcd45bce3
doc(interface-types) Add links to WIT instructions.
2020-03-24 12:48:33 +01:00