115 */ |
115 */ |
116 return base_type_name->accept(*this); |
116 return base_type_name->accept(*this); |
117 } |
117 } |
118 |
118 |
119 |
119 |
120 |
120 /* visitor for identifier_c is necessary because type_initial_value_c will be called to analyse PROGRAM identfiers, |
121 void *type_initial_value_c::visit(identifier_c *type_name) { |
121 * which are still transformed into identfier_c, instead of a derived_datatype_identifier_c |
|
122 */ |
|
123 void *type_initial_value_c::visit( identifier_c *type_name) { |
|
124 /* look up the type declaration... */ |
|
125 symbol_c *type_decl = type_symtable.find_value(type_name); |
|
126 if (type_decl == type_symtable.end_value()) |
|
127 /* Type declaration not found!! */ |
|
128 /* NOTE: Variables declared out of function block 'data types', |
|
129 * for eg: VAR timer: TON; END_VAR |
|
130 * do not have a default value, so (TON) will never be found in the |
|
131 * type symbol table. This means we cannot simply consider this |
|
132 * an error and abort, but must rather return a NULL. |
|
133 */ |
|
134 return NULL; |
|
135 |
|
136 return type_decl->accept(*this); |
|
137 } |
|
138 |
|
139 |
|
140 void *type_initial_value_c::visit(derived_datatype_identifier_c *type_name) { |
122 /* look up the type declaration... */ |
141 /* look up the type declaration... */ |
123 symbol_c *type_decl = type_symtable.find_value(type_name); |
142 symbol_c *type_decl = type_symtable.find_value(type_name); |
124 if (type_decl == type_symtable.end_value()) |
143 if (type_decl == type_symtable.end_value()) |
125 /* Type declaration not found!! */ |
144 /* Type declaration not found!! */ |
126 /* NOTE: Variables declared out of function block 'data types', |
145 /* NOTE: Variables declared out of function block 'data types', |