gaia-assembler 0.1.1

Universal assembler framework for Gaia project
Documentation
use gaia_assembler::{assembler::GaiaAssembler, program::{GaiaBlock, GaiaFunction, GaiaModule, GaiaTerminator}, types::{GaiaSignature, GaiaType}};
use gaia_types::helpers::{AbiCompatible, ApiCompatible, Architecture, CompilationTarget};

#[test]
#[cfg(feature = "clr-assembler")]
fn test_fsharp_integration() {
    // Create a simple Gaia module programmatically with a main function
    let program = GaiaModule {
        name: "fsharp_test".to_string(),
        functions: vec![GaiaFunction {
            name: "main".to_string(),
            signature: GaiaSignature {
                params: vec![],
                return_type: GaiaType::Void,
            },
            blocks: vec![GaiaBlock {
                label: "entry".to_string(),
                instructions: vec![],
                terminator: GaiaTerminator::Return,
            }],
            is_external: false,
        }],
        structs: vec![],
        classes: vec![],
        constants: vec![],
        globals: vec![],
        imports: vec![],
    };
    
    // Create a Gaia assembler
    let mut assembler = GaiaAssembler::new();
    
    // Create a target for MSIL backend
    let target = CompilationTarget {
        build: Architecture::CLR,
        host: AbiCompatible::MicrosoftIntermediateLanguage,
        target: ApiCompatible::ClrRuntime(4),
    };
    
    // Compile the Gaia module
    let result = assembler.compile(&program, &target);
    assert!(result.is_ok(), "Failed to compile Gaia module");
    
    let generated_files = result.unwrap();
    assert!(generated_files.files.contains_key("main.il"), "Expected main.il file");
    
    // Print the generated MSIL code
    let il_content = String::from_utf8(generated_files.files["main.il"].clone()).unwrap();
    println!("Generated MSIL code:");
    println!("{}", il_content);
    
    // Verify the generated MSIL code contains expected instructions
    assert!(il_content.contains(".assembly fsharp_test"));
    assert!(il_content.contains(".class public auto ansi beforefieldinit fsharp_test"));
    assert!(il_content.contains(".method public hidebysig static void main() cil managed"));
    assert!(il_content.contains("ret"));
    
    println!("F# integration test passed!");
}