libqasm
library for handling cQASM files
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | List of all members
cqasm::v1::semantic::Subcircuit Class Reference

A subcircuit. More...

Public Member Functions

 Subcircuit (const cqasm::v1::primitives::Str &name=cqasm::v1::primitives::initialize< cqasm::v1::primitives::Str >(), const cqasm::v1::primitives::Int &iterations=cqasm::v1::primitives::initialize< cqasm::v1::primitives::Int >(), const Any< Bundle > &bundles=Any< Bundle >(), const Any< AnnotationData > &annotations=Any< AnnotationData >(), const Maybe< Block > &body=Maybe< Block >())
 Constructor. More...
 
void find_reachable (::tree::base::PointerMap &map) const override
 Registers all reachable nodes with the given PointerMap. More...
 
void check_complete (const ::tree::base::PointerMap &map) const override
 Returns whether this Subcircuit is complete/fully defined. More...
 
NodeType type () const override
 Returns the NodeType of this node. More...
 
Subcircuitas_subcircuit () override
 Interprets this node to a node of type Subcircuit. More...
 
const Subcircuitas_subcircuit () const override
 Interprets this node to a node of type Subcircuit. More...
 
One< Nodecopy () const override
 Returns a shallow copy of this node. More...
 
One< Nodeclone () const override
 Returns a deep copy of this node. More...
 
bool equals (const Node &rhs) const override
 Value-based equality operator. More...
 
bool operator== (const Node &rhs) const override
 Pointer-based equality operator. More...
 
void serialize (::tree::cbor::MapWriter &map, const ::tree::base::PointerMap &ids) const override
 Serializes this node to the given map. More...
 
- Public Member Functions inherited from cqasm::v1::semantic::Annotated
 Annotated (const Any< AnnotationData > &annotations=Any< AnnotationData >())
 Constructor. More...
 
Annotatedas_annotated () override
 Interprets this node to a node of type Annotated. More...
 
const Annotatedas_annotated () const override
 Interprets this node to a node of type Annotated. More...
 
- Public Member Functions inherited from cqasm::v1::semantic::Node
bool operator!= (const Node &rhs) const
 Pointer-based inequality operator. More...
 
template<typename T >
visit (Visitor< T > &visitor)
 Visit this object. More...
 
void dump (std::ostream &out=std::cout, int indent=0)
 Writes a debug dump of this node to the given stream. More...
 
void dump_seq (std::ostream &out=std::cout, int indent=0)
 Alternate debug dump that represents links and node uniqueness via sequence number tags. More...
 
virtual AnnotationDataas_annotation_data ()
 Interprets this node to a node of type AnnotationData. More...
 
virtual const AnnotationDataas_annotation_data () const
 Interprets this node to a node of type AnnotationData. More...
 
virtual Blockas_block ()
 Interprets this node to a node of type Block. More...
 
virtual const Blockas_block () const
 Interprets this node to a node of type Block. More...
 
virtual BreakStatementas_break_statement ()
 Interprets this node to a node of type BreakStatement. More...
 
virtual const BreakStatementas_break_statement () const
 Interprets this node to a node of type BreakStatement. More...
 
virtual Bundleas_bundle ()
 Interprets this node to a node of type Bundle. More...
 
virtual const Bundleas_bundle () const
 Interprets this node to a node of type Bundle. More...
 
virtual BundleExtas_bundle_ext ()
 Interprets this node to a node of type BundleExt. More...
 
virtual const BundleExtas_bundle_ext () const
 Interprets this node to a node of type BundleExt. More...
 
virtual ContinueStatementas_continue_statement ()
 Interprets this node to a node of type ContinueStatement. More...
 
virtual const ContinueStatementas_continue_statement () const
 Interprets this node to a node of type ContinueStatement. More...
 
virtual ErrorModelas_error_model ()
 Interprets this node to a node of type ErrorModel. More...
 
virtual const ErrorModelas_error_model () const
 Interprets this node to a node of type ErrorModel. More...
 
virtual ForLoopas_for_loop ()
 Interprets this node to a node of type ForLoop. More...
 
virtual const ForLoopas_for_loop () const
 Interprets this node to a node of type ForLoop. More...
 
virtual ForeachLoopas_foreach_loop ()
 Interprets this node to a node of type ForeachLoop. More...
 
virtual const ForeachLoopas_foreach_loop () const
 Interprets this node to a node of type ForeachLoop. More...
 
virtual GotoInstructionas_goto_instruction ()
 Interprets this node to a node of type GotoInstruction. More...
 
virtual const GotoInstructionas_goto_instruction () const
 Interprets this node to a node of type GotoInstruction. More...
 
virtual IfElseas_if_else ()
 Interprets this node to a node of type IfElse. More...
 
virtual const IfElseas_if_else () const
 Interprets this node to a node of type IfElse. More...
 
