File: countcalls_python.cocci

package info (click to toggle)
coccinelle 1.3.0.deb-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 20,888 kB
  • sloc: ml: 96,585; ansic: 23,664; sh: 1,695; perl: 1,576; makefile: 1,002; python: 922; lisp: 832; cpp: 655; awk: 70; csh: 12
file content (61 lines) | stat: -rw-r--r-- 673 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
@initialize:python@
@@

coccinelle.tbl = {}
local = set()

def inc(f):
  try:
    coccinelle.tbl[f] += 1
  except KeyError:
    coccinelle.tbl[f] = 1

@script:python@
@@
local.clear()

@r@
identifier f;
@@

f(...) { ... }

@script:python@
f << r.f;
@@

local.add(f)

@r1@
identifier f;
type T;
@@

T f(...);

@script:python@
f << r1.f;
@@

local.add(f)

@s@
identifier f;
@@
f(...);

@script:python@
f << s.f;
@@

if f not in local and f.lower() == f:
  inc(f)

@finalize:python@
tbls << merge.tbl;
@@
tbl = tbls[0]
for i in range(1, len(tbls)):
  tbl.update(tbls[i])
for (v, f) in sorted([(v, k) for (k, v) in tbl.items()], reverse = True):
  print("{}: {}".format(f, v))