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
|
#!/usr/bin/env perl
use strict;
use warnings;
use DDP {deparse => 1};
my $file_name = shift // "vm.h";
open my $fh, '<', $file_name;
my @res = ();
while (my $line = <$fh>) {
if ($line =~ /__code (\w+)/) {
my $args = $';
#$args eq (Impl* vm, pde_t* pgdir, char* init, uint sz, __code next(...));
while ($args =~ /((?:struct|union|const)\s+)?([\w*\[\]_]+)\s*(\w+),?/g) {
my $const_type = $1;
my $type = $2;
my $vname = $3;
my $val = "$type $vname";
push(@res, $const_type ? "$const_type$val" : $val);
}
}
}
my @uniq = uniq(@res);
p @uniq;
sub uniq {
my %seen;
return grep { !$seen{$_}++ } @_;
}
|