VariableLexerRepository Class Reference

#include <VariableLexerRepository.hpp>

Inheritance diagram for VariableLexerRepository:

Inheritance graph
[legend]
Collaboration diagram for VariableLexerRepository:

Collaboration graph
[legend]

List of all members.

Public Member Functions

Type find (const std::string &name) const
void add (const std::string &name, const Type &type)
void markAsUnknown (const std::string &name)
void beginBlock ()
void endBlock ()
 VariableLexerRepository ()
 ~VariableLexerRepository ()

Static Public Member Functions

static VariableLexerRepositoryinstance ()
static void create ()
static void destroy ()

Static Protected Attributes

static VariableLexerRepository__pInstance

Private Types

typedef int Type
typedef std::map< std::string,
Type
Container
 The container of variables.

Private Attributes

std::vector< Container__repository
size_t __blockLevel


Detailed Description

Definition at line 35 of file VariableLexerRepository.hpp.


Member Typedef Documentation

typedef int VariableLexerRepository::Type [private]

Definition at line 39 of file VariableLexerRepository.hpp.

typedef std::map<std::string, Type> VariableLexerRepository::Container [private]

The container of variables.

Definition at line 43 of file VariableLexerRepository.hpp.


Constructor & Destructor Documentation

VariableLexerRepository::VariableLexerRepository (  ) 

Constructor

Definition at line 202 of file VariableLexerRepository.cpp.

References __repository.

00203   : __blockLevel(0)
00204 {
00205   __repository.push_back(Container());
00206 }

VariableLexerRepository::~VariableLexerRepository (  ) 

Destructor

Definition at line 209 of file VariableLexerRepository.cpp.

00210 {
00211   ;
00212 }


Member Function Documentation

VariableLexerRepository::Type VariableLexerRepository::find ( const std::string &  name  )  const

Search for a variable in the list

Parameters:
name name of the variable to find
Returns:
the type of the variable

Definition at line 126 of file VariableLexerRepository.cpp.

References __blockLevel, and __repository.

Referenced by FFLexer::isVariable().

00127 {
00128   Container::const_iterator i;
00129   size_t level=0;
00130   for (; level<=__blockLevel;++level) {
00131     i = __repository[level].find(name);
00132     if (i != __repository[level].end()) break;
00133   }
00134   if (level>__blockLevel) return -1;
00135   if (i == __repository[level].end()) return -1;
00136   else {
00137     return i->second;
00138   } 
00139 }

void VariableLexerRepository::add ( const std::string &  name,
const Type type 
)

Adds a variable to the list

Parameters:
name name of the variable
type type of the variable

Definition at line 169 of file VariableLexerRepository.cpp.

References __blockLevel, and __repository.

00170 {
00171   __repository[__blockLevel][name]=type;
00172 }

void VariableLexerRepository::markAsUnknown ( const std::string &  name  ) 

Marks a function as a variable

Parameters:
name name of the variable

Definition at line 142 of file VariableLexerRepository.cpp.

References __blockLevel, __repository, and ErrorHandler::unexpected.

00143 {
00144   Container::iterator i;
00145   size_t level=0;
00146   for (; level<=__blockLevel;++level) {
00147     i = __repository[level].find(name);
00148     if (i != __repository[level].end()) break;
00149   }
00150 
00151   if (level>__blockLevel) {
00152     throw ErrorHandler(__FILE__,__LINE__,
00153                        "cannot find variable "+name,
00154                        ErrorHandler::unexpected);
00155   }
00156 
00157   if (i == __repository[level].end())
00158   {
00159     throw ErrorHandler(__FILE__,__LINE__,
00160                        "cannot find variable "+name,
00161                        ErrorHandler::unexpected);
00162   } else {
00163     i->second = VARUNKNOWNID;
00164   } 
00165 }

void VariableLexerRepository::beginBlock (  ) 

Begins a new block

Definition at line 175 of file VariableLexerRepository.cpp.

References __blockLevel, and __repository.

00176 {
00177   __blockLevel++;
00178   __repository.push_back(Container());
00179 }

void VariableLexerRepository::endBlock (  ) 

Ends a block

Definition at line 182 of file VariableLexerRepository.cpp.

References __blockLevel, __repository, and ASSERT.

00183 {
00184   ASSERT(__blockLevel>0);
00185   __repository[__blockLevel].clear();
00186   __blockLevel--;
00187 
00188   __repository.pop_back();
00189 
00190   // At the end of a block, unknowns are always variables!
00191   for (size_t level=0; level<=__blockLevel;++level) {
00192     for (Container::iterator ivariable = __repository[level].begin();
00193          ivariable != __repository[level].end(); ++ivariable) {
00194       if (ivariable->second == VARUNKNOWNID) {
00195         ivariable->second = VARFNCTID;
00196       }
00197     }
00198   }    
00199 }

static VariableLexerRepository & StaticBase< VariableLexerRepository >::instance (  )  [inline, static, inherited]

Access to auto instanciated static;

Returns:
*__pInstance

Definition at line 46 of file StaticBase.hpp.

Referenced by FFLexer::isVariable().

00047   {
00048     return *__pInstance;
00049   }

static void StaticBase< VariableLexerRepository >::create (  )  [inline, static, inherited]

Creates __pInstance in Embedding class.

Definition at line 55 of file StaticBase.hpp.

Referenced by ThreadStaticCenter::ThreadStaticCenter().

00056   {
00057     __pInstance = new EmbeddingClass();
00058   }

static void StaticBase< VariableLexerRepository >::destroy (  )  [inline, static, inherited]

Destroyes __autoInstanciated in Embedding class.

Definition at line 64 of file StaticBase.hpp.

Referenced by ThreadStaticCenter::~ThreadStaticCenter().

00065   {
00066     delete __pInstance;
00067   }


Member Data Documentation

per level variable lists

Definition at line 46 of file VariableLexerRepository.hpp.

Referenced by add(), beginBlock(), endBlock(), find(), markAsUnknown(), and VariableLexerRepository().

current level

Definition at line 48 of file VariableLexerRepository.hpp.

Referenced by add(), beginBlock(), endBlock(), find(), and markAsUnknown().

The static variable

Definition at line 37 of file StaticBase.hpp.


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

Generated on Wed Nov 19 00:16:46 2008 for FreeFEM3D (aka ff3d) by  doxygen 1.5.6