Skip to main content

ClrProgram

Struct ClrProgram 

Source
pub struct ClrProgram {
    pub name: String,
    pub version: ClrVersion,
    pub access_flags: ClrAccessFlags,
    pub external_assemblies: Vec<ClrExternalAssembly>,
    pub module: Option<ClrModule>,
    pub types: Vec<ClrType>,
    pub global_methods: Vec<ClrMethod>,
    pub global_fields: Vec<ClrField>,
    pub attributes: Vec<ClrAttribute>,
    pub constant_pool: ClrConstantPool,
    pub source_file: Option<String>,
}
Expand description

CLR 程序的高层语义信息结构

该结构体表示一个完整的 .NET 程序集,包含了运行时所需的所有信息。 采用与 wasi-assembler 和 jvm-assembler 相同的架构设计。

Fields§

§name: String

程序集名称

§version: ClrVersion

程序集版本信息

§access_flags: ClrAccessFlags

访问标志

§external_assemblies: Vec<ClrExternalAssembly>

外部程序集引用

§module: Option<ClrModule>

模块信息

§types: Vec<ClrType>

类型定义列表

§global_methods: Vec<ClrMethod>

全局方法列表

§global_fields: Vec<ClrField>

全局字段列表

§attributes: Vec<ClrAttribute>

属性列表

§constant_pool: ClrConstantPool

常量池(字符串、GUID、Blob 等)

§source_file: Option<String>

源文件信息

Implementations§

Source§

impl ClrProgram

Source

pub fn new(name: impl Into<String>) -> Self

创建新的 CLR 程序

Source

pub fn add_type(&mut self, clr_type: ClrType)

添加类型

Source

pub fn add_external_assembly(&mut self, assembly: ClrExternalAssembly)

添加外部程序集引用

Source

pub fn set_module(&mut self, module: ClrModule)

设置模块信息

Source

pub fn set_source_file(&mut self, filename: String)

设置源文件

Source

pub fn validate(&self) -> Result<()>

验证程序的完整性

Source

pub fn get_type_count(&self) -> usize

获取类型数量

Source

pub fn get_method_count(&self) -> usize

获取方法数量(包括全局方法和类型中的方法)

Source

pub fn get_field_count(&self) -> usize

获取字段数量(包括全局字段和类型中的字段)

Source

pub fn get_sample_type_name(&self) -> Option<String>

获取示例类型名称

Source

pub fn get_sample_method_name(&self) -> Option<String>

获取示例方法名称

Source

pub fn get_referenced_assemblies(&self) -> Vec<String>

获取引用的程序集列表

Source

pub fn to_msil(&self) -> MsilRoot

转换为 MSIL AST

Trait Implementations§

Source§

impl Clone for ClrProgram

Source§

fn clone(&self) -> ClrProgram

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ClrProgram

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,