Pass the wasmparser::Operator by value, simplifying the code.
This commit is contained in:
@@ -38,7 +38,7 @@ use std::{i32, u32};
|
|||||||
/// Translates wasm operators into Cretonne IL instructions. Returns `true` if it inserted
|
/// Translates wasm operators into Cretonne IL instructions. Returns `true` if it inserted
|
||||||
/// a return.
|
/// a return.
|
||||||
pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
|
pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
|
||||||
op: &Operator,
|
op: Operator,
|
||||||
builder: &mut FunctionBuilder<Local>,
|
builder: &mut FunctionBuilder<Local>,
|
||||||
state: &mut TranslationState,
|
state: &mut TranslationState,
|
||||||
environ: &mut FE,
|
environ: &mut FE,
|
||||||
@@ -48,7 +48,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This big match treats all Wasm code operators.
|
// This big match treats all Wasm code operators.
|
||||||
match *op {
|
match op {
|
||||||
/********************************** Locals ****************************************
|
/********************************** Locals ****************************************
|
||||||
* `get_local` and `set_local` are treated as non-SSA variables and will completely
|
* `get_local` and `set_local` are treated as non-SSA variables and will completely
|
||||||
* disappear in the Cretonne Code
|
* disappear in the Cretonne Code
|
||||||
@@ -265,7 +265,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
|
|||||||
state.peekn(return_count),
|
state.peekn(return_count),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Operator::BrTable { ref table } => {
|
Operator::BrTable { table } => {
|
||||||
let (depths, default) = table.read_table();
|
let (depths, default) = table.read_table();
|
||||||
let mut min_depth = default;
|
let mut min_depth = default;
|
||||||
for depth in &depths {
|
for depth in &depths {
|
||||||
@@ -935,11 +935,11 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
|
|||||||
/// are dropped but special ones like `End` or `Else` signal the potential end of the unreachable
|
/// are dropped but special ones like `End` or `Else` signal the potential end of the unreachable
|
||||||
/// portion so the translation state muts be updated accordingly.
|
/// portion so the translation state muts be updated accordingly.
|
||||||
fn translate_unreachable_operator(
|
fn translate_unreachable_operator(
|
||||||
op: &Operator,
|
op: Operator,
|
||||||
builder: &mut FunctionBuilder<Local>,
|
builder: &mut FunctionBuilder<Local>,
|
||||||
state: &mut TranslationState,
|
state: &mut TranslationState,
|
||||||
) {
|
) {
|
||||||
match *op {
|
match op {
|
||||||
Operator::If { ty: _ } => {
|
Operator::If { ty: _ } => {
|
||||||
// Push a placeholder control stack entry. The if isn't reachable,
|
// Push a placeholder control stack entry. The if isn't reachable,
|
||||||
// so we don't have any branches anywhere.
|
// so we don't have any branches anywhere.
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ fn parse_function_body<FE: FuncEnvironment + ?Sized>(
|
|||||||
while !state.control_stack.is_empty() {
|
while !state.control_stack.is_empty() {
|
||||||
builder.set_srcloc(cur_srcloc(&reader));
|
builder.set_srcloc(cur_srcloc(&reader));
|
||||||
let op = reader.read_operator().map_err(|_| CtonError::InvalidInput)?;
|
let op = reader.read_operator().map_err(|_| CtonError::InvalidInput)?;
|
||||||
translate_operator(&op, builder, state, environ);
|
translate_operator(op, builder, state, environ);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The final `End` operator left us in the exit block where we need to manually add a return
|
// The final `End` operator left us in the exit block where we need to manually add a return
|
||||||
|
|||||||
Reference in New Issue
Block a user