Ivan Enderlin
b80ddc2a9c
doc(interface-types) Add record
instructions.
2020-04-07 11:58:13 +02:00
Ivan Enderlin
d4b762e505
doc(interface-types) Update from_interface_values
's doc.
...
Using `InterfaceValue::Record` explicitely doesn't change anything
since values are flatten, but it's better for a usual reading to avoid
confusion.
2020-04-06 08:13:10 +02:00
Ivan Enderlin
1f814a445a
doc(interface-types) Rewrite record_lift_
documentation.
2020-04-06 08:09:10 +02:00
Ivan Enderlin
1db6712ae3
feat(interface-types) Use VecDeque
to remove unsafe code.
2020-04-06 07:55:56 +02:00
Ivan Enderlin
2992a2d21f
feat(interface-types) Avoid clones by using owned items in an iterator.
...
`into_iter` owned the item, so no need to clone when moving them in
the stack.
2020-04-06 07:54:51 +02:00
Ivan Enderlin
136518e77e
doc(interface-types) Explain a part of an algorithm.
2020-04-04 08:10:38 +02:00
Ivan Enderlin
b9b5a32154
feat(interface-types) Simplify FlattenInterfaceValueIterator
with last_mut
.
2020-04-03 16:22:26 +02:00
Ivan Enderlin
d184ddbe37
feat(interface-types) Use Vec::last_mut
to simplify code.
2020-04-03 16:20:22 +02:00
Ivan Enderlin
3426921a8b
fix(interface-types) Also apply another lazy evaluation in the deserializer.
2020-04-03 16:19:07 +02:00
Ivan Enderlin
099bf70712
fix(interface-types) Use lazy evaluation in the deserializer.
2020-04-03 16:18:24 +02:00
Ivan Enderlin
b9f54fb5c4
doc(interface-types) Fix a typo.
2020-04-03 16:16:53 +02:00
Ivan Enderlin
419dcc6415
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
643659801c
doc(interface-types) Fix typos.
2020-04-03 14:46:59 +02:00
Ivan Enderlin
858233a66d
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
18414ea305
doc(interface-types) Improve serde
module documentation.
2020-04-02 16:41:03 +02:00
Ivan Enderlin
88ad448486
feat(interface-types) Make unwrap
s safe by introducing more errors.
2020-04-02 16:38:40 +02:00
Ivan Enderlin
c8e0220d29
doc(interface-types) Update an example.
2020-04-02 16:29:52 +02:00
Ivan Enderlin
4690893ec1
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
41f5e5b2a0
doc(interface-types) Describe to_interface_value
.
2020-04-02 15:59:07 +02:00
Ivan Enderlin
8a6b29257e
feat(interface-types) Implement a serializer for WIT values.
2020-04-02 15:54:39 +02:00
Ivan Enderlin
93abfd3d55
feat(interface-types) Rename from_values
to from_interface_values
.
2020-04-02 13:56:20 +02:00
Ivan Enderlin
d8c4d8fa83
feat(interface-types) Make serde
optional behind a feature flag.
2020-04-02 13:53:10 +02:00
Ivan Enderlin
dc87c44d52
fix(interface-types) Fix a git-merge
issue.
2020-04-02 12:16:30 +02:00
Ivan Enderlin
cd90973e72
Merge branch 'master' into feat-interface-types-record-instructions
2020-04-02 12:10:01 +02:00
Ivan Enderlin
af465870db
chore(interface-types) Improve code readabilit of the record.lift
instruction.
2020-04-02 12:06:54 +02:00
Ivan Enderlin
260585726c
feat(interface-types) Implement the record.lower
instruction.
2020-04-02 12:06:27 +02:00
Ivan Enderlin
c7bb9904f7
feat(interface-types) Encodes/decodes the record.lower
instruction.
2020-04-02 12:05:22 +02:00
Ivan Enderlin
3aeff59b11
test(interface-types) Rename test cases.
2020-04-02 11:59:35 +02:00
Ivan Enderlin
a17eb6004a
test(interface-types) Rename a test case.
2020-04-02 11:58:05 +02:00
Ivan Enderlin
3f48740c06
feat(interface-types) Implement From<&Vec<InterfaceValue>>
for RecordType
.
2020-04-02 11:55:54 +02:00
Ivan Enderlin
576bf74b28
feat(interface-types) Move serde::InterfaceTypeIterator
into values::FlattenInterfaceValueIterator
.
2020-04-02 11:55:20 +02:00
Ivan Enderlin
0d026171ef
chore(interface-types) Improve code readibility of string
instructions.
2020-04-02 11:51:34 +02:00
Ivan Enderlin
7a4a16319b
test(interface-types) Deserialize WIT record to Rust struct.
2020-03-31 14:44:04 +02:00
Ivan Enderlin
2f0f4b1e84
feat(interface-types) Implement the record.lift
instruction.
2020-03-31 12:34:32 +02:00
Ivan Enderlin
5249b243ee
feat(interface-types) Encodes/decodes the record.lift
instruction.
2020-03-31 08:17:52 +02:00
Ivan Enderlin
3a929ddf73
chore(interface-types) Reorganize the serde module.
2020-03-31 08:02:46 +02:00
Ivan Enderlin
c2933925ad
feat(interface-types) Improve the Deserializer
API.
2020-03-31 07:47:54 +02:00
Ivan Enderlin
e7ee54cb2e
feat(interface-values) Improve the TypeMismatch
error.
2020-03-31 07:47:15 +02:00
Ivan Enderlin
886204495d
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
7ad156bd6a
feat(interface-types) Add the Record
WIT value.
2020-03-30 08:32:31 +02:00
Ivan Enderlin
41f9c231c0
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
b528e965c5
chore(interface-types) Move the instruction.rs
module in instructions/mod.rs
.
2020-03-26 11:24:10 +01:00
Ivan Enderlin
bddb4e90ee
test(interface-types) Test Type::Record
.
2020-03-26 11:18:24 +01:00
Ivan Enderlin
c3c6fcbfdd
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
8705de9cc0
feat(interface-types) Simplify code by implementing From<TryFromIntError>
.
2020-03-26 10:49:49 +01:00
Ivan Enderlin
5275f3f306
feat(interface-types) Add the NegativeValue
instruction error.
2020-03-26 08:31:06 +01:00
Ivan Enderlin
c35996c233
test(interface-types) Test negative pointer or length in string.lift_memory
.
2020-03-26 08:30:32 +01:00
Ivan Enderlin
bf7f7cf927
fix(interface-types) Avoid integer overflows in string instructions.
2020-03-26 08:27:51 +01:00
Ivan Enderlin
2074ce8bce
fix(interface-types) Instruction::CallCore.function_index
is a u32
.
2020-03-26 07:53:44 +01:00
Ivan Enderlin
b63ce1be6c
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