virtual IfElseBranchas_if_else_branch ()
 Interprets this node to a node of type IfElseBranch. More...
 
virtual const IfElseBranchas_if_else_branch () const
 Interprets this node to a node of type IfElseBranch. More...
 
virtual Instructionas_instruction ()
 Interprets this node to a node of type Instruction. More...
 
virtual const Instructionas_instruction () const
 Interprets this node to a node of type Instruction. More...
 
virtual InstructionBaseas_instruction_base ()
 Interprets this node to a node of type InstructionBase. More...
 
virtual const InstructionBaseas_instruction_base () const
 Interprets this node to a node of type InstructionBase. More...
 
virtual Mappingas_mapping ()
 Interprets this node to a node of type Mapping. More...
 
virtual const Mappingas_mapping () const
 Interprets this node to a node of type Mapping. More...
 
virtual Programas_program ()
 Interprets this node to a node of type Program. More...
 
virtual const Programas_program () const
 Interprets this node to a node of type Program. More...
 
virtual RepeatUntilLoopas_repeat_until_loop ()
 Interprets this node to a node of type RepeatUntilLoop. More...
 
virtual const RepeatUntilLoopas_repeat_until_loop () const
 Interprets this node to a node of type RepeatUntilLoop. More...
 
virtual SetInstructionas_set_instruction ()
 Interprets this node to a node of type SetInstruction. More...
 
virtual const SetInstructionas_set_instruction () const
 Interprets this node to a node of type SetInstruction. More...
 
virtual Statementas_statement ()
 Interprets this node to a node of type Statement. More...
 
virtual const Statementas_statement () const
 Interprets this node to a node of type Statement. More...
 
virtual Structuredas_structured ()
 Interprets this node to a node of type Structured. More...
 
virtual const Structuredas_structured () const
 Interprets this node to a node of type Structured. More...
 
virtual Variableas_variable ()
 Interprets this node to a node of type Variable. More...
 
virtual const Variableas_variable () const
 Interprets this node to a node of type Variable. More...
 
virtual Versionas_version ()
 Interprets this node to a node of type Version. More...
 
virtual const Versionas_version () const
 Interprets this node to a node of type Version. More...
 
virtual WhileLoopas_while_loop ()
 Interprets this node to a node of type WhileLoop. More...
 
virtual const WhileLoopas_while_loop () const
 Interprets this node to a node of type WhileLoop. More...
 

Static Public Member Functions

