knit_script.knit_script_interpreter.statements.Drop_Pass module
A pass of drop operations.
- This module provides the Drop_Pass statement class, which implements specialized carriage passes that drop stitches from specified needles.
It creates dedicated drop operations that are executed in a consistent direction for reliable stitch removal.
- class Drop_Pass(parser_node, needles)[source]
Bases:
Statement
Executes a set of drop operations from left to right.
Creates a specialized carriage pass that drops stitches from the specified needles. Always executes in rightward direction for consistency and proper machine operation. This statement is used when stitches need to be removed from needles, typically for shaping operations or pattern requirements.
The drop pass handles evaluation of needle expressions, flattening of nested needle lists, and creation of appropriate carriage pass specifications for reliable stitch dropping operations.
- _needles
List of expressions that evaluate to needles to drop from.
- Type:
- Parameters:
parser_node (
LRStackNode
)needles (
list
[Expression
])
- __init__(parser_node, needles)[source]
Initialize a drop pass.
- Parameters:
parser_node (LRStackNode) – The parser node from the abstract syntax tree.
needles (list[Expression]) – List of expressions that evaluate to needles to drop from. Can include nested lists of needles which will be flattened during execution.
- execute(context)[source]
Execute drop operations on all specified needles.
- Evaluates all needle expressions, flattens any nested lists, validates that all results are Needle objects, then creates a carriage pass to drop all stitches.
The results are stored in the context for potential use by subsequent operations.
- Parameters:
context (Knit_Script_Context) – The current execution context of the knit script interpreter.
- Raises:
TypeError – If any expression doesn’t evaluate to a Needle object.
- Return type:
- 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:
- 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