mirror of
https://github.com/fluencelabs/parity-wasm
synced 2025-06-29 14:42:02 +00:00
globals
This commit is contained in:
@ -10,6 +10,47 @@ impl Opcodes {
|
||||
pub fn elements(&self) -> &[Opcode] { &self.0 }
|
||||
}
|
||||
|
||||
impl Deserialize for Opcodes {
|
||||
type Error = Error;
|
||||
|
||||
fn deserialize<R: io::Read>(reader: &mut R) -> Result<Self, Self::Error> {
|
||||
let mut opcodes = Vec::new();
|
||||
|
||||
loop {
|
||||
let opcode = Opcode::deserialize(reader)?;
|
||||
let is_terminal = opcode.is_terminal();
|
||||
opcodes.push(opcode);
|
||||
if is_terminal {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(Opcodes(opcodes))
|
||||
}
|
||||
}
|
||||
|
||||
pub struct InitExpr(Vec<Opcode>);
|
||||
|
||||
// todo: check if kind of opcode sequence is valid as an expression
|
||||
impl Deserialize for InitExpr {
|
||||
type Error = Error;
|
||||
|
||||
fn deserialize<R: io::Read>(reader: &mut R) -> Result<Self, Self::Error> {
|
||||
let mut opcodes = Vec::new();
|
||||
|
||||
loop {
|
||||
let opcode = Opcode::deserialize(reader)?;
|
||||
let is_terminal = opcode.is_terminal();
|
||||
opcodes.push(opcode);
|
||||
if is_terminal {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(InitExpr(opcodes))
|
||||
}
|
||||
}
|
||||
|
||||
pub enum Opcode {
|
||||
Unreachable,
|
||||
Nop,
|
||||
@ -486,22 +527,3 @@ impl Deserialize for Opcode {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl Deserialize for Opcodes {
|
||||
type Error = Error;
|
||||
|
||||
fn deserialize<R: io::Read>(reader: &mut R) -> Result<Self, Self::Error> {
|
||||
let mut opcodes = Vec::new();
|
||||
|
||||
loop {
|
||||
let opcode = Opcode::deserialize(reader)?;
|
||||
let is_terminal = opcode.is_terminal();
|
||||
opcodes.push(opcode);
|
||||
if is_terminal {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(Opcodes(opcodes))
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user