linera_wasmer_compiler_singlepass/
config.rs1#![allow(unused_imports, dead_code)]
3
4use crate::compiler::SinglepassCompiler;
5use std::sync::Arc;
6use wasmer_compiler::{Compiler, CompilerConfig, Engine, EngineBuilder, ModuleMiddleware};
7use wasmer_types::{CpuFeature, Features, Target};
8
9#[derive(Debug, Clone)]
10pub struct Singlepass {
11 pub(crate) enable_nan_canonicalization: bool,
12 pub(crate) middlewares: Vec<Arc<dyn ModuleMiddleware>>,
14}
15
16impl Singlepass {
17 pub fn new() -> Self {
20 Self {
21 enable_nan_canonicalization: true,
22 middlewares: vec![],
23 }
24 }
25
26 pub fn canonicalize_nans(&mut self, enable: bool) -> &mut Self {
27 self.enable_nan_canonicalization = enable;
28 self
29 }
30}
31
32impl CompilerConfig for Singlepass {
33 fn enable_pic(&mut self) {
34 }
37
38 fn compiler(self: Box<Self>) -> Box<dyn Compiler> {
40 Box::new(SinglepassCompiler::new(*self))
41 }
42
43 fn default_features_for_target(&self, _target: &Target) -> Features {
45 let mut features = Features::default();
46 features.multi_value(false);
47 features
48 }
49
50 fn push_middleware(&mut self, middleware: Arc<dyn ModuleMiddleware>) {
52 self.middlewares.push(middleware);
53 }
54}
55
56impl Default for Singlepass {
57 fn default() -> Singlepass {
58 Self::new()
59 }
60}
61
62impl From<Singlepass> for Engine {
63 fn from(config: Singlepass) -> Self {
64 EngineBuilder::new(config).engine()
65 }
66}