Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
59e8aa6db4a8342f3af099ab695500c1b4d86871
[simgrid.git] / src / smpi / replace_globals.cocci
1 // FIXME: problems
2 //   - does not match array initializers
3
4 // Function prototype looks like variable dec, but has parentheses
5 @funcproto@
6 type T;
7 identifier func;
8 position p;
9 @@
10 T@p func(...);
11
12 // Define a local variable as one whose declaration is encased in brackets
13 @localvardecl@
14 type T;
15 identifier var;
16 position p;
17 expression E;
18 @@
19 {
20 <...
21 (
22 T@p
23 var
24 ;
25 |
26 T@p
27 var = E
28 ;
29 )
30 ...>
31 }
32
33 // global variable is one whose declaration is neither local nor a function
34 // prototype
35 @globalvardecl@
36 type T;
37 identifier var;
38 position p != { localvardecl.p, funcproto.p };
39 expression E;
40 @@
41 (
42 T@p 
43 - var
44 + *var = SMPI_INITIALIZE_GLOBAL(T)
45 ;
46 |
47 T@p
48 - var = E
49 + *var = SMPI_INITIALIZE_AND_SET_GLOBAL(T, E)
50 ;
51 )
52
53 @rewritelocalaccess@
54 local idexpression x;
55 identifier globalvardecl.var;
56 @@
57 {
58 <...
59 (
60 x
61 |
62 +SMPI_GLOBAL_VAR_LOCAL_ACCESS(
63 var
64 +)
65 )
66 ...>
67 }