This commit is contained in:
bjorn3
2019-01-15 17:30:40 +01:00
committed by Dan Gohman
parent 80031cb2b4
commit eb032fd0f4

View File

@@ -517,8 +517,9 @@ where
ctx: &mut Context,
peek_compiled: impl FnOnce(u32, &Context, &isa::TargetIsa) -> T,
) -> ModuleResult<T> {
let (compiled, peek_res) = {
let code_size = ctx.compile(self.backend.isa()).map_err(|e| {
let code_size;
let compiled = {
code_size = ctx.compile(self.backend.isa()).map_err(|e| {
info!(
"defining function {}: {}",
func,
@@ -535,23 +536,18 @@ where
return Err(ModuleError::InvalidImportDefinition(info.decl.name.clone()));
}
let peek_res = peek_compiled(code_size, &ctx, self.backend.isa());
(
self.backend.define_function(
Some(self.backend.define_function(
&info.decl.name,
ctx,
&ModuleNamespace::<B> {
contents: &self.contents,
},
code_size,
)?,
peek_res,
)
)?)
};
self.contents.functions[func].compiled = Some(compiled);
self.contents.functions[func].compiled = compiled;
self.functions_to_finalize.push(func);
Ok(peek_res)
Ok(peek_compiled(code_size, &ctx, self.backend.isa()))
}
/// Define a function, producing the data contents from the given `DataContext`.