harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pavel Pervov" <pmcfi...@gmail.com>
Subject Re: [drlvm][gc] Question about references and fields.
Date Thu, 24 Jan 2008 12:26:55 GMT
Yuri,

1) Use the Xiao-Feng's proposal to find "next" field in each object of
your list.
2) From that field retrieve its offset.
3) Use offset to find the value of 'next' field. Smth like this:

Partial_Reveal_Object* next_obj =
(Partial_Reveal_Object*)((char*)this_obj + next_field_offset);

WBR,
Pavel.

On 1/24/08, Yuri Kashnikoff <yuri.kashnikoff@gmail.com> wrote:
> On Jan 24, 2008 5:47 PM, Xiao-Feng Li <xiaofeng.li@gmail.com> wrote:
> > Yuri, to get reference field you need different approach. Object field
> > meta info are kept in its class structure. From an object, you can get
> > it's vtable pointer (VTable*), from vtable pointer you can get its
> > class structure (Class* or Class_Handle). Assuming you have the
> > Class_Handle of a class _clss, then you can iterate its fields by
> > following routine:
> >
> >   unsigned int nfields = class_number_fields(_clss);
> >   unsigned int i;
> >
> >   for(i=0; i<nfields; i++){
> >     Field_Handle field = class_get_field(_clss, i);
> >     char* field_name = field_get_name(field);
> >   }
> >
> > Please play around to be familiar with the APIs.
> Xiao-Feng, first of all thank You for your answer!
>
> Sorry may be I was incorrect. I know how to iterate fields with such
> method as You have mentioned above. Imagine that there is a list
> implementation and 'next' field is typically 'next' field of list
> implementation ('next' refers to the next element of the list).
> How to get the address of the object on which it('next') refers?
>
> --
> Yuri S. Kashnikov
> Novosibirsk State University, Russia
> 2 Pirogova street
> 630090, Novosibirsk-90
> yuri.kashnikoff@gmail.com
>

Mime
View raw message