Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite OpenQASM 3 exporter symbol table #12776

Merged
merged 6 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions crates/circuit/src/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,16 @@ impl StandardGate {
pub fn get_name(&self) -> &str {
self.name()
}

pub fn __eq__(&self, other: &Bound<PyAny>) -> Py<PyAny> {
let py = other.py();
let Ok(other) = other.extract::<Self>() else { return py.NotImplemented() };
(*self == other).into_py(py)
}

pub fn __hash__(&self) -> isize {
*self as isize
}
}

// This must be kept up-to-date with `StandardGate` when adding or removing
Expand Down
32 changes: 8 additions & 24 deletions qiskit/qasm3/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,39 +456,23 @@ class SubroutineBlock(ProgramBlock):
pass


class QuantumArgument(QuantumDeclaration):
"""
quantumArgument
: 'qreg' Identifier designator? | 'qubit' designator? Identifier
"""


class QuantumGateSignature(ASTNode):
class QuantumGateDefinition(Statement):
"""
quantumGateSignature
: quantumGateName ( LPAREN identifierList? RPAREN )? identifierList
quantumGateDefinition
: 'gate' quantumGateSignature quantumBlock
"""

def __init__(
self,
name: Identifier,
qargList: List[Identifier],
params: Optional[List[Expression]] = None,
params: Tuple[Identifier, ...],
qubits: Tuple[Identifier, ...],
body: QuantumBlock,
):
self.name = name
self.qargList = qargList
self.params = params


class QuantumGateDefinition(Statement):
"""
quantumGateDefinition
: 'gate' quantumGateSignature quantumBlock
"""

def __init__(self, quantumGateSignature: QuantumGateSignature, quantumBlock: QuantumBlock):
self.quantumGateSignature = quantumGateSignature
self.quantumBlock = quantumBlock
self.qubits = qubits
self.body = body


class SubroutineDefinition(Statement):
Expand Down
Loading
Loading