Repository navigation
feat(circuit): add instruction payload accessors and Python ClassicalDataOp - #54
Merged
Merged
Conversation
Pair every is_*() predicate with an Option-returning payload accessor, so callers can dispatch on the predicate and read the payload without pattern matching or parsing instruction names: - Instruction: mc_gate(), unitary_gate(), circuit_gate(), classical_data() and classical_control() return references, directive() returns the Copy payload by value - ValueInstruction: mc_gate(), unitary_gate(), circuit_gate() and classical_data() delegate to the wrapped Instruction, and classical_control() returns the value-level control-flow payload
…calDataOp - Add mc_gate / unitary_gate / circuit_gate / classical_data getters to Instruction and ValueInstruction, cloning the payload by value; gate parameters belong to the operation layer (ValueOperation.params) - Register the new ClassicalDataOp class wrapping core classical data ops, with kind / target / value / result getters, its runtime module and type stubs
- List the new Instruction / ValueInstruction payload accessors in the Python and Rust API references (EN + CN) - Add a ClassicalDataOp section to the classical data / control flow pages and to the circuit overview tables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
cqlib-core): pair everyis_*()predicate onInstructionandValueInstructionwith anOption-returning payload accessor —mc_gate(),unitary_gate(),circuit_gate(),classical_data(),classical_control()return references;directive()returns the Copy payload by value.ValueInstructiondelegates to the wrappedInstructionviaas_instruction().mc_gate/unitary_gate/circuit_gate/classical_datagetters toInstructionandValueInstruction(payload cloned by value), and register the newClassicalDataOpclass (kind/target/value/result) with its runtime module, type stubs and tests.ClassicalDataOpsection to the classical data / control flow pages and the circuit overview tables.0.1.0-beta.3/2.0.0-beta3.Design notes
ValueOperation.params). This matches the pre-rewrite semantics and is now documented.Instruction.classical_controlis intentionally not exposed on the Python storage-layer type: the storage-layerClassicalControlOpinlines circuit-internal handles, so control-flow content is read viaValueInstruction.classical_control(or the DAG). This exception is documented in the API reference.