Module

compiler._protocols

Type protocols for Kida compiler.

Provides minimal type contracts for compiler mixins to enable type-safe mixin patterns without exposing implementation details.

See: plan/rfc-mixin-protocol-typing.md

Classes

CompilerCoreProtocol 11
Minimal contract for cross-mixin dependencies in compiler. Contains ONLY: 1. Host class attributes…

Minimal contract for cross-mixin dependencies in compiler.

Contains ONLY:

  1. Host class attributes (defined in Compiler.init)
  2. Core compilation methods (used by all compilation mixins)
  3. Operator utilities (used by expression compilation)

Individual mixin methods are NOT included—mixins declare their own methods via inline TYPE_CHECKING declarations.

Attributes

Name Type Description
_env Environment
_name str | None
_filename str | None
_locals set[str]
_blocks dict[str, Any]
_block_counter int

Methods

Internal Methods 5
_compile_expr 2 ast.expr
Compile expression node to Python AST expression.
def _compile_expr(self, node: Any, store: bool = False) -> ast.expr
Parameters
Name Type Description
node
store Default:False
Returns
ast.expr
_compile_node 1 list[ast.stmt]
Compile a single AST node to Python statements.
def _compile_node(self, node: Any) -> list[ast.stmt]
Parameters
Name Type Description
node
Returns
list[ast.stmt]
_get_binop 1 ast.operator
Map operator string to AST operator.
def _get_binop(self, op: str) -> ast.operator
Parameters
Name Type Description
op
Returns
ast.operator
_get_unaryop 1 ast.unaryop
Map unary operator string to AST operator.
def _get_unaryop(self, op: str) -> ast.unaryop
Parameters
Name Type Description
op
Returns
ast.unaryop
_get_cmpop 1 ast.cmpop
Map comparison operator string to AST operator.
def _get_cmpop(self, op: str) -> ast.cmpop
Parameters
Name Type Description
op
Returns
ast.cmpop