Use the symtab to check for qualified id.

type_id is implemented as a pointer to "struct obj_object" (ie, not really
a class), so the correct check is to ensure the type is:
 1  a pointer
 2  to a struct
 3  using the same symbol table as type_obj_object
This commit is contained in:
Bill Currie 2012-12-18 21:08:52 +09:00
parent 4f81a659b4
commit 686858a59d
2 changed files with 10 additions and 3 deletions

View file

@ -178,9 +178,14 @@ is_id (const type_t *type)
{
if (type == &type_id)
return 1;
// type may be a qualified id
if (type->type == ev_pointer
&& type->t.fldptr.type == type_id.t.fldptr.type)
// type may be a qualified id, in which case it will be a pointer to
// a qualified obj_object struct
if (type->type != ev_pointer)
return 0;
if (!is_struct (type->t.fldptr.type))
return 0;
// if the the symtabs match, then type is id in disguise
if (type->t.fldptr.type->t.symtab == type_obj_object.t.symtab)
return 1;
return 0;
}

View file

@ -461,6 +461,8 @@ print_type_str (dstring_t *str, const type_t *type)
switch (type->meta) {
case ty_class:
dasprintf (str, " %s", type->t.class->name);
if (type->protos)
print_protocollist (str, type->protos);
break;
case ty_enum:
dasprintf (str, " enum %s", type->name);