Skip to main content

oxilean_codegen/native_backend/
nativemodule_traits.rs

1//! # NativeModule - Trait Implementations
2//!
3//! This module contains trait implementations for `NativeModule`.
4//!
5//! ## Implemented Traits
6//!
7//! - `Display`
8//!
9//! 🤖 Generated with [SplitRS](https://github.com/cool-japan/splitrs)
10
11use crate::lcnf::*;
12
13use super::types::NativeModule;
14use std::fmt;
15
16impl fmt::Display for NativeModule {
17    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18        writeln!(f, "; module: {}", self.name)?;
19        for (name, params, ret) in &self.extern_fns {
20            write!(f, "declare @{}(", name)?;
21            for (i, ty) in params.iter().enumerate() {
22                if i > 0 {
23                    write!(f, ", ")?;
24                }
25                write!(f, "{}", ty)?;
26            }
27            writeln!(f, ") -> {}", ret)?;
28        }
29        writeln!(f)?;
30        for func in &self.functions {
31            write!(f, "{}", func)?;
32        }
33        Ok(())
34    }
35}