Skip to contentSkip to conversation

parameter list to expression list?

Cocci Michael Stefaniuc 2 participants 5 messages Mar 25, 2013 – Apr 8, 2013 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

Hello,

is there an intrinsic way to get from a parameter list to an expression list? That would come in handy when forwarding from one function to another one. At the moment I help myself with a python rule that transforms the parameter list to an identifier but that feels clumsy. E.g. in SmPL pseudo code something like this would be nice:

@@
type T;
parameter list P;
expression list E = P;
expression ret;
@@
T foo(P)
{
return
- ret
+ bar(E)

     ;

}

thanks
bye
michael

#1 lore raw
Quoted 17 lines · Michael Stefaniuc

Hello,

is there an intrinsic way to get from a parameter list to an expression list? That would come in handy when forwarding from one function to another one. At the moment I help myself with a python rule that transforms the parameter list to an identifier but that feels clumsy. E.g. in SmPL pseudo code something like this would be nice:

@@
type T;
parameter list P;
expression list E = P;
expression ret;
@@
T foo(P)
{
return

Review

Quoted 4 lines
(quoted diff) +1 -1
-           ret
+           bar(E)
     ;
 }

No, there is nothing. I guess your transformation gets rid of the types in the parameter list? Perhaps what you would liek is a way to just match the list of identifier parts?

julia

#2 lore raw
Quoted 24 lines · Julia Lawall
Quoted 17 lines · Michael Stefaniuc

Hello,

is there an intrinsic way to get from a parameter list to an expression list? That would come in handy when forwarding from one function to another one. At the moment I help myself with a python rule that transforms the parameter list to an identifier but that feels clumsy. E.g. in SmPL pseudo code something like this would be nice:

@@
type T;
parameter list P;
expression list E = P;
expression ret;
@@
T foo(P)
{
return

Review

Quoted 4 lines
(quoted diff) +1 -1
-           ret
+           bar(E)
     ;
 }
Quoted 3 lines

No, there is nothing. I guess your transformation gets rid of the types in the parameter list? Perhaps what you would liek is a way to just match the list of identifier parts?

Yes, something like that.
What I do now is:

@script:python new@
params << get.params;
args;
@@
import re
for p in params.elements:

    coccinelle.args += ", " + re.sub(r".* (\w+)$", r"\1", p)

thanks
bye
michael

#4 lore raw
In reply to a message not in the archive

Hello Julia,

Quoted 2 lines · Julia Lawall

Could you try the attached patch? The line numbers are almost certain not to work out, but maybe it will be able to figure out what to do.

sorry for the late reply. The patch works like a charm.

Thanks!
bye
michael

Quoted 15 lines

The idea is to do the following:

@r@
parameter list P;
expression list E;
@@

main(P at E) {
+ foo(E);
return 0;
}

julia

#5 lore raw
Quoted 6 lines · Michael Stefaniuc

Hello Julia,

Quoted 2 lines · Julia Lawall

Could you try the attached patch? The line numbers are almost certain not to work out, but maybe it will be able to figure out what to do.

sorry for the late reply. The patch works like a charm.

Great. It is in rc17.

julia

Quoted 22 lines

Thanks!
bye
michael

Quoted 15 lines

The idea is to do the following:

@r@
parameter list P;
expression list E;
@@

main(P at E) {
+ foo(E);
return 0;
}

julia