Change name help function.
--- a/stage3/datatype_functions.cc Thu Feb 16 12:59:02 2012 +0000
+++ b/stage3/datatype_functions.cc Thu Feb 16 14:18:23 2012 +0100
@@ -24,6 +24,7 @@
#include "datatype_functions.hh"
#include "../absyntax_utils/absyntax_utils.hh"
+#include <algorithm>
@@ -171,7 +172,7 @@
/* Search for a datatype inside a candidate_datatypes list.
* Returns: position of datatype in the list, or -1 if not found.
*/
-int search_in_datatype_list(symbol_c *datatype, std::vector <symbol_c *> candidate_datatypes) {
+int search_in_candidate_datatype_list(symbol_c *datatype, std::vector <symbol_c *> candidate_datatypes) {
if (NULL == datatype)
return -1;
@@ -192,9 +193,7 @@
void copy_candidate_datatype_list(symbol_c *from, symbol_c *to) {
if ((NULL == from) || (NULL == to))
return;
-
- for(unsigned int i = 0; i < from->candidate_datatypes.size(); i++)
- to->candidate_datatypes.push_back(from->candidate_datatypes[i]);
+ std::copy(from->candidate_datatypes.begin(), from->candidate_datatypes.end(), to->candidate_datatypes.begin());
}
--- a/stage3/datatype_functions.hh Thu Feb 16 12:59:02 2012 +0000
+++ b/stage3/datatype_functions.hh Thu Feb 16 14:18:23 2012 +0100
@@ -139,7 +139,7 @@
/* Search for a datatype inside a candidate_datatypes list.
* Returns: position of datatype in the list, or -1 if not found.
*/
-int search_in_datatype_list(symbol_c *datatype, std::vector <symbol_c *> candidate_datatypes);
+int search_in_candidate_datatype_list(symbol_c *datatype, std::vector <symbol_c *> candidate_datatypes);
/* Copy the elements in the candidate_datatype_list in one symbol (from)
* into the candidate_datatype_list of another symbol (to)
--- a/stage3/fill_candidate_datatypes.cc Thu Feb 16 12:59:02 2012 +0000
+++ b/stage3/fill_candidate_datatypes.cc Thu Feb 16 14:18:23 2012 +0100
@@ -95,7 +95,7 @@
param_type = base_type(fp_iterator.param_type());
/* check whether one of the candidate_data_types of the value being passed is the same as the param_type */
- if (search_in_datatype_list(param_type, call_param_value->candidate_datatypes) < 0)
+ if (search_in_candidate_datatype_list(param_type, call_param_value->candidate_datatypes) < 0)
return false; /* return false if param_type not in the list! */
}
/* call is compatible! */
@@ -138,7 +138,7 @@
/* Get the parameter type */
param_type = base_type(fp_iterator.param_type());
/* check whether one of the candidate_data_types of the value being passed is the same as the param_type */
- if (search_in_datatype_list(param_type, call_param_types) < 0)
+ if (search_in_candidate_datatype_list(param_type, call_param_types) < 0)
return false; /* return false if param_type not in the list! */
}
/* call is compatible! */
@@ -434,7 +434,7 @@
// SYM_REF2(integer_literal_c, type, value)
void *fill_candidate_datatypes_c::visit(integer_literal_c *symbol) {
symbol->value->accept(*this);
- if (search_in_datatype_list(symbol->type, symbol->value->candidate_datatypes) >= 0)
+ if (search_in_candidate_datatype_list(symbol->type, symbol->value->candidate_datatypes) >= 0)
symbol->candidate_datatypes.push_back(symbol->type);
if (debug) std::cout << "INT_LITERAL [" << symbol->candidate_datatypes.size() << "]\n";
return NULL;
@@ -442,7 +442,7 @@
void *fill_candidate_datatypes_c::visit(real_literal_c *symbol) {
symbol->value->accept(*this);
- if (search_in_datatype_list(symbol->type, symbol->value->candidate_datatypes) >= 0)
+ if (search_in_candidate_datatype_list(symbol->type, symbol->value->candidate_datatypes) >= 0)
symbol->candidate_datatypes.push_back(symbol->type);
if (debug) std::cout << "REAL_LITERAL [" << symbol->candidate_datatypes.size() << "]\n";
return NULL;
@@ -450,14 +450,14 @@
void *fill_candidate_datatypes_c::visit(bit_string_literal_c *symbol) {
symbol->value->accept(*this);
- if (search_in_datatype_list(symbol->type, symbol->value->candidate_datatypes) >= 0)
+ if (search_in_candidate_datatype_list(symbol->type, symbol->value->candidate_datatypes) >= 0)
symbol->candidate_datatypes.push_back(symbol->type);
return NULL;
}
void *fill_candidate_datatypes_c::visit(boolean_literal_c *symbol) {
symbol->value->accept(*this);
- if (search_in_datatype_list(symbol->type, symbol->value->candidate_datatypes) >= 0)
+ if (search_in_candidate_datatype_list(symbol->type, symbol->value->candidate_datatypes) >= 0)
/* if an explicit datat type has been provided (e.g. SAFEBOOL#true), check whether
* the possible datatypes of the value is consistent with the desired type.
*/
--- a/stage3/narrow_candidate_datatypes.cc Thu Feb 16 12:59:02 2012 +0000
+++ b/stage3/narrow_candidate_datatypes.cc Thu Feb 16 14:18:23 2012 +0100
@@ -58,7 +58,7 @@
/* Only set the symbol's desired datatype to 'datatype' if that datatype is in the candidate_datatype list */
static void set_datatype(symbol_c *datatype, symbol_c *symbol) {
symbol->datatype = NULL;
- if (search_in_datatype_list(datatype, symbol->candidate_datatypes) >= 0)
+ if (search_in_candidate_datatype_list(datatype, symbol->candidate_datatypes) >= 0)
symbol->datatype = datatype;
}
@@ -288,7 +288,7 @@
void *narrow_candidate_datatypes_c::visit(simple_spec_init_c *symbol) {
symbol_c *datatype = base_type(symbol->simple_specification);
if (NULL != symbol->constant) {
- int typeoffset = search_in_datatype_list(datatype, symbol->constant->candidate_datatypes);
+ int typeoffset = search_in_candidate_datatype_list(datatype, symbol->constant->candidate_datatypes);
if (typeoffset >= 0)
symbol->constant->datatype = symbol->constant->candidate_datatypes[typeoffset];
}