mirror of
https://github.com/fluencelabs/parity-wasm
synced 2025-06-02 17:41:37 +00:00
Renamed VarUint8 to Uint8, which makes since since it's not variable-length
Also fixed a couple other small parts I missed.
This commit is contained in:
parent
5b19c5fb94
commit
f390d9a8e4
@ -25,7 +25,7 @@ pub use self::import_entry::{ImportEntry, ResizableLimits, MemoryType, TableType
|
|||||||
pub use self::export_entry::{ExportEntry, Internal};
|
pub use self::export_entry::{ExportEntry, Internal};
|
||||||
pub use self::global_entry::GlobalEntry;
|
pub use self::global_entry::GlobalEntry;
|
||||||
pub use self::primitives::{
|
pub use self::primitives::{
|
||||||
VarUint32, VarUint7, VarUint8, VarUint1, VarInt7, Uint32, VarInt32, VarInt64,
|
VarUint32, VarUint7, Uint8, VarUint1, VarInt7, Uint32, VarInt32, VarInt64,
|
||||||
Uint64, VarUint64, CountedList, CountedWriter, CountedListWriter,
|
Uint64, VarUint64, CountedList, CountedWriter, CountedListWriter,
|
||||||
};
|
};
|
||||||
pub use self::types::{Type, ValueType, BlockType, FunctionType, TableElementType};
|
pub use self::types::{Type, ValueType, BlockType, FunctionType, TableElementType};
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use std::{io, fmt};
|
use std::{io, fmt};
|
||||||
use super::{
|
use super::{
|
||||||
Serialize, Deserialize, Error, VarUint7,
|
Serialize, Deserialize, Error,
|
||||||
VarUint8, VarUint32, CountedList, BlockType,
|
Uint8, VarUint32, CountedList, BlockType,
|
||||||
Uint32, Uint64, CountedListWriter,
|
Uint32, Uint64, CountedListWriter,
|
||||||
VarInt32, VarInt64,
|
VarInt32, VarInt64,
|
||||||
};
|
};
|
||||||
@ -319,7 +319,7 @@ impl Deserialize for Opcode {
|
|||||||
fn deserialize<R: io::Read>(reader: &mut R) -> Result<Self, Self::Error> {
|
fn deserialize<R: io::Read>(reader: &mut R) -> Result<Self, Self::Error> {
|
||||||
use self::Opcode::*;
|
use self::Opcode::*;
|
||||||
|
|
||||||
let val: u8 = VarUint7::deserialize(reader)?.into();
|
let val: u8 = Uint8::deserialize(reader)?.into();
|
||||||
|
|
||||||
Ok(
|
Ok(
|
||||||
match val {
|
match val {
|
||||||
@ -346,7 +346,7 @@ impl Deserialize for Opcode {
|
|||||||
0x10 => Call(VarUint32::deserialize(reader)?.into()),
|
0x10 => Call(VarUint32::deserialize(reader)?.into()),
|
||||||
0x11 => CallIndirect(
|
0x11 => CallIndirect(
|
||||||
VarUint32::deserialize(reader)?.into(),
|
VarUint32::deserialize(reader)?.into(),
|
||||||
VarUint8::deserialize(reader)?.into()),
|
Uint8::deserialize(reader)?.into()),
|
||||||
0x1a => Drop,
|
0x1a => Drop,
|
||||||
0x1b => Select,
|
0x1b => Select,
|
||||||
|
|
||||||
@ -449,8 +449,8 @@ impl Deserialize for Opcode {
|
|||||||
VarUint32::deserialize(reader)?.into()),
|
VarUint32::deserialize(reader)?.into()),
|
||||||
|
|
||||||
|
|
||||||
0x3f => CurrentMemory(VarUint8::deserialize(reader)?.into()),
|
0x3f => CurrentMemory(Uint8::deserialize(reader)?.into()),
|
||||||
0x40 => GrowMemory(VarUint8::deserialize(reader)?.into()),
|
0x40 => GrowMemory(Uint8::deserialize(reader)?.into()),
|
||||||
|
|
||||||
0x41 => I32Const(VarInt32::deserialize(reader)?.into()),
|
0x41 => I32Const(VarInt32::deserialize(reader)?.into()),
|
||||||
0x42 => I64Const(VarInt64::deserialize(reader)?.into()),
|
0x42 => I64Const(VarInt64::deserialize(reader)?.into()),
|
||||||
@ -644,7 +644,7 @@ impl Serialize for Opcode {
|
|||||||
}),
|
}),
|
||||||
CallIndirect(index, reserved) => op!(writer, 0x11, {
|
CallIndirect(index, reserved) => op!(writer, 0x11, {
|
||||||
VarUint32::from(index).serialize(writer)?;
|
VarUint32::from(index).serialize(writer)?;
|
||||||
VarUint7::from(reserved).serialize(writer)?;
|
Uint8::from(reserved).serialize(writer)?;
|
||||||
}),
|
}),
|
||||||
Drop => op!(writer, 0x1a),
|
Drop => op!(writer, 0x1a),
|
||||||
Select => op!(writer, 0x1b),
|
Select => op!(writer, 0x1b),
|
||||||
@ -756,10 +756,10 @@ impl Serialize for Opcode {
|
|||||||
VarUint32::from(offset).serialize(writer)?;
|
VarUint32::from(offset).serialize(writer)?;
|
||||||
}),
|
}),
|
||||||
CurrentMemory(flag) => op!(writer, 0x3f, {
|
CurrentMemory(flag) => op!(writer, 0x3f, {
|
||||||
VarUint7::from(flag).serialize(writer)?;
|
Uint8::from(flag).serialize(writer)?;
|
||||||
}),
|
}),
|
||||||
GrowMemory(flag) => op!(writer, 0x40, {
|
GrowMemory(flag) => op!(writer, 0x40, {
|
||||||
VarUint7::from(flag).serialize(writer)?;
|
Uint8::from(flag).serialize(writer)?;
|
||||||
}),
|
}),
|
||||||
I32Const(def) => op!(writer, 0x41, {
|
I32Const(def) => op!(writer, 0x41, {
|
||||||
VarInt32::from(def).serialize(writer)?;
|
VarInt32::from(def).serialize(writer)?;
|
||||||
|
@ -209,31 +209,31 @@ impl Serialize for VarInt7 {
|
|||||||
/// 8-bit unsigned integer, NOT encoded in LEB128;
|
/// 8-bit unsigned integer, NOT encoded in LEB128;
|
||||||
/// it's just a single byte.
|
/// it's just a single byte.
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub struct VarUint8(u8);
|
pub struct Uint8(u8);
|
||||||
|
|
||||||
impl From<VarUint8> for u8 {
|
impl From<Uint8> for u8 {
|
||||||
fn from(v: VarUint8) -> u8 {
|
fn from(v: Uint8) -> u8 {
|
||||||
v.0
|
v.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<u8> for VarUint8 {
|
impl From<u8> for Uint8 {
|
||||||
fn from(v: u8) -> Self {
|
fn from(v: u8) -> Self {
|
||||||
VarUint8(v)
|
Uint8(v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Deserialize for VarUint8 {
|
impl Deserialize for Uint8 {
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
|
||||||
fn deserialize<R: io::Read>(reader: &mut R) -> Result<Self, Self::Error> {
|
fn deserialize<R: io::Read>(reader: &mut R) -> Result<Self, Self::Error> {
|
||||||
let mut u8buf = [0u8; 1];
|
let mut u8buf = [0u8; 1];
|
||||||
reader.read_exact(&mut u8buf)?;
|
reader.read_exact(&mut u8buf)?;
|
||||||
Ok(VarUint8(u8buf[0]))
|
Ok(Uint8(u8buf[0]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Serialize for VarUint8 {
|
impl Serialize for Uint8 {
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
|
||||||
fn serialize<W: io::Write>(self, writer: &mut W) -> Result<(), Self::Error> {
|
fn serialize<W: io::Write>(self, writer: &mut W) -> Result<(), Self::Error> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user