bolt_control_flow.helpers#

Runtime implementation helpers

Danger

This is an internal module, not meant for public usage

Module Contents#

Classes#

Functions#

get_runtime_helpers(→ dict[str, Any])

call_branch(→ contextlib.AbstractContextManager[Any])

call_not(→ Any)

binary_logical(→ Any)

Attributes#

bolt_control_flow.helpers.get_runtime_helpers() dict[str, Any]#
bolt_control_flow.helpers.call_branch(
condition: Any,
runtime: bolt.Runtime,
) contextlib.AbstractContextManager[Any]#
bolt_control_flow.helpers.call_not(condition: Any, runtime: bolt.Runtime) Any#
bolt_control_flow.helpers.binary_logical(op: Literal[and, or], runtime: bolt.Runtime, left: Any, right: collections.abc.Callable[[], Any]) Any#
bolt_control_flow.helpers.CaseCallable: TypeAlias#
class bolt_control_flow.helpers.CaseDriver(obj: Any, runtime: bolt.Runtime)#
obj: Any#
runtime: bolt.Runtime#
case_func: CaseCallable | None#
not_obj: Any#
case_definitely_matched: bool = False#
static codegen_access_underlying(target: str) str#

Generate an access to the underlying case object

This is a helper to keep the hardcoded name of the attribute close to the definition of the attribute

Parameters:

target (str) -- Code str for accessing a CaseDriver

Returns:

Code str for accessing the underlying case object

Return type:

str

class bolt_control_flow.helpers.MultibranchDriver(
branch_type: bolt_control_flow.types.BranchType,
obj: Any,
runtime: bolt.Runtime,
parent_cases: Any | None,
)#
obj: Any#
context_manager: contextlib.AbstractContextManager[Any] | None#
runtime: bolt.Runtime#
static codegen_call(
acc: bolt.Accumulator,
parent_cases: str,
branch_type: bolt_control_flow.types.BranchType,
condition: str,
) str#