stage3/fill_candidate_datatypes.cc
changeset 651 b3504608cf38
parent 650 d39eed7cc2af
child 652 7fe1533d2260
equal deleted inserted replaced
650:d39eed7cc2af 651:b3504608cf38
  1329 void *fill_candidate_datatypes_c::visit(    gt_expression_c *symbol) {return handle_binary_expression(widen_CMP_table, symbol, symbol->l_exp, symbol->r_exp);}
  1329 void *fill_candidate_datatypes_c::visit(    gt_expression_c *symbol) {return handle_binary_expression(widen_CMP_table, symbol, symbol->l_exp, symbol->r_exp);}
  1330 void *fill_candidate_datatypes_c::visit(    le_expression_c *symbol) {return handle_binary_expression(widen_CMP_table, symbol, symbol->l_exp, symbol->r_exp);}
  1330 void *fill_candidate_datatypes_c::visit(    le_expression_c *symbol) {return handle_binary_expression(widen_CMP_table, symbol, symbol->l_exp, symbol->r_exp);}
  1331 void *fill_candidate_datatypes_c::visit(    ge_expression_c *symbol) {return handle_binary_expression(widen_CMP_table, symbol, symbol->l_exp, symbol->r_exp);}
  1331 void *fill_candidate_datatypes_c::visit(    ge_expression_c *symbol) {return handle_binary_expression(widen_CMP_table, symbol, symbol->l_exp, symbol->r_exp);}
  1332 
  1332 
  1333 
  1333 
  1334 /* The following code is correct when handling the addition of 2 symbolic_variables
       
  1335  * In this case, adding two variables (e.g. USINT_var1 + USINT_var2) will always yield
       
  1336  * the same data type, even if the result of the adition could not fit inside the same
       
  1337  * data type (due to overflowing)
       
  1338  *
       
  1339  * However, when adding two literals (e.g. USINT#42 + USINT#3)
       
  1340  * we should be able to detect overflows of the result, and therefore not consider
       
  1341  * that the result may be of type USINT.
       
  1342  * Currently we do not yet detect these overflows, and allow handling the sum of two USINTs
       
  1343  * as always resulting in an USINT, even in the following expression
       
  1344  * (USINT#65535 + USINT#2).
       
  1345  *
       
  1346  * In the future we can add some code to reduce
       
  1347  * all the expressions that are based on literals into the resulting literal
       
  1348  * value (maybe some visitor class that will run before or after data type
       
  1349  * checking). Since this class will have to be very careful to make sure it implements the same mathematical
       
  1350  * details (e.g. how to round and truncate numbers) as defined in IEC 61131-3, we will leave this to the future.
       
  1351  * Also, the question will arise if we should also replace calls to standard
       
  1352  * functions if the input parameters are all literals (e.g. ADD(42, 42)). This
       
  1353  * means this class will be more difficult than it appears at first.
       
  1354  */
       
  1355 void *fill_candidate_datatypes_c::visit(  add_expression_c *symbol) {return handle_binary_expression(widen_ADD_table,  symbol, symbol->l_exp, symbol->r_exp);}
  1334 void *fill_candidate_datatypes_c::visit(  add_expression_c *symbol) {return handle_binary_expression(widen_ADD_table,  symbol, symbol->l_exp, symbol->r_exp);}
  1356 void *fill_candidate_datatypes_c::visit(  sub_expression_c *symbol) {return handle_binary_expression(widen_SUB_table,  symbol, symbol->l_exp, symbol->r_exp);}
  1335 void *fill_candidate_datatypes_c::visit(  sub_expression_c *symbol) {return handle_binary_expression(widen_SUB_table,  symbol, symbol->l_exp, symbol->r_exp);}
  1357 void *fill_candidate_datatypes_c::visit(  mul_expression_c *symbol) {return handle_binary_expression(widen_MUL_table,  symbol, symbol->l_exp, symbol->r_exp);}
  1336 void *fill_candidate_datatypes_c::visit(  mul_expression_c *symbol) {return handle_binary_expression(widen_MUL_table,  symbol, symbol->l_exp, symbol->r_exp);}
  1358 void *fill_candidate_datatypes_c::visit(  div_expression_c *symbol) {return handle_binary_expression(widen_DIV_table,  symbol, symbol->l_exp, symbol->r_exp);}
  1337 void *fill_candidate_datatypes_c::visit(  div_expression_c *symbol) {return handle_binary_expression(widen_DIV_table,  symbol, symbol->l_exp, symbol->r_exp);}
  1359 void *fill_candidate_datatypes_c::visit(  mod_expression_c *symbol) {return handle_binary_expression(widen_MOD_table,  symbol, symbol->l_exp, symbol->r_exp);}
  1338 void *fill_candidate_datatypes_c::visit(  mod_expression_c *symbol) {return handle_binary_expression(widen_MOD_table,  symbol, symbol->l_exp, symbol->r_exp);}