|
| Node (const Rule *r=nullptr, double _lp=0.0, bool cr=true) |
|
| Node (const Node &n) |
|
| Node (Node &&n) |
|
virtual | ~Node () |
|
void | assign (Node &n) |
| Assign will set everything to n BUT it will not copy the parent pointer etc since we're assuming this node is staying in the same place. More...
|
|
void | assign (Node &&n) |
|
const std::string & | format () const |
|
nonterminal_t | type (const size_t i) const |
|
void | set_child (const size_t i, Node &n) |
|
void | set_child (const size_t i, Node &&n) |
|
void | operator= (const Node &n) |
|
void | operator= (Node &&n) |
|
auto | operator (const Node &other) const |
|
nonterminal_t | nt () const |
|
bool | is_null () const |
|
virtual size_t | count_nonnull () const |
|
virtual bool | is_complete () const |
|
virtual std::string | string (bool usedot=true) const override |
|
virtual std::string | parseable () const |
|
template<typename VirtualMachineState_t , typename Grammar_t > |
int | linearize (Program< VirtualMachineState_t > &program) const |
|
virtual bool | operator== (const Node &n) const override |
|
virtual size_t | hash (size_t depth=0) const |
|
virtual void | fullprint (size_t tab=0) |
| A function to print out everything, for debugging purposes. More...
|
|
| BaseNode (size_t n=0, Node *p=nullptr, size_t i=0) |
| Constructor of basenode – sizes children to n. More...
|
|
| BaseNode (const Node &n) |
|
| BaseNode (Node &&n) |
|
void | operator= (const Node &t) |
|
void | operator= (const Node &&t) |
|
void | make_root () |
| Make a node root – just nulls the parent. More...
|
|
virtual | ~BaseNode () |
|
virtual std::string | my_string () const |
|
NodeIterator | begin () const |
|
NodeIterator | end () const |
|
virtual bool | operator!= (const Node &n) const |
|
void | reserve_children (const size_t n) |
|
decltype(children) & | get_children () |
|
decltype(children) const & | get_children () const |
|
Node & | child (const size_t i) |
|
const Node & | child (const size_t i) const |
|
void | fill (size_t n, Args... args) |
|
size_t | nchildren () const |
|
Node * | left_descend () const |
|
size_t | depth () const |
|
void | fix_child_info () |
|
void | check_child_info () const |
|
Node & | operator[] (const size_t i) |
|
const Node & | operator[] (const size_t i) const |
|
void | set_child (const size_t i, Node &n) |
|
void | set_child (const size_t i, Node &&n) |
|
void | push_back (Node &n) |
|
void | push_back (Node &&n) |
|
virtual bool | is_root () const |
| Am I a root node? I am if my parent is nullptr. More...
|
|
Node * | root () |
| Find the root of this node by walking up the tree. More...
|
|
Node * | get_via (std::function< bool(Node &)> &f) |
| Return a pointer to the first node satisfying predicate f, in standard traversal; nullptr otherwise. More...
|
|
virtual size_t | count () const |
| How many nodes total are below me? More...
|
|
virtual size_t | count (const Node &n) const |
| How many nodes below me are equal to n? More...
|
|
virtual bool | is_terminal () const |
| Am I a terminal? I am if I have no children. More...
|
|
virtual size_t | count_terminals () const |
|
virtual Node * | get_nth (int n, std::function< int(const Node &)> &f) |
|
virtual Node * | get_nth (int n) |
|
T | sum (std::function< T(const Node &)> &f) const |
|
T | sum (T(*f)(const Node &)) const |
|
bool | all (std::function< bool(const Node &)> &f) const |
|
void | map (const std::function< void(Node &)> &f) |
|
void | show (size_t t=0) const |
|
template<typename VirtualMachineState_t , typename Grammar_t >
int Node::linearize |
( |
Program< VirtualMachineState_t > & |
program | ) |
const |
|
inline |
convert tree to a linear sequence of operations. To do this, we first linearize the kids, leaving their values as the top on the stack then we compute our value, remove our kids' values to clean up the stack, and push on our return the only fanciness is for if/and/or: here we will use the following layout <TOP of="" stack>=""> <bool> op_IF(xsize) X-branch JUMP(ysize) Y-branch
NOTE: Inline here lets gcc inline a few recursions of this function, which ends up speeding us up a bit (otherwise recursive inlining only happens at -O3) This optimization is why we do set max-inline-insns-recursive in Fleet.mk
- Parameters
-
program | to place our computation in |
- Returns
- This returns the size of the program that was pushed onto ops. This is useful for saving us lots of calls to program_size, which ends up being an important optimization.