307 /* NOTE: only the initialized structure is ever used when declaring a new variable instance */ |
307 /* NOTE: only the initialized structure is ever used when declaring a new variable instance */ |
308 void *search_varfb_instance_type_c::visit(initialized_structure_c *symbol) { |
308 void *search_varfb_instance_type_c::visit(initialized_structure_c *symbol) { |
309 this->is_complex = true; |
309 this->is_complex = true; |
310 if (NULL != current_structelement_name) ERROR; |
310 if (NULL != current_structelement_name) ERROR; |
311 |
311 |
312 /* make sure that we have decomposed all strcuture elements of the variable name */ |
312 /* make sure that we have decomposed all structure elements of the variable name */ |
|
313 symbol_c *var_name = decompose_var_instance_name->next_part(); |
|
314 if (NULL == var_name) { |
|
315 /* this is it... ! |
|
316 * No need to look any further... |
|
317 * Note also that, unlike for the struct types, a function block may |
|
318 * not be defined based on another (i.e. no inheritance is allowed), |
|
319 * so this function block is already the most base type. |
|
320 * We simply return it. |
|
321 */ |
|
322 return (void *)symbol; |
|
323 } |
|
324 |
|
325 /* reset current_type_id because of new structure element part */ |
|
326 this->current_typeid = NULL; |
|
327 |
|
328 /* look for the var_name in the structure declaration */ |
|
329 current_structelement_name = var_name; |
|
330 |
|
331 /* recursively find out the data type of current_structelement_name... */ |
|
332 return symbol->structure_type_name->accept(*this); |
|
333 } |
|
334 |
|
335 /* helper symbol for structure_declaration */ |
|
336 /* structure_declaration: STRUCT structure_element_declaration_list END_STRUCT */ |
|
337 /* structure_element_declaration_list structure_element_declaration ';' */ |
|
338 void *search_varfb_instance_type_c::visit(structure_element_declaration_list_c *symbol) { |
|
339 if (NULL == current_structelement_name) ERROR; |
|
340 /* now search the structure declaration */ |
|
341 return visit_list(symbol); |
|
342 } |
|
343 |
|
344 /* structure_element_name ':' spec_init */ |
|
345 void *search_varfb_instance_type_c::visit(structure_element_declaration_c *symbol) { |
|
346 if (NULL == current_structelement_name) ERROR; |
|
347 |
|
348 if (compare_identifiers(symbol->structure_element_name, current_structelement_name) == 0) { |
|
349 current_structelement_name = NULL; |
|
350 /* found the type of the element we were looking for! */ |
|
351 return symbol->spec_init->accept(*this); |
|
352 } |
|
353 |
|
354 /* Did not find the type of the element we were looking for! */ |
|
355 /* Will keep looking... */ |
|
356 return NULL; |
|
357 } |
|
358 |
|
359 /* helper symbol for structure_initialization */ |
|
360 /* structure_initialization: '(' structure_element_initialization_list ')' */ |
|
361 /* structure_element_initialization_list ',' structure_element_initialization */ |
|
362 void *search_varfb_instance_type_c::visit(structure_element_initialization_list_c *symbol) {ERROR; return NULL;} /* should never get called... */ |
|
363 /* structure_element_name ASSIGN value */ |
|
364 void *search_varfb_instance_type_c::visit(structure_element_initialization_c *symbol) {ERROR; return NULL;} /* should never get called... */ |
|
365 |
|
366 |
|
367 |
|
368 /**************************************/ |
|
369 /* B.1.5 - Program organization units */ |
|
370 /**************************************/ |
|
371 /*****************************/ |
|
372 /* B 1.5.2 - Function Blocks */ |
|
373 /*****************************/ |
|
374 /* FUNCTION_BLOCK derived_function_block_name io_OR_other_var_declarations function_block_body END_FUNCTION_BLOCK */ |
|
375 // SYM_REF4(function_block_declaration_c, fblock_name, var_declarations, fblock_body, unused) |
|
376 void *search_varfb_instance_type_c::visit(function_block_declaration_c *symbol) { |
|
377 /* make sure that we have decomposed all structure elements of the variable name */ |
313 symbol_c *var_name = decompose_var_instance_name->next_part(); |
378 symbol_c *var_name = decompose_var_instance_name->next_part(); |
314 if (NULL == var_name) { |
379 if (NULL == var_name) { |
315 /* this is it... ! |
380 /* this is it... ! |
316 * No need to look any further... |
381 * No need to look any further... |
317 * Note also that, unlike for the struct types, a function block may |
382 * Note also that, unlike for the struct types, a function block may |
320 * We simply return it. |
385 * We simply return it. |
321 */ |
386 */ |
322 return (void *)symbol; |
387 return (void *)symbol; |
323 } |
388 } |
324 |
389 |
325 /* look for the var_name in the structure declaration */ |
390 /* reset current_type_id because of new structure element part */ |
326 current_structelement_name = var_name; |
391 this->current_typeid = NULL; |
327 |
|
328 /* recursively find out the data type of current_structelement_name... */ |
|
329 return symbol->structure_type_name->accept(*this); |
|
330 } |
|
331 |
|
332 /* helper symbol for structure_declaration */ |
|
333 /* structure_declaration: STRUCT structure_element_declaration_list END_STRUCT */ |
|
334 /* structure_element_declaration_list structure_element_declaration ';' */ |
|
335 void *search_varfb_instance_type_c::visit(structure_element_declaration_list_c *symbol) { |
|
336 if (NULL == current_structelement_name) ERROR; |
|
337 /* now search the structure declaration */ |
|
338 return visit_list(symbol); |
|
339 } |
|
340 |
|
341 /* structure_element_name ':' spec_init */ |
|
342 void *search_varfb_instance_type_c::visit(structure_element_declaration_c *symbol) { |
|
343 if (NULL == current_structelement_name) ERROR; |
|
344 |
|
345 if (compare_identifiers(symbol->structure_element_name, current_structelement_name) == 0) { |
|
346 current_structelement_name = NULL; |
|
347 /* found the type of the element we were looking for! */ |
|
348 return symbol->spec_init->accept(*this); |
|
349 } |
|
350 |
|
351 /* Did not find the type of the element we were looking for! */ |
|
352 /* Will keep looking... */ |
|
353 return NULL; |
|
354 } |
|
355 |
|
356 /* helper symbol for structure_initialization */ |
|
357 /* structure_initialization: '(' structure_element_initialization_list ')' */ |
|
358 /* structure_element_initialization_list ',' structure_element_initialization */ |
|
359 void *search_varfb_instance_type_c::visit(structure_element_initialization_list_c *symbol) {ERROR; return NULL;} /* should never get called... */ |
|
360 /* structure_element_name ASSIGN value */ |
|
361 void *search_varfb_instance_type_c::visit(structure_element_initialization_c *symbol) {ERROR; return NULL;} /* should never get called... */ |
|
362 |
|
363 |
|
364 |
|
365 /**************************************/ |
|
366 /* B.1.5 - Program organization units */ |
|
367 /**************************************/ |
|
368 /*****************************/ |
|
369 /* B 1.5.2 - Function Blocks */ |
|
370 /*****************************/ |
|
371 /* FUNCTION_BLOCK derived_function_block_name io_OR_other_var_declarations function_block_body END_FUNCTION_BLOCK */ |
|
372 // SYM_REF4(function_block_declaration_c, fblock_name, var_declarations, fblock_body, unused) |
|
373 void *search_varfb_instance_type_c::visit(function_block_declaration_c *symbol) { |
|
374 /* make sure that we have decomposed all strcuture elements of the variable name */ |
|
375 symbol_c *var_name = decompose_var_instance_name->next_part(); |
|
376 if (NULL == var_name) { |
|
377 /* this is it... ! |
|
378 * No need to look any further... |
|
379 * Note also that, unlike for the struct types, a function block may |
|
380 * not be defined based on another (i.e. no inheritance is allowed), |
|
381 * so this function block is already the most base type. |
|
382 * We simply return it. |
|
383 */ |
|
384 return (void *)symbol; |
|
385 } |
|
386 |
392 |
387 /* now search the function block declaration for the variable... */ |
393 /* now search the function block declaration for the variable... */ |
388 search_var_instance_decl_c search_decl(symbol); |
394 search_var_instance_decl_c search_decl(symbol); |
389 symbol_c *var_decl = search_decl.get_decl(var_name); |
395 symbol_c *var_decl = search_decl.get_decl(var_name); |
390 if (NULL == var_decl) { |
396 if (NULL == var_decl) { |