(src, fname)
| 6 | from persper.graphs.write_graph_to_dot import write_G_to_dot_with_pr |
| 7 | |
| 8 | def get_func_ranges_cpp(src, fname): |
| 9 | re_signature = re.compile("""^(?P<return_type>\w+(\s*[\*\&])?)\s+ |
| 10 | ((?P<class_name>\w+)::)? |
| 11 | (?P<func_name>\w+)\s* |
| 12 | \([^;]+$ |
| 13 | """, re.VERBOSE ) |
| 14 | func_ids = [] |
| 15 | func_ranges = [] |
| 16 | ptr = -1 |
| 17 | num_lines = 0 |
| 18 | for lineno, line in enumerate(src.split('\n'), 1): |
| 19 | num_lines += 1 |
| 20 | m = re_signature.search(line) |
| 21 | if m: |
| 22 | d = m.groupdict() |
| 23 | if d['class_name']: |
| 24 | func_ids.append('{}::{}'.format(d['class_name'], d['func_name'])) |
| 25 | else: |
| 26 | func_ids.append(d['func_name']) |
| 27 | if ptr != -1: |
| 28 | func_ranges.append([ptr, lineno - 1]) |
| 29 | ptr = lineno |
| 30 | if ptr != -1: |
| 31 | func_ranges.append([ptr, num_lines]) |
| 32 | |
| 33 | return func_ids, func_ranges |
| 34 | |
| 35 | def fname_filter_cpp(fname): |
| 36 | return fname.endswith('.cc') or fname.endswith('.cpp') |
no outgoing calls