Skip to main content

Module builder

Module builder 

Source
Expand description

§Builder 模块

builder 模块负责构建 PythonProgram 对象,它将各种组件(如指令、常量等)组装成一个完整的、可表示 Python 字节码的程序结构。

§结构

  • PythonBuilder: 用于逐步构建 PythonProgram 的结构体。

§示例

use python_assembler::{
    builder::PythonBuilder,
    program::{PycHeader, PythonObject, PythonProgram},
};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let builder = PythonBuilder::new();
    let header = PycHeader::default();
    let program = builder.build(header);

    assert_eq!(program.code_object.source_name, "<string>".to_string());
    Ok(())
}

Structs§

PythonBuilder
PycProgram 的构建器