stage3/narrow_candidate_datatypes.cc
changeset 909 8b2a31dea131
parent 895 f824bf8e1579
child 910 a0518971127d
equal deleted inserted replaced
908:9e8e1ba5ca46 909:8b2a31dea131
   645 /* structure_initialization may be NULL ! */
   645 /* structure_initialization may be NULL ! */
   646 // SYM_REF2(initialized_structure_c, structure_type_name, structure_initialization)
   646 // SYM_REF2(initialized_structure_c, structure_type_name, structure_initialization)
   647 void *narrow_candidate_datatypes_c::visit(fb_spec_init_c *symbol) {return narrow_spec_init(symbol, symbol->function_block_type_name, symbol->structure_initialization);}
   647 void *narrow_candidate_datatypes_c::visit(fb_spec_init_c *symbol) {return narrow_spec_init(symbol, symbol->function_block_type_name, symbol->structure_initialization);}
   648 
   648 
   649 
   649 
       
   650 /* REF_TO (non_generic_type_name | function_block_type_name) */
       
   651 // SYM_REF1(ref_spec_c, type_name)
       
   652 void *narrow_candidate_datatypes_c::visit(ref_spec_c *symbol) {
       
   653 	/* First handle the datatype being referenced (pointed to) */
       
   654 	if (symbol->type_name->candidate_datatypes.size() == 1) {
       
   655 		symbol->type_name->datatype = symbol->type_name->candidate_datatypes[0];
       
   656 		symbol->type_name->accept(*this);
       
   657 	}
       
   658 
       
   659 	/* Now handle the reference datatype itself (i.e. the pointer) */
       
   660 	// If we are handling an anonymous datatype (i.e. a datatype implicitly declared inside a VAR ... END_VAR declaration)
       
   661 	// then the symbol->datatype has not yet been set by the previous visit(type_decl) method, because it does not exist!
       
   662 	// So we set the datatype ourselves!
       
   663 	if ((NULL == symbol->datatype) && (symbol->candidate_datatypes.size() == 1))
       
   664 		symbol->datatype = symbol->candidate_datatypes[0];
       
   665 
       
   666 	return NULL;
       
   667 }
       
   668 
       
   669 /* For the moment, we do not support initialising reference data types */
       
   670 /* ref_spec [ ASSIGN ref_initialization ] */ 
       
   671 /* NOTE: ref_initialization may be NULL!! */
       
   672 // SYM_REF2(ref_spec_init_c, ref_spec, ref_initialization)
       
   673 void *narrow_candidate_datatypes_c::visit(ref_spec_init_c *symbol) {return narrow_spec_init(symbol, symbol->ref_spec, symbol->ref_initialization);}
       
   674 
       
   675 /* identifier ':' ref_spec_init */
       
   676 // SYM_REF2(ref_type_decl_c, ref_type_name, ref_spec_init)
       
   677 void *narrow_candidate_datatypes_c::visit(ref_type_decl_c *symbol) {return narrow_type_decl(symbol, symbol->ref_type_name, symbol->ref_spec_init);}
       
   678 
       
   679 
       
   680 
   650 /*********************/
   681 /*********************/
   651 /* B 1.4 - Variables */
   682 /* B 1.4 - Variables */
   652 /*********************/
   683 /*********************/
   653 // SYM_REF1(symbolic_variable_c, var_name)
   684 // SYM_REF1(symbolic_variable_c, var_name)
   654 void *narrow_candidate_datatypes_c::visit(symbolic_variable_c *symbol) {
   685 void *narrow_candidate_datatypes_c::visit(symbolic_variable_c *symbol) {