stage3/narrow_candidate_datatypes.cc
changeset 996 c752b113237b
parent 994 66dc2ef40e70
child 1028 7c8709ce6b8f
equal deleted inserted replaced
995:ce997a27c516 996:c752b113237b
   414 	return search_base_type_c::get_basetype_decl(symbol);
   414 	return search_base_type_c::get_basetype_decl(symbol);
   415 }
   415 }
   416 
   416 
   417 
   417 
   418 
   418 
       
   419 /*************************/
       
   420 /* B.1 - Common elements */
       
   421 /*************************/
       
   422 /*******************************************/
       
   423 /* B 1.1 - Letters, digits and identifiers */
       
   424 /*******************************************/
       
   425 /* Before the existance of this derived_datatype_identifier_c class, all identifiers were stored in the generic identifier_c class.
       
   426  * Since not all identifiers are used to identify a datatype, the fill/narrow algorithms could not do fill/narrow on all identifiers, and relied
       
   427  * on the parent class to do the fill/narrow when apropriate (i.e. when the identifier was known to reference a datatype
       
   428  * for example, in a variable declaration -->  var1: some_user_defined_type;)
       
   429  *
       
   430  * However, at least one location where an identifier may reference a datatype has not yet been covered:
       
   431  *     array1: ARRAY [1..2] OF INT;
       
   432  *     array2: ARRAY [1..2] OF array1;  (* array1 here is stored as a derived_datatype_identifier_c)
       
   433  *
       
   434  * Instead of doing it like the old way, I have opted to do a generic fill/narrow for all derived_datatype_identifier_c
       
   435  * This means that we can now delete the code of all parents of derived_datatype_identifier_c that are still doing the fill/narrow
       
   436  * explicitly (assuming we do also implement the visitor for poutype_identifier_c). However, I will leave this code cleanup for some later oportunity.
       
   437  */
       
   438 void *narrow_candidate_datatypes_c::visit(derived_datatype_identifier_c *symbol) {
       
   439 	// If this symbol was used (for example) in an ARRAY [1..2] OF <derived_datatype_identifier_c> (i.e. a datatype in an array)
       
   440 	// then the symbol->datatype of this derived_datatype_identifier_c has not yet been set by the previous visit() method!
       
   441 	// We therefore set the datatype ourselves!
       
   442 	if ((NULL == symbol->datatype) && (symbol->candidate_datatypes.size() == 1))
       
   443 		symbol->datatype = symbol->candidate_datatypes[0];
       
   444 	return NULL;
       
   445 }
       
   446 
       
   447 
       
   448 /* The datatype of a poutype_identifier_c is currently always being set by the parent object, so we leave this code commented out for now. */
       
   449 /* 
       
   450 void *narrow_candidate_datatypes_c::visit(         poutype_identifier_c *symbol) {
       
   451 	// If this symbol was used (for example) in an ARRAY [1..2] OF <derived_datatype_identifier_c> (i.e. a datatype in an array)
       
   452 	// then the symbol->datatype of this derived_datatype_identifier_c has not yet been set by the previous visit() method!
       
   453 	// We therefore set the datatype ourselves!
       
   454 	if ((NULL == symbol->datatype) && (symbol->candidate_datatypes.size() == 1))
       
   455 		symbol->datatype = symbol->candidate_datatypes[0];
       
   456 	return NULL;
       
   457 }
       
   458 */
       
   459     
       
   460     
   419 
   461 
   420 /**********************/
   462 /**********************/
   421 /* B 1.3 - Data types */
   463 /* B 1.3 - Data types */
   422 /**********************/
   464 /**********************/
   423 /***********************************/
   465 /***********************************/