preprocessor: remove size filed in Symbol Table class. closes #1380

issue#70
Houtan Bastani 2017-09-12 14:01:25 +02:00
parent 6e2024b6ed
commit 7c884bcae2
2 changed files with 13 additions and 16 deletions

View File

@ -38,7 +38,7 @@ AuxVarInfo::AuxVarInfo(int symb_id_arg, aux_var_t type_arg, int orig_symb_id_arg
{
}
SymbolTable::SymbolTable() : frozen(false), size(0)
SymbolTable::SymbolTable() : frozen(false)
{
}
@ -78,7 +78,7 @@ SymbolTable::addSymbol(const string &name, SymbolType type, const string &tex_na
else
non_long_name_partition_exists = true;
int id = size++;
int id = symbol_table.size();
symbol_table[name] = id;
type_table.push_back(type);
@ -110,7 +110,7 @@ SymbolTable::freeze() throw (FrozenException)
frozen = true;
for (int i = 0; i < size; i++)
for (int i = 0; i < symbol_table.size(); i++)
{
int tsi;
switch (getType(i))
@ -156,7 +156,7 @@ SymbolTable::changeType(int id, SymbolType newtype) throw (UnknownSymbolIDExcept
if (frozen)
throw FrozenException();
if (id < 0 || id >= size)
if (id < 0 || id > symbol_table.size())
throw UnknownSymbolIDException(id);
type_table[id] = newtype;
@ -732,7 +732,7 @@ SymbolTable::getAuxiliaryVarsExprNode(int symb_id) const throw (SearchFailedExce
void
SymbolTable::markPredetermined(int symb_id) throw (UnknownSymbolIDException, FrozenException)
{
if (symb_id < 0 || symb_id >= size)
if (symb_id < 0 || symb_id > symbol_table.size())
throw UnknownSymbolIDException(symb_id);
if (frozen)
throw FrozenException();
@ -745,7 +745,7 @@ SymbolTable::markPredetermined(int symb_id) throw (UnknownSymbolIDException, Fro
bool
SymbolTable::isPredetermined(int symb_id) const throw (UnknownSymbolIDException)
{
if (symb_id < 0 || symb_id >= size)
if (symb_id < 0 || symb_id > symbol_table.size())
throw UnknownSymbolIDException(symb_id);
return (predetermined_variables.find(symb_id) != predetermined_variables.end());
@ -760,7 +760,7 @@ SymbolTable::predeterminedNbr() const
void
SymbolTable::addObservedVariable(int symb_id) throw (UnknownSymbolIDException)
{
if (symb_id < 0 || symb_id >= size)
if (symb_id < 0 || symb_id > symbol_table.size())
throw UnknownSymbolIDException(symb_id);
assert(getType(symb_id) == eEndogenous);

View File

@ -111,9 +111,6 @@ private:
//! Has method freeze() been called?
bool frozen;
//! Number of symbols contained in the table
int size;
typedef map<string, int> symbol_table_type;
//! Maps strings to symbol IDs
symbol_table_type symbol_table;
@ -375,7 +372,7 @@ SymbolTable::exists(const string &name) const
inline string
SymbolTable::getName(int id) const throw (UnknownSymbolIDException)
{
if (id < 0 || id >= size)
if (id < 0 || id > symbol_table.size())
throw UnknownSymbolIDException(id);
else
return name_table[id];
@ -384,7 +381,7 @@ SymbolTable::getName(int id) const throw (UnknownSymbolIDException)
inline string
SymbolTable::getTeXName(int id) const throw (UnknownSymbolIDException)
{
if (id < 0 || id >= size)
if (id < 0 || id > symbol_table.size())
throw UnknownSymbolIDException(id);
else
return tex_name_table[id];
@ -393,7 +390,7 @@ SymbolTable::getTeXName(int id) const throw (UnknownSymbolIDException)
inline string
SymbolTable::getLongName(int id) const throw (UnknownSymbolIDException)
{
if (id < 0 || id >= size)
if (id < 0 || id > symbol_table.size())
throw UnknownSymbolIDException(id);
else
return long_name_table[id];
@ -402,7 +399,7 @@ SymbolTable::getLongName(int id) const throw (UnknownSymbolIDException)
inline SymbolType
SymbolTable::getType(int id) const throw (UnknownSymbolIDException)
{
if (id < 0 || id >= size)
if (id < 0 || id > symbol_table.size())
throw UnknownSymbolIDException(id);
else
return type_table[id];
@ -430,7 +427,7 @@ SymbolTable::getTypeSpecificID(int id) const throw (UnknownSymbolIDException, No
if (!frozen)
throw NotYetFrozenException();
if (id < 0 || id >= size)
if (id < 0 || id > symbol_table.size())
throw UnknownSymbolIDException(id);
return type_specific_ids[id];
@ -481,7 +478,7 @@ SymbolTable::param_nbr() const throw (NotYetFrozenException)
inline int
SymbolTable::maxID()
{
return (size-1);
return symbol_table.size() - 1;
}
inline int