libqasm
library for handling cQASM files
Classes | Typedefs | Enumerations | Functions
cqasm::v1::values Namespace Reference

Detailed Description

Namespace for the classes representing the values (including dynamically evaluated expressions or references to registers) available within cQASM.

Namespace for the various classes representing constants, references, and dynamic expressions in cQASM.

dot_inline_dotgraph_4.png

Classes

class  BitRefs
 Represents a measurement bit, or a number of measurement bits for conditional gates with multiple conditions. More...
 
class  Constant
 Represents a constant value. More...
 
class  ConstAxis
 Represents an axis value (x, y, or z). More...
 
class  ConstBool
 Represents a value of type bool. More...
 
class  ConstComplex
 Represents a value of type complex. More...
 
class  ConstComplexMatrix
 Represents a value of type complex_matrix. More...
 
class  ConstInt
 Represents a value of type int. More...
 
class  ConstJson
 Represents a value of type json. More...
 
class  ConstReal
 Represents a value of type real. More...
 
class  ConstRealMatrix
 Represents a value of type real_matrix. More...
 
class  ConstString
 Represents a value of type string. More...
 
class  Dumper
 Visitor class that debug-dumps a tree to a stream. More...
 
class  Function
 This can be returned by user-defined functions as a placeholder value for something that needs to be evaluated at runtime rather than during constant propagation. More...
 
class  Node
 Main class for all nodes. More...
 
class  QubitRefs
 Represents a qubit, or a set of qubits for single-gate-multiple-qubit notation. More...
 
class  RecursiveVisitor
 Visitor base class defaulting to DFS pre-order traversal. More...
 
class  Reference
 Represents a reference to some storage location. More...
 
class  VariableRef
 Represents a variable reference. More...
 
class  Visitor
 Base class for the visitor pattern for the tree. More...
 
class  VisitorBase
 Internal class for implementing the visitor pattern. More...
 

Typedefs

using TypeEnum = types::NodeType
 
using ValueEnum = values::NodeType
 
using Value = tree::One< Node >
 A cQASM value, either known at compile-time or an expression for something only known at runtime. More...
 
using Values = tree::Any< Node >
 Zero or more cQASM values. More...
 
using Base = cqasm::tree::Base
 
template<class T >
using Maybe = cqasm::tree::Maybe< T >
 
template<class T >
using One = cqasm::tree::One< T >
 
template<class T >
using Any = cqasm::tree::Any< T >
 
template<class T >
using Many = cqasm::tree::Many< T >
 
template<class T >
using OptLink = cqasm::tree::OptLink< T >
 
template<class T >
using Link = cqasm::tree::Link< T >
 

Enumerations

enum  NodeType {
  NodeType::BitRefs, NodeType::ConstAxis, NodeType::ConstBool, NodeType::ConstComplex,
  NodeType::ConstComplexMatrix, NodeType::ConstInt, NodeType::ConstJson, NodeType::ConstReal,
  NodeType::ConstRealMatrix, NodeType::ConstString, NodeType::Function, NodeType::QubitRefs,
  NodeType::VariableRef
}
 Enumeration of all node types. More...
 

Functions

Value promote (const Value &value, const types::Type &type)
 Type-checks and (if necessary) promotes the given value to the given type. More...
 
types::Type type_of (const Value &value)
 Returns the type of the given value. More...
 
types::Types types_of (const Values &values)
 Returns the types of the given values. More...
 
void check_const (const Value &value)
 Throws an AnalysisError if the given value is not a constant, i.e. More...
 
void check_const (const Values &values)
 Throws an AnalysisError if any of the given values are not a constant, i.e. More...
 
std::ostream & operator<< (std::ostream &os, const Value &value)
 Stream << overload for a single value. More...
 
std::ostream & operator<< (std::ostream &os, const Values &values)
 Stream << overload for zero or more values. More...
 
std::ostream & operator<< (std::ostream &os, const Node &object)
 Stream << overload for tree nodes (writes debug dump). More...
 

Typedef Documentation

◆ TypeEnum

