Add module info transformation method to ModuleMiddleware.

This commit is contained in:
losfair
2020-06-22 00:54:44 +08:00
committed by Nick Lewycky
parent 875ac93355
commit e7dd725c6d
14 changed files with 71 additions and 48 deletions

View File

@@ -8,7 +8,7 @@ use itertools::Itertools;
use std::fmt::Debug;
use std::sync::Arc;
use target_lexicon::Architecture;
use wasmer_compiler::{Compiler, CompilerConfig, FunctionMiddlewareGenerator, Target, Triple};
use wasmer_compiler::{Compiler, CompilerConfig, ModuleMiddleware, Target, Triple};
use wasmer_types::{FunctionType, LocalFunctionIndex};
/// The InkWell ModuleInfo type
@@ -45,7 +45,7 @@ pub struct LLVM {
is_pic: bool,
pub(crate) callbacks: Option<Arc<dyn LLVMCallbacks>>,
/// The middleware chain.
pub(crate) middlewares: Vec<Arc<dyn FunctionMiddlewareGenerator>>,
pub(crate) middlewares: Vec<Arc<dyn ModuleMiddleware>>,
}
impl LLVM {
@@ -212,7 +212,7 @@ impl CompilerConfig for LLVM {
}
/// Pushes a middleware onto the back of the middleware chain.
fn push_middleware(&mut self, middleware: Arc<dyn FunctionMiddlewareGenerator>) {
fn push_middleware(&mut self, middleware: Arc<dyn ModuleMiddleware>) {
self.middlewares.push(middleware);
}
}

View File

@@ -26,8 +26,8 @@ use crate::config::{CompiledKind, LLVM};
use crate::object_file::{load_object_file, CompiledFunction};
use wasmer_compiler::wasmparser::{MemoryImmediate, Operator};
use wasmer_compiler::{
to_wasm_error, wptype_to_type, CompileError, FunctionBodyData, GenerateMiddlewareChain,
MiddlewareBinaryReader, ModuleTranslationState, RelocationTarget, Symbol, SymbolRegistry,
to_wasm_error, wptype_to_type, CompileError, FunctionBodyData, MiddlewareBinaryReader,
ModuleMiddlewareChain, ModuleTranslationState, RelocationTarget, Symbol, SymbolRegistry,
};
use wasmer_types::entity::PrimaryMap;
use wasmer_types::{
@@ -150,7 +150,7 @@ impl FuncTranslator {
reader.set_middleware_chain(
config
.middlewares
.generate_middleware_chain(*local_func_index),
.generate_function_middleware_chain(*local_func_index),
);
let mut params = vec![];