Simplify translate_type's return type.

This commit is contained in:
Dan Gohman
2017-09-25 12:11:56 -07:00
parent 14d6d1117d
commit 55e48ce7aa
2 changed files with 9 additions and 9 deletions

View File

@@ -122,7 +122,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
if let Ok(ty_cre) = type_to_type(&ty) {
builder.append_ebb_arg(next, ty_cre);
}
state.push_block(next, translate_type(ty).unwrap());
state.push_block(next, translate_type(ty));
}
Operator::Loop { ty } => {
let loop_body = builder.create_ebb();
@@ -131,7 +131,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
builder.append_ebb_arg(next, ty_cre);
}
builder.ins().jump(loop_body, &[]);
state.push_loop(loop_body, next, translate_type(ty).unwrap());
state.push_loop(loop_body, next, translate_type(ty));
builder.switch_to_block(loop_body, &[]);
}
Operator::If { ty } => {
@@ -147,7 +147,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
if let Ok(ty_cre) = type_to_type(&ty) {
builder.append_ebb_arg(if_not, ty_cre);
}
state.push_if(jump_inst, if_not, translate_type(ty).unwrap());
state.push_if(jump_inst, if_not, translate_type(ty));
}
Operator::Else => {
// We take the control frame pushed by the if, use its ebb as the else body

View File

@@ -119,13 +119,13 @@ pub fn f64_translation(x: wasmparser::Ieee64) -> cretonne::ir::immediates::Ieee6
}
/// Translate a `wasmparser` type into its `Cretonne` equivalent, when possible
pub fn translate_type(ty: wasmparser::Type) -> Result<Vec<cretonne::ir::Type>, ()> {
pub fn translate_type(ty: wasmparser::Type) -> Vec<cretonne::ir::Type> {
match ty {
wasmparser::Type::EmptyBlockType => Ok(Vec::new()),
wasmparser::Type::I32 => Ok(vec![cretonne::ir::types::I32]),
wasmparser::Type::F32 => Ok(vec![cretonne::ir::types::F32]),
wasmparser::Type::I64 => Ok(vec![cretonne::ir::types::I64]),
wasmparser::Type::F64 => Ok(vec![cretonne::ir::types::F64]),
wasmparser::Type::EmptyBlockType => Vec::new(),
wasmparser::Type::I32 => vec![cretonne::ir::types::I32],
wasmparser::Type::F32 => vec![cretonne::ir::types::F32],
wasmparser::Type::I64 => vec![cretonne::ir::types::I64],
wasmparser::Type::F64 => vec![cretonne::ir::types::F64],
_ => panic!("unsupported return value type"),
}
}