IR Tree API

Table of Contents

Include this API as

#include <wtk/IRTree.h>

Members of this API live in the following namespace

namespace wtk { ...

The IR Tree API is parameterized on a Number_T template. Number_T should be integer-like enough to be parsed from a string. This API is abstract and implemented by parsers for various IR formats. As an abstract interface many "attributes" must be accessed through accessor methods due to different storage methods of various IR formats.

At a top level, the wtk::IRTree<Number_T> is the root of an abstract syntax tree for a relation in the SIEVE IR. The wtk::DirectiveList<Number_T> defines scope block within the AST and other structs such as wtk::BinaryGate defining individual directives.

Pointer members provided by the IR Tree API may be expected to be nonnull, taking the lifetime of the parser which provided a top-level wtk::IRTree<Number_T>*. However, as defined by the parser, the wtk::IRTree<Number_T>* may itself be null. The parser retains ownership of all objects from this API, the caller may not free(…​) them.

template<typename Number_T> struct IRTree

The wtk::IRTree<Number_T> struct is the root of an IR syntax tree. The encapsulates both a list of named functions and the top-level scope of an IR relation.

size_t size()

This method indicates how many named function declarations are defined by this relation. It is an integer greater than or equal to 0.

virtual size_t size() = 0;

wtk::FunctionDeclare<Number_T>* functionDeclare(size_t n)

Retrieve a named function declaration by index. n must be between 0 (inclusive) and this→size() (exclusive) or else undefined behavior occurs. It returns a nonnull wtk::FunctionDeclare<Number_T>*.

virtual wtk::FunctionDeclare<Number_T>* functionDeclare(size_t n) = 0;

wtk::DirectiveList<Number_T>* body()

Retrieve the body of the relation. It returns a nonnull wtk::DirectiveList<Number_T>*.

virtual wtk::DirectiveList<Number_T>* body() = 0;

size_t lineNum()

Returns the line number at which the IRTree begins. It may be unsupported by the parser (for example line numbering is nonsensical in a binary format), in which case 0 is always returned.

virtual size_t lineNum();

template<typename Number_T> struct DirectiveList

The wtk::DirectiveList<Number_T> is a list type for directives. Since directives must be differentiated, each index of the list has a tag indicating a type, through which the element must be retrieved.

size_t size()

Indicates the number of elements in the list.

virtual size_t size() = 0;

enum Type

This enumerates the various types which an element may take.

wtk::DirectiveList<Number_T>::BINARY_GATE

corresponds to wtk::BinaryGate and this→binaryGate(n).

wtk::DirectiveList<Number_T>::UNARY_GATE

corresponds to wtk::UnaryGate and this→unaryGate(n).

wtk::DirectiveList<Number_T>::BINARY_CONST_GATE

corresponds to wtk::BinaryConstGate<Number_T> and this→binaryConstGate(n).

wtk::DirectiveList<Number_T>::INPUT

corresponds to wtk::Input and this→input(n).

wtk::DirectiveList<Number_T>::ASSIGN

corresponds to wtk::Assign<Number_T> and this→assign(n).

wtk::DirectiveList<Number_T>::ASSERT_ZERO

corresponds to a wtk::Terminal when used for the @assert_zero gate and this→assertZero(n).

wtk::DirectiveList<Number_T>::DELETE_SINGLE

corresponds to a wtk::Terminal when used for a @delete directive and this→deleteSingle(n).

wtk::DirectiveList<Number_T>::DELETE_RANGE

corresponds to an wtk::WireRange when used for a @delete directive and this→deleteRange(n).

wtk::DirectiveList<Number_T>::FUNCTION_INVOKE

corresponds to wtk::FunctionInvoke and this→functionInvoke(n).

wtk::DirectiveList<Number_T>::ANON_FUNCTION

corresponds to wtk::AnonFunction<Number_T> and this→anonFunction(n).

wtk::DirectiveList<Number_T>::FOR_LOOP

corresponds to wtk::ForLoop<Number_T> and this→forLoop(n).

wtk::DirectiveList<Number_T>::SWITCH_STATEMENT

corresponds to wtk::SwitchStatement<Number_T> and this→switchStatement(n).

wtk::DirectiveList<Number_T>::Type type(size_t n)

Returns the type of the nth element in this list. n must be in the range n >= 0 && n < this→size() otherwise undefined behavior occurs.

virtual Type type(size_t n) = 0;

wtk::BinaryGate* binaryGate(size_t n)

Returns the nth element as a wtk::BinaryGate type. n must be in the range n >= 0 && n < this→size() and n must have the type this→type(n) == wtk::DirectiveList<Number_T>::BINARY_GATE otherwise undefined behavior occurs.

virtual wtk::BinaryGate* binaryGate(size_t n) = 0;

wtk::UnaryGate* unaryGate(size_t n)

Returns the nth element as a wtk::UnaryGate type. n must be in the range n >= 0 && n < this→size() and n must have the type this→type(n) == wtk::DirectiveList<Number_T>::UNARY_GATE otherwise undefined behavior occurs.

virtual wtk::UnaryGate* unaryGate(size_t n) = 0;

wtk::BinaryConstGate<Number_T>* binaryConstGate(size_t n)

Returns the nth element as a wtk::BinaryConstGate<Number_T> type. n must be in the range n >= 0 && n < this→size() and n must have the type this→type(n) == wtk::DirectiveList<Number_T>::BINARY_CONST_GATE otherwise undefined behavior occurs.

virtual wtk::BinaryConstGate<Number_T>* binaryConstGate(size_t n) = 0;

wtk::Input* input(size_t n)

Returns the nth element as a wtk::Input type. n must be in the range n >= 0 && n < this→size() and n must have the type this→type(n) == wtk::DirectiveList<Number_T>::INPUT otherwise undefined behavior occurs.

virtual wtk::Input* input(size_t n) = 0;

wtk::Assign<Number_T>* assign(size_t n)

Returns the nth element as a wtk::Assign<Number_T> type. n must be in the range n >= 0 && n < this→size() and n must have the type this→type(n) == wtk::DirectiveList<Number_T>::ASSIGN otherwise undefined behavior occurs.

virtual wtk::Assign<Number_T>* assign(size_t n) = 0;

wtk::Terminal* assertZero(size_t n)

Returns the nth element as a wtk::Terminal type for the purpose of an @assert_zero gate. n must be in the range n >= 0 && n < this→size() and n must have the type this→type(n) == wtk::DirectiveList<Number_T>::ASSERT_ZERO otherwise undefined behavior occurs.

virtual wtk::Terminal* assertZero(size_t n) = 0;

wtk::Terminal* deleteSingle(size_t n)

Returns the nth element as a wtk::Terminal type for the purpose of a @delete gate. n must be in the range n >= 0 && n < this→size() and n must have the type this→type(n) == wtk::DirectiveList<Number_T>::DELETE_SINGLE otherwise undefined behavior occurs.

virtual wtk::Terminal* deleteSingle(size_t n) = 0;

wtk::WireRange* deleteRange(size_t n)

Returns the nth element as a wtk::WireRange type for the purpose of a @delete gate. n must be in the range n >= 0 && n < this→size() and n must have the type this→type(n) == wtk::DirectiveList<Number_T>::DELETE_RANGE otherwise undefined behavior occurs.

virtual wtk::WireRange* deleteRange(size_t n) = 0;

wtk::FunctionInvoke* functionInvoke(size_t n)

Returns the nth element as a wtk::FunctionInvoke type. n must be in the range n >= 0 && n < this→size() and n must have the type this→type(n) == wtk::DirectiveList<Number_T>::FUNCTION_INVOKE otherwise undefined behavior occurs.

virtual wtk::FunctionInvoke* functionInvoke(size_t n) = 0;

wtk::AnonFunction<Number_T>* anonFunction(size_t n)

Returns the nth element as a wtk::AnonFunction<Number_T> type. n must be in the range n >= 0 && n < this→size() and n must have the type this→type(n) == wtk::DirectiveList<Number_T>::ANON_FUNCTION otherwise undefined behavior occurs.

virtual wtk::AnonFunction<Number_T>* anonFunction(size_t n) = 0;

wtk::ForLoop<Number_T>* forLoop(size_t n)

Returns the nth element as a wtk::ForLoop<Number_T> type. n must be in the range n >= 0 && n < this→size() and n must have the type this→type(n) == wtk::DirectiveList<Number_T>::FOR_LOOP otherwise undefined behavior occurs.

virtual wtk::ForLoop<Number_T>* forLoop(size_t n) = 0;

wtk::SwitchStatement<Number_T>* switchStatement(size_t n)

Returns the nth element as a wtk::SwitchStatement<Number_T> type. n must be in the range n >= 0 && n < this→size() and n must have the type this→type(n) == wtk::DirectiveList<Number_T>::SWITCH_STATEMENT otherwise undefined behavior occurs.

virtual wtk::SwitchStatement<Number_T>* switchStatement(size_t n) = 0;

size_t lineNum()

Returns the line number at which the DirectiveList begins. It may be unsupported by the parser (for example line numbering is nonsensical in a binary format), in which case 0 is always returned.

virtual size_t lineNum();

struct BinaryGate

This represents a binary gate in the IR. Binary refers to the two-input wires of this gate, not numeric representation. It has methods for left and right input wires as well as the output wire. The specific gate type is the Calculation enum.

enum Calculation

Indicates what calculation this gate performs.

wtk::BinaryGate::AND

@and

wtk::BinaryGate::XOR

@xor

wtk::BinaryGate::ADD

@add

wtk::BinaryGate::MUL

@mul

wtk::BinaryGate::Calculation calculation()

returns which calculation the binary gate performs.

virtual Calculation calculation() = 0;

wtk::index_t outputWire()

Returns the gate’s output wire.

virtual wtk::index_t outputWire() = 0;

wtk::index_t leftWire()

Returns the gate’s left input wire.

virtual wtk::index_t leftWire() = 0;

wtk::index_t rightWire()

Returns the gate’s right input wire.

virtual wtk::index_t rightWire() = 0;

size_t lineNum()

Returns the line number at which the binary gate begins. It may be unsupported by the parser (for example line numbering is nonsensical in a binary format), in which case 0 is always returned.

virtual size_t lineNum();

struct UnaryGate

This represents a unary gate in the IR. Unary refers to the single input wire of this gate, not numeric representation. It has methods for the input wire as well as the output wire. The specific gate type is the Calculation enum.

enum Calculation

Indicates what calculation this gate performs.

wtk::UnaryGate::NOT

$0 ← @not($1)

wtk::UnaryGate::COPY

$0 ← $1

wtk::UnaryGate::Calculation calculation()

returns which calculation the unary gate performs.

virtual Calculation calculation() = 0;

wtk::index_t outputWire()

Returns the gate’s output wire.

virtual wtk::index_t outputWire() = 0;

wtk::index_t rightWire()

Returns the gate’s input wire.

virtual wtk::index_t inputWire() = 0;

size_t lineNum()

Returns the line number at which the unary gate begins. It may be unsupported by the parser (for example line numbering is nonsensical in a binary format), in which case 0 is always returned.

virtual size_t lineNum();

template<typename Number_T> struct BinaryConstGate

This represents a binary constant gate in the IR. Binary refers to the input wire and input constant of this gate, not numeric representation. It has methods for left input wire and right input constant as well as the output wire. The specific gate type is the Calculation enum.

enum Calculation

Indicates what calculation this gate performs.

wtk::BinaryConstGate<Number_T>::ADDC

@addc

wtk::BinaryConstGate<Number_T>::MULC

@mulc

wtk::BinaryConstGate<Number_T>::Calculation calculation()

returns which calculation the binary gate performs.

virtual Calculation calculation() = 0;

wtk::index_t outputWire()

Returns the gate’s output wire.

virtual wtk::index_t outputWire() = 0;

wtk::index_t leftWire()

Returns the gate’s left input wire.

virtual wtk::index_t leftWire() = 0;

wtk::index_t rightWire()

Returns the gate’s right input constant.

virtual Number_T rightValue() = 0;

size_t lineNum()

Returns the line number at which the binary constant gate begins. It may be unsupported by the parser (for example line numbering is nonsensical in a binary format), in which case 0 is always returned.

virtual size_t lineNum();

struct Input

Represents an input directive (either @instance or @short_witness). the Stream enumeration indicates from which stream to consume.

enum Stream

An enumeration of the IR stream resources.

wtk::Input::INSTANCE

@instance

wtk::Input::SHORT_WITNESS

@short_witness

wtk::Input::Stream stream()

Returns the stream from which this directive is to consume.

virtual Stream stream() = 0;

wtk::index_t outputWire()

Returns the stream consumption’s output wire.

virtual wtk::index_t outputWire() = 0;

size_t lineNum()

Returns the line number at which the input directive begins. It may be unsupported by the parser (for example line numbering is nonsensical in a binary format), in which case 0 is always returned.

virtual size_t lineNum();

template<typename Number_T> struct Assign

A directive that assigns a constant value to an output wire.

wtk::index_t outputWire()

Returns the assign directive’s output wire.

virtual wtk::index_t outputWire() = 0;

Number_T constValue()

Returns the assign directive’s constant input value.

virtual Number_T constValue() = 0;

size_t lineNum()

Returns the line number at which the assign directive begins. It may be unsupported by the parser (for example line numbering is nonsensical in a binary format), in which case 0 is always returned.

virtual size_t lineNum();

struct Terminal

Represents a directive with just a single input wire. Its name is derived from the fact that it has no output wires, thus "terminating" some sequence of gates. It is used by the directives @assert_zero and @delete (for a single input wire), although they are distinguished by wtk::DirectiveList<Number_T>::Type rather than an enumeration within struct Terminal.

wtk::index_t wire()

Returns the terminal’s single input wire.

virtual wtk::index_t wire() = 0;

size_t lineNum()

Returns the line number at which the terminal begins. It may be unsupported by the parser (for example line numbering is nonsensical in a binary format), in which case 0 is always returned.

virtual size_t lineNum();

struct WireRange

Represents a range of wires in the IR. It is used for the range form of the @delete directive, as well as a component of the wtk::WireList.

wtk::index_t first()

Returns the first wire in the range (consider it inclusive).

virtual wtk::index_t first() = 0;

wtk::index_t last()

Returns the last wire in the range (consider it inclusive).

virtual wtk::index_t last() = 0;

size_t lineNum()

Returns the line number at which the wire range begins. It may be unsupported by the parser (for example line numbering is nonsensical in a binary format), in which case 0 is always returned.

virtual size_t lineNum();

struct WireList

The IR uses wire lists for holding parameters and returns to function-gates. These lists are "ranged" such that the elements of the list do not correspond to the length of the list. Some elements are individual wires, whereas other elements are ranges of wires. Element type is given by the Type enumeration.

size_t size()

Indicates how many elements are in the list (does not necessarily correspond to wire count).

virtual size_t size() = 0;

enum Type

Indicates if an element a single or a range element.

