Mercurial > hg > CbC > CbC_xv6
annotate src/gearsTools/lib/Gears/Context.pm @ 234:0ea4d14c54bd
remove dead codes...
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 28 Jan 2020 14:21:08 +0900 |
parents | 49a70efcbd3a |
children | 21a5761e3e7a |
rev | line source |
---|---|
110
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1 package Gears::Context; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
2 |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
3 use strict; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
4 use warnings; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
5 |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
6 use Gears::Util; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
7 use Gears::Context::Template::XV6; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
8 use Carp qw/croak/; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
9 |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
10 sub new { |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
11 my ($class, %args) = @_; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
12 my $self = { |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
13 data_gears_with_count => {}, |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
14 find_root => $args{find_root} // ".", |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
15 output => $args{output}, |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
16 }; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
17 |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
18 if ($args{compile_sources}) { |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
19 $self->{compile_sources} = $args{compile_sources}; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
20 map { Gears::Util->file_checking($_); } @{$self->{compile_sources}}; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
21 } |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
22 |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
23 return bless $self, $class; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
24 } |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
25 |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
26 |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
27 sub extraction_dg_compile_sources { |
233 | 28 my ($self, $compile_sources) = @_; |
110
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
29 my %counter; |
181 | 30 my %include_pool = (); |
233 | 31 for my $cbc_file (@{$compile_sources}) { |
110
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
32 open my $fh , '<', $cbc_file; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
33 while (my $line = <$fh>) { |
179 | 34 if ($line =~ m|//\s*:skip|) { |
35 next; | |
36 } | |
37 | |
181 | 38 if ($line =~ /#interface\s*"(.*)\.h"/) { |
180 | 39 push(@{$counter{interfaces}->{$1}->{$cbc_file}},$.); |
110
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
40 next; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
41 } |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
42 |
181 | 43 if ($line =~ /^\/\/\s*data_gear\s*"(.*)\.(?:h|dg)?"/) { |
44 push(@{$include_pool{$1}->{$cbc_file}},$.); | |
45 next; | |
46 } | |
47 | |
111
239bd73abac6
add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
110
diff
changeset
|
48 if ($line =~ m|//\s*Skip:\s*generate_context|) { |
239bd73abac6
add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
110
diff
changeset
|
49 $line = <$fh>; |
239bd73abac6
add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
110
diff
changeset
|
50 next; |
239bd73abac6
add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
110
diff
changeset
|
51 } |
239bd73abac6
add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
110
diff
changeset
|
52 |
179 | 53 |
154 | 54 #if ($line =~ /^(\w+)(\*)+ *create(\w+)\(([^]]*)\)/) { |
55 # my $interface = $1; | |
56 # my $implementation = $3; | |
57 # $self->{data_gears_with_count}->{$interface}->{caller}->{$cbc_file}++; | |
58 # $self->{data_gears_with_count}->{$implementation}->{caller}->{$cbc_file}++; | |
59 # $counter{interfaces}->{$interface}++; | |
60 # $counter{impl}->{$implementation}++; | |
61 # next; | |
62 #} | |
110
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
63 |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
64 if ($line =~ /Gearef\(context,\s*(\w+)\)/) { |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
65 my $implementation = $1; |
180 | 66 push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.); |
110
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
67 next; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
68 } |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
69 |
116 | 70 #Element* element = &ALLOCATE(cbc_context, Element)->Element; |
71 if ($line =~ /ALLOCATE\w*\((?:cbc_)?context,\s*(\w+)\)/) { | |
72 my $implementation = $1; | |
180 | 73 push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.); |
116 | 74 next; |
75 } | |
76 | |
77 if ($line =~ /ALLOCATE_(?:PTR_)?ARRAY\((?:cbc_)?context,\s*(\w+),[\s\w]+\)/) { | |
78 my $implementation = $1; | |
180 | 79 push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.); |
116 | 80 next; |
81 } | |
82 | |
83 if ($line =~ /new\s+(\w+?)\([\w\s]*\);/) { | |
110
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
84 my $implementation = $1; |
180 | 85 push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.); |
110
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
86 next; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
87 } |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
88 |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
89 if ($line =~ /ALLOCATE_DATA_GEAR\((\w+),\s*(\w+)\)/) { |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
90 my $implementation = $2; |
180 | 91 push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.); |
110
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
92 next; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
93 } |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
94 |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
95 #TaskManagerImpl* taskManager = (TaskManagerImpl*)GearImpl(context, TaskManager, taskManager); |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
96 if ($line =~ /\((\w+)\*\)GearImpl\(context,\s*(\w+),\s*(\w+)\)/) { |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
97 my $interface = $2; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
98 my $implementation = $1; |
180 | 99 push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.); |
100 push(@{$counter{interfaces}->{$interface}->{$cbc_file}},$.); | |
110
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
101 next; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
102 } |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
103 |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
104 if ($line =~ /^__code/) { |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
105 while ($line =~ /struct (\w+)\s*\*/g) { |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
106 next if $1 eq "Context"; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
107 next if (exists $counter{interfaces}->{$1}); |
180 | 108 push(@{$counter{impl}->{$1}->{$cbc_file}},$.); |
110
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
109 } |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
110 } |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
111 } |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
112 close $fh; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
113 } |
182 | 114 use Data::Dumper; |
181 | 115 |
116 for my $cg_name (keys %include_pool) { | |
117 my @tmp_cbc_file_names = keys %{$include_pool{$cg_name}}; | |
118 my $tmp_cbc_file_name = shift @tmp_cbc_file_names; | |
119 if (exists $counter{interfaces}->{$cg_name}){ | |
120 push(@{$counter{interfaces}->{$cg_name}->{$tmp_cbc_file_name}},$include_pool{$cg_name}->{$tmp_cbc_file_name}); | |
121 delete $include_pool{$cg_name}; | |
182 | 122 next; |
181 | 123 } |
124 | |
125 if (exists $counter{impl}->{$cg_name}){ | |
126 push(@{$counter{impl}->{$cg_name}->{$tmp_cbc_file_name}},$include_pool{$cg_name}->{$tmp_cbc_file_name}); | |
127 delete $include_pool{$cg_name}; | |
182 | 128 next; |
181 | 129 } |
130 push(@{$counter{interfaces}->{$cg_name}->{$tmp_cbc_file_name}},$include_pool{$cg_name}->{$tmp_cbc_file_name}); | |
131 delete $include_pool{$cg_name}; | |
132 } | |
133 | |
110
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
134 $counter{interfaces}->{Meta}++; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
135 $counter{interfaces}->{TaskManager}++; |
181 | 136 print "-----------\n"; |
180 | 137 print Dumper \%counter; |
138 print "-----------\n"; | |
110
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
139 return \%counter; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
140 } |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
141 |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
142 sub set_data_gear_header_path { |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
143 my $self = shift; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
144 my @data_gears_name; |
180 | 145 map { push (@data_gears_name,$_) if $_ ne "Context" } @_; |
110
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
146 return _find_headers($self->{find_root},\@data_gears_name); |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
147 } |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
148 |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
149 sub update_dg_each_header_path { |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
150 my ($self, $dgs, $dg2path) = @_; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
151 my $new_dgs; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
152 for my $kind (keys %$dgs) { |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
153 for my $dg_name (keys %{$dgs->{$kind}}) { |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
154 if ($dg2path->{$dg_name}) { |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
155 $new_dgs->{$kind}->{$dg_name} = $dg2path->{$dg_name}; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
156 } else { |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
157 croak "failed trans header $dg_name\n"; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
158 } |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
159 } |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
160 } |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
161 return $new_dgs; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
162 } |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
163 |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
164 sub tree2create_context_h { |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
165 my ($self, $dg2path) = @_; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
166 |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
167 my $data_struct_str = $dg2path ? $self->tree2data_struct_str($dg2path) : "\n"; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
168 |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
169 my $output = $self->_select_output(); |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
170 Gears::Context::Template::XV6->emit_top_header($output); |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
171 Gears::Context::Template::XV6->emit_data_gears($output,$data_struct_str); |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
172 Gears::Context::Template::XV6->emit_last_header($output); |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
173 close $output; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
174 } |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
175 |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
176 sub _select_output { |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
177 my $self = shift; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
178 print "$self->{output}\n"; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
179 if ($self->{output} eq 'stdout') { |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
180 return *STDOUT; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
181 } |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
182 open my $fh, '>', $self->{output}; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
183 return $fh; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
184 } |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
185 |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
186 sub tree2data_struct_str { |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
187 my ($self, $dg_str) = @_; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
188 my $data_struct_str = ""; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
189 for my $interface (sort keys %$dg_str) { |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
190 $data_struct_str .= Gears::Util->h2context_str($dg_str->{$interface}->{elem}); |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
191 next unless ($dg_str->{$interface}->{impl}); |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
192 for my $impl (sort keys %{$dg_str->{$interface}->{impl}}) { |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
193 $data_struct_str .= Gears::Util->h2context_str($dg_str->{$interface}->{impl}->{$impl}); |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
194 } |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
195 } |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
196 return $data_struct_str; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
197 } |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
198 |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
199 sub createImplTree_from_header { |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
200 my ($self, $dg2path) = @_; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
201 my %dg_str = (); |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
202 |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
203 my $inters = $dg2path->{interfaces}; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
204 my $impls = $dg2path->{impl}; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
205 |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
206 use Data::Dumper; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
207 print Dumper $dg2path; |
111
239bd73abac6
add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
110
diff
changeset
|
208 print Dumper $self; |
110
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
209 |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
210 map { $dg_str{$_}->{elem} = Gears::Util->parse_interface($inters->{$_}) } keys %$inters; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
211 |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
212 map { |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
213 my $res = Gears::Util->parse($impls->{$_}); |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
214 if ($res->{isa}) { |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
215 $dg_str{$res->{isa}}->{impl}->{$_} = $res; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
216 } else { |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
217 $dg_str{$_}->{elem} = $res; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
218 } |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
219 } keys %$impls; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
220 return \%dg_str; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
221 } |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
222 |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
223 sub _find_headers { |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
224 my ($search_bash_path, $targets) = @_; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
225 my %res; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
226 map { $res{$_}++ } @$targets; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
227 |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
228 my $header_paths = Gears::Util->find_headers_path($search_bash_path); |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
229 map { |
199 | 230 if (/(\w+)\.(?:h|dg)$/) { |
116 | 231 my $header_file = $1; |
232 if (exists $res{$header_file}) { | |
233 if ($res{$header_file} =~ /^\d+$/){ | |
234 $res{$header_file} = $_; | |
235 } elsif (($_ =~ /\.dg$/) && ($res{$header_file} =~ /\.h$/)) { | |
236 $res{$header_file} = $_; | |
237 } | |
238 } | |
110
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
239 } |
112 | 240 } sort @$header_paths; |
110
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
241 return \%res; |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
242 } |
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
243 |
133
ae25a4e76377
fix gen_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
131
diff
changeset
|
244 |
110
8c7c1ea49f21
impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
245 1; |