preprocessor: remove size filed in Symbol Table class. closes #1380
parent
6e2024b6ed
commit
7c884bcae2
|
@ -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
|
else
|
||||||
non_long_name_partition_exists = true;
|
non_long_name_partition_exists = true;
|
||||||
|
|
||||||
int id = size++;
|
int id = symbol_table.size();
|
||||||
|
|
||||||
symbol_table[name] = id;
|
symbol_table[name] = id;
|
||||||
type_table.push_back(type);
|
type_table.push_back(type);
|
||||||
|
@ -110,7 +110,7 @@ SymbolTable::freeze() throw (FrozenException)
|
||||||
|
|
||||||
frozen = true;
|
frozen = true;
|
||||||
|
|
||||||
for (int i = 0; i < size; i++)
|
for (int i = 0; i < symbol_table.size(); i++)
|
||||||
{
|
{
|
||||||
int tsi;
|
int tsi;
|
||||||
switch (getType(i))
|
switch (getType(i))
|
||||||
|
@ -156,7 +156,7 @@ SymbolTable::changeType(int id, SymbolType newtype) throw (UnknownSymbolIDExcept
|
||||||
if (frozen)
|
if (frozen)
|
||||||
throw FrozenException();
|
throw FrozenException();
|
||||||
|
|
||||||
if (id < 0 || id >= size)
|
if (id < 0 || id > symbol_table.size())
|
||||||
throw UnknownSymbolIDException(id);
|
throw UnknownSymbolIDException(id);
|
||||||
|
|
||||||
type_table[id] = newtype;
|
type_table[id] = newtype;
|
||||||
|
@ -732,7 +732,7 @@ SymbolTable::getAuxiliaryVarsExprNode(int symb_id) const throw (SearchFailedExce
|
||||||
void
|
void
|
||||||
SymbolTable::markPredetermined(int symb_id) throw (UnknownSymbolIDException, FrozenException)
|
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);
|
throw UnknownSymbolIDException(symb_id);
|
||||||
if (frozen)
|
if (frozen)
|
||||||
throw FrozenException();
|
throw FrozenException();
|
||||||
|
@ -745,7 +745,7 @@ SymbolTable::markPredetermined(int symb_id) throw (UnknownSymbolIDException, Fro
|
||||||
bool
|
bool
|
||||||
SymbolTable::isPredetermined(int symb_id) const throw (UnknownSymbolIDException)
|
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);
|
throw UnknownSymbolIDException(symb_id);
|
||||||
|
|
||||||
return (predetermined_variables.find(symb_id) != predetermined_variables.end());
|
return (predetermined_variables.find(symb_id) != predetermined_variables.end());
|
||||||
|
@ -760,7 +760,7 @@ SymbolTable::predeterminedNbr() const
|
||||||
void
|
void
|
||||||
SymbolTable::addObservedVariable(int symb_id) throw (UnknownSymbolIDException)
|
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);
|
throw UnknownSymbolIDException(symb_id);
|
||||||
|
|
||||||
assert(getType(symb_id) == eEndogenous);
|
assert(getType(symb_id) == eEndogenous);
|
||||||
|
|
|
@ -111,9 +111,6 @@ private:
|
||||||
//! Has method freeze() been called?
|
//! Has method freeze() been called?
|
||||||
bool frozen;
|
bool frozen;
|
||||||
|
|
||||||
//! Number of symbols contained in the table
|
|
||||||
int size;
|
|
||||||
|
|
||||||
typedef map<string, int> symbol_table_type;
|
typedef map<string, int> symbol_table_type;
|
||||||
//! Maps strings to symbol IDs
|
//! Maps strings to symbol IDs
|
||||||
symbol_table_type symbol_table;
|
symbol_table_type symbol_table;
|
||||||
|
@ -375,7 +372,7 @@ SymbolTable::exists(const string &name) const
|
||||||
inline string
|
inline string
|
||||||
SymbolTable::getName(int id) const throw (UnknownSymbolIDException)
|
SymbolTable::getName(int id) const throw (UnknownSymbolIDException)
|
||||||
{
|
{
|
||||||
if (id < 0 || id >= size)
|
if (id < 0 || id > symbol_table.size())
|
||||||
throw UnknownSymbolIDException(id);
|
throw UnknownSymbolIDException(id);
|
||||||
else
|
else
|
||||||
return name_table[id];
|
return name_table[id];
|
||||||
|
@ -384,7 +381,7 @@ SymbolTable::getName(int id) const throw (UnknownSymbolIDException)
|
||||||
inline string
|
inline string
|
||||||
SymbolTable::getTeXName(int id) const throw (UnknownSymbolIDException)
|
SymbolTable::getTeXName(int id) const throw (UnknownSymbolIDException)
|
||||||
{
|
{
|
||||||
if (id < 0 || id >= size)
|
if (id < 0 || id > symbol_table.size())
|
||||||
throw UnknownSymbolIDException(id);
|
throw UnknownSymbolIDException(id);
|
||||||
else
|
else
|
||||||
return tex_name_table[id];
|
return tex_name_table[id];
|
||||||
|
@ -393,7 +390,7 @@ SymbolTable::getTeXName(int id) const throw (UnknownSymbolIDException)
|
||||||
inline string
|
inline string
|
||||||
SymbolTable::getLongName(int id) const throw (UnknownSymbolIDException)
|
SymbolTable::getLongName(int id) const throw (UnknownSymbolIDException)
|
||||||
{
|
{
|
||||||
if (id < 0 || id >= size)
|
if (id < 0 || id > symbol_table.size())
|
||||||
throw UnknownSymbolIDException(id);
|
throw UnknownSymbolIDException(id);
|
||||||
else
|
else
|
||||||
return long_name_table[id];
|
return long_name_table[id];
|
||||||
|
@ -402,7 +399,7 @@ SymbolTable::getLongName(int id) const throw (UnknownSymbolIDException)
|
||||||
inline SymbolType
|
inline SymbolType
|
||||||
SymbolTable::getType(int id) const throw (UnknownSymbolIDException)
|
SymbolTable::getType(int id) const throw (UnknownSymbolIDException)
|
||||||
{
|
{
|
||||||
if (id < 0 || id >= size)
|
if (id < 0 || id > symbol_table.size())
|
||||||
throw UnknownSymbolIDException(id);
|
throw UnknownSymbolIDException(id);
|
||||||
else
|
else
|
||||||
return type_table[id];
|
return type_table[id];
|
||||||
|
@ -430,7 +427,7 @@ SymbolTable::getTypeSpecificID(int id) const throw (UnknownSymbolIDException, No
|
||||||
if (!frozen)
|
if (!frozen)
|
||||||
throw NotYetFrozenException();
|
throw NotYetFrozenException();
|
||||||
|
|
||||||
if (id < 0 || id >= size)
|
if (id < 0 || id > symbol_table.size())
|
||||||
throw UnknownSymbolIDException(id);
|
throw UnknownSymbolIDException(id);
|
||||||
|
|
||||||
return type_specific_ids[id];
|
return type_specific_ids[id];
|
||||||
|
@ -481,7 +478,7 @@ SymbolTable::param_nbr() const throw (NotYetFrozenException)
|
||||||
inline int
|
inline int
|
||||||
SymbolTable::maxID()
|
SymbolTable::maxID()
|
||||||
{
|
{
|
||||||
return (size-1);
|
return symbol_table.size() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int
|
inline int
|
||||||
|
|
Loading…
Reference in New Issue