  • wtk::WireList::SINGLE

  • wtk::WireList::RANGE

wtk::WireList::Type type(size_t n)

Returns the type of the nth element. n must be in the range n >= 0 && n < this→size() or else undefined behavior occurs.

virtual Type type(size_t n) = 0;

wtk::index_t single(size_t n)

Returns the nth element in the list as a single element. n must be in the range n >= 0 && n < this→size() and n must have the type this→type(n) == wtk::WireList::SINGLE or else undefined behavior occurs.

virtual wtk::index_t single(size_t n) = 0;

wtk::WireRange* range(size_t n)

Returns the nth element in the list as a range element. n must be in the range n >= 0 && n < this→size() and n must have the type this→type(n) == wtk::WireList::RANGE or else undefined behavior occurs.

virtual wtk::WireRange* range(size_t n) = 0;

size_t lineNum()

Returns the line number at which the wire list begins. It may be unsupported by the parser (for example line numbering is nonsensical in a binary format), in which case 0 is always returned.

virtual size_t lineNum();

template<typename Number_T> struct FunctionDeclare

This wtk::FunctionDeclare<Number_T> is the definition of a named function-gate. It pairs with wtk::FunctionInvoke for invocation. They should be matched to eachother by a name (as a char*).

char const* name()

Returns the name of the function.

virtual char const* name() = 0;

wtk::index_t outputCount()

Returns the number of output wires this function gate expects.

virtual wtk::index_t outputCount() = 0;

wtk::index_t inputCount()

Returns the number of input wires this function gate expects.

virtual wtk::index_t inputCount() = 0;

wtk::index_t instanceCount()

Returns the number of instance values this function gate will consume.

virtual wtk::index_t instanceCount() = 0;

wtk::index_t shortWitnessCount()

Returns the number of short witness values this function gate will consume.

virtual wtk::index_t shortWitnessCount() = 0;

wtk::DirectiveList<Number_T>* body()

returns the body of the function gate.

virtual DirectiveList<Number_T>* body() = 0;

size_t lineNum()

Returns the line number at which the function declaration begins. It may be unsupported by the parser (for example line numbering is nonsensical in a binary format), in which case 0 is always returned.

virtual size_t lineNum();

struct FunctionInvoke

The wtk:FunctionInvoke invokes a function gate, carrying a name which should match with the name of a wtk::FunctionDeclare<Number_T>.

char const* name()

Returns the name of the function gate.

virtual char const* name() = 0;

wtk::WireList* outputList()

Returns a wtk::WireList for the output wires of this invocation.

virtual wtk::WireList* outputList() = 0;

wtk::WireList* inputList()

Returns a wtk::WireList for the input wires of this invocation.

virtual wtk::WireList* inputList() = 0;

size_t lineNum()

Returns the line number at which the function invocation begins. It may be unsupported by the parser (for example line numbering is nonsensical in a binary format), in which case 0 is always returned.

virtual size_t lineNum();

template<typename Number_T> struct AnonFunction

The wtk::AnonFunction<Number_T> is the simultaneous declaration and invocation of an anonymous function-gate. It mirrors the structure of both wtk::FunctionDeclare<Number_T> and wtk::FunctionInvoke, although without certain attributes such as name().

wtk::WireList* outputList()

Returns a wtk::WireList for the output wires of this anonymous function.

virtual wtk::WireList* outputList() = 0;

wtk::WireList* inputList()

Returns a wtk::WireList for the input wires of this anonymous function.

virtual wtk::WireList* inputList() = 0;

wtk::index_t instanceCount()

Returns the number of instance values this anonymous function gate will consume.

virtual wtk::index_t instanceCount() = 0;

wtk::index_t shortWitnessCount()

Returns the number of short witness values this anonymous function gate will consume.

virtual wtk::index_t shortWitnessCount() = 0;

wtk::DirectiveList<Number_T>* body()

returns the body of the anonymous function gate.

virtual DirectiveList<Number_T>* body() = 0;

size_t lineNum()

Returns the line number at which the anonymous function declaration begins. It may be unsupported by the parser (for example line numbering is nonsensical in a binary format), in which case 0 is always returned.

virtual size_t lineNum();

struct IterExpr

The wtk::IterExpr takes the place of wtk::index_t in input and output lists of For Loop bodies. Instead of representing an exact wire-index, these expressions evaluate to a wire-index, allowing the loop to traverse ranges of wires.

All iterator expressions are carried out over wtk::index_t. The expressions are a recursive datatype, with base cases for numeric literals and loop-iterators. Recursive cases exist for addition, subtraction, multiplication, and division by a constant. The expression type is given by enum Type.

enum Type

This enumerates the various types of expressions.

wtk::IterExpr::LITERAL

A numeric literal

wtk::IterExpr::ITERATOR

A reference to a loop iterator

wtk::IterExpr::ADD

Addition expression of two sub-expressions

wtk::IterExpr::SUB

Subtraction expression of two sub-expressions

wtk::IterExpr::MUL

Multiplition expression of two sub-expressions

wtk::IterExpr::DIV

Division expression of one sub-expression and a constant divisor

wtk:IterExpr::Type type()

Returns the type of this expression.

virtual Type type() = 0;

wtk::index_t literal()

Returns this literal expression or the right-hand-side of this division expression as a wtk::index_t. If the following precondition isn’t met, then undefined behavior occurs (see also this→type() and enum Type).

this->type() == wtk::IterExpr::LITERAL
  || this->type() == wtk::IterExpr::DIV
virtual wtk::index_t literal() = 0;

char const* name()

Returns this loop-iterator expression as a char*. If the following precondition isn’t met, then undefined behavior occurs (see also this→type() and enum Type).

this->type() == wtk::IterExpr::ITERATOR
virtual wtk::index_t literal() = 0;

wtk::IterExpr* lhs()

Returns the left-hand-side of this expression. If the following precondition isn’t met, then undefined behavior occurs (see also this→type() and enum Type).

this->type() == wtk::IterExpr::ADD
  || this->type() == wtk::IterExpr::SUB
  || this->type() == wtk::IterExpr::MUL
  || this->type() == wtk::IterExpr::DIV
virtual IterExpr* lhs() = 0;

wtk::IterExpr* lhs()

Returns the right-hand-side of this expression. If the following precondition isn’t met, then undefined behavior occurs (see also this→type() and enum Type).

this->type() == wtk::IterExpr::ADD
  || this->type() == wtk::IterExpr::SUB
  || this->type() == wtk::IterExpr::MUL
virtual IterExpr* lhs() = 0;

size_t lineNum()

Returns the line number at which the iterator expression begins. It may be unsupported by the parser (for example line numbering is nonsensical in a binary format), in which case 0 is always returned.

virtual size_t lineNum();

struct IterExprWireRange

Represents a range of iterator expressions, mirroring the form of wtk::WireRange. It is used as a component of the wtk::IterExprWireList (which itself mirrors wtk::WireList).

wtk::IterExpr* first()

Returns a wtk::IterExpr for the first wire in the range (consider it inclusive).

virtual wtk::IterExpr* first() = 0;

wtk::IterExpr* last()

Returns a wtk::IterExpr for the last wire in the range (consider it inclusive).

virtual wtk::IterExpr* last() = 0;

size_t lineNum()

Returns the line number at which the wire range begins. It may be unsupported by the parser (for example line numbering is nonsensical in a binary format), in which case 0 is always returned.

virtual size_t lineNum();

struct IterExprWireList

Represents a list of iterator expressions, mirroring the form of wtk::WireList. For for-loop bodies, the input and output wire lists use these to enable traversal based on the loop iterator.

These lists are "ranged" such that the elements of the list do not correspond to the length of the list. Some elements are individual expressions, whereas other elements are ranges of expressions. Element type is given by the Type enumeration.

size_t size()

Indicates how many elements are in the list (does not necessarily correspond to wire count).

virtual size_t size() = 0;

enum Type

Indicates if an element a single or a range element.

