gaia_assembler/backends/lua/
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 LuaBackend {}
13
14impl Backend for LuaBackend {
15 fn name(&self) -> &'static str {
16 "Lua"
17 }
18
19 fn primary_target(&self) -> CompilationTarget {
20 CompilationTarget { build: Architecture::Unknown, host: AbiCompatible::LuaBytecode, 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::LuaBytecode {
29 return 80.0;
30 }
31 0.0
32 }
33
34 fn generate(&self, _program: &GaiaModule, config: &GaiaConfig) -> Result<GeneratedFiles> {
35 #[cfg(feature = "lua-assembler")]
36 {
37 Ok(GeneratedFiles { artifact_type: self.artifact_type(), files: HashMap::new(), custom: None, diagnostics: vec![] })
38 }
39 #[cfg(not(feature = "lua-assembler"))]
40 {
41 Err(gaia_types::GaiaError::custom_error("Lua feature is not enabled"))
42 }
43 }
44}