Skip to main content

Crate decy_codegen

Crate decy_codegen 

Source
Expand description

Rust code generation from HIR with minimal unsafe blocks.

Generates idiomatic Rust code with <5 unsafe blocks per 1000 LOC.

§Examples

use decy_codegen::CodeGenerator;
use decy_hir::{HirFunction, HirType, HirParameter};

let func = HirFunction::new(
    "add".to_string(),
    HirType::Int,
    vec![
        HirParameter::new("a".to_string(), HirType::Int),
        HirParameter::new("b".to_string(), HirType::Int),
    ],
);

let codegen = CodeGenerator::new();
let code = codegen.generate_function(&func);

assert!(code.contains("fn add"));
assert!(code.contains("a: i32"));
assert!(code.contains("b: i32"));

Modules§

box_transform
Box<T> transformations for replacing malloc/free patterns.
concurrency_transform
Concurrency transformation module for pthread → Rust std::sync conversions.
enum_gen
Enum generation from tagged unions (DECY-081).
pattern_gen
Pattern matching generation from tag checks (DECY-082).
test_generator
Test generator for transpiled Rust code.

Structs§

CodeGenerator
Code generator for converting HIR to Rust source code.