pub struct CtfePass {
pub config: CtfeConfig,
pub known_constants: HashMap<String, CtfeValue>,
/* private fields */
}Expand description
The main CTFE optimisation pass.
Fields§
§config: CtfeConfigConfiguration.
known_constants: HashMap<String, CtfeValue>Global evaluated constants available to downstream passes.
Implementations§
Source§impl CtfePass
impl CtfePass
Sourcepub fn new(config: CtfeConfig) -> Self
pub fn new(config: CtfeConfig) -> Self
Create a new pass with the given configuration.
Sourcepub fn default_pass() -> Self
pub fn default_pass() -> Self
Create a pass with default configuration.
Sourcepub fn run(&mut self, decls: &mut [LcnfFunDecl])
pub fn run(&mut self, decls: &mut [LcnfFunDecl])
Run the CTFE pass over all declarations.
First all zero-argument (constant) functions are evaluated, then call sites inside every function are replaced with their constant folded results.
Sourcepub fn try_evaluate_decl(
&mut self,
decl: &LcnfFunDecl,
interp: &mut CtfeInterpreter,
)
pub fn try_evaluate_decl( &mut self, decl: &LcnfFunDecl, interp: &mut CtfeInterpreter, )
Attempt to evaluate decl at compile time, storing the result in
self.known_constants if successful.
Sourcepub fn replace_calls_with_constants(&mut self, decl: &mut LcnfFunDecl) -> usize
pub fn replace_calls_with_constants(&mut self, decl: &mut LcnfFunDecl) -> usize
Rewrite expressions in decl to replace calls to known constants.
Returns the number of replacements performed.
Sourcepub fn report(&self) -> CtfeReport
pub fn report(&self) -> CtfeReport
Produce a copy of the accumulated report.
Auto Trait Implementations§
impl Freeze for CtfePass
impl RefUnwindSafe for CtfePass
impl Send for CtfePass
impl Sync for CtfePass
impl Unpin for CtfePass
impl UnsafeUnpin for CtfePass
impl UnwindSafe for CtfePass
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more