stage3/fill_candidate_datatypes.cc
changeset 909 8b2a31dea131
parent 873 dea39ef02847
child 911 ef3347dbfa0c
equal deleted inserted replaced
908:9e8e1ba5ca46 909:8b2a31dea131
  1104 
  1104 
  1105 /*  function_block_type_name ASSIGN structure_initialization */
  1105 /*  function_block_type_name ASSIGN structure_initialization */
  1106 /* structure_initialization -> may be NULL ! */
  1106 /* structure_initialization -> may be NULL ! */
  1107 // SYM_REF2(fb_spec_init_c, function_block_type_name, structure_initialization)
  1107 // SYM_REF2(fb_spec_init_c, function_block_type_name, structure_initialization)
  1108 void *fill_candidate_datatypes_c::visit(fb_spec_init_c *symbol) {return fill_spec_init(symbol, symbol->function_block_type_name, symbol->structure_initialization);}
  1108 void *fill_candidate_datatypes_c::visit(fb_spec_init_c *symbol) {return fill_spec_init(symbol, symbol->function_block_type_name, symbol->structure_initialization);}
       
  1109 
       
  1110 
       
  1111 /* REF_TO (non_generic_type_name | function_block_type_name) */
       
  1112 // SYM_REF1(ref_spec_c, type_name)
       
  1113 void *fill_candidate_datatypes_c::visit(ref_spec_c *symbol) {
       
  1114   
       
  1115 	// when parsing datatype declarations, fill_candidate_datatypes_c follows a top->down algorithm (see the comment in fill_type_decl() for an explanation)
       
  1116 	add_datatype_to_candidate_list(symbol->type_name, base_type(symbol->type_name)); 
       
  1117 	symbol->type_name->accept(*this);  /* The referenced/pointed to datatype! */
       
  1118 
       
  1119 	if (symbol->candidate_datatypes.size() == 0) // i.e., if this is an anonymous datatype!
       
  1120 		add_datatype_to_candidate_list(symbol, base_type(symbol)); 
       
  1121 
       
  1122 	return NULL;
       
  1123 }
       
  1124 
       
  1125 /* For the moment, we do not support initialising reference data types */
       
  1126 /* ref_spec [ ASSIGN ref_initialization ] */ 
       
  1127 /* NOTE: ref_initialization may be NULL!! */
       
  1128 // SYM_REF2(ref_spec_init_c, ref_spec, ref_initialization)
       
  1129 void *fill_candidate_datatypes_c::visit(ref_spec_init_c *symbol) {return fill_spec_init(symbol, symbol->ref_spec, symbol->ref_initialization);}
       
  1130 
       
  1131 /* identifier ':' ref_spec_init */
       
  1132 // SYM_REF2(ref_type_decl_c, ref_type_name, ref_spec_init)
       
  1133 void *fill_candidate_datatypes_c::visit(ref_type_decl_c *symbol) {return fill_type_decl(symbol, symbol->ref_type_name, symbol->ref_spec_init);}
       
  1134 
       
  1135 
  1109 
  1136 
  1110 
  1137 
  1111 
  1138 
  1112 /*********************/
  1139 /*********************/
  1113 /* B 1.4 - Variables */
  1140 /* B 1.4 - Variables */
  1833 /* B 3.1 - Expressions */
  1860 /* B 3.1 - Expressions */
  1834 /***********************/
  1861 /***********************/
  1835 /* SYM_REF1(ref_expression_c, exp)  --> an extension to the IEC 61131-3 standard - based on the IEC 61131-3 v3 standard. Returns address of the varible! */
  1862 /* SYM_REF1(ref_expression_c, exp)  --> an extension to the IEC 61131-3 standard - based on the IEC 61131-3 v3 standard. Returns address of the varible! */
  1836 void *fill_candidate_datatypes_c::visit(  ref_expression_c  *symbol) {
  1863 void *fill_candidate_datatypes_c::visit(  ref_expression_c  *symbol) {
  1837   symbol->exp->accept(*this);
  1864   symbol->exp->accept(*this);
  1838   /* we should really check whether the expression is merely a variable. For now, leave it for the future! */
  1865   /* we should really check whether the expression is an lvalue. For now, leave it for the future! */
  1839   /* For now, we handle references (i.e. pointers) as ULINT datatypes! */
  1866   /* For now, we handle references (i.e. pointers) as ULINT datatypes! */
  1840   add_datatype_to_candidate_list(symbol, &get_datatype_info_c::ulint_type_name);
  1867   add_datatype_to_candidate_list(symbol, &get_datatype_info_c::ulint_type_name);
  1841   return NULL;
  1868   return NULL;
  1842 }
  1869 }
  1843     
  1870