28 * Based on the |
28 * Based on the |
29 * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) |
29 * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) |
30 * |
30 * |
31 */ |
31 */ |
32 |
32 |
|
33 /* NOTE: The use of this visitor class is now deprecated. |
|
34 * The new version of stage3 data type checking adds an entry to |
|
35 * every relevant object in the abstract syntax tree defining |
|
36 * the data type of that object. Please use that instead! |
|
37 */ |
|
38 |
|
39 |
|
40 |
33 /* Determine the data type of a specific constant or variable. |
41 /* Determine the data type of a specific constant or variable. |
34 * A reference to the relevant type definition is returned. |
42 * A reference to the relevant type definition is returned. |
35 * |
43 * |
36 * For example: |
44 * For example: |
37 * 22 -> returns reference to a int_type_name_c object. |
45 * 22 -> returns reference to a int_type_name_c object. |
47 #define _SEARCH_CONSTANT_TYPE_HH |
55 #define _SEARCH_CONSTANT_TYPE_HH |
48 |
56 |
49 class search_constant_type_c: public search_visitor_c { |
57 class search_constant_type_c: public search_visitor_c { |
50 |
58 |
51 public: |
59 public: |
|
60 /* object used to identify an entry in the abstract syntax tree with an invalid data type */ |
|
61 /* This is only used from stage3 onwards. Stages 1 and 2 will never create any instances of invalid_type_name_c */ |
|
62 static invalid_type_name_c invalid_type_name; |
|
63 |
52 /**********************/ |
64 /**********************/ |
53 /* B.1.3 - Data types */ |
65 /* B.1.3 - Data types */ |
54 /**********************/ |
66 /**********************/ |
55 /***********************************/ |
67 /***********************************/ |
56 /* B 1.3.1 - Elementary Data Types */ |
68 /* B 1.3.1 - Elementary Data Types */ |
75 static ulint_type_name_c ulint_type_name; |
87 static ulint_type_name_c ulint_type_name; |
76 static bool_type_name_c bool_type_name; |
88 static bool_type_name_c bool_type_name; |
77 static time_type_name_c time_type_name; |
89 static time_type_name_c time_type_name; |
78 static int_type_name_c int_type_name; |
90 static int_type_name_c int_type_name; |
79 |
91 |
80 /* temporarily here until we remove the st_code_gen.c and il_code_gen.c files... */ |
|
81 static integer_c integer; |
|
82 static real_c real; |
|
83 |
92 |
84 /******************************************************/ |
93 /******************************************************/ |
85 /* Extensions to the base standard as defined in */ |
94 /* Extensions to the base standard as defined in */ |
86 /* "Safety Software Technical Specification, */ |
95 /* "Safety Software Technical Specification, */ |
87 /* Part 1: Concepts and Function Blocks, */ |
96 /* Part 1: Concepts and Function Blocks, */ |
94 * (in this case, TIME) that is neither of the expression elements... |
103 * (in this case, TIME) that is neither of the expression elements... |
95 */ |
104 */ |
96 static safetime_type_name_c safetime_type_name; |
105 static safetime_type_name_c safetime_type_name; |
97 static safetod_type_name_c safetod_type_name; |
106 static safetod_type_name_c safetod_type_name; |
98 static safedt_type_name_c safedt_type_name; |
107 static safedt_type_name_c safedt_type_name; |
99 |
108 static safedate_type_name_c safedate_type_name; |
100 |
109 static safereal_type_name_c safereal_type_name; |
|
110 static safesint_type_name_c safesint_type_name; |
|
111 static safelint_type_name_c safelint_type_name; |
|
112 static safedint_type_name_c safedint_type_name; |
|
113 static safedword_type_name_c safedword_type_name; |
|
114 static safeudint_type_name_c safeudint_type_name; |
|
115 static safeword_type_name_c safeword_type_name; |
|
116 static safewstring_type_name_c safewstring_type_name; |
|
117 static safestring_type_name_c safestring_type_name; |
|
118 static safelword_type_name_c safelword_type_name; |
|
119 static safeuint_type_name_c safeuint_type_name; |
|
120 static safelreal_type_name_c safelreal_type_name; |
|
121 static safebyte_type_name_c safebyte_type_name; |
|
122 static safeusint_type_name_c safeusint_type_name; |
|
123 static safeulint_type_name_c safeulint_type_name; |
|
124 static safebool_type_name_c safebool_type_name; |
|
125 static safeint_type_name_c safeint_type_name; |
101 |
126 |
102 public: |
127 public: |
103 symbol_c *get_type(symbol_c *constant); |
128 symbol_c *get_type(symbol_c *constant); |
104 |
129 |
105 |
130 |
139 /************************/ |
164 /************************/ |
140 /* B 1.2.3.1 - Duration */ |
165 /* B 1.2.3.1 - Duration */ |
141 /************************/ |
166 /************************/ |
142 void *visit(neg_time_c *symbol); |
167 void *visit(neg_time_c *symbol); |
143 void *visit(duration_c *symbol); |
168 void *visit(duration_c *symbol); |
|
169 void *visit(interval_c *symbol); |
144 void *visit(fixed_point_c *symbol); |
170 void *visit(fixed_point_c *symbol); |
145 void *visit(days_c *symbol); |
|
146 void *visit(hours_c *symbol); |
|
147 void *visit(minutes_c *symbol); |
|
148 void *visit(seconds_c *symbol); |
|
149 void *visit(milliseconds_c *symbol); |
|
150 |
171 |
151 /************************************/ |
172 /************************************/ |
152 /* B 1.2.3.2 - Time of day and Date */ |
173 /* B 1.2.3.2 - Time of day and Date */ |
153 /************************************/ |
174 /************************************/ |
154 void *visit(time_of_day_c *symbol); |
175 void *visit(time_of_day_c *symbol); |