[wasm] Don't panic when seeing unexpected types but properly fail instead;

This commit is contained in:
Benjamin Bouvier
2019-07-01 12:23:14 +02:00
parent 460fdaa34d
commit f6ac165ff6
3 changed files with 40 additions and 22 deletions

View File

@@ -135,7 +135,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
if let Ok(ty_cre) = blocktype_to_type(ty) {
builder.append_ebb_param(next, ty_cre);
}
state.push_block(next, num_return_values(ty));
state.push_block(next, num_return_values(ty)?);
}
Operator::Loop { ty } => {
let loop_body = builder.create_ebb();
@@ -144,7 +144,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
builder.append_ebb_param(next, ty_cre);
}
builder.ins().jump(loop_body, &[]);
state.push_loop(loop_body, next, num_return_values(ty));
state.push_loop(loop_body, next, num_return_values(ty)?);
builder.switch_to_block(loop_body);
environ.translate_loop_header(builder.cursor())?;
}
@@ -161,7 +161,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
if let Ok(ty_cre) = blocktype_to_type(ty) {
builder.append_ebb_param(if_not, ty_cre);
}
state.push_if(jump_inst, if_not, num_return_values(ty));
state.push_if(jump_inst, if_not, num_return_values(ty)?);
}
Operator::Else => {
// We take the control frame pushed by the if, use its ebb as the else body