Logo AND Algorithmique Numérique Distribuée

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