bloqade.qasm2.parse.lowering.QASM2
classQASM2¶source
bloqade.qasm2.parse.lowering.QASM2
Bases: lowering.LoweringABC[ast.Node]
Signature
class QASM2(*, max_lines: int = 3, hint_indent: int = 2, hint_show_lineno: bool = True, stacktrace: bool = True)Parameters
| Name | Type | Default | Description |
|---|---|---|---|
max_lines | int | 3 | |
hint_indent | int | 2 | |
hint_show_lineno | bool | True | |
stacktrace | bool | True |
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
max_lines | int | field(default=3, kw_only=True) | |
hint_indent | int | field(default=2, kw_only=True) | |
hint_show_lineno | bool | field(default=True, kw_only=True) | |
stacktrace | bool | field(default=True, kw_only=True) |
methodrun¶source
bloqade.qasm2.parse.lowering.QASM2.run
Signature
def run(stmt: ast.Node, *, source: str | None = None, globals: dict[str, Any] | None = None, file: str | None = None, lineno_offset: int = 0, col_offset: int = 0, compactify: bool = True) -> ir.RegionParameters
| Name | Type | Default | Description |
|---|---|---|---|
stmt | ast.Node | required | |
source | str | None | None | |
globals | dict[str, Any] | None | None | |
file | str | None | None | |
lineno_offset | int | 0 | |
col_offset | int | 0 | |
compactify | bool | True |
Returns
ir.Region
methodget_frame¶source
bloqade.qasm2.parse.lowering.QASM2.get_frame
Signature
def get_frame(stmt: ast.Node, source: str | None = None, globals: dict[str, Any] | None = None, file: str | None = None, lineno_offset: int = 0, col_offset: int = 0, compactify: bool = True) -> lowering.FrameParameters
| Name | Type | Default | Description |
|---|---|---|---|
stmt | ast.Node | required | |
source | str | None | None | |
globals | dict[str, Any] | None | None | |
file | str | None | None | |
lineno_offset | int | 0 | |
col_offset | int | 0 | |
compactify | bool | True |
Returns
lowering.Frame
methodvisit¶source
bloqade.qasm2.parse.lowering.QASM2.visit
Signature
def visit(state: lowering.State[ast.Node], node: ast.Node) -> lowering.ResultParameters
| Name | Type | Description |
|---|---|---|
state | lowering.State[ast.Node] | |
node | ast.Node |
Returns
lowering.Result
methodgeneric_visit¶source
bloqade.qasm2.parse.lowering.QASM2.generic_visit
Signature
def generic_visit(state: lowering.State[ast.Node], node: ast.Node) -> lowering.ResultParameters
| Name | Type | Description |
|---|---|---|
state | lowering.State[ast.Node] | |
node | ast.Node |
Returns
lowering.Result
methodlower_literal¶source
bloqade.qasm2.parse.lowering.QASM2.lower_literal
def lower_literal(state: lowering.State[ast.Node], value) -> ir.SSAValueParameters
| Name | Type | Description |
|---|---|---|
state | lowering.State[ast.Node] | |
value | — |
Returns
ir.SSAValue
methodlower_global¶source
bloqade.qasm2.parse.lowering.QASM2.lower_global
Signature
def lower_global(state: lowering.State[ast.Node], node: ast.Node) -> lowering.LoweringABC.ResultParameters
| Name | Type | Description |
|---|---|---|
state | lowering.State[ast.Node] | |
node | ast.Node |
Returns
lowering.LoweringABC.Result
methodvisit_MainProgram¶source
bloqade.qasm2.parse.lowering.QASM2.visit_MainProgram
Signature
def visit_MainProgram(state: lowering.State[ast.Node], node: ast.MainProgram)Parameters
| Name | Type | Description |
|---|---|---|
state | lowering.State[ast.Node] | |
node | ast.MainProgram |
methodvisit_QReg¶source
bloqade.qasm2.parse.lowering.QASM2.visit_QReg
def visit_QReg(state: lowering.State[ast.Node], node: ast.QReg)Parameters
| Name | Type | Description |
|---|---|---|
state | lowering.State[ast.Node] | |
node | ast.QReg |
methodvisit_CReg¶source
bloqade.qasm2.parse.lowering.QASM2.visit_CReg
def visit_CReg(state: lowering.State[ast.Node], node: ast.CReg)Parameters
| Name | Type | Description |
|---|---|---|
state | lowering.State[ast.Node] | |
node | ast.CReg |
methodvisit_Barrier¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Barrier
def visit_Barrier(state: lowering.State[ast.Node], node: ast.Barrier)Parameters
| Name | Type | Description |
|---|---|---|
state | lowering.State[ast.Node] | |
node | ast.Barrier |
methodvisit_CXGate¶source
bloqade.qasm2.parse.lowering.QASM2.visit_CXGate
def visit_CXGate(state: lowering.State[ast.Node], node: ast.CXGate)Parameters
| Name | Type | Description |
|---|---|---|
state | lowering.State[ast.Node] | |
node | ast.CXGate |
methodvisit_Measure¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Measure
def visit_Measure(state: lowering.State[ast.Node], node: ast.Measure)Parameters
| Name | Type | Description |
|---|---|---|
state | lowering.State[ast.Node] | |
node | ast.Measure |
methodvisit_UGate¶source
bloqade.qasm2.parse.lowering.QASM2.visit_UGate
def visit_UGate(state: lowering.State[ast.Node], node: ast.UGate)Parameters
| Name | Type | Description |
|---|---|---|
state | lowering.State[ast.Node] | |
node | ast.UGate |
methodvisit_Reset¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Reset
def visit_Reset(state: lowering.State[ast.Node], node: ast.Reset)Parameters
| Name | Type | Description |
|---|---|---|
state | lowering.State[ast.Node] | |
node | ast.Reset |
methodvisit_IfStmt¶source
bloqade.qasm2.parse.lowering.QASM2.visit_IfStmt
def visit_IfStmt(state: lowering.State[ast.Node], node: ast.IfStmt)Parameters
| Name | Type | Description |
|---|---|---|
state | lowering.State[ast.Node] | |
node | ast.IfStmt |
methodbranch_next_if_not_terminated¶source
bloqade.qasm2.parse.lowering.QASM2.branch_next_if_not_terminated
def branch_next_if_not_terminated(frame: lowering.Frame)Branch to the next block if the current block is not terminated.
This must be used after exhausting the current frame and before popping the frame.
Parameters
| Name | Type | Description |
|---|---|---|
frame | lowering.Frame |
methodvisit_BinOp¶source
bloqade.qasm2.parse.lowering.QASM2.visit_BinOp
def visit_BinOp(state: lowering.State[ast.Node], node: ast.BinOp)Parameters
| Name | Type | Description |
|---|---|---|
state | lowering.State[ast.Node] | |
node | ast.BinOp |
methodvisit_UnaryOp¶source
bloqade.qasm2.parse.lowering.QASM2.visit_UnaryOp
def visit_UnaryOp(state: lowering.State[ast.Node], node: ast.UnaryOp)Parameters
| Name | Type | Description |
|---|---|---|
state | lowering.State[ast.Node] | |
node | ast.UnaryOp |
methodvisit_Bit¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Bit
def visit_Bit(state: lowering.State[ast.Node], node: ast.Bit)Parameters
| Name | Type | Description |
|---|---|---|
state | lowering.State[ast.Node] | |
node | ast.Bit |
methodvisit_Call¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Call
def visit_Call(state: lowering.State[ast.Node], node: ast.Call)Parameters
| Name | Type | Description |
|---|---|---|
state | lowering.State[ast.Node] | |
node | ast.Call |
methodvisit_Name¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Name
def visit_Name(state: lowering.State[ast.Node], node: ast.Name)Parameters
| Name | Type | Description |
|---|---|---|
state | lowering.State[ast.Node] | |
node | ast.Name |
methodvisit_ParaCZGate¶source
bloqade.qasm2.parse.lowering.QASM2.visit_ParaCZGate
Signature
def visit_ParaCZGate(state: lowering.State[ast.Node], node: ast.ParaCZGate)Parameters
| Name | Type | Description |
|---|---|---|
state | lowering.State[ast.Node] | |
node | ast.ParaCZGate |
methodvisit_ParaRZGate¶source
bloqade.qasm2.parse.lowering.QASM2.visit_ParaRZGate
Signature
def visit_ParaRZGate(state: lowering.State[ast.Node], node: ast.ParaRZGate)Parameters
| Name | Type | Description |
|---|---|---|
state | lowering.State[ast.Node] | |
node | ast.ParaRZGate |
methodvisit_ParaU3Gate¶source
bloqade.qasm2.parse.lowering.QASM2.visit_ParaU3Gate
Signature
def visit_ParaU3Gate(state: lowering.State[ast.Node], node: ast.ParaU3Gate)Parameters
| Name | Type | Description |
|---|---|---|
state | lowering.State[ast.Node] | |
node | ast.ParaU3Gate |
methodvisit_GlobUGate¶source
bloqade.qasm2.parse.lowering.QASM2.visit_GlobUGate
Signature
def visit_GlobUGate(state: lowering.State[ast.Node], node: ast.GlobUGate)Parameters
| Name | Type | Description |
|---|---|---|
state | lowering.State[ast.Node] | |
node | ast.GlobUGate |
methodvisit_NoisePAULI1¶source
bloqade.qasm2.parse.lowering.QASM2.visit_NoisePAULI1
Signature
def visit_NoisePAULI1(state: lowering.State[ast.Node], node: ast.NoisePAULI1)Parameters
| Name | Type | Description |
|---|---|---|
state | lowering.State[ast.Node] | |
node | ast.NoisePAULI1 |
methodvisit_Number¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Number
def visit_Number(state: lowering.State[ast.Node], node: ast.Number)Parameters
| Name | Type | Description |
|---|---|---|
state | lowering.State[ast.Node] | |
node | ast.Number |
methodvisit_Pi¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Pi
def visit_Pi(state: lowering.State[ast.Node], node: ast.Pi)Parameters
| Name | Type | Description |
|---|---|---|
state | lowering.State[ast.Node] | |
node | ast.Pi |
methodvisit_Include¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Include
def visit_Include(state: lowering.State[ast.Node], node: ast.Include)Parameters
| Name | Type | Description |
|---|---|---|
state | lowering.State[ast.Node] | |
node | ast.Include |
methodvisit_Gate¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Gate
def visit_Gate(state: lowering.State[ast.Node], node: ast.Gate)Parameters
| Name | Type | Description |
|---|---|---|
state | lowering.State[ast.Node] | |
node | ast.Gate |
methodvisit_Instruction¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction
Signature
def visit_Instruction(state: lowering.State[ast.Node], node: ast.Instruction)Parameters
| Name | Type | Description |
|---|---|---|
state | lowering.State[ast.Node] | |
node | ast.Instruction |
methodvisit_Instruction_id¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction_id
methodvisit_Instruction_x¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction_x
methodvisit_Instruction_y¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction_y
methodvisit_Instruction_z¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction_z
methodvisit_Instruction_h¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction_h
methodvisit_Instruction_s¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction_s
methodvisit_Instruction_sdg¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction_sdg
methodvisit_Instruction_sx¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction_sx
methodvisit_Instruction_sxdg¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction_sxdg
methodvisit_Instruction_t¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction_t
methodvisit_Instruction_tdg¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction_tdg
methodvisit_Instruction_rx¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction_rx
methodvisit_Instruction_ry¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction_ry
methodvisit_Instruction_rz¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction_rz
methodvisit_Instruction_p¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction_p
methodvisit_Instruction_u¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction_u
methodvisit_Instruction_u1¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction_u1
methodvisit_Instruction_u2¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction_u2
methodvisit_Instruction_u3¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction_u3
methodvisit_Instruction_CX¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction_CX
methodvisit_Instruction_cx¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction_cx
methodvisit_Instruction_cy¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction_cy
methodvisit_Instruction_cz¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction_cz
methodvisit_Instruction_ch¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction_ch
methodvisit_Instruction_crx¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction_crx
methodvisit_Instruction_cry¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction_cry
methodvisit_Instruction_crz¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction_crz
methodvisit_Instruction_ccx¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction_ccx
methodvisit_Instruction_csx¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction_csx
methodvisit_Instruction_cswap¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction_cswap
methodvisit_Instruction_cp¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction_cp
methodvisit_Instruction_cu1¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction_cu1
methodvisit_Instruction_cu3¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction_cu3
methodvisit_Instruction_cu¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction_cu
methodvisit_Instruction_rxx¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction_rxx
methodvisit_Instruction_rzz¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction_rzz
methodvisit_Instruction_swap¶source
bloqade.qasm2.parse.lowering.QASM2.visit_Instruction_swap