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

Define symbol class. More...

#include <symbol.hh>

Inheritance diagram for misc::symbol:
Collaboration diagram for misc::symbol:

Public Types

typedef unique< std::string,
std::less< std::string > > 
value_type
typedef std::string data_type

Public Member Functions

Ctor & Dtor.
 symbol (const std::string &s)
 Construct a symbol.
 symbol (const char *s="")
 Construct a symbol.
virtual ~symbol ()
 Destroy a symbol.
Operators.
symboloperator= (const symbol &rhs)
 Assign a symbol to this symbol.
bool operator== (const symbol &rhs) const
 Compare two symbol for equality.
bool operator!= (const symbol &rhs) const
 Compare two symbol for inequality.
Operators.
virtual bool operator== (const value_type &rhs) const
 Compare two unique for equality.
virtual bool operator!= (const value_type &rhs) const
 Compare two unique for inequality.
virtual bool operator< (const value_type &rhs) const
 Compare two sunique for order.

Static Public Member Functions

Factory methods.
static symbol fresh ()
 Create a new unique symbol.
static symbol fresh (const symbol &s)
 Create a new unique symbol, forged from s.

Protected Types

typedef std::set< std::string,
std::less< std::string > > 
object_set_type
 The unique's object type.
typedef object_set_type::size_type object_size_type
 The type for the size of the unique set.

Static Protected Member Functions

static object_set_typeobject_set_instance ()
 Return the set of uniques.

Protected Attributes

const data_typeobj_
 Pointer to the unique referenced object.

Private Types

typedef unique< std::string > super_type
typedef super_type::object_set_type string_set_type
 The type "set of strings".
typedef string_set_type::size_type string_size_type
 The type for the size of string map.

Accessors.

const std::string & name_get () const
 Return the string referenced by this.
static string_size_type string_map_size ()
 Return the number of referenced strings.

Accessors.

virtual const data_typeobject_get () const
 Return the object referenced by this.
virtual operator const data_type & () const
static object_size_type object_map_size ()
 Return the number of referenced objects.

Detailed Description

Define symbol class.

Map any string to a unique reference. This allows to avoid an "strcmp()" style comparison of strings: reference comparison is much faster.

Member Typedef Documentation

typedef std::string misc::unique< std::string , std::less<std::string > >::data_type
inherited
typedef std::set<std::string , std::less<std::string > > misc::unique< std::string , std::less<std::string > >::object_set_type
protectedinherited

The unique's object type.

typedef object_set_type::size_type misc::unique< std::string , std::less<std::string > >::object_size_type
protectedinherited

The type for the size of the unique set.

The type "set of strings".

typedef string_set_type::size_type misc::symbol::string_size_type
private

The type for the size of string map.

typedef unique<std::string> misc::symbol::super_type
private
typedef unique<std::string , std::less<std::string > > misc::unique< std::string , std::less<std::string > >::value_type
inherited

Constructor & Destructor Documentation

misc::symbol::symbol ( const std::string &  s)

Construct a symbol.

Parameters
sreferenced string

Referenced by fresh().

misc::symbol::symbol ( const char *  s = "")

Construct a symbol.

Parameters
sreferenced string
misc::symbol::~symbol ( )
virtual

Destroy a symbol.

Member Function Documentation

symbol misc::symbol::fresh ( )
static

Create a new unique symbol.

symbol misc::symbol::fresh ( const symbol s)
static

Create a new unique symbol, forged from s.

Counter of unique symbols.

References misc::unique< T, C >::object_get(), str(), and symbol().

const std::string& misc::symbol::name_get ( ) const
virtual const data_type& misc::unique< std::string , std::less<std::string > >::object_get ( ) const
virtualinherited

Return the object referenced by this.

static object_size_type misc::unique< std::string , std::less<std::string > >::object_map_size ( )
staticinherited

Return the number of referenced objects.

Referenced by string_map_size().

static object_set_type& misc::unique< std::string , std::less<std::string > >::object_set_instance ( )
staticprotectedinherited

Return the set of uniques.

virtual misc::unique< std::string , std::less<std::string > >::operator const data_type & ( ) const
virtualinherited
virtual bool misc::unique< std::string , std::less<std::string > >::operator!= ( const value_type rhs) const
virtualinherited

Compare two unique for inequality.

Parameters
rhsunique to compare with.
bool misc::symbol::operator!= ( const symbol rhs) const

Compare two symbol for inequality.

Parameters
rhsstring to compare with.
virtual bool misc::unique< std::string , std::less<std::string > >::operator< ( const value_type rhs) const
virtualinherited

Compare two sunique for order.

Parameters
rhsunique to compare with.
symbol& misc::symbol::operator= ( const symbol rhs)

Assign a symbol to this symbol.

Parameters
rhssymbol to copy.
virtual bool misc::unique< std::string , std::less<std::string > >::operator== ( const value_type rhs) const
virtualinherited

Compare two unique for equality.

Parameters
rhsunique to compare with.
bool misc::symbol::operator== ( const symbol rhs) const

Compare two symbol for equality.

Parameters
rhsstring to compare with.
symbol::string_size_type misc::symbol::string_map_size ( )
static

Return the number of referenced strings.

References misc::unique< std::string >::object_map_size().

Member Data Documentation

const data_type* misc::unique< std::string , std::less<std::string > >::obj_
protectedinherited

Pointer to the unique referenced object.


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