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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
49a70efcbd3a fix_arguments...
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 199
diff changeset
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
f431400da994 fix_use_data_gears
anatofuz
parents: 180
diff changeset
30 my %include_pool = ();
233
49a70efcbd3a fix_arguments...
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 199
diff changeset
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
2842d9e65751 fix_skip_codegear
anatofuz
parents: 178
diff changeset
34 if ($line =~ m|//\s*:skip|) {
2842d9e65751 fix_skip_codegear
anatofuz
parents: 178
diff changeset
35 next;
2842d9e65751 fix_skip_codegear
anatofuz
parents: 178
diff changeset
36 }
2842d9e65751 fix_skip_codegear
anatofuz
parents: 178
diff changeset
37
181
f431400da994 fix_use_data_gears
anatofuz
parents: 180
diff changeset
38 if ($line =~ /#interface\s*"(.*)\.h"/) {
180
f9df567f7f2d tweak_gen_context.pl
anatofuz
parents: 179
diff changeset
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
f431400da994 fix_use_data_gears
anatofuz
parents: 180
diff changeset
43 if ($line =~ /^\/\/\s*data_gear\s*"(.*)\.(?:h|dg)?"/) {
f431400da994 fix_use_data_gears
anatofuz
parents: 180
diff changeset
44 push(@{$include_pool{$1}->{$cbc_file}},$.);
f431400da994 fix_use_data_gears
anatofuz
parents: 180
diff changeset
45 next;
f431400da994 fix_use_data_gears
anatofuz
parents: 180
diff changeset
46 }
f431400da994 fix_use_data_gears
anatofuz
parents: 180
diff changeset
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
2842d9e65751 fix_skip_codegear
anatofuz
parents: 178
diff changeset
53
154
343f8f3c8f18 add pipe.h
anatofuz
parents: 134
diff changeset
54 #if ($line =~ /^(\w+)(\*)+ *create(\w+)\(([^]]*)\)/) {
343f8f3c8f18 add pipe.h
anatofuz
parents: 134
diff changeset
55 # my $interface = $1;
343f8f3c8f18 add pipe.h
anatofuz
parents: 134
diff changeset
56 # my $implementation = $3;
343f8f3c8f18 add pipe.h
anatofuz
parents: 134
diff changeset
57 # $self->{data_gears_with_count}->{$interface}->{caller}->{$cbc_file}++;
343f8f3c8f18 add pipe.h
anatofuz
parents: 134
diff changeset
58 # $self->{data_gears_with_count}->{$implementation}->{caller}->{$cbc_file}++;
343f8f3c8f18 add pipe.h
anatofuz
parents: 134
diff changeset
59 # $counter{interfaces}->{$interface}++;
343f8f3c8f18 add pipe.h
anatofuz
parents: 134
diff changeset
60 # $counter{impl}->{$implementation}++;
343f8f3c8f18 add pipe.h
anatofuz
parents: 134
diff changeset
61 # next;
343f8f3c8f18 add pipe.h
anatofuz
parents: 134
diff changeset
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
f9df567f7f2d tweak_gen_context.pl
anatofuz
parents: 179
diff changeset
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
e45b8d57b9e8 tweak context.pm
anatofuz
parents: 115
diff changeset
70 #Element* element = &ALLOCATE(cbc_context, Element)->Element;
e45b8d57b9e8 tweak context.pm
anatofuz
parents: 115
diff changeset
71 if ($line =~ /ALLOCATE\w*\((?:cbc_)?context,\s*(\w+)\)/) {
e45b8d57b9e8 tweak context.pm
anatofuz
parents: 115
diff changeset
72 my $implementation = $1;
180
f9df567f7f2d tweak_gen_context.pl
anatofuz
parents: 179
diff changeset
73 push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.);
116
e45b8d57b9e8 tweak context.pm
anatofuz
parents: 115
diff changeset
74 next;
e45b8d57b9e8 tweak context.pm
anatofuz
parents: 115
diff changeset
75 }
e45b8d57b9e8 tweak context.pm
anatofuz
parents: 115
diff changeset
76
e45b8d57b9e8 tweak context.pm
anatofuz
parents: 115
diff changeset
77 if ($line =~ /ALLOCATE_(?:PTR_)?ARRAY\((?:cbc_)?context,\s*(\w+),[\s\w]+\)/) {
e45b8d57b9e8 tweak context.pm
anatofuz
parents: 115
diff changeset
78 my $implementation = $1;
180
f9df567f7f2d tweak_gen_context.pl
anatofuz
parents: 179
diff changeset
79 push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.);
116
e45b8d57b9e8 tweak context.pm
anatofuz
parents: 115
diff changeset
80 next;
e45b8d57b9e8 tweak context.pm
anatofuz
parents: 115
diff changeset
81 }
e45b8d57b9e8 tweak context.pm
anatofuz
parents: 115
diff changeset
82
e45b8d57b9e8 tweak context.pm
anatofuz
parents: 115
diff changeset
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
f9df567f7f2d tweak_gen_context.pl
anatofuz
parents: 179
diff changeset
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
f9df567f7f2d tweak_gen_context.pl
anatofuz
parents: 179
diff changeset
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
f9df567f7f2d tweak_gen_context.pl
anatofuz
parents: 179
diff changeset
99 push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.);
f9df567f7f2d tweak_gen_context.pl
anatofuz
parents: 179
diff changeset
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
f9df567f7f2d tweak_gen_context.pl
anatofuz
parents: 179
diff changeset
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
anatofuz
parents: 181
diff changeset
114 use Data::Dumper;
181
f431400da994 fix_use_data_gears
anatofuz
parents: 180
diff changeset
115
f431400da994 fix_use_data_gears
anatofuz
parents: 180
diff changeset
116 for my $cg_name (keys %include_pool) {
f431400da994 fix_use_data_gears
anatofuz
parents: 180
diff changeset
117 my @tmp_cbc_file_names = keys %{$include_pool{$cg_name}};
f431400da994 fix_use_data_gears
anatofuz
parents: 180
diff changeset
118 my $tmp_cbc_file_name = shift @tmp_cbc_file_names;
f431400da994 fix_use_data_gears
anatofuz
parents: 180
diff changeset
119 if (exists $counter{interfaces}->{$cg_name}){
f431400da994 fix_use_data_gears
anatofuz
parents: 180
diff changeset
120 push(@{$counter{interfaces}->{$cg_name}->{$tmp_cbc_file_name}},$include_pool{$cg_name}->{$tmp_cbc_file_name});
f431400da994 fix_use_data_gears
anatofuz
parents: 180
diff changeset
121 delete $include_pool{$cg_name};
182
anatofuz
parents: 181
diff changeset
122 next;
181
f431400da994 fix_use_data_gears
anatofuz
parents: 180
diff changeset
123 }
f431400da994 fix_use_data_gears
anatofuz
parents: 180
diff changeset
124
f431400da994 fix_use_data_gears
anatofuz
parents: 180
diff changeset
125 if (exists $counter{impl}->{$cg_name}){
f431400da994 fix_use_data_gears
anatofuz
parents: 180
diff changeset
126 push(@{$counter{impl}->{$cg_name}->{$tmp_cbc_file_name}},$include_pool{$cg_name}->{$tmp_cbc_file_name});
f431400da994 fix_use_data_gears
anatofuz
parents: 180
diff changeset
127 delete $include_pool{$cg_name};
182
anatofuz
parents: 181
diff changeset
128 next;
181
f431400da994 fix_use_data_gears
anatofuz
parents: 180
diff changeset
129 }
f431400da994 fix_use_data_gears
anatofuz
parents: 180
diff changeset
130 push(@{$counter{interfaces}->{$cg_name}->{$tmp_cbc_file_name}},$include_pool{$cg_name}->{$tmp_cbc_file_name});
f431400da994 fix_use_data_gears
anatofuz
parents: 180
diff changeset
131 delete $include_pool{$cg_name};
f431400da994 fix_use_data_gears
anatofuz
parents: 180
diff changeset
132 }
f431400da994 fix_use_data_gears
anatofuz
parents: 180
diff changeset
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
f431400da994 fix_use_data_gears
anatofuz
parents: 180
diff changeset
136 print "-----------\n";
180
f9df567f7f2d tweak_gen_context.pl
anatofuz
parents: 179
diff changeset
137 print Dumper \%counter;
f9df567f7f2d tweak_gen_context.pl
anatofuz
parents: 179
diff changeset
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
f9df567f7f2d tweak_gen_context.pl
anatofuz
parents: 179
diff changeset
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
8a55878f6a25 loaduvm
tobaru
parents: 182
diff changeset
230 if (/(\w+)\.(?:h|dg)$/) {
116
e45b8d57b9e8 tweak context.pm
anatofuz
parents: 115
diff changeset
231 my $header_file = $1;
e45b8d57b9e8 tweak context.pm
anatofuz
parents: 115
diff changeset
232 if (exists $res{$header_file}) {
e45b8d57b9e8 tweak context.pm
anatofuz
parents: 115
diff changeset
233 if ($res{$header_file} =~ /^\d+$/){
e45b8d57b9e8 tweak context.pm
anatofuz
parents: 115
diff changeset
234 $res{$header_file} = $_;
e45b8d57b9e8 tweak context.pm
anatofuz
parents: 115
diff changeset
235 } elsif (($_ =~ /\.dg$/) && ($res{$header_file} =~ /\.h$/)) {
e45b8d57b9e8 tweak context.pm
anatofuz
parents: 115
diff changeset
236 $res{$header_file} = $_;
e45b8d57b9e8 tweak context.pm
anatofuz
parents: 115
diff changeset
237 }
e45b8d57b9e8 tweak context.pm
anatofuz
parents: 115
diff changeset
238 }
110
8c7c1ea49f21 impl auto gen context tools
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
239 }
112
b9df8ea87b42 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 111
diff changeset
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;