knit_script.knit_script_interpreter.statements.xfer_pass_statement module

Statement for executing a transfer pass.

This module provides the Xfer_Pass_Statement class, which handles transfer operations between needle beds and to slider needles. It manages the complex racking requirements and bed-specific processing needed for reliable stitch transfers.

class Xfer_Pass_Statement(parser_node, racking, needles, bed, is_sliders=False)[source]

Bases: Statement

Executes transfer operations at specified racking with target needles.

This statement manages the transfer of stitches between needle beds or to sliders,

handling the complex racking requirements for different bed configurations and ensuring proper sequencing of operations. For non-zero racking, it separates front and back bed transfers since they require different racking values due to the mechanical constraints of the knitting machine.

The transfer pass handles evaluation of needle expressions, racking calculations, bed filtering, and creation of appropriate carriage pass specifications for reliable stitch transfer operations.

_is_sliders

True if transferring to sliders instead of regular needles.

Type:

bool

_bed

Expression that evaluates to the target bed position.

Type:

Expression | None

_racking

Expression that evaluates to the racking position for transfers.

Type:

Expression

_needles

List of expressions that evaluate to needles to transfer from.

Type:

list[Expression]

Parameters:
__init__(parser_node, racking, needles, bed, is_sliders=False)[source]

Initialize a transfer pass statement.

Parameters:
  • parser_node (LRStackNode) – The parser node from the abstract syntax tree.

  • racking (Expression) – Expression that evaluates to the racking position for transfers.

  • needles (list[Expression]) – List of expressions that evaluate to needles to transfer from.

  • bed (Expression | None) – Expression that evaluates to the target bed position, or None to transfer to the opposite bed. Needles already on the target bed are excluded from the transfer.

  • is_sliders (bool, optional) – True if transferring to sliders instead of regular needles. Defaults to False.

__str__()[source]

Return string representation of the transfer pass statement.

Returns:

A string showing the needles, racking, target bed, and slider flag.

Return type:

str

__repr__()[source]

Return detailed string representation of the transfer pass statement.

Returns:

Same as __str__ for this class.

Return type:

str

execute(context)[source]

Execute transfer operations with proper racking and bed handling.

Evaluates all needle expressions, determines the target bed, and creates appropriate carriage pass specifications. For non-zero racking, separates front and back bed transfers since they require different racking values due to mechanical constraints.

Parameters:

context (Knit_Script_Context) – The current execution context of the knit script interpreter.

Raises:

TypeError – If needle expressions don’t evaluate to Needle objects or if the bed expression doesn’t evaluate to a Machine_Bed_Position.

Return type:

None

property line_number: int

Get the line number of the symbol that generated this statement.

Returns:

The line number where this element appears in the source file.

Return type:

int

property location: Location

Get the location of this symbol in KnitScript file.

Returns:

The location of this symbol in the source file, including file name, line number, and position information.

Return type:

Location