X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=type_hash.c;h=3f84c5d4620227a4bb302a013bee24920fbfe76c;hb=e66a2691d3291916ed2ec07ed1cdead2a95e1a9a;hp=29535ffcd0e719e834cad1a5948deb263580dc8a;hpb=05dbb10d24382cce46842d47c7eab8471a8c8834;p=cparser diff --git a/type_hash.c b/type_hash.c index 29535ff..3f84c5d 100644 --- a/type_hash.c +++ b/type_hash.c @@ -52,12 +52,11 @@ unsigned hash_method_type(const method_type_t *type) { unsigned result = hash_ptr(type->result_type); - method_parameter_type_t *parameter = type->parameter_types; + declaration_t *parameter = type->parameters; while(parameter != NULL) { - result ^= hash_ptr(parameter->type); + result ^= hash_ptr(parameter); parameter = parameter->next; } - result ^= hash_ptr(type->abi_style); return result; } @@ -118,22 +117,24 @@ static int compound_types_equal(const compound_type_t *type1, const compound_type_t *type2) { + if(type1->type.type != type2->type.type) + return 0; if(type1->symbol != type2->symbol) return 0; -#if 0 - struct_entry_t *entry1 = type1->entries; - struct_entry_t *entry2 = type2->entries; + declaration_t *entry1 = type1->context.declarations; + declaration_t *entry2 = type2->context.declarations; while(entry1 != NULL && entry2 != NULL) { if(entry1->type != entry2->type) return 0; + if(entry1->symbol != entry2->symbol) + return 0; entry1 = entry1->next; entry2 = entry2->next; } if(entry1 != NULL || entry2 != NULL) return 0; -#endif return 1; } @@ -144,11 +145,8 @@ int method_types_equal(const method_type_t *type1, const method_type_t *type2) if(type1->result_type != type2->result_type) return 0; - if(type1->abi_style != type2->abi_style) - return 0; - - method_parameter_type_t *param1 = type1->parameter_types; - method_parameter_type_t *param2 = type2->parameter_types; + declaration_t *param1 = type1->parameters; + declaration_t *param2 = type2->parameters; while(param1 != NULL && param2 != NULL) { if(param1->type != param2->type) return 0; @@ -171,8 +169,22 @@ int pointer_types_equal(const pointer_type_t *type1, static int enum_types_equal(const enum_type_t *type1, const enum_type_t *type2) { - /* TODO */ - return type1->symbol == type2->symbol; + if(type1->symbol != NULL && type1->symbol == type2->symbol) + return 1; + + enum_entry_t *entry1 = type1->entries; + enum_entry_t *entry2 = type2->entries; + while(entry1 != NULL && entry2 != NULL) { + if(entry1->symbol != entry2->symbol) + return 0; + /* TODO: compare expressions */ + entry1 = entry1->next; + entry2 = entry2->next; + } + if(entry1 != NULL || entry2 != NULL) + return 0; + + return 1; } static