stage3/narrow_candidate_datatypes.cc
changeset 937 887e7d90445a
parent 936 0f7bcc160568
child 940 61e2bdae5899
equal deleted inserted replaced
936:0f7bcc160568 937:887e7d90445a
  1379 /* B 3.1 - Expressions */
  1379 /* B 3.1 - Expressions */
  1380 /***********************/
  1380 /***********************/
  1381 /* SYM_REF1(deref_expression_c, exp)  --> an extension to the IEC 61131-3 standard - based on the IEC 61131-3 v3 standard. Returns address of the varible! */
  1381 /* SYM_REF1(deref_expression_c, exp)  --> an extension to the IEC 61131-3 standard - based on the IEC 61131-3 v3 standard. Returns address of the varible! */
  1382 void *narrow_candidate_datatypes_c::visit(deref_expression_c  *symbol) {
  1382 void *narrow_candidate_datatypes_c::visit(deref_expression_c  *symbol) {
  1383   for (unsigned int i = 0; i < symbol->exp->candidate_datatypes.size(); i++) {
  1383   for (unsigned int i = 0; i < symbol->exp->candidate_datatypes.size(); i++) {
  1384     /* Determine whether the datatype is a ref_spec_c, as this is the class used as the    */
  1384     symbol_c *typ = symbol->exp->candidate_datatypes[i];
  1385     /* canonical/base datatype of REF_TO types (see search_base_type_c ...)                */ 
  1385     symbol_c *ref = get_datatype_info_c::get_ref_to(typ);
  1386     ref_spec_c *ref_spec = dynamic_cast<ref_spec_c *>(symbol->exp->candidate_datatypes[i]);
  1386     if (   (get_datatype_info_c::is_ref_to(typ)) 
  1387     
  1387         && (get_datatype_info_c::is_type_equal(search_base_type_c::get_basetype_decl(ref), symbol->datatype))
  1388     if ((NULL != ref_spec) && get_datatype_info_c::is_type_equal(ref_spec->type_name, symbol->datatype))
  1388        )
  1389       /* if it points to the required datatype for symbol, then that is the required datatype for symbol->exp */
  1389       /* if it points to the required datatype for symbol, then that is the required datatype for symbol->exp */
  1390       symbol->exp->datatype = ref_spec;
  1390       symbol->exp->datatype = typ;
  1391   }
  1391   }
  1392   
  1392   
  1393   symbol->exp->accept(*this);
  1393   symbol->exp->accept(*this);
  1394   return NULL;
  1394   return NULL;
  1395 }
  1395 }
  1396 
  1396 
  1397 
  1397 
  1398 /* SYM_REF1(deref_operator_c, exp)  --> an extension to the IEC 61131-3 standard - based on the IEC 61131-3 v3 standard. Returns address of the varible! */
  1398 /* SYM_REF1(deref_operator_c, exp)  --> an extension to the IEC 61131-3 standard - based on the IEC 61131-3 v3 standard. Returns address of the varible! */
  1399 void *narrow_candidate_datatypes_c::visit(deref_operator_c  *symbol) {
  1399 void *narrow_candidate_datatypes_c::visit(deref_operator_c  *symbol) {
  1400   for (unsigned int i = 0; i < symbol->exp->candidate_datatypes.size(); i++) {
  1400   for (unsigned int i = 0; i < symbol->exp->candidate_datatypes.size(); i++) {
  1401     /* Determine whether the datatype is a ref_spec_c, as this is the class used as the    */
  1401     symbol_c *typ = symbol->exp->candidate_datatypes[i];
  1402     /* canonical/base datatype of REF_TO types (see search_base_type_c ...)                */ 
  1402     symbol_c *ref = get_datatype_info_c::get_ref_to(typ);
  1403     ref_spec_c *ref_spec = dynamic_cast<ref_spec_c *>(symbol->exp->candidate_datatypes[i]);
  1403     if (   (get_datatype_info_c::is_ref_to(typ)) 
  1404     
  1404         && (get_datatype_info_c::is_type_equal(search_base_type_c::get_basetype_decl(ref), symbol->datatype))
  1405     if ((NULL != ref_spec) && get_datatype_info_c::is_type_equal(ref_spec->type_name, symbol->datatype))
  1405        )
  1406       /* if it points to the required datatype for symbol, then that is the required datatype for symbol->exp */
  1406       /* if it points to the required datatype for symbol, then that is the required datatype for symbol->exp */
  1407       symbol->exp->datatype = ref_spec;
  1407       symbol->exp->datatype = typ;
  1408   }
  1408   }
  1409   
  1409   
  1410   symbol->exp->accept(*this);
  1410   symbol->exp->accept(*this);
  1411   return NULL;
  1411   return NULL;
  1412 }
  1412 }