Classes

Philip Herron redbrain@gcc.gnu.org
Tue Apr 5 02:58:00 GMT 2011


Whoops i pressed space by accident and it send the mail sorry i didnt
get to finish this email, the questions was how would i go about
representing:

class foobar {
  int x,y

  int member_method (int);
}

So i guess you would follow your nomal record_type stuff but i am not
sure what the field_decl should look like for the member_functions.

On 5 April 2011 03:55, Philip Herron <redbrain@gcc.gnu.org> wrote:
> Hey all
>
> I am getting my program model in my front-end devloped to be more
> sensible now since all the ground work i've done is now paying off.
>
> And i just have a few questions about creating classes in GENERIC from
> what i've been reading and poking about so far you seem to make a
> RECORD_TYPE then add all your VAR_DECLS as FIELD_DECL's as usual but i
> am unsure how you add in member functions do you do the same thing but
> simply TREE_CHAIN the field decl with the member function name and its
> return type or something but i dont think that makes sense.
>
> Not sure if that made sense well for example i want to represent:
>
> class foobar {
>  int x,y;
>
>
> }
>
>
>
>  i have a record type like:
>
>  tree gpy_object_struct_Type = make_node (RECORD_TYPE);
>
>  name = get_identifier("type");
>  field = build_decl(BUILTINS_LOCATION, FIELD_DECL, name, integer_type_node);
>  DECL_CONTEXT(field) = gpy_object_struct_Type;
>  DECL_CHAIN(last_field) = field;
>  last_field = field;
>
> Then say i wanted to add a member function what should the FIELD_DECL
> look like I am up far too late so its probably really obvious but i am
> too sleepy to realise.
>



More information about the Gcc-help mailing list