Joos1W Compiler Framework
All Classes Functions Typedefs Pages
ast::ExprNodeList Class Referencefinal

A list of ExprNodes* that can be iterated and concatenated. More...

#include <ExprNode.h>

Public Member Functions

 ExprNodeList (ExprNode *node)
 
void push_back (ExprNode *node)
 Pushes a node to the back of the list. More...
 
void concat (ExprNodeList &&other)
 Concatenates another list to the end of this list. More...
 
void concat (ExprNodeList &other)
 Concatenates another list to the end of this list. The other list will be invalidated and empty after this operation. More...
 
auto size () const
 Returns the number of nodes in the list.
 
utils::Generator< ExprNode const * > nodes () const
 Returns a generator that yields each node in the list.
 
utils::Generator< ExprNode * > mut_nodes () const
 Non-const version of nodes()
 
ExprNodemut_head () const
 
ExprNode const * tail () const
 
void dump () const
 
std::ostream & print (std::ostream &) const
 

Public Attributes

bool isBracketed = false
 

Detailed Description

A list of ExprNodes* that can be iterated and concatenated.

Definition at line 60 of file ExprNode.h.

Member Function Documentation

◆ concat() [1/2]

void ast::ExprNodeList::concat ( ExprNodeList &&  other)
inline

Concatenates another list to the end of this list.

Parameters
otherThe list to concatenate (rvalue reference)

Definition at line 90 of file ExprNode.h.

90  {
91  if(other.size_ == 0) return;
92  if(head_ == nullptr) {
93  head_ = other.head_;
94  tail_ = other.tail_;
95  } else {
96  tail_->setNext(other.head_);
97  tail_ = other.tail_;
98  }
99  size_ += other.size_;
100  check_invariants();
101  }

◆ concat() [2/2]

void ast::ExprNodeList::concat ( ExprNodeList other)
inline

Concatenates another list to the end of this list. The other list will be invalidated and empty after this operation.

Parameters
otherThe list to concatenate

Definition at line 108 of file ExprNode.h.

108  {
109  concat(std::move(other));
110  other.head_ = nullptr;
111  other.tail_ = nullptr;
112  other.size_ = 0;
113  }
void concat(ExprNodeList &&other)
Concatenates another list to the end of this list.
Definition: ExprNode.h:90

◆ push_back()

void ast::ExprNodeList::push_back ( ExprNode node)
inline

Pushes a node to the back of the list.

Parameters
nodeThe node to push

Definition at line 72 of file ExprNode.h.

72  {
73  if(node == nullptr) return;
74  if(head_ == nullptr) {
75  head_ = node;
76  tail_ = node;
77  } else {
78  tail_->setNext(node);
79  tail_ = node;
80  }
81  node->setNext(nullptr);
82  size_ += 1;
83  check_invariants();
84  }

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