Simplify translate_type's return type.
This commit is contained in:
@@ -122,7 +122,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
|
|||||||
if let Ok(ty_cre) = type_to_type(&ty) {
|
if let Ok(ty_cre) = type_to_type(&ty) {
|
||||||
builder.append_ebb_arg(next, ty_cre);
|
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 } => {
|
Operator::Loop { ty } => {
|
||||||
let loop_body = builder.create_ebb();
|
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.append_ebb_arg(next, ty_cre);
|
||||||
}
|
}
|
||||||
builder.ins().jump(loop_body, &[]);
|
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, &[]);
|
builder.switch_to_block(loop_body, &[]);
|
||||||
}
|
}
|
||||||
Operator::If { ty } => {
|
Operator::If { ty } => {
|
||||||
@@ -147,7 +147,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
|
|||||||
if let Ok(ty_cre) = type_to_type(&ty) {
|
if let Ok(ty_cre) = type_to_type(&ty) {
|
||||||
builder.append_ebb_arg(if_not, ty_cre);
|
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 => {
|
Operator::Else => {
|
||||||
// We take the control frame pushed by the if, use its ebb as the else body
|
// We take the control frame pushed by the if, use its ebb as the else body
|
||||||
|
|||||||
@@ -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
|
/// 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 {
|
match ty {
|
||||||
wasmparser::Type::EmptyBlockType => Ok(Vec::new()),
|
wasmparser::Type::EmptyBlockType => Vec::new(),
|
||||||
wasmparser::Type::I32 => Ok(vec![cretonne::ir::types::I32]),
|
wasmparser::Type::I32 => vec![cretonne::ir::types::I32],
|
||||||
wasmparser::Type::F32 => Ok(vec![cretonne::ir::types::F32]),
|
wasmparser::Type::F32 => vec![cretonne::ir::types::F32],
|
||||||
wasmparser::Type::I64 => Ok(vec![cretonne::ir::types::I64]),
|
wasmparser::Type::I64 => vec![cretonne::ir::types::I64],
|
||||||
wasmparser::Type::F64 => Ok(vec![cretonne::ir::types::F64]),
|
wasmparser::Type::F64 => vec![cretonne::ir::types::F64],
|
||||||
_ => panic!("unsupported return value type"),
|
_ => panic!("unsupported return value type"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user