Struct libunseemly::ast_walk::LazyWalkReses [−][src]
pub struct LazyWalkReses<Mode: WalkMode> {
pub parts: EnvMBE<Rc<LazilyWalkedTerm<Mode>>>,
pub env: ResEnv<Mode::Elt>,
pub prelude_env: ResEnv<Mode::Elt>,
pub more_quoted_env: Vec<ResEnv<Mode::Elt>>,
pub less_quoted_env: Vec<ResEnv<Mode::Elt>>,
pub less_quoted_out_env: Vec<Option<OutEnvHandle<Mode>>>,
pub this_ast: Ast,
pub extra_info: Mode::ExtraInfo,
}
Expand description
Package containing enough information to walk the subforms of some form on-demand.
It is safe to have unwalkable subforms, as long as nothing ever refers to them.
Contents probably shouldn’t be pub
…
Fields
parts: EnvMBE<Rc<LazilyWalkedTerm<Mode>>>
Things that we have walked and that we might walk
env: ResEnv<Mode::Elt>
The environment of the overall walk.
prelude_env: ResEnv<Mode::Elt>
The environment to use when entering a new phase. It’s like a prelude, except that it’s affected by syntax extensions.
more_quoted_env: Vec<ResEnv<Mode::Elt>>
The environment for syntax quotation (deeper on the front, shallower on the back)
less_quoted_env: Vec<ResEnv<Mode::Elt>>
The environment for interpolation (further out on the front, nearer on the back)
less_quoted_out_env: Vec<Option<OutEnvHandle<Mode>>>
For all the less-quoted walks ongoing whose direction is negative, we need to smuggle out results. This is a stack of (optional, because not all walks are negative) mutable handles to the environments being accumulated.
this_ast: Ast
extra_info: Mode::ExtraInfo
Implementations
pub fn new(
env: ResEnv<Mode::Elt>,
prelude_env: ResEnv<Mode::Elt>,
this_ast: Ast
) -> LazyWalkReses<Mode>
Slight hack: this is just to get a recursion started with some environment. Only use this in tests or at the top level; this discards any non-phase-0-environments!
pub fn new_mq_wrapper(
env: ResEnv<Mode::Elt>,
mqe: Vec<ResEnv<Mode::Elt>>
) -> LazyWalkReses<Mode>
The result of walking the subform named part_name
. This is memoized.
Will get_res
or get_term
panic?
Rarely used, because a form typically knows which named subterms it has based on parsing.
Like get_res
, but for subforms that are repeated at depth 1. Sort of a hack.
Like get_res
, but with depth
levels of repetition, and calling f
to flatten the result
Like flatten_res_at_depth
, but uses leaf
instead of doing get_res
TODO: this is used in only one place, and feels really awkward.
Like get_term
, but with depth
levels of repetition, and calling m
to map and f
to
flatten the result
The subform named part_name
, without any processing.
Only needed if, for some reason, a form could occur with or without a particular term. (a hack involving “mu_type” and “opacity_for_different_phase” does this)
pub fn get_rep_term(&self, part_name: Name) -> Vec<Ast>ⓘ
Only sensible for negative walks
Change the context (by editing the environment). Only sensible for negative walks.
Don’t do .with_context(…).with_environment(…)
; it’s the same as .with_environment(…)
.
Change the whole environment
Change the prelude environment
Clear the memo table; important if you’re re-evaluating the same term, but have changed the environment
pub fn switch_mode<NewMode: WalkMode<Elt = Mode::Elt, ExtraInfo = Mode::ExtraInfo>>(
&self
) -> LazyWalkReses<NewMode>
pub fn switch_mode<NewMode: WalkMode<Elt = Mode::Elt, ExtraInfo = Mode::ExtraInfo>>(
&self
) -> LazyWalkReses<NewMode>
Switch to a different mode with the same Elt
type.
If Mode
is positive, returns self
.
If Mode
is negative, switch_mode
s it to be positive
If Mode
is negative, returns self
.
If Mode
is positive, switch_mode
s it to be negative
Shift to a less-quoted level. If the OEH is non-None
, you need to call squirrel_away
.
March by example, turning a repeated set of part names into one LWR per repetition. Keeps the same environment.
HACK: The mbe_one_name!
macro expects a type with march_all
(it can accept both LazyWalkReses
and EnvMBE
).
But, for LazyWalkReses
, prefer march_parts
, so don’t use this ) :
pub fn march_parts_with(
&self,
driving_names: &[Name],
new_contexts: Vec<Mode::Elt>
) -> Option<Vec<LazyWalkReses<Mode>>>
pub fn march_parts_with(
&self,
driving_names: &[Name],
new_contexts: Vec<Mode::Elt>
) -> Option<Vec<LazyWalkReses<Mode>>>
Combines march_parts
and with_context
. new_contexts
should have the same length
as the repetition marched.
Trait Implementations
A name for that type, so that recursive types are okay.
Ignore the type parameters of Self
; invoke like Self::<Irr,Irr>::ty_name()
.
e.g. WithInteger
Read more
The Unseemly type that corresponds to to the Reifiable
type.
This leaves abstract the type parameters of Self
; invoke like Self::<Irr,Irr>::ty()
.
e.g. ∀ A. Pair<A int>
TODO: rename to generic_ty
Read more
How to refer to this type, given an environment in which
ty_name()
is defined to be ty()
.
Parameters will be concrete.
e.g. WithInteger<Float>
(Types using this type will use this, rather than ty
)
Don’t override this. Read more
Auto Trait Implementations
impl<Mode> !RefUnwindSafe for LazyWalkReses<Mode>
impl<Mode> !Send for LazyWalkReses<Mode>
impl<Mode> !Sync for LazyWalkReses<Mode>
impl<Mode> Unpin for LazyWalkReses<Mode> where
<Mode as WalkMode>::Elt: Unpin,
<Mode as WalkMode>::ExtraInfo: Unpin,
impl<Mode> !UnwindSafe for LazyWalkReses<Mode>
Blanket Implementations
Mutably borrows from an owned value. Read more
Pipes by value. This is generally the method you want to use. Read more
Borrows self
and passes that borrow into the pipe function. Read more
Mutably borrows self
and passes that borrow into the pipe function. Read more
Borrows self
, then passes self.borrow()
into the pipe function. Read more
Mutably borrows self
, then passes self.borrow_mut()
into the pipe
function. Read more
Borrows self
, then passes self.as_ref()
into the pipe function.
Mutably borrows self
, then passes self.as_mut()
into the pipe
function. Read more
Borrows self
, then passes self.deref()
into the pipe function.
type Output = T
type Output = T
Should always be Self
Immutable access to the Borrow<B>
of a value. Read more
Mutable access to the BorrowMut<B>
of a value. Read more
Immutable access to the AsRef<R>
view of a value. Read more
Mutable access to the AsMut<R>
view of a value. Read more
Immutable access to the Deref::Target
of a value. Read more
Mutable access to the Deref::Target
of a value. Read more
Calls .tap()
only in debug builds, and is erased in release builds.
Calls .tap_mut()
only in debug builds, and is erased in release
builds. Read more
Calls .tap_borrow()
only in debug builds, and is erased in release
builds. Read more
Calls .tap_borrow_mut()
only in debug builds, and is erased in release
builds. Read more
Calls .tap_ref()
only in debug builds, and is erased in release
builds. Read more
Calls .tap_ref_mut()
only in debug builds, and is erased in release
builds. Read more
Calls .tap_deref()
only in debug builds, and is erased in release
builds. Read more