Add EXPT widen table.
--- a/stage3/datatype_functions.cc Thu Mar 15 12:50:44 2012 +0000
+++ b/stage3/datatype_functions.cc Thu Mar 15 13:18:02 2012 +0000
@@ -80,12 +80,16 @@
#define __ANY_UINT_1(DO,P1) DO(usint,P1) DO(uint,P1) DO(udint,P1) DO(ulint,P1)
-
-
-/*
- * 2.5.1.5.6 Functions of time data types
- * Table 30 - page 64
- */
+/**************************************************************/
+/**************************************************************/
+/**************************************************************/
+/******* TABLE 24: Standard arithmetic functions *******/
+/******* merged with *******/
+/******* TABLE 30: Functions of time data types *******/
+/**************************************************************/
+/**************************************************************/
+/**************************************************************/
+
const struct widen_entry widen_ADD_table[] = {
#define __add(TYPE) \
@@ -296,6 +300,21 @@
+const struct widen_entry widen_EXPT_table[] = {
+#define __expt(IN2TYPE, IN1TYPE) \
+ { &search_constant_type_c::IN1TYPE##_type_name, &search_constant_type_c::IN2TYPE##_type_name, &search_constant_type_c::IN1TYPE##_type_name, widen_entry::ok }, \
+ { &search_constant_type_c::safe##IN1TYPE##_type_name, &search_constant_type_c::IN2TYPE##_type_name, &search_constant_type_c::IN1TYPE##_type_name, widen_entry::ok }, \
+ { &search_constant_type_c::IN1TYPE##_type_name, &search_constant_type_c::safe##IN2TYPE##_type_name, &search_constant_type_c::IN1TYPE##_type_name, widen_entry::ok }, \
+ { &search_constant_type_c::safe##IN1TYPE##_type_name, &search_constant_type_c::safe##IN2TYPE##_type_name, &search_constant_type_c::safe##IN1TYPE##_type_name, widen_entry::ok },
+#define __IN2_anynum_(IN1_TYPENAME) __ANY_NUM_1(__expt,IN1_TYPENAME)
+ __ANY_REAL(__IN2_anynum_)
+#undef __expt
+#undef __IN2_anynum_
+ { NULL, NULL, NULL, widen_entry::ok },
+};
+
+
+
/**************************************************************/
/**************************************************************/
/**************************************************************/
--- a/stage3/datatype_functions.hh Thu Mar 15 12:50:44 2012 +0000
+++ b/stage3/datatype_functions.hh Thu Mar 15 13:18:02 2012 +0000
@@ -133,6 +133,7 @@
extern const struct widen_entry widen_MUL_table[];
extern const struct widen_entry widen_DIV_table[];
extern const struct widen_entry widen_MOD_table[];
+extern const struct widen_entry widen_EXPT_table[];
extern const struct widen_entry widen_AND_table[];
extern const struct widen_entry widen_OR_table[];
extern const struct widen_entry widen_XOR_table[];
--- a/stage3/fill_candidate_datatypes.cc Thu Mar 15 12:50:44 2012 +0000
+++ b/stage3/fill_candidate_datatypes.cc Thu Mar 15 13:18:02 2012 +0000
@@ -1171,43 +1171,12 @@
* functions if the input parameters are all literals (e.g. ADD(42, 42)). This
* means this class will be more difficult than it appears at first.
*/
-void *fill_candidate_datatypes_c::visit(add_expression_c *symbol) {return handle_binary_expression(widen_ADD_table, symbol, symbol->l_exp, symbol->r_exp);}
-void *fill_candidate_datatypes_c::visit(sub_expression_c *symbol) {return handle_binary_expression(widen_SUB_table, symbol, symbol->l_exp, symbol->r_exp);}
-void *fill_candidate_datatypes_c::visit(mul_expression_c *symbol) {return handle_binary_expression(widen_MUL_table, symbol, symbol->l_exp, symbol->r_exp);}
-void *fill_candidate_datatypes_c::visit(div_expression_c *symbol) {return handle_binary_expression(widen_DIV_table, symbol, symbol->l_exp, symbol->r_exp);}
-void *fill_candidate_datatypes_c::visit(mod_expression_c *symbol) {return handle_binary_expression(widen_MOD_table, symbol, symbol->l_exp, symbol->r_exp);}
-
-
-void *fill_candidate_datatypes_c::visit(power_expression_c *symbol) {
- symbol_c *left_type, *right_type;
- bool check_ok;
-
- symbol->l_exp->accept(*this);
- symbol->r_exp->accept(*this);
- check_ok = false;
- for (unsigned int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
- left_type = symbol->l_exp->candidate_datatypes[i];
- if (is_ANY_REAL_compatible(left_type)) {
- check_ok = true;
- break;
- }
- }
- if (! check_ok) return NULL;
- check_ok = false;
- for(unsigned int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) {
- right_type = symbol->r_exp->candidate_datatypes[j];
- if (is_ANY_NUM_compatible(right_type)) {
- check_ok = true;
- break;
- }
- }
- if (! check_ok) return NULL;
- for (unsigned int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
- add_datatype_to_candidate_list(symbol, symbol->l_exp->candidate_datatypes[i]);
- }
- if (debug) std::cout << "** [" << symbol->l_exp->candidate_datatypes.size() << "," << symbol->r_exp->candidate_datatypes.size() << "] ==> " << symbol->candidate_datatypes.size() << " result.\n";
- return NULL;
-}
+void *fill_candidate_datatypes_c::visit( add_expression_c *symbol) {return handle_binary_expression(widen_ADD_table, symbol, symbol->l_exp, symbol->r_exp);}
+void *fill_candidate_datatypes_c::visit( sub_expression_c *symbol) {return handle_binary_expression(widen_SUB_table, symbol, symbol->l_exp, symbol->r_exp);}
+void *fill_candidate_datatypes_c::visit( mul_expression_c *symbol) {return handle_binary_expression(widen_MUL_table, symbol, symbol->l_exp, symbol->r_exp);}
+void *fill_candidate_datatypes_c::visit( div_expression_c *symbol) {return handle_binary_expression(widen_DIV_table, symbol, symbol->l_exp, symbol->r_exp);}
+void *fill_candidate_datatypes_c::visit( mod_expression_c *symbol) {return handle_binary_expression(widen_MOD_table, symbol, symbol->l_exp, symbol->r_exp);}
+void *fill_candidate_datatypes_c::visit(power_expression_c *symbol) {return handle_binary_expression(widen_EXPT_table, symbol, symbol->l_exp, symbol->r_exp);}
void *fill_candidate_datatypes_c::visit(neg_expression_c *symbol) {
--- a/stage3/narrow_candidate_datatypes.cc Thu Mar 15 12:50:44 2012 +0000
+++ b/stage3/narrow_candidate_datatypes.cc Thu Mar 15 13:18:02 2012 +0000
@@ -1024,19 +1024,7 @@
void *narrow_candidate_datatypes_c::visit( mul_expression_c *symbol) {return narrow_binary_expression(widen_MUL_table, symbol, symbol->l_exp, symbol->r_exp, &symbol->deprecated_operation);}
void *narrow_candidate_datatypes_c::visit( div_expression_c *symbol) {return narrow_binary_expression(widen_DIV_table, symbol, symbol->l_exp, symbol->r_exp, &symbol->deprecated_operation);}
void *narrow_candidate_datatypes_c::visit( mod_expression_c *symbol) {return narrow_binary_expression(widen_MOD_table, symbol, symbol->l_exp, symbol->r_exp);}
-
-
-
-
-void *narrow_candidate_datatypes_c::visit(power_expression_c *symbol) {
- symbol->l_exp->datatype = symbol->datatype;
- symbol->l_exp->accept(*this);
- if (! symbol->r_exp->candidate_datatypes.size()){
- symbol->r_exp->datatype = symbol->r_exp->candidate_datatypes[0];
- symbol->r_exp->accept(*this);
- }
- return NULL;
-}
+void *narrow_candidate_datatypes_c::visit( power_expression_c *symbol) {return narrow_binary_expression(widen_EXPT_table,symbol, symbol->l_exp, symbol->r_exp);}
void *narrow_candidate_datatypes_c::visit(neg_expression_c *symbol) {
--- a/stage3/print_datatypes_error.cc Thu Mar 15 12:50:44 2012 +0000
+++ b/stage3/print_datatypes_error.cc Thu Mar 15 13:18:02 2012 +0000
@@ -992,17 +992,7 @@
void *print_datatypes_error_c::visit( mul_expression_c *symbol) {return print_binary_expression_errors( "*" , symbol, symbol->l_exp, symbol->r_exp, symbol->deprecated_operation);}
void *print_datatypes_error_c::visit( div_expression_c *symbol) {return print_binary_expression_errors( "/" , symbol, symbol->l_exp, symbol->r_exp, symbol->deprecated_operation);}
void *print_datatypes_error_c::visit( mod_expression_c *symbol) {return print_binary_expression_errors("MOD", symbol, symbol->l_exp, symbol->r_exp);}
-
-
-void *print_datatypes_error_c::visit(power_expression_c *symbol) {
- symbol->l_exp->accept(*this);
- symbol->r_exp->accept(*this);
- if ((symbol->candidate_datatypes.size() == 0) &&
- (symbol->l_exp->candidate_datatypes.size() > 0) &&
- (symbol->r_exp->candidate_datatypes.size() > 0))
- STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for '**' expression.");
- return NULL;
-}
+void *print_datatypes_error_c::visit( power_expression_c *symbol) {return print_binary_expression_errors( "**", symbol, symbol->l_exp, symbol->r_exp);}
void *print_datatypes_error_c::visit(neg_expression_c *symbol) {