From 55e48ce7aa4c64db5f29f1df2ece053fcfe97435 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Mon, 25 Sep 2017 12:11:56 -0700 Subject: [PATCH] Simplify translate_type's return type. --- lib/wasm/src/code_translator.rs | 6 +++--- lib/wasm/src/translation_utils.rs | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/wasm/src/code_translator.rs b/lib/wasm/src/code_translator.rs index c66f9cea79..8af0127410 100644 --- a/lib/wasm/src/code_translator.rs +++ b/lib/wasm/src/code_translator.rs @@ -122,7 +122,7 @@ pub fn translate_operator( 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( 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( 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 diff --git a/lib/wasm/src/translation_utils.rs b/lib/wasm/src/translation_utils.rs index 2c915f1e43..2d522a1ba8 100644 --- a/lib/wasm/src/translation_utils.rs +++ b/lib/wasm/src/translation_utils.rs @@ -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, ()> { +pub fn translate_type(ty: wasmparser::Type) -> Vec { 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"), } }