--- a/absyntax_utils/function_param_iterator.cc Fri Feb 03 10:54:35 2012 +0000
+++ b/absyntax_utils/function_param_iterator.cc Fri Feb 03 14:43:14 2012 +0000
@@ -206,7 +206,9 @@
_first_extensible_param_index = -1;
current_param_is_extensible = false;
current_param_name = NULL;
- current_param_type = current_param_default_value = NULL;
+ current_param_type = NULL;
+ current_param_default_value = NULL;
+ last_returned_parameter = NULL; /* the last parameter returned by search() or next() */
}
@@ -248,6 +250,7 @@
return current_param_name;
}
+ last_returned_parameter = NULL;
param_count = 0;
en_eno_param_implicit = false;
next_param++;
@@ -268,6 +271,7 @@
if (identifier == NULL)
ERROR;
current_param_name = identifier;
+ last_returned_parameter = current_param_name;
return current_param_name;
}
@@ -281,6 +285,7 @@
current_operation = function_param_iterator_c::search_op;
void *res = f_decl->accept(*this);
identifier_c *res_param_name = dynamic_cast<identifier_c *>((symbol_c *)res);
+ last_returned_parameter = res_param_name;
return res_param_name;
}
@@ -288,28 +293,38 @@
* or NULL if none is specified in the function declrataion itself.
*/
symbol_c *function_param_iterator_c::default_value(void) {
+ if (NULL == last_returned_parameter)
+ return NULL;
return current_param_default_value;
}
/* Returns the currently referenced parameter's type name. */
symbol_c *function_param_iterator_c::param_type(void) {
+ if (NULL == last_returned_parameter)
+ return NULL;
return current_param_type;
}
/* Returns if currently referenced parameter is an implicit defined EN/ENO parameter. */
bool function_param_iterator_c::is_en_eno_param_implicit(void) {
+ if (NULL == last_returned_parameter)
+ ERROR;
return en_eno_param_implicit;
}
/* Returns if currently referenced parameter is an extensible parameter. */
/* extensible paramters only occur in some standard functions, e.g. AND(word#34, word#44, word#65); */
bool function_param_iterator_c::is_extensible_param(void) {
+ if (NULL == last_returned_parameter)
+ ERROR;
return current_param_is_extensible;
}
/* Returns the index of the current extensible parameter. */
/* If the current parameter is not an extensible paramter, returns -1 */
int function_param_iterator_c::extensible_param_index(void) {
+ if (NULL == last_returned_parameter)
+ ERROR;
return (current_param_is_extensible? current_extensible_param_index : -1);
}
@@ -323,6 +338,8 @@
* i.e. VAR_INPUT, VAR_OUTPUT or VAR_INOUT
*/
function_param_iterator_c::param_direction_t function_param_iterator_c::param_direction(void) {
+ if (NULL == last_returned_parameter)
+ ERROR;
return current_param_direction;
}