stage3/narrow_candidate_datatypes.cc
changeset 552 3c39d80fdede
parent 534 d13a38011af4
child 652 7fe1533d2260
equal deleted inserted replaced
551:a75e3aea98ff 552:3c39d80fdede
    30  * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
    30  * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
    31  *
    31  *
    32  */
    32  */
    33 
    33 
    34 
    34 
       
    35 /* NOTE: The algorithm implemented here assumes that candidate datatype lists have already been filled!
       
    36  *       BEFORE running this visitor, be sure to CALL the fill_candidate_datatype_c visitor!
       
    37  */
       
    38 
       
    39 
    35 /*
    40 /*
    36  *  Narrow class select and store a data type from candidate data types list for all symbols
    41  *  Choose, from the list of all the possible datatypes each expression may take, the single datatype that it will in fact take.
       
    42  *  The resulting (chosen) datatype, will be stored in the symbol_c.datatype variable, leaving the candidate datatype list untouched!
       
    43  * 
       
    44  *  For rvalue expressions, this decision will be based on the datatype of the lvalue expression.
       
    45  *  For lvalue expressions, the candidate datatype list should have a single entry.
       
    46  * 
       
    47  *  For example, the very simple literal '0' in 'foo := 0', may represent a:
       
    48  *    BOOL, BYTE, WORD, DWORD, LWORD, USINT, SINT, UINT, INT, UDINT, DINT, ULINT, LINT (as well as the SAFE versions of these data tyes too!)
       
    49  * 
       
    50  *  In this class, the datatype of '0' will be set to the same datatype as the 'foo' variable.
       
    51  *  If the intersection of the candidate datatype lists of the left and right side expressions is empty, 
       
    52  *  then a datatype error has been found, and the datatype is either left at NULL, or set to a pointer of an invalid_type_name_c object!
    37  */
    53  */
       
    54 
    38 
    55 
    39 #include "narrow_candidate_datatypes.hh"
    56 #include "narrow_candidate_datatypes.hh"
    40 #include "datatype_functions.hh"
    57 #include "datatype_functions.hh"
    41 #include <typeinfo>
    58 #include <typeinfo>
    42 #include <list>
    59 #include <list>