Skip to main content

llvm_assembler/program/
mod.rs

1use crate::formats::llvm::reader;
2use gaia_types::Result;
3use oak_llvm_ir::ast::LLirRoot;
4
5/// LLVM 程序表示
6#[derive(Debug, Clone, Default)]
7pub struct LLvmProgram {
8    pub root: LLirRoot,
9}
10
11impl LLvmProgram {
12    pub fn new() -> Self {
13        Self::default()
14    }
15
16    /// 从源代码加载程序
17    pub fn from_source(source: &str) -> Result<Self> {
18        let root = reader::parse(source)?;
19        Ok(Self { root })
20    }
21}