autoqasm.converters.assignments module
Converters for assignment nodes.
- class autoqasm.converters.assignments.AssignTransformer(ctx)[source]
Bases:
BaseInitialize the transformer.
Subclasses should call this.
- Parameters:
ctx – A Context object.
- visit_AugAssign(node: stmt) stmt[source]
Converts augmented assignment operations (
+=,-=, etc.) into regular assignments so they flow throughassign_stmt.val += expris desugared toval = val + exprand then transformed byvisit_Assign.- Parameters:
node (ast.stmt) – AST node to transform.
- Returns:
ast.stmt – Transformed node.
- visit_Assign(node: stmt) stmt[source]
Converts assignment operations to their AutoQASM counterpart. Supports assignment to a single variable. Operator declares the
oqvariable, or sets variable’s value if it’s already declared.- Parameters:
node (ast.stmt) – AST node to transform.
- Returns:
ast.stmt – Transformed node.