  • wtk::IterExprWireList::SINGLE

  • wtk::IterExprWireList::RANGE

wtk::IterExprWireList::Type type(size_t n)

Returns the type of the nth element. n must be in the range n >= 0 && n < this→size() or else undefined behavior occurs.

virtual Type type(size_t n) = 0;

wtk::ItereExpr* single(size_t n)

Returns the nth element in the list as a single element. n must be in the range n >= 0 && n < this→size() and n must have the type this→type(n) == wtk::IterExprWireList::SINGLE or else undefined behavior occurs.

virtual wtk::IterExpr* single(size_t n) = 0;

wtk::IterExprWireRange* range(size_t n)

Returns the nth element in the list as a range element. n must be in the range n >= 0 && n < this→size() and n must have the type this→type(n) == wtk::IterExprWireList::RANGE or else undefined behavior occurs.

virtual wtk::WireRange* range(size_t n) = 0;

size_t lineNum()

Returns the line number at which the wire list begins. It may be unsupported by the parser (for example line numbering is nonsensical in a binary format), in which case 0 is always returned.

virtual size_t lineNum();

struct IterExprFunctionInvoke

The wtk:IterExprFunctionInvoke invokes a function gate as the body of a for-loop, carrying a name which should match with the name of a wtk::FunctionDeclare<Number_T>. It mirrors wtk::FunctionInvoke replacing input and output lists with wtk::IterExprWireList.

char const* name()

Returns the name of the function gate.

virtual char const* name() = 0;

wtk::IterExprWireList* outputList()

Returns a wtk::IterExprWireList for the output wires of this invocation.

virtual wtk::IterExprWireList* outputList() = 0;

wtk::IterExprWireList* inputList()

Returns a wtk::IterExprWireList for the input wires of this invocation.

virtual wtk::IterExprWireList* inputList() = 0;

size_t lineNum()

Returns the line number at which the function invocation begins. It may be unsupported by the parser (for example line numbering is nonsensical in a binary format), in which case 0 is always returned.

virtual size_t lineNum();

template<typename Number_T> struct IterExprAnonFunction

The wtk::IterExprAnonFunction<Number_T> is the simultaneous declaration and invocation of an anonymous function-gate as the body of a for-loop. It mirrors the structure of both wtk::FunctionDeclare<Number_T> and wtk::FunctionInvoke, although without certain attributes such as name(), and with the input and output lists replaced by wtk::IterExprWireList

wtk::IterExprWireList* outputList()

Returns a wtk::IterExprWireList for the output wires of this anonymous function.

virtual wtk::IterExprWireList* outputList() = 0;

wtk::IterExprWireList* inputList()

Returns a wtk::IterExprWireList for the input wires of this anonymous function.

virtual wtk::IterExprWireList* inputList() = 0;

wtk::index_t instanceCount()

Returns the number of instance values this anonymous function gate will consume.

virtual wtk::index_t instanceCount() = 0;

wtk::index_t shortWitnessCount()

Returns the number of short witness values this anonymous function gate will consume.

virtual wtk::index_t shortWitnessCount() = 0;

wtk::DirectiveList<Number_T>* body()

returns the body of the anonymous function gate.

virtual DirectiveList<Number_T>* body() = 0;

size_t lineNum()

Returns the line number at which the anonymous function declaration begins. It may be unsupported by the parser (for example line numbering is nonsensical in a binary format), in which case 0 is always returned.

virtual size_t lineNum();

template<typename Number_T> struct ForLoop

This represents a for-loop directive in the IR.

wtk::WireList* outputList()

Returns the output list of the entire for-loop (not to be confused with the output list of one iteration of the for-loop) as a wtk::WireList.

virtual WireList* outputList() = 0;

char const* iterName()

Returns the name of the loop’s iterator.

virtual char const* iterName() = 0;

wtk::index_t first()

Returns the first iteration of the loop (inclusive).

virtual wtk::index_t first() = 0;

wtk::index_t last()

Returns the last iteration of the loop (inclusive).

virtual wtk::index_t last() = 0;

enum BodyType

An enumeration to indicate whether the loop’s body is named or anonymous.

wtk::ForLoop<Number_T>::INVOKE

Named body (use this→invokeBody() and wtk::IterExprFunctionInvoke).

wtk::ForLoop<Number_T>::ANONYMOUS

Anonymous body (use this→anonymousBody() and wtk::IterExprAnonFunction<Number_T>).

BodyType bodyType()

Returns the body type of this for-loop.

virtual BodyType bodyType() = 0;

wtk::IterExprFunctionInvoke* invokeBody()

Returns the body of this for-loop as an wtk::IterExprFunctionInvoke. If the loop’s body type is not this→bodyType() == wtk::ForLoop<Number_T>::INVOKE, then undefined behavior occurs.

virtual IterExprFunctionInvoke* invokeBody() = 0;

wtk::IterExprAnonFunction<Number_T>* anonymousBody()

Returns the body of this for-loop as an wtk::IterExprAnonFunction<Number_T>. If the loop’s body type is not this→bodyType() == wtk::ForLoop<Number_T>::ANONYMOUS, then undefined behavior occurs.

virtual IterExprAnonFunction<Number_T>* anonymousBody() = 0;

size_t lineNum()

Returns the line number at which the for-loop begins. It may be unsupported by the parser (for example line numbering is nonsensical in a binary format), in which case 0 is always returned.

virtual size_t lineNum();

struct CaseFunctionInvoke

The wtk:CaseFunctionInvoke invokes a function gate as the body of a switch-case. It mirrors the form of wtk::FunctionInvoke, however, as the body of a switch-case, it is missing outputList().

char const* name()

Returns the name of the function gate.

virtual char const* name() = 0;

wtk::WireList* inputList()

Returns a wtk::WireList for the input wires of this invocation.

virtual wtk::WireList* inputList() = 0;

size_t lineNum()

Returns the line number at which the function invocation begins. It may be unsupported by the parser (for example line numbering is nonsensical in a binary format), in which case 0 is always returned.

virtual size_t lineNum();

template<typename Number_T> struct CaseAnonFunction

The wtk:CaseAnonFunction is the simultaneous declaration and invocation of an anonymous function-gate as the body of a switch-case. It mirrors the structure of both wtk::FunctionDeclare<Number_T> and wtk::FunctionInvoke, although without certain attributes such as name() or, as the body of a switch-case, outputList().

wtk::WireList* inputList()

Returns a wtk::WireList for the input wires of this anonymous function.

virtual wtk::WireList* inputList() = 0;

wtk::index_t instanceCount()

Returns the number of instance values this anonymous function gate will consume.

virtual wtk::index_t instanceCount() = 0;

wtk::index_t shortWitnessCount()

Returns the number of short witness values this anonymous function gate will consume.

virtual wtk::index_t shortWitnessCount() = 0;

wtk::DirectiveList<Number_T>* body()

returns the body of the anonymous function gate.

virtual DirectiveList<Number_T>* body() = 0;

size_t lineNum()

Returns the line number at which the anonymous function declaration begins. It may be unsupported by the parser (for example line numbering is nonsensical in a binary format), in which case 0 is always returned.

virtual size_t lineNum();

template<typename Number_T> struct CaseBlock

This represents a case within a switch-statement.

Number_T match()

Returns the field-literal which is matched against the switch-statement’s condition() wire to indicate if this case is active.

virtual Number_T match() = 0;

enum BodyType

An enumeration to indicate whether the case’s body is named or anonymous.

wtk::CaseBlock<Number_T>::INVOKE

Named body (use this→invokeBody() and wtk::CaseFunctionInvoke).

wtk::CaseBlock<Number_T>::ANONYMOUS

Anonymous body (use this→anonymousBody() and wtk::CaseAnonFunction<Number_T>).

BodyType bodyType()

Returns the body type of this case block.

virtual BodyType bodyType() = 0;

wtk::CaseFunctionInvoke* invokeBody()

Returns the body of this case-block as a wtk::CaseFunctionInvoke. If the case’s body type is not this→bodyType() == wtk::CaseBlock<Number_T>::INVOKE, then undefined behavior occurs.

virtual CaseFunctionInvoke* invokeBody() = 0;

wtk::CaseAnonFunction<Number_T>* anonymousBody()

Returns the body of this case-block as a wtk::CaseAnonFunction<Number_T>. If the case’s body type is not this→bodyType() == wtk::CaseBlock<Number_T>::ANONYMOUS, then undefined behavior occurs.

virtual CaseAnonFunction<Number_T>* anonymousBody() = 0;

size_t lineNum()

Returns the line number at which the case-block begins. It may be unsupported by the parser (for example line numbering is nonsensical in a binary format), in which case 0 is always returned.

virtual size_t lineNum();

template<typename Number_T> struct SwitchStatement

This represents a switch-statement directive in the IR.

wtk::WireList* outputList()

Returns the switch-statement’s output list as a wtk::WireList.

virtual wtk::WireList* outputList() = 0;

wtk::index_t condition()

Returns the condition (or "selector") wire of this switch-statement.

virtual wtk::index_t condition() = 0;

size_t size()

Returns the number of cases in the switch-statement.

virtual size_t size() = 0;

wtk::CaseBlock<Number_T>* caseBlock(size_t n)

Returns the nth wtk::CaseBlock<Number_T> in this switch-statement. If n is outside of the range n >= 0 && n < this→size(), then undefined behavior occurs.

virtual CaseBlock<Number_T>* caseBlock(size_t n) = 0;

size_t lineNum()

Returns the line number at which the switch-statement begins. It may be unsupported by the parser (for example line numbering is nonsensical in a binary format), in which case 0 is always returned.

virtual size_t lineNum();