mirror of
https://github.com/fluencelabs/wasmer
synced 2025-04-02 07:51:03 +00:00
feat(interface-types) The “helper adapter” has been removed.
This commit is contained in:
parent
ac68325cc9
commit
8538e3be33
@ -58,9 +58,6 @@ pub(crate) enum AdapterKind {
|
|||||||
|
|
||||||
/// An adapter defined for an exported function of a WebAssembly instance.
|
/// An adapter defined for an exported function of a WebAssembly instance.
|
||||||
Export,
|
Export,
|
||||||
|
|
||||||
/// A helper function.
|
|
||||||
HelperFunction,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents an exported function signature.
|
/// Represents an exported function signature.
|
||||||
@ -176,21 +173,6 @@ pub enum Adapter<'input> {
|
|||||||
/// The instructions of the adapter.
|
/// The instructions of the adapter.
|
||||||
instructions: Vec<Instruction<'input>>,
|
instructions: Vec<Instruction<'input>>,
|
||||||
},
|
},
|
||||||
|
|
||||||
/// An adapter for a helper function.
|
|
||||||
HelperFunction {
|
|
||||||
/// The helper name.
|
|
||||||
name: &'input str,
|
|
||||||
|
|
||||||
/// The helper input types.
|
|
||||||
input_types: Vec<InterfaceType>,
|
|
||||||
|
|
||||||
/// The helper output types.
|
|
||||||
output_types: Vec<InterfaceType>,
|
|
||||||
|
|
||||||
/// The instructions of the adapter.
|
|
||||||
instructions: Vec<Instruction<'input>>,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represented a forwarded export.
|
/// Represented a forwarded export.
|
||||||
|
@ -40,7 +40,6 @@ impl TryFrom<u8> for AdapterKind {
|
|||||||
Ok(match code {
|
Ok(match code {
|
||||||
0x0 => Self::Import,
|
0x0 => Self::Import,
|
||||||
0x1 => Self::Export,
|
0x1 => Self::Export,
|
||||||
0x2 => Self::HelperFunction,
|
|
||||||
_ => return Err("Unknown adapter kind code."),
|
_ => return Err("Unknown adapter kind code."),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -374,20 +373,6 @@ fn adapters<'input, E: ParseError<&'input [u8]>>(
|
|||||||
instructions: adapter_instructions,
|
instructions: adapter_instructions,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
AdapterKind::HelperFunction => {
|
|
||||||
consume!((input, adapter_name) = string(input)?);
|
|
||||||
consume!((input, adapter_input_types) = list(input, ty)?);
|
|
||||||
consume!((input, adapter_output_types) = list(input, ty)?);
|
|
||||||
consume!((input, adapter_instructions) = list(input, instruction)?);
|
|
||||||
|
|
||||||
adapters.push(Adapter::HelperFunction {
|
|
||||||
name: adapter_name,
|
|
||||||
input_types: adapter_input_types,
|
|
||||||
output_types: adapter_output_types,
|
|
||||||
instructions: adapter_instructions,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -846,7 +831,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_adapters() {
|
fn test_adapters() {
|
||||||
let input = &[
|
let input = &[
|
||||||
0x03, // 3 adapters
|
0x02, // 3 adapters
|
||||||
0x00, // adapter kind: import
|
0x00, // adapter kind: import
|
||||||
0x01, // string of 1 byte
|
0x01, // string of 1 byte
|
||||||
0x61, // "a"
|
0x61, // "a"
|
||||||
@ -867,15 +852,6 @@ mod tests {
|
|||||||
0x0c, // I32
|
0x0c, // I32
|
||||||
0x01, // list of 1 item
|
0x01, // list of 1 item
|
||||||
0x00, 0x01, // ArgumentGet { index: 1 }
|
0x00, 0x01, // ArgumentGet { index: 1 }
|
||||||
0x02, // adapter kind: helper function
|
|
||||||
0x01, // string of 1 byte
|
|
||||||
0x64, // "d"
|
|
||||||
0x01, // list of 1 item
|
|
||||||
0x0c, // I32
|
|
||||||
0x01, // list of 1 item
|
|
||||||
0x0c, // I32
|
|
||||||
0x01, // list of 1 item
|
|
||||||
0x00, 0x01, // ArgumentGet { index: 1 }
|
|
||||||
];
|
];
|
||||||
let output = Ok((
|
let output = Ok((
|
||||||
&[] as &[u8],
|
&[] as &[u8],
|
||||||
@ -893,12 +869,6 @@ mod tests {
|
|||||||
output_types: vec![InterfaceType::I32],
|
output_types: vec![InterfaceType::I32],
|
||||||
instructions: vec![Instruction::ArgumentGet { index: 1 }],
|
instructions: vec![Instruction::ArgumentGet { index: 1 }],
|
||||||
},
|
},
|
||||||
Adapter::HelperFunction {
|
|
||||||
name: "d",
|
|
||||||
input_types: vec![InterfaceType::I32],
|
|
||||||
output_types: vec![InterfaceType::I32],
|
|
||||||
instructions: vec![Instruction::ArgumentGet { index: 1 }],
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -426,8 +426,6 @@ impl<'a> Parse<'a> for Adapter<'a> {
|
|||||||
output_types,
|
output_types,
|
||||||
instructions,
|
instructions,
|
||||||
},
|
},
|
||||||
|
|
||||||
_ => unimplemented!("Adapter of kind “helper” is not implemented yet."),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,6 @@ where
|
|||||||
match self {
|
match self {
|
||||||
AdapterKind::Import => 0x00_u8.to_bytes(writer),
|
AdapterKind::Import => 0x00_u8.to_bytes(writer),
|
||||||
AdapterKind::Export => 0x01_u8.to_bytes(writer),
|
AdapterKind::Export => 0x01_u8.to_bytes(writer),
|
||||||
AdapterKind::HelperFunction => 0x02_u8.to_bytes(writer),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -214,19 +213,6 @@ where
|
|||||||
output_types.to_bytes(writer)?;
|
output_types.to_bytes(writer)?;
|
||||||
instructions.to_bytes(writer)?;
|
instructions.to_bytes(writer)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Adapter::HelperFunction {
|
|
||||||
name,
|
|
||||||
input_types,
|
|
||||||
output_types,
|
|
||||||
instructions,
|
|
||||||
} => {
|
|
||||||
AdapterKind::HelperFunction.to_bytes(writer)?;
|
|
||||||
name.to_bytes(writer)?;
|
|
||||||
input_types.to_bytes(writer)?;
|
|
||||||
output_types.to_bytes(writer)?;
|
|
||||||
instructions.to_bytes(writer)?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -468,7 +454,6 @@ mod tests {
|
|||||||
fn test_adapter_kind() {
|
fn test_adapter_kind() {
|
||||||
assert_to_bytes!(AdapterKind::Import, &[0x00]);
|
assert_to_bytes!(AdapterKind::Import, &[0x00]);
|
||||||
assert_to_bytes!(AdapterKind::Export, &[0x01]);
|
assert_to_bytes!(AdapterKind::Export, &[0x01]);
|
||||||
assert_to_bytes!(AdapterKind::HelperFunction, &[0x02]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -590,30 +575,6 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_adapter_helper_function() {
|
|
||||||
assert_to_bytes!(
|
|
||||||
Adapter::HelperFunction {
|
|
||||||
name: "a",
|
|
||||||
input_types: vec![InterfaceType::I32, InterfaceType::I64],
|
|
||||||
output_types: vec![InterfaceType::I32],
|
|
||||||
instructions: vec![Instruction::ArgumentGet { index: 1 }],
|
|
||||||
},
|
|
||||||
&[
|
|
||||||
0x02, // AdapterKind::HelperFunction
|
|
||||||
0x01, // string of length 1
|
|
||||||
0x61, // "a"
|
|
||||||
0x02, // list of 2 items
|
|
||||||
0x0c, // I32
|
|
||||||
0x0d, // I64
|
|
||||||
0x01, // list of 1 items
|
|
||||||
0x0c, // I32
|
|
||||||
0x01, // list of 1 item
|
|
||||||
0x00, 0x01, // ArgumentGet { index: 1 }
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_forward() {
|
fn test_forward() {
|
||||||
assert_to_bytes!(
|
assert_to_bytes!(
|
||||||
|
@ -279,8 +279,6 @@ impl<'input> ToString for &Adapter<'input> {
|
|||||||
accumulator
|
accumulator
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
|
|
||||||
_ => todo!("To be implemented."),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -345,8 +343,6 @@ impl<'input> ToString for &Interfaces<'input> {
|
|||||||
Adapter::Export { name, .. } => {
|
Adapter::Export { name, .. } => {
|
||||||
accumulator.push_str(&format!("\n\n;; Interface, Adapter {}\n", name))
|
accumulator.push_str(&format!("\n\n;; Interface, Adapter {}\n", name))
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => todo!("To be implemented."),
|
|
||||||
}
|
}
|
||||||
accumulator.push_str(&adapter.to_string());
|
accumulator.push_str(&adapter.to_string());
|
||||||
accumulator
|
accumulator
|
||||||
|
Loading…
x
Reference in New Issue
Block a user