1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
mod build;
mod codegen_rust;

use lark_error::WithError;
use lark_query_system::LarkDatabase;

#[derive(Copy, Clone)]
pub enum CodegenType {
    Rust,
}

/// Converts the MIR context of definitions into the chosen source type
pub fn codegen(db: &LarkDatabase, codegen_type: CodegenType) -> WithError<String> {
    match codegen_type {
        CodegenType::Rust => codegen_rust::codegen_rust(db),
        //CodegenType::C => codegen_c::codegen_c(context),
    }
}

/// Builds source code for the given source type
pub fn build(
    target_filename: &str,
    src: &String,
    codegen_type: CodegenType,
) -> std::io::Result<()> {
    build::build(target_filename, &src, codegen_type)
}