Skip to main content

ComptimeSolver

Struct ComptimeSolver 

Source
pub struct ComptimeSolver { /* private fields */ }
Expand description

编译时求解器主结构。

负责编译时 AST 的求解、扩展、以及编译时代码的执行。 集成了状态管理、诊断收集、VM 执行等功能。

Implementations§

Source§

impl ComptimeSolver

Source

pub fn new( user_definitions: Arc<RwLock<HashMap<String, OnionStaticObject>>>, import_cycle_detector: CycleDetector<PathBuf>, ) -> Self

创建新的编译时求解器。

§参数
  • user_definitions:用户定义的变量映射。
  • import_cycle_detector:导入循环检测器。
§返回

新的 ComptimeSolver 实例。

Source

pub fn diagnostics(&self) -> &Arc<RwLock<DiagnosticCollector>>

获取诊断收集器的引用。

Source

pub fn solve(&mut self, ast: &ASTNode) -> Result<ASTNode, ()>

递归求解 AST 节点,处理编译时表达式。

§参数
  • ast:要求解的 AST 节点。
§返回

求解后的 AST 节点,或错误。

Source

pub fn expand(&mut self, ast: &ASTNode) -> Result<Option<ASTNode>, ()>

扩展给定的 AST 节点(如果是编译时节点)。

§参数
  • ast:要扩展的 AST 节点。
§返回
  • Ok(Some(expanded)):节点已扩展
  • Ok(None):节点无需扩展
  • Err(()):扩展失败

Trait Implementations§

Source§

impl Debug for ComptimeSolver

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.