gaia_assembler/backends/
mod.rs

1//! Backend compiler module
2//!
3//! Contains compiler implementations for various target platforms
4
5pub mod jvm;
6pub mod msil;
7pub mod pe;
8pub mod wasi;
9
10// Re-export backend structs
11pub use self::{jvm::JvmBackend, msil::ClrBackend, pe::PeBackend, wasi::WasiBackend};
12
13use crate::config::{GaiaConfig, GaiaSettings};
14use gaia_types::{
15    helpers::{AbiCompatible, ApiCompatible, Architecture, CompilationTarget},
16    GaiaError, Result,
17};
18use std::collections::HashMap;
19use crate::program::GaiaProgram;
20
21
22/// Backend compiler trait
23pub trait Backend {
24    /// Get backend name
25    fn name(&self) -> &'static str;
26
27    /// 获取此后端支持的主要编译目标
28    fn primary_target(&self) -> CompilationTarget;
29
30    /// 计算与给定编译目标的匹配度 (0-100)
31    /// 0 表示不支持
32    fn match_score(&self, target: &CompilationTarget) -> f32;
33
34    /// Compile Gaia program to target platform
35    fn generate(&self, program: &GaiaProgram, config: &GaiaConfig) -> Result<GeneratedFiles>;
36}
37
38pub struct GeneratedFiles {
39    pub files: HashMap<String, Vec<u8>>,
40    pub diagnostics: Vec<GaiaError>,
41}