Skip to content

Commit

Permalink
Merge #798
Browse files Browse the repository at this point in the history
798: Replace panics in codegen_x64 by CodegenError r=nlewycky a=pventuzelo

Replace panics! inside `lib/singlepass-backend/src/codegen_x64.rs` by CodegenError

Co-authored-by: Patrick Ventuzelo <[email protected]>
  • Loading branch information
bors[bot] and pventuzelo authored Sep 16, 2019
2 parents 9068777 + 00c2e09 commit 56c5714
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions lib/singlepass-backend/src/codegen_x64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ impl RunnableModule for X64ExecutionContext {

#[derive(Debug)]
pub struct CodegenError {
pub message: &'static str,
pub message: String,
}

#[derive(Copy, Clone, Debug)]
Expand Down Expand Up @@ -474,15 +474,15 @@ impl ModuleCodeGenerator<X64FunctionCode, X64ExecutionContext, CodegenError>
Some(x) => x,
None => {
return Err(CodegenError {
message: "label not found",
message: format!("label not found"),
});
}
};
let offset = match offset {
Some(x) => x,
None => {
return Err(CodegenError {
message: "offset is none",
message: format!("offset is none"),
});
}
};
Expand Down Expand Up @@ -3873,7 +3873,11 @@ impl FunctionCodeGenerator<CodegenError> for X64FunctionCode {
returns: match ty {
WpTypeOrFuncType::Type(WpType::EmptyBlockType) => smallvec![],
WpTypeOrFuncType::Type(inner_ty) => smallvec![inner_ty],
_ => panic!("multi-value returns not yet implemented"),
_ => {
return Err(CodegenError {
message: format!("multi-value returns not yet implemented"),
})
}
},
value_stack_depth: self.value_stack.len(),
state: self.machine.state.clone(),
Expand Down Expand Up @@ -3980,7 +3984,11 @@ impl FunctionCodeGenerator<CodegenError> for X64FunctionCode {
returns: match ty {
WpTypeOrFuncType::Type(WpType::EmptyBlockType) => smallvec![],
WpTypeOrFuncType::Type(inner_ty) => smallvec![inner_ty],
_ => panic!("multi-value returns not yet implemented"),
_ => {
return Err(CodegenError {
message: format!("multi-value returns not yet implemented"),
})
}
},
value_stack_depth: self.value_stack.len(),
state: self.machine.state.clone(),
Expand All @@ -4005,7 +4013,11 @@ impl FunctionCodeGenerator<CodegenError> for X64FunctionCode {
returns: match ty {
WpTypeOrFuncType::Type(WpType::EmptyBlockType) => smallvec![],
WpTypeOrFuncType::Type(inner_ty) => smallvec![inner_ty],
_ => panic!("multi-value returns not yet implemented"),
_ => {
return Err(CodegenError {
message: format!("multi-value returns not yet implemented"),
})
}
},
value_stack_depth: self.value_stack.len(),
state: self.machine.state.clone(),
Expand Down Expand Up @@ -4966,7 +4978,9 @@ impl FunctionCodeGenerator<CodegenError> for X64FunctionCode {
}
}
_ => {
panic!("not yet implemented: {:?}", op);
return Err(CodegenError {
message: format!("not yet implemented: {:?}", op),
});
}
}

Expand Down

0 comments on commit 56c5714

Please sign in to comment.