[LLVMdev] Order of fiels and structure usage
Eli Friedman
eli.friedman at gmail.com
Sat Sep 13 11:45:50 PDT 2008
On Sat, Sep 13, 2008 at 11:09 AM, Hendrik Boom <hendrik at topoi.pooq.com> wrote:
> What I want is to be able to use the fields that have already been
> defined, even though the type isn't complete yet. The vector<const
> Type*> is all I have at that moment, and it isn't a type. But by the
> time I have a type it's frozen and I can't add new fields to it.
>
> Do I gather that I keep making new types, each slightly larger than the
> previous ones, cast each pointer to my growing type to the type-of-the-
> moment, and field-select from it; then finally complete the type when
> all is known? That might just work, if field-allocation is independent
> of later fields, but it is ugly.
Field-allocation is guaranteed to be independent of later fields, so
the casting solution would work.
It might be slightly cleaner to define the types recursively... for
example, define a struct as { i32 { float { i32* } } }. That way, you
wouldn't have a bunch of partial types floating around.
-Eli
More information about the llvm-dev
mailing list