Middleware for singlepass.

This commit is contained in:
losfair
2020-06-16 00:56:56 +08:00
parent 1bbaafb819
commit 711ffb6692
2 changed files with 16 additions and 21 deletions

View File

@@ -2,7 +2,10 @@
#![allow(unused_imports, dead_code)]
use crate::compiler::SinglepassCompiler;
use wasmer_compiler::{Compiler, CompilerConfig, CpuFeature, Features, Target};
use std::sync::Arc;
use wasmer_compiler::{
Compiler, CompilerConfig, CpuFeature, Features, FunctionMiddlewareGenerator, Target,
};
#[derive(Clone)]
pub struct SinglepassConfig {
@@ -23,6 +26,9 @@ pub struct SinglepassConfig {
features: Features,
target: Target,
/// The middleware chain.
pub(crate) middlewares: Vec<Arc<dyn FunctionMiddlewareGenerator>>,
}
impl SinglepassConfig {
@@ -37,6 +43,7 @@ impl SinglepassConfig {
enable_stack_check: false,
features,
target,
middlewares: vec![],
}
}
}
@@ -62,6 +69,11 @@ impl CompilerConfig for SinglepassConfig {
fn compiler(&self) -> Box<dyn Compiler + Send> {
Box::new(SinglepassCompiler::new(&self))
}
/// Pushes a middleware onto the back of the middleware chain.
fn push_middleware(&mut self, middleware: Arc<dyn FunctionMiddlewareGenerator>) {
self.middlewares.push(middleware);
}
}
impl Default for SinglepassConfig {