Fix mangling of types when attaching protocols.

The protocol attachment test was in the wrong place, and there were some
typos in compare_protocols and procollist_find_protocol.
This commit is contained in:
Bill Currie 2012-12-20 13:12:05 +09:00
parent 211a7a8bbb
commit 6d6f231bd2
4 changed files with 11 additions and 5 deletions

View file

@ -153,6 +153,7 @@ void protocol_add_protocols (protocol_t *protocol, protocollist_t *protocols);
struct def_s *protocol_def (protocol_t *protocol);
protocollist_t *new_protocol_list (void);
protocollist_t *add_protocol (protocollist_t *protocollist, const char *name);
int procollist_find_protocol (protocollist_t *protocollist, protocol_t *proto);
int compare_protocols (protocollist_t *protos1, protocollist_t *protos2);
void print_protocollist (struct dstring_s *dstr, protocollist_t *protocollist);
struct def_s *emit_protocol (protocol_t *protocol);

View file

@ -1295,10 +1295,12 @@ add_protocol (protocollist_t *protocollist, const char *name)
return protocollist;
}
static int
int
procollist_find_protocol (protocollist_t *protocollist, protocol_t *proto)
{
int i;
if (!protocollist)
return 0;
for (i = 0; i < protocollist->count; i++)
if (protocollist->list[i] == proto)
return 1;
@ -1310,7 +1312,7 @@ compare_protocols (protocollist_t *protos1, protocollist_t *protos2)
{
int i;
if (protos2 == protos2)
if (protos1 == protos2)
return 1;
if (!protos1 || !protos2)
return 0;

View file

@ -466,8 +466,9 @@ type_specifier
{
if ($2) {
type_t type = *type_id.t.fldptr.type;
type.next = 0;
type.protos = $2;
$$ = make_spec (pointer_type (&type), 0, 0, 0);
$$ = make_spec (pointer_type (find_type (&type)), 0, 0, 0);
} else {
$$ = make_spec (&type_id, 0, 0, 0);
}
@ -476,6 +477,7 @@ type_specifier
{
if ($2) {
type_t type = *$1->type;
type.next = 0;
type.protos = $2;
$$ = make_spec (find_type (&type), 0, 0, 0);
} else {

View file

@ -237,7 +237,6 @@ types_same (type_t *a, type_t *b)
case ev_pointer:
if (a->t.fldptr.type != b->t.fldptr.type)
return 0;
return compare_protocols (a->protos, b->protos);
case ev_func:
if (a->t.func.type != b->t.func.type
|| a->t.func.num_params != b->t.func.num_params)
@ -259,6 +258,8 @@ types_same (type_t *a, type_t *b)
case ty_enum:
if (strcmp (a->name, b->name))
return 0;
if (a->meta == ty_struct)
return compare_protocols (a->protos, b->protos);
return 1;
case ty_array:
if (a->t.array.type != b->t.array.type
@ -269,7 +270,7 @@ types_same (type_t *a, type_t *b)
case ty_class:
if (a->t.class != b->t.class)
return 0;
return 1;
return compare_protocols (a->protos, b->protos);
}
internal_error (0, "we be broke");
}