All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cocci] iteration.cocci
@ 2015-05-26 15:34 Zied Habtoul
  2015-05-26 17:17 ` Julia Lawall
  0 siblings, 1 reply; 6+ messages in thread
From: Zied Habtoul @ 2015-05-26 15:34 UTC (permalink / raw)
  To: cocci

hello,
 Can you tell me please what is the function of this part in the
file coccinelle/demos/iteration.cocci

virtual after_start @initialize:ocaml@@@ let tbl = Hashtbl.create(100) let
add_if_not_present from f file =try let _ = Hashtbl.find tbl (f,file) in ()with
Not_found -> Hashtbl.add tbl (f,file) file; let it = new iteration() in
(match file with Some fl -> it#set_files [fl] | None -> ());
it#add_virtual_rule After_start; it#add_virtual_identifier Err_ptr_function
f; it#register()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://systeme.lip6.fr/pipermail/cocci/attachments/20150526/8de78b86/attachment.html>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Cocci] iteration.cocci
  2015-05-26 15:34 [Cocci] iteration.cocci Zied Habtoul
@ 2015-05-26 17:17 ` Julia Lawall
  2015-05-26 17:57   ` Zied Habtoul
  0 siblings, 1 reply; 6+ messages in thread
From: Julia Lawall @ 2015-05-26 17:17 UTC (permalink / raw)
  To: cocci

On Tue, 26 May 2015, Zied Habtoul wrote:

> hello,
> ?Can you tell me please what is the function of this part in the
> file?coccinelle/demos/iteration.cocci
>
> virtual after_start
> @initialize:ocaml@
> @@
> let tbl = Hashtbl.create(100)
> let add_if_not_present from f file =
> try let _ = Hashtbl.find tbl (f,file) in ()
> with Not_found ->
> Hashtbl.add tbl (f,file) file;
> let it = new iteration() in

Obtain a data structure representing another runthat you would like to do
on the code base.

> (match file with
> Some fl -> it#set_files [fl]
> | None -> ());

Choose the set of files to which the new run should apply.  If nothing is
specified, then the same set of files a used in the current run is used.

> it#add_virtual_rule After_start;

Consider that the virtual rule after_start is satisfied.  Virtual rules
are like a big if on your semantic patch.  In the header of a semantic
patch you can say that it eg depends on after_start or depends on
!after_start to cause the rule to be applied if and only if someother rule
has or has not matched.  You can also do this for the names of actual
rules.  Virtual rules can also be activated on the command line.  So you
could say spatch --sp-file foo.cocci foo.c -D after_start.

> it#add_virtual_identifier Err_ptr_function f;

This is an identifier typed metavariable that is given a value.  In the
code it can be referred to as identifier virtual.err_ptr_function.

> it#register()

After setting up all the command line variables for the next iteration,
this calls puts it in a queue to be executed at some time in the future.

julia

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Cocci] iteration.cocci
  2015-05-26 17:17 ` Julia Lawall
@ 2015-05-26 17:57   ` Zied Habtoul
  2015-05-26 19:01     ` Julia Lawall
  2015-05-27  9:41     ` [Cocci] Source code analysis around function name lists SF Markus Elfring
  0 siblings, 2 replies; 6+ messages in thread
From: Zied Habtoul @ 2015-05-26 17:57 UTC (permalink / raw)
  To: cocci

virtual after_start
> @initialize:ocaml@
> @@
> let tbl = Hashtbl.create(100)
> let add_if_not_present from f file =
> try let _ = Hashtbl.find tbl (f,file) in ()
> with Not_found ->
> Hashtbl.add tbl (f,file) file;
> let it = new iteration()


how the f file is created ?
i have a file that contains a list of functions , i want to apply a script
to my code when it  detects a function not present in my file.

2015-05-26 19:17 GMT+02:00 Julia Lawall <julia.lawall@lip6.fr>:

> On Tue, 26 May 2015, Zied Habtoul wrote:
>
> > hello,
> >  Can you tell me please what is the function of this part in the
> > file coccinelle/demos/iteration.cocci
> >
> > virtual after_start
> > @initialize:ocaml@
> > @@
> > let tbl = Hashtbl.create(100)
> > let add_if_not_present from f file =
> > try let _ = Hashtbl.find tbl (f,file) in ()
> > with Not_found ->
> > Hashtbl.add tbl (f,file) file;
> > let it = new iteration() in
>
> Obtain a data structure representing another runthat you would like to do
> on the code base.
>
> > (match file with
> > Some fl -> it#set_files [fl]
> > | None -> ());
>
> Choose the set of files to which the new run should apply.  If nothing is
> specified, then the same set of files a used in the current run is used.
>
> > it#add_virtual_rule After_start;
>
> Consider that the virtual rule after_start is satisfied.  Virtual rules
> are like a big if on your semantic patch.  In the header of a semantic
> patch you can say that it eg depends on after_start or depends on
> !after_start to cause the rule to be applied if and only if someother rule
> has or has not matched.  You can also do this for the names of actual
> rules.  Virtual rules can also be activated on the command line.  So you
> could say spatch --sp-file foo.cocci foo.c -D after_start.
>
> > it#add_virtual_identifier Err_ptr_function f;
>
> This is an identifier typed metavariable that is given a value.  In the
> code it can be referred to as identifier virtual.err_ptr_function.
>
> > it#register()
>
> After setting up all the command line variables for the next iteration,
> this calls puts it in a queue to be executed at some time in the future.
>
> julia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://systeme.lip6.fr/pipermail/cocci/attachments/20150526/fbcb993d/attachment.html>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Cocci] iteration.cocci
  2015-05-26 17:57   ` Zied Habtoul
