gaia_assembler/backends/python/
mod.rs1use crate::{config::GaiaConfig, program::GaiaModule, Backend, GeneratedFiles};
4use gaia_types::{
5 helpers::{AbiCompatible, ApiCompatible, Architecture, ArtifactType, CompilationTarget},
6 Result,
7};
8use std::collections::HashMap;
9
10#[derive(Default)]
12pub struct PythonBackend {}
13
14impl Backend for PythonBackend {
15 fn name(&self) -> &'static str {
16 "Python"
17 }
18
19 fn primary_target(&self) -> CompilationTarget {
20 CompilationTarget { build: Architecture::Unknown, host: AbiCompatible::PythonBytecode, target: ApiCompatible::Unknown }
21 }
22
23 fn artifact_type(&self) -> ArtifactType {
24 ArtifactType::Bytecode
25 }
26
27 fn match_score(&self, target: &CompilationTarget) -> f32 {
28 if target.host == AbiCompatible::PythonBytecode {
29 return 80.0;
30 }
31 0.0
32 }
33
34 fn generate(&self, _program: &GaiaModule, config: &GaiaConfig) -> Result<GeneratedFiles> {
35 #[cfg(feature = "python-assembler")]
36 {
37 Ok(GeneratedFiles { artifact_type: self.artifact_type(), files: HashMap::new(), custom: None, diagnostics: vec![] })
38 }
39 #[cfg(not(feature = "python-assembler"))]
40 {
41 Err(gaia_types::GaiaError::custom_error("Python feature is not enabled"))
42 }
43 }
44}