This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Re : Re : Classes


Hey again i havent had much time to play with it but my main mis
understanding was in your post:

tree operation_type = build_method_type_directly (class_t, void_type_node,
NULL_TREE);

tree operation = build_decl(BUILTINS_LOCATION, FUNCTION_DECL,
get_identifier("MyOperation"), operation_type);
tree parm = build_decl (BUILTINS_LOCATION, PARM_DECL, get_identifier("this"),
build_pointer_type(class_t));

tree ptr_obj = build1(ADDR_EXPR, build_pointer_type(TREE_TYPE(object)),object);
tree __call_expr = build_call_expr(__field2, 1, ptr_obj);

What is your __field2 ? is this your function in your record_type for
your class? And if so what way do you declare it do you do build_decl
(function_decl) or is it Method_type ?

I really should play around with this now.

--Phil

On 16 April 2011 21:56, charfi asma <charfiasma@yahoo.fr> wrote:
> Hello Phil,
>
> you will find answer to your question here :
> http://gcc.gnu.org/ml/gcc-help/2010-11/msg00090.html
> Ian suggest that I see the c++ front end and do the same, but it was a little
> diffucult for me ;)
>
> that's why I do it manually : I added the instance param in the CALL_EXPR tree
> code.
> you find also in the post my gimple and the cp gimple they are almost the same.
>
> Hope it helps.
>
> Asma
>
>
>
> ----- Message d'origine ----
> De : Philip Herron <redbrain@gcc.gnu.org>
> À : charfi asma <charfiasma@yahoo.fr>
> Cc : gcc-help@gcc.gnu.org
> Envoyé le : Ven 15 avril 2011, 8h 39min 35s
> Objet : Re: Re : Classes
>
> On 5 April 2011 08:44, charfi asma <charfiasma@yahoo.fr> wrote:
>>
>>
>> Hello Phil,
>>
>> have a look at those post:
>>
>> http://gcc.gnu.org/ml/gcc-help/2010-11/msg00019.html
>> http://gcc.gnu.org/ml/gcc-help/2010-10/msg00388.html
>>
>> I got the same problem when I want to add a method to my class.
>>
>> hope it helps
>>
> Hey
>
> Thanks for those links i am a little confused still not sure if i've
> done everything right.
>
> Say for example i wanted to implment this:
>
> int main() ()
> {
> ?int D.1710;
>
> ?{
> ? ?struct myClass test;
>
> ? ?myClass::set_values (&test, 3, 4);
> ? ?D.1710 = 0;
> ? ?return D.1710;
> ?}
> ?D.1710 = 0;
> ?return D.1710;
> }
>
>
> void myClass::set_values(int, int) (struct myClass * const this, int a, int b)
> {
> ?this->x = a;
> ?this->y = b;
> }
>
> Which is the gimple dump of:
>
> class myClass
> {
> ?int x, y;
>
> ?public:
> ? ?void set_values (int, int);
> };
>
> void myClass::set_values (int a, int b)
> {
> ?x = a;
> ?y = b;
> }
>
> int main ()
> {
> ?myClass test;
>
> ?test.set_values (3,4);
>
> ?return 0;
> }
>
>
> I make a RECORD_TYPE called myClass and having FIELD_DECLS for x and y.
>
> set_values = FUNCTION_DECL....
> Then i use TYPE_METHODS(myClass) = set_values
>
> Then i dont understand how i call the method not sure how i use the
> build_call_expr to do that.
>
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]