--- 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<typename value_type, value_type null_value>
-symtable_c<value_type, null_value>::symtable_c(void) {inner_scope = NULL;}
+template<typename value_type>
+symtable_c<value_type>::symtable_c(void) {inner_scope = NULL;}
/* clear all entries... */
-template<typename value_type, value_type null_value>
-void symtable_c<value_type, null_value>::reset(void) {
+template<typename value_type>
+void symtable_c<value_type>::reset(void) {
_base.clear();
}
/* create new inner scope */
-template<typename value_type, value_type null_value>
-void symtable_c<value_type, null_value>::push(void) {
+template<typename value_type>
+void symtable_c<value_type>::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<typename value_type, value_type null_value>
-int symtable_c<value_type, null_value>::pop(void) {
+template<typename value_type>
+int symtable_c<value_type>::pop(void) {
if (inner_scope != NULL) {
if (inner_scope->pop() == 1) {
delete inner_scope;
@@ -78,8 +78,8 @@
}
}
-template<typename value_type, value_type null_value>
-void symtable_c<value_type, null_value>::set(const symbol_c *symbol, value_t new_value) {
+template<typename value_type>
+void symtable_c<value_type>::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<typename value_type, value_type null_value>
-void symtable_c<value_type, null_value>::set(const char *identifier_str, value_t new_value) {
+template<typename value_type>
+void symtable_c<value_type>::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<typename value_type, value_type null_value>
-void symtable_c<value_type, null_value>::insert(const char *identifier_str, value_t new_value) {
+template<typename value_type>
+void symtable_c<value_type>::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<typename value_type, value_type null_value>
-void symtable_c<value_type, null_value>::insert(const symbol_c *symbol, value_t new_value) {
+template<typename value_type>
+void symtable_c<value_type>::insert(const symbol_c *symbol, value_t new_value) {
/*
// not required...
if (inner_scope != NULL) {
@@ -141,39 +141,37 @@
}
+template<typename value_type>
+typename symtable_c<value_type>::iterator symtable_c<value_type>::end(void) {return _base.end();}
-/* returns null_value if not found! */
-template<typename value_type, value_type null_value>
-value_type symtable_c<value_type, null_value>::find_value(const char *identifier_str) {
+/* returns end() if not found! */
+template<typename value_type>
+typename symtable_c<value_type>::iterator symtable_c<value_type>::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<typename value_type, value_type null_value>
-value_type symtable_c<value_type, null_value>::find_value(const symbol_c *symbol) {
+template<typename value_type>
+typename symtable_c<value_type>::iterator symtable_c<value_type>::find(const symbol_c *symbol) {
const token_c *name = dynamic_cast<const token_c *>(symbol);
if (name == NULL)
ERROR;
- return find_value(name->value);
+ return find(name->value);
}
+
/* debuging function... */
-template<typename value_type, value_type null_value>
-void symtable_c<value_type, null_value>::print(void) {
+template<typename value_type>
+void symtable_c<value_type>::print(void) {
for(iterator i = _base.begin();
i != _base.end();
i++)
@@ -192,4 +190,3 @@
-