Module

compiler.partial_eval_inlining

Small component call inlining for partial evaluation.

Classes

ComponentInliningMixin 9
Partial-evaluator phase for small statically bound component calls.

Partial-evaluator phase for small statically bound component calls.

Attributes

Name Type Description
_ctx dict[str, Any]
_defs dict[str, Def]

Methods

Internal Methods 7
_try_eval 2 Any
Evaluate an expression against the current static context.
abstract
def _try_eval(self, expr: Expr, depth: int = 0) -> Any
Parameters
Name Type Description
expr
depth Default:0
Returns
Any
_transform_body 1 Sequence[Node]
Transform a sequence of template nodes.
abstract
def _transform_body(self, body: Sequence[Node]) -> Sequence[Node]
Parameters
Name Type Description
body
Returns
Sequence[Node]
_make_sub_evaluator 1 Self
Create an evaluator that shares this evaluator's configuration.
abstract
def _make_sub_evaluator(self, ctx: dict[str, Any]) -> Self
Parameters
Name Type Description
ctx
Returns
Self
_try_inline_call 1 Node | None
Expand a small, slot-free component call when all args resolve.
def _try_inline_call(self, node: CallBlock) -> Node | None
Parameters
Name Type Description
node
Returns
Node | None
_slot_body_is_empty 1 bool
Return whether a provided slot contains only whitespace data.
staticmethod
def _slot_body_is_empty(body: Sequence[Node]) -> bool
Parameters
Name Type Description
body
Returns
bool
_count_nodes 1 int
Count nodes for the component inlining size guard.
staticmethod
def _count_nodes(body: Sequence[Node]) -> int
Parameters
Name Type Description
body
Returns
int
_has_slot 1 bool
Return whether a component body recursively declares a slot.
staticmethod
def _has_slot(body: Sequence[Node]) -> bool
Parameters
Name Type Description
body
Returns
bool