LRDE Tiger Compiler  1.34a $Id: 7fef12e1f5fa43449d667a0eec1d837c40fc1202 $
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
temp::Identifier< Traits_ > Class Template Reference

Root for Named or anonymous (fresh) identifiers. More...

#include <identifier.hh>

Collaboration diagram for temp::Identifier< Traits_ >:

Public Types

typedef Identifier< Traits_ > self_type
typedef boost::variant
< unsigned, misc::symbol
value_type
 Type of the ``content'' of the identifier.
typedef misc::endo_map
< Identifier
map_type
 Identifier filter type.

Public Member Functions

 Identifier ()
 Identifier (const misc::symbol &sym)
 Identifier (const std::string &str)
 Identifier (const char *str)
 Identifier (const self_type &id)
std::ostream & dump (std::ostream &) const
std::string string_get () const
 Same as dump, but return a string.
const value_typevalue_get () const
const std::string & prefix_get () const
int rank_get () const
self_typeoperator= (const self_type &rhs)
bool operator== (const self_type &rhs) const
bool operator!= (const self_type &rhs) const
bool operator< (const self_type &rhs) const
bool operator<= (const self_type &rhs) const
bool operator> (const self_type &rhs) const
bool operator>= (const self_type &rhs) const

Static Public Attributes

static const misc::xalloc
< map_type * > 
map
 Filtering identifier outputs.

Private Member Functions

template<>
unsigned count_
template<>
unsigned count_
template<>
unsigned count_
template<>
unsigned count_

Private Attributes

value_type value_
const std::string * prefix_
int rank_

Static Private Attributes

static unsigned count_
 Unique counter for this kind of identifier.

Detailed Description

template<template< typename Tag_ > class Traits_>
class temp::Identifier< Traits_ >

Root for Named or anonymous (fresh) identifiers.

It is used to factor the implementation of temp::Temp and temp::Label.

Parameters
Traitsa traits that should have two members: the string prefix and the integer rank.

This class template makes it possible to instantiate several natures of identifiers, say identifiers tagged with an int, a misc::symbol, and so forth. Identifiers uses a boost::variant to store its actual value. Currently, this variant can hold an unsigned or a misc::symbol.

We need a total order on Identifier, so first we need a comparison on identifier of same value type (i.e., an order on int, an order on misc::symbol etc.), but we also need an order between identifiers of different kinds: int versus misc::symbol etc.

To implement this, Traits<Tag_>::rank must return a unique int which will serve to compare heterogeneous identifiers. For instance if

Traits<int>::rank < Traits<misc::symbol>::rank

then a numbered Identifier will be sorted before a named Identifier.

We also need to know how to print an Identifier. For instance, numbered temporaries are reported as t42, while the temp named $fp is to be printed as is. The value of Traits_<Tag_ >::prefix will be printed before the value of the tag itself. Hence, to print t42, specify

const std::string temp_traits<int> prefix = "t";

Member Typedef Documentation

template<template< typename Tag_ > class Traits_>
typedef misc::endo_map<Identifier> temp::Identifier< Traits_ >::map_type

Identifier filter type.

template<template< typename Tag_ > class Traits_>
typedef Identifier<Traits_> temp::Identifier< Traits_ >::self_type
template<template< typename Tag_ > class Traits_>
typedef boost::variant<unsigned, misc::symbol> temp::Identifier< Traits_ >::value_type

Type of the ``content'' of the identifier.

Constructor & Destructor Documentation

template<template< typename Tag_ > class Traits_>
temp::Identifier< Traits_ >::Identifier ( )
template<template< typename Tag_ > class Traits_>
temp::Identifier< Traits_ >::Identifier ( const misc::symbol sym)
template<template< typename Tag_ > class Traits_>
temp::Identifier< Traits_ >::Identifier ( const std::string &  str)
template<template< typename Tag_ > class Traits_>
temp::Identifier< Traits_ >::Identifier ( const char *  str)
template<template< typename Tag_ > class Traits_>
temp::Identifier< Traits_ >::Identifier ( const self_type id)

Member Function Documentation

template<>
unsigned temp::Identifier< label_traits >::count_ ( )
private
template<>
unsigned temp::Identifier< temp_traits >::count_ ( )
private
template<>
unsigned temp::Identifier< label_traits >::count_ ( )
private
template<>
unsigned temp::Identifier< temp_traits >::count_ ( )
private
template<template< typename Tag_ > class Traits_>
std::ostream& temp::Identifier< Traits_ >::dump ( std::ostream &  ) const
template<template< typename Tag_ > class Traits_>
bool temp::Identifier< Traits_ >::operator!= ( const self_type rhs) const
template<template< typename Tag_ > class Traits_>
bool temp::Identifier< Traits_ >::operator< ( const self_type rhs) const
template<template< typename Tag_ > class Traits_>
bool temp::Identifier< Traits_ >::operator<= ( const self_type rhs) const
template<template< typename Tag_ > class Traits_>
self_type& temp::Identifier< Traits_ >::operator= ( const self_type rhs)
template<template< typename Tag_ > class Traits_>
bool temp::Identifier< Traits_ >::operator== ( const self_type rhs) const
template<template< typename Tag_ > class Traits_>
bool temp::Identifier< Traits_ >::operator> ( const self_type rhs) const
template<template< typename Tag_ > class Traits_>
bool temp::Identifier< Traits_ >::operator>= ( const self_type rhs) const
template<template< typename Tag_ > class Traits_>
const std::string& temp::Identifier< Traits_ >::prefix_get ( ) const

Referenced by target::mips::Cpu::Cpu().

template<template< typename Tag_ > class Traits_>
int temp::Identifier< Traits_ >::rank_get ( ) const
template<template< typename Tag_ > class Traits_>
const value_type& temp::Identifier< Traits_ >::value_get ( ) const

Referenced by target::mips::Cpu::Cpu().

Member Data Documentation

template<template< typename Tag_ > class Traits_>
unsigned temp::Identifier< Traits_ >::count_
staticprivate

Unique counter for this kind of identifier.

template<template< typename Tag_ > class Traits_>
const misc::xalloc< typename Identifier< Traits_ >::map_type * > temp::Identifier< Traits_ >::map
static
template<template< typename Tag_ > class Traits_>
const std::string* temp::Identifier< Traits_ >::prefix_
private
template<template< typename Tag_ > class Traits_>
int temp::Identifier< Traits_ >::rank_
private
template<template< typename Tag_ > class Traits_>
value_type temp::Identifier< Traits_ >::value_
private

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