Definition at line 15 of file cqasm-v1-values.cpp.

◆ ValueEnum

Definition at line 16 of file cqasm-v1-values.cpp.

◆ Value

A cQASM value, either known at compile-time or an expression for something only known at runtime.

Definition at line 26 of file cqasm-v1-values.hpp.

◆ Values

Zero or more cQASM values.

Definition at line 31 of file cqasm-v1-values.hpp.

◆ Base

Definition at line 85 of file cqasm-v1-values-gen.hpp.

◆ Maybe

template<class T >
using cqasm::v1::values::Maybe = typedef cqasm::tree::Maybe<T>

Definition at line 86 of file cqasm-v1-values-gen.hpp.

◆ One

template<class T >
using cqasm::v1::values::One = typedef cqasm::tree::One<T>

Definition at line 87 of file cqasm-v1-values-gen.hpp.

◆ Any

template<class T >
using cqasm::v1::values::Any = typedef cqasm::tree::Any<T>

Definition at line 88 of file cqasm-v1-values-gen.hpp.

◆ Many

template<class T >
using cqasm::v1::values::Many = typedef cqasm::tree::Many<T>

Definition at line 89 of file cqasm-v1-values-gen.hpp.

◆ OptLink

template<class T >
using cqasm::v1::values::OptLink = typedef cqasm::tree::OptLink<T>

Definition at line 90 of file cqasm-v1-values-gen.hpp.

◆ Link

template<class T >
using cqasm::v1::values::Link = typedef cqasm::tree::Link<T>

Definition at line 91 of file cqasm-v1-values-gen.hpp.

Enumeration Type Documentation

◆ NodeType

Enumeration of all node types.

Enumerator
BitRefs 
ConstAxis 
ConstBool 
ConstComplex 
ConstComplexMatrix 
ConstInt 
ConstJson 
ConstReal 
ConstRealMatrix 
ConstString 
Function 
QubitRefs 
VariableRef 

Definition at line 119 of file cqasm-v1-values-gen.hpp.

Function Documentation

◆ promote()

Value cqasm::v1::values::promote ( const Value value,
const types::Type type 
)

Type-checks and (if necessary) promotes the given value to the given type.

Also checks assignability of the value if the type says the value must be assignable. Returns null if the check/promotion fails, otherwise returns the constructed value by way of a smart pointer. If the type was an exact match, this may return the given value without modification or a clone thereof.

Definition at line 25 of file cqasm-v1-values.cpp.

◆ type_of()

types::Type cqasm::v1::values::type_of ( const Value value)

Returns the type of the given value.

Definition at line 108 of file cqasm-v1-values.cpp.

◆ types_of()

types::Types cqasm::v1::values::types_of ( const Values values)

Returns the types of the given values.

Definition at line 149 of file cqasm-v1-values.cpp.

◆ check_const() [1/2]

void cqasm::v1::values::check_const ( const Value value)

Throws an AnalysisError if the given value is not a constant, i.e.

if it doesn't have a known value at this time.

Definition at line 161 of file cqasm-v1-values.cpp.

◆ check_const() [2/2]

void cqasm::v1::values::check_const ( const Values values)

Throws an AnalysisError if any of the given values are not a constant, i.e.

if it doesn't have a known value at this time.

Definition at line 171 of file cqasm-v1-values.cpp.

◆ operator<<() [1/3]

std::ostream & cqasm::v1::values::operator<< ( std::ostream &  os,
const Value value 
)

Stream << overload for a single value.

Definition at line 180 of file cqasm-v1-values.cpp.

◆ operator<<() [2/3]

std::ostream & cqasm::v1::values::operator<< ( std::ostream &  os,
const Values values 
)

Stream << overload for zero or more values.

Definition at line 192 of file cqasm-v1-values.cpp.

◆ operator<<() [3/3]

std::ostream & cqasm::v1::values::operator<< ( std::ostream &  os,
const Node object 
)

Stream << overload for tree nodes (writes debug dump).

Definition at line 2818 of file cqasm-v1-values-gen.cpp.