stage3/fill_candidate_datatypes.cc
changeset 972 bc90dd4bbf4f
parent 965 c9eeb67ba939
child 994 66dc2ef40e70
equal deleted inserted replaced
971:8aee27d46208 972:bc90dd4bbf4f
    88 /* Add to the global_enumerated_value_symtable the global enum value constants, i.e. the enum constants used in the enumerated
    88 /* Add to the global_enumerated_value_symtable the global enum value constants, i.e. the enum constants used in the enumerated
    89  * datatypes that are defined inside a TYPE ... END_TYPE declaration.
    89  * datatypes that are defined inside a TYPE ... END_TYPE declaration.
    90  */
    90  */
    91 /* NOTE: we do not store any NULL values in this symbol table, so we can safely use NULL and the null value. */
    91 /* NOTE: we do not store any NULL values in this symbol table, so we can safely use NULL and the null value. */
    92 
    92 
    93 symbol_c null_enumvalue_symbol; /* cannot be static, so it may be used in the template!! */
    93 typedef dsymtable_c<symbol_c *> enumerated_value_symtable_t;
    94 typedef dsymtable_c<symbol_c *, &null_enumvalue_symbol> enumerated_value_symtable_t;
       
    95 static enumerated_value_symtable_t global_enumerated_value_symtable;
    94 static enumerated_value_symtable_t global_enumerated_value_symtable;
    96  
    95  
    97  
    96  
    98 class populate_globalenumvalue_symtable_c: public iterator_visitor_c {
    97 class populate_globalenumvalue_symtable_c: public iterator_visitor_c {
    99   private:
    98   private:
  1050 		for (; lower != upper; lower++)
  1049 		for (; lower != upper; lower++)
  1051 			if (get_datatype_info_c::is_type_equal(base_type(lower->second), base_type(symbol->type)))
  1050 			if (get_datatype_info_c::is_type_equal(base_type(lower->second), base_type(symbol->type)))
  1052 				enumerated_type = symbol->type; 
  1051 				enumerated_type = symbol->type; 
  1053 	}
  1052 	}
  1054 	else {
  1053 	else {
  1055 		symbol_c *global_enumerated_type = global_enumerated_value_symtable.find_value  (symbol->value);
  1054 		symbol_c *global_enumerated_type = global_enumerated_value_symtable.find (symbol->value)->second;
  1056 		symbol_c * local_enumerated_type =  local_enumerated_value_symtable.find_value  (symbol->value);
  1055 		symbol_c * local_enumerated_type =  local_enumerated_value_symtable.find (symbol->value)->second;
  1057 		int       global_multiplicity    = global_enumerated_value_symtable.count(symbol->value);
  1056 		int       global_multiplicity    = global_enumerated_value_symtable.count(symbol->value);
  1058 		int        local_multiplicity    =  local_enumerated_value_symtable.count(symbol->value);
  1057 		int        local_multiplicity    =  local_enumerated_value_symtable.count(symbol->value);
  1059 
  1058 
  1060 		if      (( local_multiplicity == 0) && (global_multiplicity == 0))
  1059 		if      (( local_multiplicity == 0) && (global_multiplicity == 0))
  1061 		  enumerated_type = NULL; // not found!
  1060 		  enumerated_type = NULL; // not found!