Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
f93cafc4cb141d5ce131f90f23df93f5340a60cc
[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 b@p
37 + = SMPI_INITIALIZE_GLOBAL(b, T)
38 ;
39 |
40
41 b@p = 
42 + SMPI_INITIALIZE_AND_SET_GLOBAL(b, T,
43 E
44 +)
45 ;
46 )
47
48 @rewritelocalaccess@
49 local idexpression x;
50 identifier globalvardecl.b;
51 @@
52 {
53 <...
54 (
55 x
56 |
57 +SMPI_GLOBAL_VAR_LOCAL_ACCESS(
58 b
59 +)
60 )
61 ...>
62 }