LRDE Tiger Compiler  1.34a $Id: 7fef12e1f5fa43449d667a0eec1d837c40fc1202 $
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
tree::Tree Class Reference

#include <tree.hh>

Inheritance diagram for tree::Tree:
Collaboration diagram for tree::Tree:

Public Member Functions

 Tree ()
 A fresh node.
 Tree (const tree_list_type &children)
 A new node with these children.
virtual ~Tree ()
 Recursively destroy the children.
void child_push_back (const rTree &tree)
tree_list_typechildren_get ()
const tree_list_typechildren_get () const
rTree & child_get (int nth)
rTree child_get (int nth) const
rTree & left_get ()
rTree & right_get ()
void parent_get_assert () const
Treeparent_get ()
const Treeparent_get () const
void parent_set (Tree *parent)
void replace_by (const rTree &tree)
virtual std::ostream & tag_print (std::ostream &o) const =0
 Report on o the kind of this instruction.
virtual std::ostream & dump (std::ostream &o) const
 Report this instruction on o.
temp::Tempasm_get ()
void asm_set (const temp::Temp &temp)
void * state_get () const
void *& state_get ()
bool reducible_get () const
void reducible_set (bool b)

Protected Attributes

tree_list_type children_
 The arguments.
Treeparent_ = nullptr
 The Tree instruction this is a child from.
temp::Temptemp_ = nullptr
 The Temp for asm output.
void * state_ = nullptr
 The state for asm output.
bool reducible_ = true
 Tell if the tree is reducible.

Private Member Functions

void child_set (rTree &dst, const rTree &src)

Friends

std::ostream & operator<< (std::ostream &ostr, const Tree &tree)
 Print t on o.

Kinds of Tree nodes.

enum  kind_tree_type {
  const_kind, name_kind, temp_kind, binop_kind,
  mem_kind, call_kind, eseq_kind, move_kind,
  sxp_kind, jump_kind, cjump_kind, seq_kind,
  label_kind
}
 The kinds of Tree instuctions. More...
virtual kind_tree_type kind_get () const =0
 The kind of this instruction.

Member Enumeration Documentation

The kinds of Tree instuctions.

These flags are used to facilitate the pattern matching during instruction selection. This method is not very clean nevertheless this way is cleaner and more efficient than the use of dynamic_cast<>().

Enumerator:
const_kind 
name_kind 
temp_kind 
binop_kind 
mem_kind 
call_kind 
eseq_kind 
move_kind 
sxp_kind 
jump_kind 
cjump_kind 
seq_kind 
label_kind 

Constructor & Destructor Documentation

tree::Tree::Tree ( )
inline

A fresh node.

tree::Tree::Tree ( const tree_list_type children)
inline

A new node with these children.

tree::Tree::~Tree ( )
virtual

Recursively destroy the children.

References temp_.

Member Function Documentation

temp::Temp & tree::Tree::asm_get ( )
inline

References temp_.

void tree::Tree::asm_set ( const temp::Temp temp)
inline

References temp_.

rTree tree::Tree::child_get ( int  nth) const
inline

References children_, and postcondition.

void tree::Tree::child_set ( rTree &  dst,
const rTree &  src 
)
inlineprivate

Referenced by replace_by().

tree_list_type & tree::Tree::children_get ( )
inline
const tree_list_type & tree::Tree::children_get ( ) const
inline

References children_.

std::ostream & tree::Tree::dump ( std::ostream &  o) const
virtual

Report this instruction on o.

Reimplemented in tree::Seq, tree::Eseq, and tree::Call.

References children_, misc::decindent(), misc::incendl(), and tag_print().

Referenced by tree::operator<<().

virtual kind_tree_type tree::Tree::kind_get ( ) const
pure virtual
rTree & tree::Tree::left_get ( )
inline

References child_get().

Tree * tree::Tree::parent_get ( )
inline

References parent_.

const Tree * tree::Tree::parent_get ( ) const
inline

References parent_.

void tree::Tree::parent_get_assert ( ) const
void tree::Tree::parent_set ( Tree parent)
inline

References parent_.

bool tree::Tree::reducible_get ( ) const
inline

References reducible_.

void tree::Tree::reducible_set ( bool  b)
inline

References children_, and reducible_.

void tree::Tree::replace_by ( const rTree &  tree)
rTree & tree::Tree::right_get ( )
inline

References child_get().

void * tree::Tree::state_get ( ) const
inline

References state_.

void *& tree::Tree::state_get ( )
inline

References state_.

virtual std::ostream& tree::Tree::tag_print ( std::ostream &  o) const
pure virtual

Report on o the kind of this instruction.

Implemented in tree::Cjump, tree::Binop, tree::Seq, tree::Jump, tree::Eseq, tree::Move, tree::Mem, tree::Sxp, tree::Temp, tree::Call, tree::Label, tree::Name, and tree::Const.

Referenced by dump().

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  ostr,
const Tree tree 
)
friend

Print t on o.

Member Data Documentation

Tree* tree::Tree::parent_ = nullptr
protected

The Tree instruction this is a child from.

Referenced by parent_get(), parent_get_assert(), parent_set(), and replace_by().

bool tree::Tree::reducible_ = true
protected

Tell if the tree is reducible.

Referenced by reducible_get(), and reducible_set().

void* tree::Tree::state_ = nullptr
protected

The state for asm output.

Referenced by state_get().

temp::Temp* tree::Tree::temp_ = nullptr
protected

The Temp for asm output.

Referenced by asm_get(), asm_set(), and ~Tree().


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