Logo AND Algorithmique Numérique Distribuée

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