Mercurial > hg > CbC > CbC_xv6
annotate src/gearsTools/generate_context.pl @ 395:17e8a4bc06a7 default tip
add macOS AR/RANLIB
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 14 Dec 2020 21:59:50 +0900 |
parents | 5ff90ae1fa04 |
children |
rev | line source |
---|---|
44 | 1 #!/usr/bin/perl |
2 | |
354
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
3 use Getopt::Long; |
44 | 4 use strict; |
5 | |
6 # | |
7 # generrate Gears OS context heaader and initializer from CbC sources | |
8 # | |
9 # CodeGear | |
10 # | |
11 # get stub information from # *.c | |
354
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
12 # __code taskManager_stub(struct Context* context) { |
44 | 13 # |
14 # generate CodeGear indexn in context.h | |
15 # C_taskManager, | |
16 # | |
17 # generate CodeGear stub reference in context.h | |
18 # extern __code taskManager_stub(struct Context*); | |
19 # | |
20 # generate CodeGear stub reference in $name-context.h for each module | |
354
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
21 # context->code[C_taskManager] = taskManager_stub; |
44 | 22 # |
23 # DataGear | |
24 # | |
25 # get DataGear information from context.h | |
26 # struct Worker { | |
27 # int id; | |
28 # struct Context* contexts; | |
29 # enum Code execute; | |
30 # enum Code taskSend; | |
31 # enum Code taskRecive; | |
32 # enum Code shutdown; | |
33 # struct Queue* tasks; | |
34 # } Worker; | |
35 # | |
36 # generate typedefs and DataGear index in context.h | |
37 # typedef struct Worker Worker; | |
38 # D_Worker, | |
39 # | |
40 # generate DataGear allocator in context.h | |
41 # ALLOC_DATA(context, Worker); | |
42 # | |
43 | |
44 my $ddir = "c"; | |
45 | |
354
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
46 our($opt_o,$opt_d,$opt_h,$opt_w, $opt_project); |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
47 GetOptions( |
357 | 48 "o=s" => \$opt_o, |
49 "d=s" => \$opt_d, | |
50 "h" => \$opt_h, | |
51 "w" => \$opt_w, | |
52 "project=s" => \$opt_project, | |
354
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
53 ); |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
54 |
44 | 55 |
56 my $name = $opt_o?$opt_o:"gears"; | |
57 | |
58 if ($opt_d) { | |
59 $ddir = $opt_d; | |
60 } | |
61 | |
62 if ( ! -d $ddir) { | |
63 mkdir $ddir; | |
64 } | |
65 | |
66 if ($opt_h) { | |
67 print "$0 [-d distdir] [-h]\n"; | |
68 exit; | |
69 } | |
70 | |
354
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
71 my %projects = ( |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
72 gears => { name => "gears", cotnext => "context" , template => "Gears::Context::Template"}, |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
73 xv6 => { name => "xv6" , context => "cbc_context" , template => "Gears::Context::Template::XV6"}, |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
74 ); |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
75 |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
76 |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
77 my $context_name = "context"; |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
78 |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
79 my $project = $projects{gears}; |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
80 |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
81 if ($opt_project && exists $projects{$opt_project}) { |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
82 $context_name = $projects{$opt_project}->{context}; |
358 | 83 $project = $projects{$opt_project}; |
354
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
84 } |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
85 |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
86 |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
87 |
44 | 88 my %codeGear; |
89 my %dataGear; | |
90 my %constructor; | |
91 | |
111
239bd73abac6
add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
53
diff
changeset
|
92 { |
239bd73abac6
add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
53
diff
changeset
|
93 use FindBin; |
239bd73abac6
add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
53
diff
changeset
|
94 use lib "$FindBin::Bin/lib"; |
239bd73abac6
add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
53
diff
changeset
|
95 |
239bd73abac6
add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
53
diff
changeset
|
96 use File::Spec; |
239bd73abac6
add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
53
diff
changeset
|
97 use Cwd 'getcwd'; |
239bd73abac6
add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
53
diff
changeset
|
98 |
239bd73abac6
add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
53
diff
changeset
|
99 use Gears::Context; |
239bd73abac6
add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
53
diff
changeset
|
100 use Getopt::Std; |
239bd73abac6
add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
53
diff
changeset
|
101 |
239bd73abac6
add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
53
diff
changeset
|
102 my $output = $opt_w ? "context.h" : "stdout"; |
239bd73abac6
add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
53
diff
changeset
|
103 |
239bd73abac6
add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
53
diff
changeset
|
104 my @cbc_files; |
239bd73abac6
add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
53
diff
changeset
|
105 map { push(@cbc_files,File::Spec->rel2abs($_)); } @ARGV; |
354
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
106 my $gears = Gears::Context->new(compile_sources => \@cbc_files, find_root => "$FindBin::Bin/../", output => $output, template => $project->{template}); |
233 | 107 my $data_gears = $gears->extraction_dg_compile_sources($gears->{compile_sources}); |
180 | 108 my $g = $gears->set_data_gear_header_path(keys %{$data_gears->{impl}},keys %{$data_gears->{interfaces}}); |
111
239bd73abac6
add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
53
diff
changeset
|
109 |
239bd73abac6
add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
53
diff
changeset
|
110 my $dg2path = $gears->update_dg_each_header_path($data_gears,$g); |
239bd73abac6
add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
53
diff
changeset
|
111 my $tree = $gears->createImplTree_from_header($dg2path); |
239bd73abac6
add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
53
diff
changeset
|
112 $gears->tree2create_context_h($tree); |
239bd73abac6
add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
53
diff
changeset
|
113 } |
239bd73abac6
add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
53
diff
changeset
|
114 |
44 | 115 # gather module Information for code table initialization |
116 for (@ARGV) { | |
117 next if (/context.c/); | |
118 &getStubInfo($_); | |
119 } | |
120 | |
121 my (%mCodeGear) = (%codeGear); | |
122 | |
123 # anyway we gather all Gears Information | |
124 while (<*.c test/*.c>) { | |
125 next if (/context.c/); | |
126 &getStubInfo($_); | |
127 } | |
128 | |
129 &generateContext(); | |
130 | |
131 sub getStubInfo { | |
132 my ($filename) = @_; | |
133 open my $fd,"<",$filename or die("can't open $filename $!"); | |
134 while (<$fd>) { | |
363 | 135 if (/^__code (\w+)_stub\(/) { |
44 | 136 $codeGear{$1} = $filename; |
137 } elsif (/^(\w+)(\*)+ *create(\w+)\(([^]]*)\)/) { | |
138 my $interface = $1; | |
139 my $implementation = $3; | |
140 my $constructorArgs = $4; | |
141 $constructor{$implementation} = [$interface, $constructorArgs]; | |
142 } | |
143 } | |
144 | |
145 open my $cx,"<","context.h" or die("can't open context.h $!"); | |
146 my $inUnionData = 0; | |
147 while (<$cx>) { | |
148 if (! $inUnionData) { | |
149 if ( /^union Data/) { | |
150 $inUnionData = 1; | |
151 } | |
152 next; | |
153 } | |
154 last if (/union Data end/); | |
155 if (/struct (\w+) \{/) { | |
156 $dataGear{$1} = 'struct'; | |
157 } elsif (/^\s{4}(\w+) (\w+);/) { # primitive type | |
346 | 158 my $vtype = $1; |
159 my $vname = $2; | |
160 if (exists $dataGear{$vname}) { | |
161 next; | |
162 } | |
163 $dataGear{$vtype} = 'primitive'; | |
44 | 164 } |
165 $dataGear{"Context"} = "struct"; | |
166 } | |
167 } | |
168 | |
169 sub generateContext { | |
170 $codeGear{"start_code"} = "$ddir/$name-context.c"; | |
171 $codeGear{"exit_code"} = "$ddir/$name-context.c"; | |
172 $mCodeGear{"start_code"} = "$ddir/$name-context.c"; | |
173 $mCodeGear{"exit_code"} = "$ddir/$name-context.c"; | |
174 open my $fd,">","$ddir/extern.h" or die("can't open $ddir/extern.h $!"); | |
175 for my $code ( sort keys %codeGear ) { | |
176 print $fd "extern __code ${code}_stub(struct Context*);\n"; | |
177 } | |
178 for my $impl ( sort keys %constructor ) { | |
179 my ($interface, $constructorArgs) = @{$constructor{$impl}}; | |
180 print $fd "extern ${interface}* create${impl}($constructorArgs);\n"; | |
181 } | |
182 print $fd "\n"; | |
183 | |
184 open my $fd,">","$ddir/enumCode.h" or die("can't open $ddir/enumCode.h $!"); | |
185 print $fd "enum Code {\n"; | |
186 for my $code ( sort keys %codeGear ) { | |
187 print $fd " C_${code},\n"; | |
188 } | |
189 print $fd "};\n"; | |
190 | |
191 my $code_init = ''; | |
192 for my $code ( sort keys %mCodeGear ) { | |
358 | 193 $code_init .= " ${context_name}->code[C_${code}] = ${code}_stub;\n"; |
44 | 194 } |
195 | |
196 my $data_num = keys(%dataGear); | |
197 $data_num++; | |
354
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
198 my $context_c; |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
199 if ($project->{name} eq "xv6") { |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
200 $context_c .= << "EOFEOF"; |
47 | 201 #ifndef CBCXV6 |
44 | 202 #include <stdlib.h> |
47 | 203 #endif |
354
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
204 EOFEOF |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
205 } else { |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
206 $context_c .= << "EOFEOF"; |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
207 #include <stdlib.h> |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
208 EOFEOF |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
209 } |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
210 |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
211 $context_c .= << "EOFEOF"; |
44 | 212 |
213 #include "../context.h" | |
214 | |
354
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
215 void initContext(struct Context* $context_name) { |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
216 ${context_name}\->heapLimit = sizeof(union Data)*ALLOCATE_SIZE; |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
217 ${context_name}\->code = (__code(**) (struct Context*)) NEWN(ALLOCATE_SIZE, void*); |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
218 ${context_name}\->data = NEWN(ALLOCATE_SIZE, union Data*); |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
219 ${context_name}\->heapStart = NEWN(${context_name}\->heapLimit, char); |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
220 ${context_name}\->heap = ${context_name}\->heapStart; |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
221 // ${context_name}\->codeNum = Exit; |
44 | 222 |
223 $code_init | |
224 | |
225 #include "dataGearInit.c" | |
354
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
226 ${context_name}\->dataNum = $data_num; |
44 | 227 } |
228 EOFEOF | |
229 | |
230 open my $fd,">","$ddir/$name-context.c" or die("can't open $ddir/$name-context.c $!"); | |
231 print $fd $context_c; | |
232 | |
233 my $meta_call = <<"EOFEOF"; | |
354
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
234 __code meta(struct Context* ${context_name}, enum Code next) { |
44 | 235 // printf("meta %d\\n",next); |
354
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
236 goto (${context_name}\->code[next])(${context_name}); |
45 | 237 } |
238 | |
354
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
239 __code parGotoMeta(struct Context* ${context_name}, enum Code next) { |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
240 ${context_name}->task = NULL; |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
241 ${context_name}->taskList = NULL; |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
242 goto (${context_name}\->code[Gearef(${context_name}, TaskManager)->taskManager->TaskManager.spawnTasks])(${context_name}); |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
243 } |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
244 |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
245 __code start_code(struct Context* ${context_name}) { |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
246 goto meta(${context_name}, ${context_name}\->next); |
44 | 247 } |
248 | |
354
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
249 __code start_code_stub(struct Context* ${context_name}) { |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
250 goto start_code(${context_name}); |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
251 } |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
252 EOFEOF |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
253 |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
254 if ($project->{name} eq "gears") { |
355 | 255 $meta_call .= <<"EOFEOF"; |
354
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
256 __code exit_code(struct Context* ${context_name}) { |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
257 free(${context_name}->code); |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
258 free(${context_name}->data); |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
259 free(${context_name}->heapStart); |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
260 goto exit(0); |
44 | 261 } |
354
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
262 EOFEOF |
44 | 263 |
354
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
264 } else { |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
265 |
355 | 266 $meta_call .= <<"EOFEOF"; |
354
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
267 __code exit_code(struct Context* ${context_name}) { |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
268 // free(${context_name}->code); |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
269 // free(${context_name}->data); |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
270 // free(${context_name}->heapStart); |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
271 goto exit_code(cbc_context); |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
272 } |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
273 EOFEOF |
44 | 274 } |
275 | |
355 | 276 $meta_call .= <<"EOFEOF"; |
354
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
277 __code exit_code_stub(struct Context* ${context_name}) { |
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
278 goto exit_code(${context_name}); |
44 | 279 } |
280 | |
281 // end context_c | |
282 EOFEOF | |
283 | |
284 print $fd $meta_call; | |
285 | |
286 open my $fd,">","$ddir/enumData.h" or die("can't open $ddir/enumData.h $!"); | |
287 print $fd "enum DataType {\n"; | |
288 print $fd " D_Code,\n"; | |
289 for my $data ( sort keys %dataGear ) { | |
290 print $fd " D_${data},\n"; | |
291 } | |
292 print $fd "};\n\n"; | |
293 | |
294 open my $fd,">","$ddir/typedefData.h" or die("can't open $ddir/typedefData.h $!"); | |
295 for my $data ( sort keys %dataGear ) { | |
296 if ($dataGear{$data} eq 'struct') { | |
297 print $fd "typedef struct ${data} ${data};\n"; | |
298 } | |
299 } | |
300 | |
301 open my $fd,">","$ddir/dataGearInit.c" or die("can't open $ddir/dataGearInit.c $!"); | |
302 for my $data ( sort keys %dataGear ) { | |
354
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
346
diff
changeset
|
303 print $fd " ALLOC_DATA(${context_name}, ${data});\n"; |
44 | 304 } |
305 } | |
306 | |
307 # end |