@ 2015-05-26 19:01     ` Julia Lawall
  2015-05-27  9:41     ` [Cocci] Source code analysis around function name lists SF Markus Elfring
  1 sibling, 0 replies; 6+ messages in thread
From: Julia Lawall @ 2015-05-26 19:01 UTC (permalink / raw)
  To: cocci

On Tue, 26 May 2015, Zied Habtoul wrote:

> virtual after_start
> > @initialize:ocaml@
> > @@
> > let tbl = Hashtbl.create(100)
> > let add_if_not_present from f file =
> > try let _ = Hashtbl.find tbl (f,file) in ()
> > with Not_found ->
> > Hashtbl.add tbl (f,file) file;
> > let it = new iteration()?
> 
> 
> how the f file is created ?
> i have a file that contains a list of functions , i want to apply a script
> to my code when it ?detects a function not present in my file.

f and file are arguments to the function add_if_present.  You have to look 
at the call site to see how they are determined.

julia

> 2015-05-26 19:17 GMT+02:00 Julia Lawall <julia.lawall@lip6.fr>:
>       On Tue, 26 May 2015, Zied Habtoul wrote:
> 
>       > hello,
>       > ?Can you tell me please what is the function of this part in
>       the
>       > file?coccinelle/demos/iteration.cocci
>       >
>       > virtual after_start
>       > @initialize:ocaml@
>       > @@
>       > let tbl = Hashtbl.create(100)
>       > let add_if_not_present from f file =
>       > try let _ = Hashtbl.find tbl (f,file) in ()
>       > with Not_found ->
>       > Hashtbl.add tbl (f,file) file;
>       > let it = new iteration() in
> 
>       Obtain a data structure representing another runthat you would
>       like to do
>       on the code base.
> 
>       > (match file with
>       > Some fl -> it#set_files [fl]
>       > | None -> ());
> 
>       Choose the set of files to which the new run should apply.? If
>       nothing is
>       specified, then the same set of files a used in the current run
>       is used.
> 
>       > it#add_virtual_rule After_start;
> 
>       Consider that the virtual rule after_start is satisfied.?
>       Virtual rules
>       are like a big if on your semantic patch.? In the header of a
>       semantic
>       patch you can say that it eg depends on after_start or depends
>       on
>       !after_start to cause the rule to be applied if and only if
>       someother rule
>       has or has not matched.? You can also do this for the names of
>       actual
>       rules.? Virtual rules can also be activated on the command
>       line.? So you
>       could say spatch --sp-file foo.cocci foo.c -D after_start.
> 
>       > it#add_virtual_identifier Err_ptr_function f;
> 
>       This is an identifier typed metavariable that is given a value.?
>       In the
>       code it can be referred to as identifier
>       virtual.err_ptr_function.
> 
>       > it#register()
> 
>       After setting up all the command line variables for the next
>       iteration,
>       this calls puts it in a queue to be executed at some time in the
>       future.
> 
>       julia
> 
> 
> 
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Cocci] Source code analysis around function name lists
  2015-05-26 17:57   ` Zied Habtoul
  2015-05-26 19:01     ` Julia Lawall
@ 2015-05-27  9:41     ` SF Markus Elfring
  2015-05-27  9:44       ` Julia Lawall
  1 sibling, 1 reply; 6+ messages in thread
From: SF Markus Elfring @ 2015-05-27  9:41 UTC (permalink / raw)
  To: cocci

> i have a file that contains a list of functions ,

Such an use case was discussed a few times here.


> i want to apply a script to my code when it  detects a function not
> present in my file.

How do you think about to convert the list from your input file to an
other data structure like the following?
* SmPL disjunction
* Alternation in a regular expression for a SmPL constraint

Regards,
Markus

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Cocci] Source code analysis around function name lists
  2015-05-27  9:41     ` [Cocci] Source code analysis around function name lists SF Markus Elfring
@ 2015-05-27  9:44       ` Julia Lawall
  0 siblings, 0 replies; 6+ messages in thread
From: Julia Lawall @ 2015-05-27  9:44 UTC (permalink / raw)
  To: cocci

On Wed, 27 May 2015, SF Markus Elfring wrote:

> > i have a file that contains a list of functions ,
>
> Such an use case was discussed a few times here.
>
>
> > i want to apply a script to my code when it  detects a function not
> > present in my file.
>
> How do you think about to convert the list from your input file to an
> other data structure like the following?
> * SmPL disjunction
> * Alternation in a regular expression for a SmPL constraint

A SmPL disjunction will give Coccinelle more information that will allow
it to ignore files that cannot possibly match.

julia

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-05-27  9:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-26 15:34 [Cocci] iteration.cocci Zied Habtoul
2015-05-26 17:17 ` Julia Lawall
2015-05-26 17:57   ` Zied Habtoul
2015-05-26 19:01     ` Julia Lawall
2015-05-27  9:41     ` [Cocci] Source code analysis around function name lists SF Markus Elfring
2015-05-27  9:44       ` Julia Lawall

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.