mirror of
https://github.com/fluencelabs/parity-wasm
synced 2025-04-24 14:52:14 +00:00
Add possibility to use enum Instruction in hash structures
This commit is contained in:
parent
e586a7ac87
commit
c7c2d1f246
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,3 +3,4 @@ Cargo.lock
|
||||
.vscode
|
||||
**/.DS_Store
|
||||
rls
|
||||
.idea
|
||||
|
@ -104,7 +104,7 @@ impl Deserialize for InitExpr {
|
||||
}
|
||||
|
||||
/// Instruction.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
#[allow(missing_docs)]
|
||||
pub enum Instruction {
|
||||
Unreachable,
|
||||
@ -539,14 +539,14 @@ pub enum Instruction {
|
||||
TableCopy,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
#[allow(missing_docs)]
|
||||
pub struct MemArg {
|
||||
pub align: u8,
|
||||
pub offset: u32,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
#[allow(missing_docs)]
|
||||
pub struct BrTableData {
|
||||
pub table: Box<[u32]>,
|
||||
@ -2780,3 +2780,13 @@ fn display() {
|
||||
fn size_off() {
|
||||
assert!(::std::mem::size_of::<Instruction>() <= 24);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn instructions_hashset() {
|
||||
use self::Instruction::{Call, Block, Drop};
|
||||
use super::types::{BlockType::Value, ValueType};
|
||||
|
||||
let set: std::collections::HashSet<Instruction> =
|
||||
vec![Call(1), Block(Value(ValueType::I32)), Drop].into_iter().collect();
|
||||
assert_eq!(set.contains(&Drop), true)
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ impl fmt::Display for ValueType {
|
||||
}
|
||||
|
||||
/// Block type which is basically `ValueType` + NoResult (to define blocks that have no return type)
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
pub enum BlockType {
|
||||
/// Value-type specified block type
|
||||
Value(ValueType),
|
||||
|
Loading…
x
Reference in New Issue
Block a user