diff -r 0ede7ca157e2 -r 8aee27d46208 util/symtable.cc --- a/util/symtable.cc Fri Dec 26 09:39:18 2014 +0000 +++ b/util/symtable.cc Fri Dec 26 09:57:02 2014 +0000 @@ -41,19 +41,19 @@ -template -symtable_c::symtable_c(void) {inner_scope = NULL;} +template +symtable_c::symtable_c(void) {inner_scope = NULL;} /* clear all entries... */ -template -void symtable_c::reset(void) { +template +void symtable_c::reset(void) { _base.clear(); } /* create new inner scope */ -template -void symtable_c::push(void) { +template +void symtable_c::push(void) { if (inner_scope != NULL) { inner_scope->push(); } else { @@ -64,8 +64,8 @@ /* clear most inner scope */ /* returns 1 if this is the inner most scope */ /* 0 otherwise */ -template -int symtable_c::pop(void) { +template +int symtable_c::pop(void) { if (inner_scope != NULL) { if (inner_scope->pop() == 1) { delete inner_scope; @@ -78,8 +78,8 @@ } } -template -void symtable_c::set(const symbol_c *symbol, value_t new_value) { +template +void symtable_c::set(const symbol_c *symbol, value_t new_value) { if (inner_scope != NULL) { inner_scope->set(symbol, new_value); return; @@ -92,8 +92,8 @@ } -template -void symtable_c::set(const char *identifier_str, value_t new_value) { +template +void symtable_c::set(const char *identifier_str, value_t new_value) { if (inner_scope != NULL) { inner_scope->set(identifier_str, new_value); return; @@ -108,8 +108,8 @@ _base[identifier_str] = new_value; } -template -void symtable_c::insert(const char *identifier_str, value_t new_value) { +template +void symtable_c::insert(const char *identifier_str, value_t new_value) { if (inner_scope != NULL) { inner_scope->insert(identifier_str, new_value); return; @@ -125,8 +125,8 @@ if (!res.second) {ERROR;} /* unknown error inserting new identifier */ } -template -void symtable_c::insert(const symbol_c *symbol, value_t new_value) { +template +void symtable_c::insert(const symbol_c *symbol, value_t new_value) { /* // not required... if (inner_scope != NULL) { @@ -141,39 +141,37 @@ } +template +typename symtable_c::iterator symtable_c::end(void) {return _base.end();} -/* returns null_value if not found! */ -template -value_type symtable_c::find_value(const char *identifier_str) { +/* returns end() if not found! */ +template +typename symtable_c::iterator symtable_c::find(const char *identifier_str) { if (inner_scope != NULL) { - value_t token = inner_scope->find_value(identifier_str); - if (token != null_value) + iterator i = inner_scope->find(identifier_str); + if (i != inner_scope->end()) // NOTE: must use the end() value of the inner scope! /* found in the lower level */ - return token; + return i; } /* if no lower level, or not found in lower level... */ - iterator i = _base.find(identifier_str); - - if (i == _base.end()) - return null_value; - else - return i->second; + return _base.find(identifier_str); } -template -value_type symtable_c::find_value(const symbol_c *symbol) { +template +typename symtable_c::iterator symtable_c::find(const symbol_c *symbol) { const token_c *name = dynamic_cast(symbol); if (name == NULL) ERROR; - return find_value(name->value); + return find(name->value); } + /* debuging function... */ -template -void symtable_c::print(void) { +template +void symtable_c::print(void) { for(iterator i = _base.begin(); i != _base.end(); i++) @@ -192,4 +190,3 @@ -