53 |
53 |
54 private: // this is a purely static class. No need for constructors! |
54 private: // this is a purely static class. No need for constructors! |
55 get_datatype_info_c(void) {}; |
55 get_datatype_info_c(void) {}; |
56 ~get_datatype_info_c(void) {}; |
56 ~get_datatype_info_c(void) {}; |
57 |
57 |
|
58 // A helper method to get_datatype_info_c::is_type_equal() |
|
59 // Assuming the relaxed datatype model, return whether the two array datatypes are equal/equivalent |
|
60 static bool is_arraytype_equal_relaxed(symbol_c *first_type, symbol_c *second_type); |
58 |
61 |
59 public: |
62 public: |
60 static symbol_c *get_id (symbol_c *datatype); /* get the identifier (name) of the datatype); returns NULL if anonymous datatype! Does not work for elementary datatypes!*/ |
63 static symbol_c *get_id (symbol_c *datatype); /* get the identifier (name) of the datatype); returns NULL if anonymous datatype! Does not work for elementary datatypes!*/ |
61 static const char *get_id_str(symbol_c *datatype); /* get the identifier (name) of the datatype); returns NULL if anonymous datatype! */ |
64 static const char *get_id_str(symbol_c *datatype); /* get the identifier (name) of the datatype); returns NULL if anonymous datatype! */ |
62 |
65 |
63 static symbol_c *get_struct_field_type_id (symbol_c *struct_datatype, symbol_c *struct_fieldname); // returns datatype of a field in a structure |
66 static symbol_c *get_struct_field_type_id (symbol_c *struct_datatype, symbol_c *struct_fieldname); // returns datatype of a field in a structure |
64 static symbol_c *get_array_storedtype_id (symbol_c *type_symbol); // returns the datatype of the variables stored in the array |
67 static symbol_c *get_array_storedtype_id (symbol_c *type_symbol); // returns the datatype of the variables stored in the array |
65 static symbol_c *get_ref_to (symbol_c *type_symbol); // Defined in IEC 61131-3 v3 (returns the type that is being referenced/pointed to) |
68 static symbol_c *get_ref_to (symbol_c *type_symbol); // Defined in IEC 61131-3 v3 (returns the type that is being referenced/pointed to) |
66 |
69 |
67 /* Returns true if both datatypes are equivalent (not necessarily equal!). |
70 /* Returns true if both datatypes are equivalent (not necessarily equal!). |
68 * WARNING: May return true even though the datatypes are not the same/identicial!!! |
71 * Two datatype models are supported: relaxed and strict (chosen from a command line option). |
69 * This occurs when at least one of the datatypes is of a generic |
72 * WARNING: May return true even though the datatypes are not the same/identical!!! |
70 * datatype (or a REF_TO a generic datatype). |
73 * In both of the models, this may occur when at least one of the datatypes is of a generic |
71 * (Generic dataypes: ANY, ANY_INT, ANY_NUM, ...) |
74 * datatype (Generic dataypes: ANY, ANY_INT, ANY_NUM, ...), |
|
75 * or when two REF_TO datatypes both reference an equivalent datatype. |
|
76 * In only the relaxed datatype, it may also return true if two array datatypes |
|
77 * have the same subrange limits, and contain the same data. |
|
78 * |
72 * NOTE: Currently only the ANY generic datatype is implemented! |
79 * NOTE: Currently only the ANY generic datatype is implemented! |
73 * NOTE: Currently stage1_2 only allows the use of the ANY keyword when in conjuntion with |
80 * NOTE: Currently stage1_2 only allows the use of the ANY keyword when in conjuntion with |
74 * the REF_TO keyword (i.e. REF_TO ANY), so when handling non REF_TO datatypes, |
81 * the REF_TO keyword (i.e. REF_TO ANY). |
75 * this function will currently only return true if the dataypes are identicial. |
|
76 */ |
82 */ |
77 static bool is_type_equal(symbol_c *first_type, symbol_c *second_type); |
83 static bool is_type_equal(symbol_c *first_type, symbol_c *second_type); |
78 static bool is_type_valid(symbol_c *type); |
84 static bool is_type_valid(symbol_c *type); |
79 |
85 |
80 static bool is_ref_to (symbol_c *type_symbol); // Defined in IEC 61131-3 v3 |
86 static bool is_ref_to (symbol_c *type_symbol); // Defined in IEC 61131-3 v3 |