annotate src/parallel_execution/lib/Gears/Util.pm @ 625:d02866506b9b

...
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Tue, 09 Jun 2020 15:01:53 +0900
parents d560184a7ce7
children 670b972b6ff0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
556
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 package Gears::Util;
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 use strict;
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 use warnings;
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 use Carp qw/croak/;
557
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 556
diff changeset
5 use File::Find;
556
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 sub parse {
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 my ($class, $file_name) = @_;
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 my $ir = _parse_base($file_name);
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 return $ir;
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 }
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12
559
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
13
556
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 sub parse_interface {
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 my ($class, $file_name) = @_;
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 my $ir = _parse_base($file_name);
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 unless ($ir->{name}) {
624
d560184a7ce7 auto load header to context
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
19 croak "invalid struct name $file_name";
556
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 }
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 return $ir;
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 }
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 sub _parse_base {
559
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 558
diff changeset
26 my ($file,$code_verbose) = @_;
556
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 my $ir = {};
594
f821570d5ab7 bump gears tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 589
diff changeset
28 $ir->{file_name} = $file;
556
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29
564
9cca20bcb558 add auto_generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 559
diff changeset
30 Gears::Util->file_checking($file);
556
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 open my $fh, '<', $file;
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 my $line = <$fh>;
598
32388e7467bc pull from xv6
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 597
diff changeset
33 my $static_data_gear_write_mode = 0;
556
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34
624
d560184a7ce7 auto load header to context
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
35 my $directory_containing_file = "";
d560184a7ce7 auto load header to context
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
36
d560184a7ce7 auto load header to context
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
37 if ($file =~ m<([\.\w/]+)/\w+\.(?:cbc|h|c)>) {
d560184a7ce7 auto load header to context
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
38 $directory_containing_file = $1;
d560184a7ce7 auto load header to context
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
39 }
d560184a7ce7 auto load header to context
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
40
d560184a7ce7 auto load header to context
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
41
d560184a7ce7 auto load header to context
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
42 while ($line =~ /#include\s+"([\w\/\.]+)"/) {
d560184a7ce7 auto load header to context
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
43 my $header_file = $1;
d560184a7ce7 auto load header to context
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
44 if ($header_file =~ m|\./context\.h|) {
d560184a7ce7 auto load header to context
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
45 next;
d560184a7ce7 auto load header to context
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
46 }
d560184a7ce7 auto load header to context
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
47 push(@{$ir->{cbc_context_include_headers}}, "$directory_containing_file/$header_file");
d560184a7ce7 auto load header to context
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
48 $line = <$fh>;
d560184a7ce7 auto load header to context
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
49 }
d560184a7ce7 auto load header to context
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
50
d560184a7ce7 auto load header to context
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
51 # skip space
d560184a7ce7 auto load header to context
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
52
d560184a7ce7 auto load header to context
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
53 while ($line =~ /^\s*$/) {
d560184a7ce7 auto load header to context
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
54 $line = <$fh>;
d560184a7ce7 auto load header to context
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
55 }
d560184a7ce7 auto load header to context
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
56
556
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 if ($line =~ /typedef struct (\w+)\s?<.*>([\s\w{]+)/) {
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 die "invalied struct name $1" unless $1;
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 $ir->{name} = $1;
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 if ($2 =~ m|\s*impl\s*([\w+]+)\s*{|) {
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 $ir->{isa} = $1;
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 }
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 }
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
65
598
32388e7467bc pull from xv6
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 597
diff changeset
66 unless ($ir->{name}) {
32388e7467bc pull from xv6
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 597
diff changeset
67 return undef;
32388e7467bc pull from xv6
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 597
diff changeset
68 }
32388e7467bc pull from xv6
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 597
diff changeset
69
597
410924949569 impl auto search data gear
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 595
diff changeset
70 my @tmp_args;
556
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 while ($line = <$fh>) {
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 if ($line =~ m|\s*/\*|) {
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 while ( $line !~ m|\*/|) {
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 $line = <$fh>;
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 next;
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 }
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 next;
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 }
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 next if ($line =~ /^\s+$/);
583
ba529ff3f068 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 580
diff changeset
80 next if ($line =~ m[^\s*//]);
575
3e3158198cb5 bug fix...
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 574
diff changeset
81 next if ($line =~ m[^\}\s*$ir->{name};]);
556
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
82
597
410924949569 impl auto search data gear
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 595
diff changeset
83 if ($line =~ m|__code (\w+)|) {
410924949569 impl auto search data gear
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 595
diff changeset
84 push(@tmp_args,"enum Code $1;\n");
598
32388e7467bc pull from xv6
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 597
diff changeset
85 next if $static_data_gear_write_mode;
597
410924949569 impl auto search data gear
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 595
diff changeset
86 my $args = $';
410924949569 impl auto search data gear
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 595
diff changeset
87 #$args eq (Impl* vm, pde_t* pgdir, char* init, uint sz, __code next(...));
618
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 609
diff changeset
88 while ($args =~ /\s*(struct|union|const|enum)?\s*([\w*\[\]_]+)\s*(\w+),?/g) {
597
410924949569 impl auto search data gear
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 595
diff changeset
89 my $const_type = $1;
410924949569 impl auto search data gear
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 595
diff changeset
90 my $type = $2;
410924949569 impl auto search data gear
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 595
diff changeset
91 my $vname = $3;
410924949569 impl auto search data gear
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 595
diff changeset
92 next if ($type eq '__code');
625
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 624
diff changeset
93 $type =~ s/^(?:Impl|Type|Isa)\s*(\*)?/union Data$1/;
597
410924949569 impl auto search data gear
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 595
diff changeset
94 my $val = "$type $vname;\n";
598
32388e7467bc pull from xv6
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 597
diff changeset
95 push(@tmp_args, $const_type ? "$const_type $val" : $val);
597
410924949569 impl auto search data gear
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 595
diff changeset
96 }
410924949569 impl auto search data gear
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 595
diff changeset
97 next;
556
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 }
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
99
597
410924949569 impl auto search data gear
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 595
diff changeset
100 $line =~ s/^\s+//;
410924949569 impl auto search data gear
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 595
diff changeset
101 push(@tmp_args,$line);
598
32388e7467bc pull from xv6
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 597
diff changeset
102 $static_data_gear_write_mode = 1;
556
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 }
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
104
598
32388e7467bc pull from xv6
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 597
diff changeset
105 push(@{$ir->{content}}, _uniq(@tmp_args));
556
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 return $ir;
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 }
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
108
598
32388e7467bc pull from xv6
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 597
diff changeset
109 sub _uniq {
32388e7467bc pull from xv6
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 597
diff changeset
110 my %seen;
32388e7467bc pull from xv6
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 597
diff changeset
111 return grep { !$seen{$_}++ } @_;
32388e7467bc pull from xv6
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 597
diff changeset
112 }
32388e7467bc pull from xv6
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 597
diff changeset
113
32388e7467bc pull from xv6
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 597
diff changeset
114 sub parse_with_separate_code_data_gears{
583
ba529ff3f068 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 580
diff changeset
115 my ($class, $file) = @_;
ba529ff3f068 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 580
diff changeset
116 my $ir = _parse_base($file);
ba529ff3f068 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 580
diff changeset
117
ba529ff3f068 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 580
diff changeset
118 my @data_gears;
ba529ff3f068 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 580
diff changeset
119 my @code_gears;
ba529ff3f068 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 580
diff changeset
120 map { push (@data_gears, $_) unless ($_ =~ /enum Code/);} @{$ir->{content}};
ba529ff3f068 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 580
diff changeset
121 map { push (@code_gears, $1) if ($_ =~ /enum Code (\w+);/);} @{$ir->{content}};
ba529ff3f068 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 580
diff changeset
122
ba529ff3f068 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 580
diff changeset
123 open my $fh , '<', $file;
ba529ff3f068 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 580
diff changeset
124 my $i = 0;
ba529ff3f068 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 580
diff changeset
125 while (($i < scalar @code_gears) && (my $line = <$fh>)) {
ba529ff3f068 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 580
diff changeset
126 my $cg = $code_gears[$i];
ba529ff3f068 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 580
diff changeset
127 if ($line =~ m|__code $cg\(([()\.\*\s\w,_]+)\)|) {
ba529ff3f068 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 580
diff changeset
128 $code_gears[$i] = {
ba529ff3f068 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 580
diff changeset
129 name => $cg,
589
841e1d8673a5 bump gears tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 583
diff changeset
130 args => $1,
583
ba529ff3f068 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 580
diff changeset
131 };
ba529ff3f068 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 580
diff changeset
132 $i++;
ba529ff3f068 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 580
diff changeset
133 }
ba529ff3f068 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 580
diff changeset
134 }
ba529ff3f068 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 580
diff changeset
135 $ir->{codes} = \@code_gears;
ba529ff3f068 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 580
diff changeset
136 $ir->{data} = \@data_gears;
ba529ff3f068 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 580
diff changeset
137 return $ir;
ba529ff3f068 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 580
diff changeset
138 }
ba529ff3f068 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 580
diff changeset
139
564
9cca20bcb558 add auto_generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 559
diff changeset
140 sub file_checking {
9cca20bcb558 add auto_generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 559
diff changeset
141 my ($class, $file_name) = @_;
556
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
142 unless (-f $file_name) {
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
143 croak "invalid filepath :$file_name\n";
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 }
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
145 }
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
146
557
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 556
diff changeset
147 sub slup {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 556
diff changeset
148 my ($class,$file) = @_;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 556
diff changeset
149 open my $fh, '<', $file;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 556
diff changeset
150 local $/;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 556
diff changeset
151 my $f = <$fh>;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 556
diff changeset
152 return $f;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 556
diff changeset
153 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 556
diff changeset
154
598
32388e7467bc pull from xv6
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 597
diff changeset
155 sub find_using_interface_header {
558
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 557
diff changeset
156 my $class = shift;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 557
diff changeset
157 my $header_name = shift;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 557
diff changeset
158
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 557
diff changeset
159 my $find_path = shift // ".";
589
841e1d8673a5 bump gears tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 583
diff changeset
160 my @header_list = ();
558
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 557
diff changeset
161
557
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 556
diff changeset
162 find(
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 556
diff changeset
163 {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 556
diff changeset
164 wanted => sub {
595
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
165 if ($_ =~ /\/$header_name\.(h|dg)$/) {
589
841e1d8673a5 bump gears tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 583
diff changeset
166 push(@header_list,$_);
557
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 556
diff changeset
167 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 556
diff changeset
168 },
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 556
diff changeset
169 no_chdir => 1,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 556
diff changeset
170 },
558
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 557
diff changeset
171 $find_path);
589
841e1d8673a5 bump gears tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 583
diff changeset
172 my @find_headers = grep { $_ =~ /\/$header_name\.(h|dg)/} @header_list;
841e1d8673a5 bump gears tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 583
diff changeset
173 if (@find_headers > 1) {
841e1d8673a5 bump gears tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 583
diff changeset
174 @find_headers = grep { $_ =~ /\/$header_name\.dg/} @find_headers;
841e1d8673a5 bump gears tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 583
diff changeset
175 }
841e1d8673a5 bump gears tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 583
diff changeset
176 return shift @find_headers;
557
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 556
diff changeset
177 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 556
diff changeset
178
573
5f4b7ff18a34 set header path each include struct
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 564
diff changeset
179 sub find_headers_path {
5f4b7ff18a34 set header path each include struct
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 564
diff changeset
180 my $class = shift;
5f4b7ff18a34 set header path each include struct
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 564
diff changeset
181 my $find_path = shift // ".";
5f4b7ff18a34 set header path each include struct
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 564
diff changeset
182
5f4b7ff18a34 set header path each include struct
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 564
diff changeset
183 my @files;
583
ba529ff3f068 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 580
diff changeset
184 find( { wanted => sub { push @files, $_ if /\.(?:h|dg)/ }, no_chdir => 1 }, $find_path);
573
5f4b7ff18a34 set header path each include struct
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 564
diff changeset
185
5f4b7ff18a34 set header path each include struct
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 564
diff changeset
186 return \@files;
5f4b7ff18a34 set header path each include struct
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 564
diff changeset
187 }
5f4b7ff18a34 set header path each include struct
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 564
diff changeset
188
595
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
189 sub extraction_dg_compile_sources {
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
190 my ($class, $compile_sources) = @_;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
191 my %counter;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
192 my %include_pool = ();
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
193 for my $cbc_file (@{$compile_sources}) {
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
194 open my $fh , '<', $cbc_file;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
195 while (my $line = <$fh>) {
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
196 if ($line =~ m|//\s*:skip|) {
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
197 next;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
198 }
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
199
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
200 if ($line =~ /#interface\s*"(.*)\.h"/) {
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
201 push(@{$counter{interfaces}->{$1}->{$cbc_file}},$.);
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
202 next;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
203 }
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
204
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
205 if ($line =~ /^\/\/\s*data_gear\s*"(.*)\.(?:h|dg)?"/) {
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
206 push(@{$include_pool{$1}->{$cbc_file}},$.);
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
207 next;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
208 }
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
209
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
210 if ($line =~ m|//\s*Skip:\s*generate_context|) {
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
211 $line = <$fh>;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
212 next;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
213 }
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
214
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
215
598
32388e7467bc pull from xv6
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 597
diff changeset
216 if ($line =~ /^(\w+)\*\s*create(\w+)\(([*\w\s]+)\)/) {
595
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
217 my $interface = $1;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
218 my $implementation = $2;
598
32388e7467bc pull from xv6
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 597
diff changeset
219 my $arg = $3;
32388e7467bc pull from xv6
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 597
diff changeset
220 if ($arg eq "") {
32388e7467bc pull from xv6
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 597
diff changeset
221 next;
32388e7467bc pull from xv6
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 597
diff changeset
222 }
595
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
223 push(@{$counter{interfaces}->{$interface}->{$cbc_file}},$.);
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
224 push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.);
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
225 next;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
226 }
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
227
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
228 if ($line =~ /Gearef\(context,\s*(\w+)\)/) {
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
229 my $implementation = $1;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
230 push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.);
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
231 next;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
232 }
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
233
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
234 #Element* element = &ALLOCATE(cbc_context, Element)->Element;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
235 if ($line =~ /ALLOCATE\w*\((?:cbc_)?context,\s*(\w+)\)/) {
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
236 my $implementation = $1;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
237 push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.);
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
238 next;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
239 }
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
240
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
241 if ($line =~ /ALLOCATE_(?:PTR_)?ARRAY\((?:cbc_)?context,\s*(\w+),[\s\w]+\)/) {
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
242 my $implementation = $1;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
243 push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.);
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
244 next;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
245 }
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
246
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
247 if ($line =~ /new\s+(\w+?)\([\w\s]*\);/) {
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
248 my $implementation = $1;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
249 push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.);
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
250 next;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
251 }
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
252
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
253 if ($line =~ /ALLOCATE_DATA_GEAR\((\w+),\s*(\w+)\)/) {
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
254 my $implementation = $2;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
255 push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.);
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
256 next;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
257 }
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
258
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
259 #TaskManagerImpl* taskManager = (TaskManagerImpl*)GearImpl(context, TaskManager, taskManager);
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
260 if ($line =~ /\((\w+)\*\)GearImpl\(context,\s*(\w+),\s*(\w+)\)/) {
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
261 my $interface = $2;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
262 my $implementation = $1;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
263 push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.);
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
264 push(@{$counter{interfaces}->{$interface}->{$cbc_file}},$.);
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
265 next;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
266 }
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
267
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
268 if ($line =~ /^__code/) {
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
269 while ($line =~ /struct (\w+)\s*\*/g) {
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
270 next if $1 eq "Context";
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
271 next if (exists $counter{interfaces}->{$1});
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
272 push(@{$counter{impl}->{$1}->{$cbc_file}},$.);
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
273 }
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
274 }
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
275 }
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
276 close $fh;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
277 }
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
278 use Data::Dumper;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
279
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
280 for my $cg_name (keys %include_pool) {
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
281 my @tmp_cbc_file_names = keys %{$include_pool{$cg_name}};
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
282 my $tmp_cbc_file_name = shift @tmp_cbc_file_names;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
283 if (exists $counter{interfaces}->{$cg_name}){
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
284 push(@{$counter{interfaces}->{$cg_name}->{$tmp_cbc_file_name}},$include_pool{$cg_name}->{$tmp_cbc_file_name});
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
285 delete $include_pool{$cg_name};
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
286 next;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
287 }
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
288
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
289 if (exists $counter{impl}->{$cg_name}){
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
290 push(@{$counter{impl}->{$cg_name}->{$tmp_cbc_file_name}},$include_pool{$cg_name}->{$tmp_cbc_file_name});
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
291 delete $include_pool{$cg_name};
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
292 next;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
293 }
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
294 push(@{$counter{interfaces}->{$cg_name}->{$tmp_cbc_file_name}},$include_pool{$cg_name}->{$tmp_cbc_file_name});
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
295 delete $include_pool{$cg_name};
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
296 }
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
297
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
298 $counter{interfaces}->{Meta}++;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
299 $counter{interfaces}->{TaskManager}++;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
300 print "-----------\n";
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
301 print Dumper \%counter;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
302 print "-----------\n";
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
303 return \%counter;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
304 }
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
305
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
306 sub docking_header_name_to_path {
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
307 my ($class, $search_bash_path, $targets) = @_;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
308 my %res;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
309 map { $res{$_}++ } @$targets;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
310
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
311 my $header_paths = Gears::Util->find_headers_path($search_bash_path);
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
312 map {
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
313 if (/(\w+)\.(?:h|dg)$/) {
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
314 my $header_file = $1;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
315 if (exists $res{$header_file}) {
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
316 if ($res{$header_file} =~ /^\d+$/){
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
317 $res{$header_file} = $_;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
318 } elsif (($_ =~ /\.dg$/) && ($res{$header_file} =~ /\.h$/)) {
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
319 $res{$header_file} = $_;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
320 }
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
321 }
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
322 }
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
323 } sort @$header_paths;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
324 return \%res;
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
325 }
00429c9e0a45 bump PerlSciripts
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 594
diff changeset
326
556
a0b7eb5e58c0 add Gears::Util module
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
327 1;