static std::shared_ptr< Subcircuitdeserialize (const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
 Deserializes the given node. More...
 
- Static Public Member Functions inherited from cqasm::v1::semantic::Annotated
static std::shared_ptr< Annotateddeserialize (const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
 Deserializes the given node. More...
 
- Static Public Member Functions inherited from cqasm::v1::semantic::Node
static std::shared_ptr< Nodedeserialize (const ::tree::cbor::MapReader &map, ::tree::base::IdentifierMap &ids)
 Deserializes the given node. More...
 

Public Attributes

cqasm::v1::primitives::Str name
 The name of the subcircuit. More...
 
cqasm::v1::primitives::Int iterations
 An optional integer expression representing the number of iterations for this subcircuit. More...
 
Any< Bundlebundles
 The instruction bundles contained by this subcircuit. More...
 
Maybe< Blockbody
 The statements contained by this subcircuit. More...
 
- Public Attributes inherited from cqasm::v1::semantic::Annotated
Any< AnnotationDataannotations
 Zero or more annotations attached to this object. More...
 

Protected Member Functions

void visit_internal (VisitorBase &visitor, void *retval) override
 Helper method for visiting nodes. More...
 

Detailed Description

A subcircuit.

That is, a named collection of bundles, possibly repeated a number of times.

Definition at line 2332 of file cqasm-v1-semantic-gen.hpp.

#include <cqasm-v1-semantic-gen.hpp>

Inheritance diagram for cqasm::v1::semantic::Subcircuit:
Inheritance graph
[legend]
Collaboration diagram for cqasm::v1::semantic::Subcircuit:
Collaboration graph
[legend]

Constructor & Destructor Documentation

◆ Subcircuit()

cqasm::v1::semantic::Subcircuit::Subcircuit ( const cqasm::v1::primitives::Str name = cqasm::v1::primitives::initialize<cqasm::v1::primitives::Str>(),
const cqasm::v1::primitives::Int iterations = cqasm::v1::primitives::initialize<cqasm::v1::primitives::Int>(),
const Any< Bundle > &  bundles = Any<Bundle>(),
const Any< AnnotationData > &  annotations = Any<AnnotationData>(),
const Maybe< Block > &  body = Maybe<Block>() 
)

Constructor.

Definition at line 2969 of file cqasm-v1-semantic-gen.cpp.

Member Function Documentation

◆ find_reachable()

void cqasm::v1::semantic::Subcircuit::find_reachable ( ::tree::base::PointerMap &  map) const
override

Registers all reachable nodes with the given PointerMap.

Definition at line 2976 of file cqasm-v1-semantic-gen.cpp.

◆ check_complete()

void cqasm::v1::semantic::Subcircuit::check_complete ( const ::tree::base::PointerMap &  map) const
override

Returns whether this Subcircuit is complete/fully defined.

Definition at line 2986 of file cqasm-v1-semantic-gen.cpp.

◆ type()

NodeType cqasm::v1::semantic::Subcircuit::type ( ) const
overridevirtual

Returns the NodeType of this node.

Implements cqasm::v1::semantic::Node.

Definition at line 2996 of file cqasm-v1-semantic-gen.cpp.

◆ visit_internal()

void cqasm::v1::semantic::Subcircuit::visit_internal ( VisitorBase visitor,
void *  retval 
)
overrideprotectedvirtual

Helper method for visiting nodes.

Implements cqasm::v1::semantic::Node.

Definition at line 3003 of file cqasm-v1-semantic-gen.cpp.

◆ as_subcircuit() [1/2]

Subcircuit * cqasm::v1::semantic::Subcircuit::as_subcircuit ( )
overridevirtual

Interprets this node to a node of type Subcircuit.

Returns null if it has the wrong type.

Reimplemented from cqasm::v1::semantic::Node.

Definition at line 3011 of file cqasm-v1-semantic-gen.cpp.

◆ as_subcircuit() [2/2]

const Subcircuit * cqasm::v1::semantic::Subcircuit::as_subcircuit ( ) const
overridevirtual

Interprets this node to a node of type Subcircuit.

Returns null if it has the wrong type.

Reimplemented from cqasm::v1::semantic::Node.

Definition at line 3019 of file cqasm-v1-semantic-gen.cpp.

◆ copy()

One< Node > cqasm::v1::semantic::Subcircuit::copy ( ) const
overridevirtual

Returns a shallow copy of this node.

Implements cqasm::v1::semantic::Node.

Definition at line 3026 of file cqasm-v1-semantic-gen.cpp.

◆ clone()

One< Node > cqasm::v1::semantic::Subcircuit::clone ( ) const
overridevirtual

Returns a deep copy of this node.

Implements cqasm::v1::semantic::Node.

Definition at line 3033 of file cqasm-v1-semantic-gen.cpp.

◆ equals()

bool cqasm::v1::semantic::Subcircuit::equals ( const Node rhs) const
overridevirtual

Value-based equality operator.

Ignores annotations!

Implements cqasm::v1::semantic::Node.

Definition at line 3044 of file cqasm-v1-semantic-gen.cpp.

◆ operator==()

bool cqasm::v1::semantic::Subcircuit::operator== ( const Node rhs) const
overridevirtual

Pointer-based equality operator.

Implements cqasm::v1::semantic::Node.

Definition at line 3058 of file cqasm-v1-semantic-gen.cpp.

◆ serialize()

void cqasm::v1::semantic::Subcircuit::serialize ( ::tree::cbor::MapWriter &  map,
const ::tree::base::PointerMap &  ids 
) const
overridevirtual

Serializes this node to the given map.

Implements cqasm::v1::semantic::Node.

Definition at line 3072 of file cqasm-v1-semantic-gen.cpp.

◆ deserialize()

std::shared_ptr< Subcircuit > cqasm::v1::semantic::Subcircuit::deserialize ( const ::tree::cbor::MapReader &  map,
::tree::base::IdentifierMap &  ids 
)
static

Deserializes the given node.

Writes a debug dump of this node to the given stream.

Definition at line 3099 of file cqasm-v1-semantic-gen.cpp.

Member Data Documentation

◆ name

cqasm::v1::primitives::Str cqasm::v1::semantic::Subcircuit::name

The name of the subcircuit.

If the file doesn't start with a subcircuit definition, this is empty for the first subcircuit.

Definition at line 2339 of file cqasm-v1-semantic-gen.hpp.

◆ iterations

cqasm::v1::primitives::Int cqasm::v1::semantic::Subcircuit::iterations

An optional integer expression representing the number of iterations for this subcircuit.

This is 1 when the iteration count is not specified.

Definition at line 2345 of file cqasm-v1-semantic-gen.hpp.

◆ bundles

Any<Bundle> cqasm::v1::semantic::Subcircuit::bundles

The instruction bundles contained by this subcircuit.

Only used for API level 1.0 and 1.1; use body for 1.2+.

Definition at line 2351 of file cqasm-v1-semantic-gen.hpp.

◆ body

Maybe<Block> cqasm::v1::semantic::Subcircuit::body

The statements contained by this subcircuit.

Only used for API level 1.2+; use bundles for 1.0 and 1.1.

Definition at line 2357 of file cqasm-v1-semantic-gen.hpp.


The documentation for this class was generated from the following files: