pub struct DynSegmentContext(/* private fields */);Expand description
ParserContext implementation that executes directly into a [DynSegment], reproducing
the runtime-execution behavior CELParser always had before this trait existed.
§Examples
use cel_parser::parser_context::{DynSegmentContext, ParserContext};
use proc_macro2::Span;
let mut ctx = DynSegmentContext::new_context();
ctx.push_literal(10i32, Span::call_site());Implementations§
Source§impl DynSegmentContext
impl DynSegmentContext
Sourcepub fn into_inner(self) -> DynSegment
pub fn into_inner(self) -> DynSegment
Returns the wrapped [DynSegment], consuming self.
Methods from Deref<Target = DynSegment>§
pub fn new_fragment(&self) -> DynSegment
pub fn new_fragment(&self) -> DynSegment
Creates a conditional fragment above the ambient stack below the condition.
- Precondition: at least one operand is present.
§Examples
See [Self::join2].
pub fn current_stack_offset(&self) -> usize
pub fn current_stack_offset(&self) -> usize
Returns the current canonical stack byte length.
§Examples
assert_eq!(cel_runtime::DynSegment::new::<()>().current_stack_offset(), 0);pub fn stack_offset_before_top(&self, n: usize) -> Result<usize, Error>
pub fn stack_offset_before_top(&self, n: usize) -> Result<usize, Error>
pub fn peek_stack_infos(&self, n: usize) -> &[StackInfo]
pub fn peek_stack_infos(&self, n: usize) -> &[StackInfo]
Borrows up to the top n complete descriptors.
§Examples
let body = cel_runtime::DynSegment::new::<()>();
assert!(body.peek_stack_infos(0).is_empty());pub fn peek_output_type_id(&self) -> Option<TypeId>
pub fn peek_output_type_id(&self) -> Option<TypeId>
Returns a diagnostic dispatch identity, never a structural cast authority.
§Examples
assert!(cel_runtime::DynSegment::new::<()>().peek_output_type_id().is_none());pub fn peek_tuple_arity(&self) -> Option<usize>
pub fn peek_tuple_arity(&self) -> Option<usize>
Returns the source tuple arity, including zero for canonical unit.
§Examples
assert!(cel_runtime::DynSegment::new::<()>().peek_tuple_arity().is_none());pub fn op0<R, F>(&mut self, f: F)where
R: 'static,
F: Fn() -> R + 'static,
pub fn op0<R, F>(&mut self, f: F)where
R: 'static,
F: Fn() -> R + 'static,
Registers a nullary opaque-leaf host operation.
§Panics
Rejects erased whole-value owner results or unrepresentable frames. Use op0_repr
for fallible registration and just_external for checked owner imports.
§Examples
let mut b = cel_runtime::DynSegment::new::<()>();
b.op0(|| 7i32);
assert_eq!(b.call0::<i32>().unwrap(), 7);pub fn op0r<R, F>(&mut self, f: F)
pub fn op0r<R, F>(&mut self, f: F)
pub fn op0_repr<R, F>(&mut self, f: F) -> Result<(), Error>where
R: ValueRepr,
F: Fn() -> <R as ValueRepr>::Value + 'static,
pub fn op0_repr<R, F>(&mut self, f: F) -> Result<(), Error>where
R: ValueRepr,
F: Fn() -> <R as ValueRepr>::Value + 'static,
Registers a witnessed nullary operation.
§Errors
Rejects unrepresentable stack positions.
- Complexity: O(n) registration work for n ambient slots.
§Examples
let mut b = cel_runtime::DynSegment::new::<()>();
b.op0_repr::<cel_runtime::Nil, _>(|| cel_runtime::IntoCStackList::into_c_stack_list(())).unwrap();pub fn op0r_repr<R, F>(&mut self, f: F) -> Result<(), Error>
pub fn op0r_repr<R, F>(&mut self, f: F) -> Result<(), Error>
Registers a fallible witnessed nullary operation.
§Errors
Rejects unrepresentable stack positions; host errors propagate on execution.
- Complexity: O(n) registration work for n ambient slots.
§Examples
let mut b = cel_runtime::DynSegment::new::<()>();
b.op0r_repr::<cel_runtime::Leaf<i32>, _>(|| Ok(7)).unwrap();pub fn op1<A, R, F>(&mut self, f: F) -> Result<(), Error>where
A: 'static,
R: 'static,
F: Fn(A) -> R + 'static,
pub fn op1<A, R, F>(&mut self, f: F) -> Result<(), Error>where
A: 'static,
R: 'static,
F: Fn(A) -> R + 'static,
pub fn op1_repr<A, R, F>(&mut self, f: F) -> Result<(), Error>where
A: ValueRepr,
R: ValueRepr,
F: Fn(<A as ValueRepr>::Value) -> <R as ValueRepr>::Value + 'static,
pub fn op1_repr<A, R, F>(&mut self, f: F) -> Result<(), Error>where
A: ValueRepr,
R: ValueRepr,
F: Fn(<A as ValueRepr>::Value) -> <R as ValueRepr>::Value + 'static,
Registers a unary operation after checking its complete operand witness.
§Errors
Rejects insufficient operands or recursive representation mismatch.
- Complexity: O(n) registration work for n frame/descriptor nodes.
§Examples
let mut b = cel_runtime::DynSegment::new::<()>();
b.just(1i32);
b.op1_repr::<cel_runtime::Leaf<i32>, cel_runtime::Leaf<i32>, _>(|x| x).unwrap();pub fn op1r_repr<A, R, F>(&mut self, f: F) -> Result<(), Error>
pub fn op1r_repr<A, R, F>(&mut self, f: F) -> Result<(), Error>
Registers a fallible unary witnessed operation with error/unwind cleanup.
§Errors
Rejects insufficient operands or recursive mismatch; propagates host errors on execution.
- Complexity: O(n) registration work for n frame/descriptor nodes.
§Examples
let mut b = cel_runtime::DynSegment::new::<()>();
b.just(1i32);
b.op1r_repr::<cel_runtime::Leaf<i32>, cel_runtime::Leaf<i32>, _>(Ok).unwrap();pub fn op2<A, B, R, F>(&mut self, f: F) -> Result<(), Error>where
A: 'static,
B: 'static,
R: 'static,
F: Fn(A, B) -> R + 'static,
pub fn op2<A, B, R, F>(&mut self, f: F) -> Result<(), Error>where
A: 'static,
B: 'static,
R: 'static,
F: Fn(A, B) -> R + 'static,
Registers a binary opaque-leaf operation in source order.
§Errors
Rejects insufficient or mismatched operands.
- Complexity: O(n) registration work for n frame/descriptor nodes.
§Examples
let mut b = cel_runtime::DynSegment::new::<()>();
b.just(1i32); b.just(2i32); b.op2(|a: i32, b: i32| a + b).unwrap();pub fn op2r<A, B, R, F>(&mut self, f: F) -> Result<(), Error>
pub fn op2r<A, B, R, F>(&mut self, f: F) -> Result<(), Error>
Registers a fallible binary opaque-leaf operation.
§Errors
Rejects insufficient/mismatched operands; propagates host errors on execution.
- Complexity: O(n) registration work for n frame/descriptor nodes.
§Examples
let mut b = cel_runtime::DynSegment::new::<()>();
b.just(1i32); b.just(2i32); b.op2r(|a: i32, b: i32| Ok(a + b)).unwrap();pub fn op2_repr<A, B, R, F>(&mut self, f: F) -> Result<(), Error>where
A: ValueRepr,
B: ValueRepr,
R: ValueRepr,
F: Fn(<A as ValueRepr>::Value, <B as ValueRepr>::Value) -> <R as ValueRepr>::Value + 'static,
pub fn op2_repr<A, B, R, F>(&mut self, f: F) -> Result<(), Error>where
A: ValueRepr,
B: ValueRepr,
R: ValueRepr,
F: Fn(<A as ValueRepr>::Value, <B as ValueRepr>::Value) -> <R as ValueRepr>::Value + 'static,
pub fn op3<A, B, C, R, F>(&mut self, f: F) -> Result<(), Error>where
A: 'static,
B: 'static,
C: 'static,
R: 'static,
F: Fn(A, B, C) -> R + 'static,
pub fn op3<A, B, C, R, F>(&mut self, f: F) -> Result<(), Error>where
A: 'static,
B: 'static,
C: 'static,
R: 'static,
F: Fn(A, B, C) -> R + 'static,
pub fn op3_repr<A, B, C, R, F>(&mut self, f: F) -> Result<(), Error>where
A: ValueRepr,
B: ValueRepr,
C: ValueRepr,
R: ValueRepr,
F: Fn(<A as ValueRepr>::Value, <B as ValueRepr>::Value, <C as ValueRepr>::Value) -> <R as ValueRepr>::Value + 'static,
pub fn op3_repr<A, B, C, R, F>(&mut self, f: F) -> Result<(), Error>where
A: ValueRepr,
B: ValueRepr,
C: ValueRepr,
R: ValueRepr,
F: Fn(<A as ValueRepr>::Value, <B as ValueRepr>::Value, <C as ValueRepr>::Value) -> <R as ValueRepr>::Value + 'static,
pub fn op1_slice<E, R, F>(&mut self, f: F) -> Result<(), Error>where
E: ValueRepr,
R: ValueRepr,
F: Fn(&[<E as ValueRepr>::Value]) -> <R as ValueRepr>::Value + 'static,
pub fn op1_slice<E, R, F>(&mut self, f: F) -> Result<(), Error>where
E: ValueRepr,
R: ValueRepr,
F: Fn(&[<E as ValueRepr>::Value]) -> <R as ValueRepr>::Value + 'static,
Borrows the original canonical array payload during a host callback.
The consumed array is destroyed after the callback; the result is owned.
§Errors
Rejects insufficient operands or complete element witness mismatch.
- Complexity: O(n) registration work; O(1) borrowing plus destruction.
§Examples
See [Self::op1_vec].
pub fn op1r_slice<E, R, F>(&mut self, f: F) -> Result<(), Error>
pub fn op1r_slice<E, R, F>(&mut self, f: F) -> Result<(), Error>
pub fn just_external(
&mut self,
value_type: ValueType,
value: Box<dyn Any>,
) -> Result<(), Error>
pub fn just_external( &mut self, value_type: ValueType, value: Box<dyn Any>, ) -> Result<(), Error>
Imports an external constant once and emits only trusted canonical cloning.
The descriptor must include every borrowed clone capability. Wrapper headers are converted before registration, never during interpreter execution.
§Errors
Rejects noncanonical descriptors, unavailable cloning, invalid external identity/shape, unsupported external conversions, or frame overflow.
- Complexity: Boundary validation/import at setup; value cloning on each execution.
§Examples
use cel_runtime::{DynSegment, Array, OwnedValue, ValueType, Nil, ArrayOf, Leaf, IntoCStackList};
let mut body = DynSegment::new::<()>();
body.just_external(ValueType::array(ValueType::cloneable_leaf::<i32>()),
Box::new(OwnedValue::new::<ArrayOf<Leaf<i32>>>(Array::from_vec(vec![7i32])))).unwrap();
let mut body = body.prepare::<Nil, ArrayOf<Leaf<i32>>>().unwrap();
assert_eq!(body.call(&().into_c_stack_list()).unwrap().as_slice(), [7]);pub fn push_arg<T>(&mut self, index: usize)where
T: Clone + 'static,
pub fn push_arg<T>(&mut self, index: usize)where
T: Clone + 'static,
Registers a borrowed opaque-leaf argument read.
§Examples
let mut b = cel_runtime::DynSegment::new::<()>();
b.push_arg::<i32>(0);
assert_eq!(b.call_dyn::<i32>(&[&7i32]).unwrap(), 7);pub fn push_argument(
&mut self,
index: usize,
value_type: ValueType,
) -> Result<(), Error>
pub fn push_argument( &mut self, index: usize, value_type: ValueType, ) -> Result<(), Error>
Registers a canonical borrowed argument read with its frozen clone plan.
§Errors
Rejects missing clone capability or unrepresentable frame positions. Preparation validates its complete identity against the argument witness.
- Complexity: O(d) registration for d descriptor nodes; execution has the value’s clone cost without temporary whole-value allocation.
§Examples
let mut b = cel_runtime::DynSegment::new::<()>();
b.push_argument(0, cel_runtime::ValueType::cloneable_leaf::<i32>()).unwrap();pub fn make_tuple(
&mut self,
n: usize,
ambient_start: usize,
) -> Result<(), Error>
pub fn make_tuple( &mut self, n: usize, ambient_start: usize, ) -> Result<(), Error>
Packs source-ordered operands into their canonical concrete list layout.
§Errors
Rejects insufficient operands, a wrong ambient snapshot, or layout overflow.
- Complexity: O(n + s) registration and raw moves for n fields and s bytes.
§Examples
let mut b = cel_runtime::DynSegment::new::<()>();
b.just(1i32); b.just(2f64); b.make_tuple(2, 0).unwrap();pub fn make_array(
&mut self,
n: usize,
ambient_start: usize,
) -> Result<(), Error>
pub fn make_array( &mut self, n: usize, ambient_start: usize, ) -> Result<(), Error>
Packs homogeneous operands into a canonical owning array header.
§Errors
Rejects empty inference, differing complete types, wrong ambient origin, insufficient operands, or allocation-layout overflow.
- Complexity: O(n + s) checks and moves for n elements and s bytes.
§Examples
let mut b = cel_runtime::DynSegment::new::<()>();
b.just(1i32); b.make_array(1, 0).unwrap();pub fn make_typed_array(
&mut self,
n: usize,
ambient_start: usize,
element: ValueType,
) -> Result<(), Error>
pub fn make_typed_array( &mut self, n: usize, ambient_start: usize, element: ValueType, ) -> Result<(), Error>
Packs operands using an explicit complete element descriptor.
§Errors
Rejects wrong ambient origin, insufficient/differently shaped operands, or allocation-layout overflow. Empty arrays need no element capabilities.
- Complexity: O(n + s) checks and moves for n elements and s bytes.
§Examples
let mut b = cel_runtime::DynSegment::new::<()>();
b.make_typed_array(0, 0, cel_runtime::ValueType::leaf::<i32>()).unwrap();pub fn tuple_index(&mut self, index: usize) -> Result<(), Error>
pub fn tuple_index(&mut self, index: usize) -> Result<(), Error>
Moves one source-ordered tuple field and destroys every other field.
§Errors
Rejects a missing tuple or an out-of-range index before emitting.
- Complexity: O(n) registration/destruction for n fields, plus representation moves.
§Examples
let mut b = cel_runtime::DynSegment::new::<()>();
b.just(1i32); b.just(2f64); b.make_tuple(2, 0).unwrap();
b.tuple_index(0).unwrap(); assert_eq!(b.call0::<i32>().unwrap(), 1);pub fn array_index<I>(&mut self) -> Result<(), Error>
pub fn array_index<I>(&mut self) -> Result<(), Error>
Moves an indexed canonical array element and destroys the consumed array’s siblings.
The stack holds the array followed by an opaque index of type I.
No clone capability is required, including for nested tuple/array elements.
Moving the validated index into its concrete type does not allocate.
§Errors
Rejects absent/nonmatching operands during registration. Execution rejects negative/unrepresentable or out-of-bounds indices and cleans every operand.
- Complexity: O(n) setup/destruction for n stack slots or array elements.
§Examples
let mut body = cel_runtime::DynSegment::new::<()>();
body.just(7i32); body.make_array(1, 0).unwrap();
body.just(0i32); body.array_index::<i32>().unwrap();
assert_eq!(body.call0::<i32>().unwrap(), 7);pub fn drop_value(&mut self) -> Result<(), Error>
pub fn drop_value(&mut self) -> Result<(), Error>
Destroys the top canonical value without synthesizing a result.
Ambient values survive success and are cleaned if a destructor unwinds.
§Errors
Rejects an empty stack before registration.
- Complexity: O(1) setup; value-dependent destruction.
§Examples
let mut body = cel_runtime::DynSegment::new::<()>();
body.just(1i32); body.make_array(1, 0).unwrap();
body.drop_value().unwrap();
body.just(7i32); assert_eq!(body.call0::<i32>().unwrap(), 7);pub fn relabel_repr<R>(&mut self) -> Result<(), Error>where
R: ValueRepr,
pub fn relabel_repr<R>(&mut self) -> Result<(), Error>where
R: ValueRepr,
Validates a complete value using an explicit matching structural witness.
§Errors
Rejects an absent or mismatched value; this never authorizes opaque casts.
- Complexity: O(n) complete descriptor comparison for n nodes.
§Examples
let mut b = cel_runtime::DynSegment::new::<()>();
b.make_tuple(0, 0).unwrap(); b.relabel_repr::<cel_runtime::Nil>().unwrap();pub fn annotate_top(&mut self, value_type: ValueType) -> Result<(), Error>
pub fn annotate_top(&mut self, value_type: ValueType) -> Result<(), Error>
Installs complete registered capabilities without changing the top value’s identity.
A host registry can retain clone/equality/debug adapters on operation results for checked external export. No instruction or raw cast is emitted.
§Errors
Rejects a missing value or any recursive identity/layout mismatch.
- Complexity: O(n) complete comparison for n descriptor nodes.
§Examples
use cel_runtime::{DynSegment, Leaf, ValueType};
let mut body = DynSegment::new::<()>(); body.just(7i32);
body.annotate_top(ValueType::cloneable_leaf::<i32>()
.with_equality::<Leaf<i32>>().unwrap()
.with_debug::<Leaf<i32>>().unwrap()).unwrap();pub fn pop_tuple_as<R>(&mut self) -> Result<(), Error>where
R: ValueRepr,
pub fn pop_tuple_as<R>(&mut self) -> Result<(), Error>where
R: ValueRepr,
Relabels a canonical tuple as its concrete opaque list using an explicit witness.
No bytes move. The witness authorizes the concrete Rust destructor and
permits an ordinary typed operation or direct Segment conversion.
§Errors
Rejects a missing/nontuple value or any complete witness mismatch.
- Complexity: O(n) complete comparison for n descriptor nodes.
§Examples
let mut body = cel_runtime::DynSegment::new::<()>();
body.make_tuple(0, 0).unwrap();
body.pop_tuple_as::<cel_runtime::Nil>().unwrap();pub fn push_tuple<R>(&mut self) -> Result<(), Error>where
R: ValueRepr,
pub fn push_tuple<R>(&mut self) -> Result<(), Error>where
R: ValueRepr,
Relabels a concrete opaque canonical list as a structural tuple using its witness.
§Errors
Rejects missing values, nontuple witnesses, or a different opaque concrete type.
- Complexity: O(n) witness construction for n tuple descriptor nodes.
§Examples
use cel_runtime::{DynSegment, Nil, IntoCStackList};
let mut body = DynSegment::new::<()>();
body.just(().into_c_stack_list());
body.push_tuple::<Nil>().unwrap();pub fn call_dyn<R>(
&mut self,
inputs: &[&(dyn Any + 'static)],
) -> Result<R, Error>where
R: 'static,
pub fn call_dyn<R>(
&mut self,
inputs: &[&(dyn Any + 'static)],
) -> Result<R, Error>where
R: 'static,
Evaluates a result at a checked external host boundary.
Structural results return canonical whole-value owners; callable results return their concrete carrier. Interpreter operations never use this conversion. Scalar inputs are borrowed after complete input preflight and cloned only by executed reads; compound inputs borrow checked canonical owners.
§Errors
Rejects dependent bodies, non-single results, unsupported external shapes, unavailable argument capabilities, or mismatched arguments/results; propagates body errors.
- Complexity: Boundary validation and argument clones plus evaluation.
§Examples
See [Self::push_arg].
pub fn call_dyn_value(
&mut self,
inputs: &[&(dyn Any + 'static)],
) -> Result<OwnedValue, Error>
pub fn call_dyn_value( &mut self, inputs: &[&(dyn Any + 'static)], ) -> Result<OwnedValue, Error>
Evaluates an owned canonical value through a checked external argument boundary.
§Errors
Rejects dependent bodies, non-single results, or invalid external arguments. Propagates operation errors without erasing their context.
- Complexity: Boundary validation/cloning plus body evaluation and one raw result move.
§Examples
let mut body = cel_runtime::DynSegment::new::<()>();
body.just(7i32);
assert_eq!(body.call_dyn_value(&[]).unwrap().try_into_typed::<cel_runtime::Leaf<i32>>().unwrap(), 7);pub fn call1<A, R>(&mut self, arg: A) -> Result<R, Error>where
A: 'static,
R: 'static,
pub fn call1<A, R>(&mut self, arg: A) -> Result<R, Error>where
A: 'static,
R: 'static,
Executes a preloaded single opaque-leaf argument and result.
§Errors
Rejects nonmatching argument/result identities, positional reads, or extra results.
- Complexity: Body-dependent.
§Examples
let mut b = cel_runtime::DynSegment::new::<(i32,)>();
b.op1(|x: i32| x.to_string()).unwrap();
assert_eq!(b.call1::<i32, String>(7).unwrap(), "7");pub fn push_closure(&mut self, closure: DynClosure) -> Result<(), Error>
pub fn push_closure(&mut self, closure: DynClosure) -> Result<(), Error>
pub fn invoke_closure(&mut self, arity: usize) -> Result<(), Error>
pub fn invoke_closure(&mut self, arity: usize) -> Result<(), Error>
Invokes a canonical callable below its source-ordered evaluated arguments.
Moving the bound callee into its concrete carrier does not allocate. Argument and result transfers retain their erased ownership.
§Errors
Rejects unavailable/mismatched callable metadata or insufficient operands. Execution propagates body errors, retaining their original context.
- Complexity: O(n) setup; body execution plus argument/result raw moves.
§Examples
use cel_runtime::{DynClosure, DynSegment};
let mut body = DynSegment::new::<()>(); body.just(7i32);
let closure = DynClosure::typed(vec![], body).unwrap();
let mut b = DynSegment::new::<()>();
b.push_closure(closure).unwrap(); b.invoke_closure(0).unwrap();
assert_eq!(b.call0::<i32>().unwrap(), 7);pub fn join2(&mut self, yes: DynSegment, no: DynSegment) -> Result<(), Error>
pub fn join2(&mut self, yes: DynSegment, no: DynSegment) -> Result<(), Error>
Joins conditional fragments with identical complete results and origins.
§Errors
Rejects a nonboolean condition, wrong fragment origins, or different results.
- Complexity: O(n) setup for n frame/descriptor nodes; executes one branch.
§Examples
let mut b = cel_runtime::DynSegment::new::<()>(); b.just(true);
let mut yes = b.new_fragment(); yes.just(1i32);
let mut no = b.new_fragment(); no.just(2i32);
b.join2(yes, no).unwrap(); assert_eq!(b.call0::<i32>().unwrap(), 1);Trait Implementations§
Source§impl Deref for DynSegmentContext
impl Deref for DynSegmentContext
Source§impl DerefMut for DynSegmentContext
impl DerefMut for DynSegmentContext
Source§impl ParserContext for DynSegmentContext
impl ParserContext for DynSegmentContext
Source§fn apply_member(
&mut self,
lookup: &OpLookup,
name: &str,
name_span: ExprSpan,
explicit_args: Option<usize>,
_start: Span,
_end: Span,
) -> Result<()>
fn apply_member( &mut self, lookup: &OpLookup, name: &str, name_span: ExprSpan, explicit_args: Option<usize>, _start: Span, _end: Span, ) -> Result<()>
Emits receiver-first direct dispatch with diagnostics anchored to the member name.
Source§fn make_record(
&mut self,
lookup: &OpLookup,
name: &str,
_name_span: ExprSpan,
fields: Vec<(String, ExprSpan)>,
ambient_start: usize,
start: Span,
end: Span,
) -> Result<()>
fn make_record( &mut self, lookup: &OpLookup, name: &str, _name_span: ExprSpan, fields: Vec<(String, ExprSpan)>, ambient_start: usize, start: Span, end: Span, ) -> Result<()>
Validates and emits the registered constructor without rearranging field values.
Source§fn new_context() -> Self
fn new_context() -> Self
Source§fn new_fragment(&self) -> Self
fn new_fragment(&self) -> Self
||/&&, or an if/else branch), independent of self. Read moreSource§fn push_literal<T: 'static + Clone>(&mut self, value: T, _span: Span)
fn push_literal<T: 'static + Clone>(&mut self, value: T, _span: Span)
Source§fn apply_op(
&mut self,
op_lookup: &OpLookup,
name: &str,
arity: usize,
start: Span,
end: Span,
) -> Result<()>
fn apply_op( &mut self, op_lookup: &OpLookup, name: &str, arity: usize, start: Span, end: Span, ) -> Result<()>
op_lookup to resolve it
against whatever this context currently holds. Read moreSource§fn apply_logical(
&mut self,
name: &str,
rhs: Self,
start: Span,
end: Span,
) -> Result<()>
fn apply_logical( &mut self, name: &str, rhs: Self, start: Span, end: Span, ) -> Result<()>
"||" or "&&"), consuming a leading
condition value already present on self and folding in rhs, the already-parsed
right-hand-side fragment. Read moreSource§fn join2(
&mut self,
then_fragment: Self,
else_fragment: Option<Self>,
_start: Span,
_end: Span,
) -> Result<()>
fn join2( &mut self, then_fragment: Self, else_fragment: Option<Self>, _start: Span, _end: Span, ) -> Result<()>
self, consuming a leading condition value already
present on self. then_fragment’s contribution is used when the condition is true;
else_fragment’s when false, or None if the source had no else/else if at all.
start/end cover the whole if/else construct. Read moreSource§fn make_tuple(
&mut self,
n: usize,
ambient_start: usize,
start: Span,
end: Span,
) -> Result<()>
fn make_tuple( &mut self, n: usize, ambient_start: usize, start: Span, end: Span, ) -> Result<()>
n emitted values into a single tuple value. start/end cover the
whole (...) construct. Read moreSource§fn make_array(
&mut self,
n: usize,
ambient_start: usize,
start: Span,
end: Span,
) -> Result<()>
fn make_array( &mut self, n: usize, ambient_start: usize, start: Span, end: Span, ) -> Result<()>
n emitted values into a single homogeneous array value. start/end
cover the whole [...] construct, and ambient_start is the stack offset the first
element was emitted at (as reported by Self::current_stack_offset before parsing it). Read moreSource§fn make_annotated_array(
&mut self,
n: usize,
ambient_start: usize,
annotation: AnnotatedArray<'_>,
start: Span,
end: Span,
) -> Result<()>
fn make_annotated_array( &mut self, n: usize, ambient_start: usize, annotation: AnnotatedArray<'_>, start: Span, end: Span, ) -> Result<()>
n emitted values into a single array value, honoring annotation’s
optional type ascription. Read moreSource§fn peek_tuple_arity(&self) -> Option<usize>
fn peek_tuple_arity(&self) -> Option<usize>
None if the top value isn’t a
tuple.Source§fn tuple_index(&mut self, index: usize, start: Span, end: Span) -> Result<()>
fn tuple_index(&mut self, index: usize, start: Span, end: Span) -> Result<()>
index-th element. start/end cover the base
expression through the index token. Read moreSource§fn current_stack_offset(&self) -> usize
fn current_stack_offset(&self) -> usize
Source§fn apply_cast(
&mut self,
op_lookup: &OpLookup,
type_name: &str,
start: Span,
end: Span,
) -> Result<()>
fn apply_cast( &mut self, op_lookup: &OpLookup, type_name: &str, start: Span, end: Span, ) -> Result<()>
expr as Type), consuming the operand already present on self
and replacing it with the converted value. type_name is the target type’s bare
identifier text (e.g. "i32", "bool", "String"), unresolved by the grammar itself. Read moreSource§fn push_closure(
&mut self,
param_types: Vec<ValueType>,
params: Vec<ClosureParam>,
body: Self,
span: Span,
) -> Result<()>
fn push_closure( &mut self, param_types: Vec<ValueType>, params: Vec<ClosureParam>, body: Self, span: Span, ) -> Result<()>
self, given the closure’s declared parameter types in two parallel
forms: param_types (each parameter’s complete runtime shape, in order) for an implementation
that executes, and params (each parameter’s name, span, and unresolved type expression)
for one that builds an AST instead. An implementation uses whichever it needs and ignores
the other. Read moreSource§fn output_type_id(&self) -> Option<TypeId>
fn output_type_id(&self) -> Option<TypeId>
TypeId of the single value self currently holds, or None if that isn’t
known/applicable for this ParserContext implementation. Read more