Mercurial > hg > Gears > GearsAgda
annotate src/parallel_execution/generate_stub.pl @ 516:62a77785cb2b
Bounded Loop for boundedBuffer examples
author | Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 04 Jan 2018 19:50:46 +0900 |
parents | 809974b25ecb |
children |
rev | line source |
---|---|
194 | 1 #!/usr/bin/perl |
2 | |
250 | 3 use strict; |
254 | 4 use Getopt::Std; |
393 | 5 use File::Path qw(make_path); |
250 | 6 |
482
5859bed4edff
Refactoring spawnTasks method
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
7 # interface.h |
194 | 8 # typedef struct Worker { |
9 # int id; | |
10 # struct Context* contexts; | |
11 # enum Code execute; | |
12 # enum Code taskSend; | |
13 # enum Code taskRecive; | |
14 # enum Code shutdown; | |
15 # struct Queue* tasks; | |
16 # } Worker; | |
17 | |
255 | 18 our($opt_o,$opt_d,$opt_h); |
19 getopts('o:d:h'); | |
20 | |
21 my $dir = "."; | |
22 if ($opt_d) { | |
23 $dir = $opt_d; | |
24 if (! -d $dir) { | |
393 | 25 make_path $dir; |
255 | 26 } |
27 } | |
254 | 28 |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
29 for my $fn (@ARGV) { |
255 | 30 next if ($fn !~ /\.cbc$/); |
249 | 31 &getDataGear($fn); |
32 &generateDataGear($fn); | |
194 | 33 } |
34 | |
250 | 35 my %var; |
36 my %code; | |
37 my %dataGearVar; | |
260
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
38 my %outputVar; # output var initializer |
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
39 my %outputArgs; # continuation's output variables |
250 | 40 my %dataGear; |
41 my %dataGearName; | |
384
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
42 my %generic; |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
43 my %dataGearVarType; |
396
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
44 my %codeGear; |
253 | 45 my $implementation; |
46 my $interface; | |
250 | 47 |
384
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
48 # interface definision |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
49 # |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
50 # typedef struct Stack<Type, Impl>{ |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
51 # Type* stack; |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
52 # Type* data; |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
53 # Type* data1; |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
54 # __code whenEmpty(...); |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
55 # __code clear(Impl* stack,__code next(...)); |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
56 # __code push(Impl* stack,Type* data, __code next(...)); |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
57 # __code pop(Impl* stack, __code next(Type*, ...)); |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
58 # __code pop2(Impl* stack, Type** data, Type** data1, __code next(Type**, Type**, ...)); |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
59 # __code isEmpty(Impl* stack, __code next(...), __code whenEmpty(...)); |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
60 # __code get(Impl* stack, Type** data, __code next(...)); |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
61 # __code get2(Impl* stack,..., __code next(...)); |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
62 # __code next(...); |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
63 # } Stack; |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
64 # |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
65 # calling example |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
66 # |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
67 # goto nodeStack->push((union Data*)node, stackTest3); |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
68 # |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
69 # generated meta level code |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
70 # |
442
481fce540daf
Fix goto implement method of generate_stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
424
diff
changeset
|
71 # Gearef(context, Stack)->stack = (union Data*)nodeStack; |
384
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
72 # Gearef(context, Stack)->data = (union Data*)node; |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
73 # Gearef(context, Stack)->next = C_stackTest3; |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
74 # goto meta(context, nodeStack->push); |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
75 |
194 | 76 sub getDataGear { |
77 my ($filename) = @_; | |
253 | 78 my ($codeGearName, $name, $inTypedef); |
194 | 79 open my $fd,"<",$filename or die("can't open $filename $!"); |
80 while (<$fd>) { | |
81 if (! $inTypedef) { | |
384
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
82 if (/^typedef struct (\w+)\s*<(.*)>/) { |
194 | 83 $inTypedef = 1; |
84 $name = $1; | |
85 $dataGear{$name} = $_; | |
259
195518ab62fc
fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
255
diff
changeset
|
86 $var{$name} = {}; |
195518ab62fc
fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
255
diff
changeset
|
87 $code{$name} = {}; |
384
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
88 $generic{$name} = \split(/,/,$2); |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
89 } elsif (/^typedef struct (\w+)/) { |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
90 $inTypedef = 1; |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
91 $name = $1; |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
92 $dataGear{$name} = $_; |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
93 $var{$name} = {}; |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
94 $code{$name} = {}; |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
95 $generic{$name} = []; |
269 | 96 } elsif (/^(\w+)(\*)+ create(\w+)\(/) { |
249 | 97 if (defined $interface) { |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
98 die "duplicate interface $interface\n"; |
249 | 99 } |
100 $interface = $1; | |
269 | 101 $implementation = $3; |
250 | 102 if ( -f "$interface.cbc") { |
103 &getDataGear("$interface.cbc"); | |
104 } | |
396
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
105 } elsif(/^(.*)par goto (\w+)\((.*)\)/) { |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
106 my $codeGearName = $2; |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
107 if ($filename =~ /^(.*)\/(.*)/) { |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
108 $codeGearName = "$1/$codeGearName"; |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
109 } |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
110 if ( -f "$codeGearName.cbc") { |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
111 &getCodeGear("$codeGearName.cbc"); |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
112 } |
468
ac244346c85d
Change used interface syntax from #include to #interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
113 } elsif(/^#interface "(.*)"/) { |
ac244346c85d
Change used interface syntax from #include to #interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
114 # use interface |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
115 my $interfaceHeader = $1; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
116 next if ($interfaceHeader =~ /context.h/); |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
117 if (-f $interfaceHeader) { |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
118 &getDataGear("$interfaceHeader"); |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
119 &getCodeGear("$interfaceHeader"); |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
120 } |
226 | 121 } |
194 | 122 next; |
123 } | |
249 | 124 # gather type name and type |
194 | 125 $dataGear{$name} .= $_; |
385 | 126 if (/^\s*(.*)\s+(\w+);$/ ) { |
280 | 127 my $ttype = $1; |
128 my $tname = $2; | |
497
809974b25ecb
Genrate stub for MultiDimIterator
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
493
diff
changeset
|
129 if ($ttype =~ /^(union|struct)?\s*(\w+)/) { |
280 | 130 $ttype = $2; |
131 } | |
132 $var{$name}->{$tname} = $ttype; | |
250 | 133 } |
194 | 134 if (/^}/) { |
135 $inTypedef = 0; | |
136 } | |
137 } | |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
138 |
194 | 139 } |
140 | |
385 | 141 sub getCodeGear { |
142 my ($filename) = @_; | |
143 open my $fd,"<",$filename or die("can't open $filename $!"); | |
144 my ($name,$impln); | |
145 while (<$fd>) { | |
146 if (/^(\w+)(\*)+ create(\w+)\(/) { | |
147 $name = $1; | |
148 $impln = $3; | |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
149 } elsif(/^typedef struct (.*)<.*>\s*{/) { |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
150 $name = $1; |
385 | 151 } |
152 if (defined $name) { | |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
153 if (/^\s*\_\_code (\w+)\((.*)\);/) { |
385 | 154 my $args = $2; |
155 my $method = $1; | |
156 $code{$name}->{$method} = []; | |
157 while($args) { | |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
158 # replace comma |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
159 $args =~ s/(^\s*,\s*)//; |
385 | 160 # continuation case |
161 if ($args =~ s/^(\s)*\_\_code\s+(\w+)\(([^)]*)\)//) { | |
162 my $next = $2; | |
163 my @args = split(/,/,$3); | |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
164 push(@{$code{$name}->{$method}},"\_\_code $next"); |
466
831b7f6fd687
Fix warning pointer type
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
165 } elsif ($args =~ s/^(struct|union)?\s*(\w+)(\**)\s+(\w+)//) { |
385 | 166 my $structType = $1; |
167 my $typeName = $2; | |
466
831b7f6fd687
Fix warning pointer type
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
168 my $ptrType = $3; |
385 | 169 my $varName = $4; |
170 my $typeField = lcfirst($typeName); | |
466
831b7f6fd687
Fix warning pointer type
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
171 push(@{$code{$name}->{$method}},"$typeName$ptrType $varName"); |
385 | 172 } elsif ($args =~ s/(.*,)//) { |
173 } else { | |
174 last; | |
175 } | |
176 } | |
177 } | |
396
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
178 } elsif (/^\_\_code (\w+)\((.*)\)(.*)/) { |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
179 my $codeGearName = $1; |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
180 my $args = $2; |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
181 my $inputCount = 0; |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
182 my $outputCount = 0; |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
183 my $inputIncFlag = 1; |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
184 while($args) { |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
185 if ($args =~ s/(^\s*,\s*)//) { |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
186 } |
404
c5cd9888bf2a
Fix bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
187 if ($args =~ s/^(\s)*\_\_code\s+(\w+)\((.*?)\)//) { |
396
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
188 $inputIncFlag = 0; |
404
c5cd9888bf2a
Fix bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
189 $outputCount = split(/,/,$3); |
c5cd9888bf2a
Fix bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
403
diff
changeset
|
190 $outputCount--; |
516
62a77785cb2b
Bounded Loop for boundedBuffer examples
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
497
diff
changeset
|
191 } elsif ($args =~ s/^(struct|union)?\s*(\w+)(\*)?+\s(\w+)//) { |
396
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
192 if($inputIncFlag) { |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
193 $inputCount++; |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
194 } |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
195 } elsif ($args =~ s/(.*,)//) { |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
196 } else { |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
197 last; |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
198 } |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
199 } |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
200 $codeGear{$codeGearName}->{"input"} = $inputCount; |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
201 $codeGear{$codeGearName}->{"output"} = $outputCount; |
385 | 202 } |
203 } | |
204 } | |
205 | |
250 | 206 sub generateStub { |
251 | 207 my($fd,$prevCodeGearName,$dataGearName) = @_; |
274 | 208 print $fd "__code ", $prevCodeGearName ,"_stub(struct Context* context) {\n"; |
251 | 209 print $fd $dataGearName; |
250 | 210 print $fd "\n} \n\n"; |
251 | 211 return 1; |
250 | 212 } |
213 | |
253 | 214 sub generateStubArgs { |
466
831b7f6fd687
Fix warning pointer type
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
215 my($codeGearName, $varName, $typeName, $ptrType, $typeField, $interface,$output) = @_; |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
216 my $varname1 = $output?"O_$varName":$varName; |
260
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
217 for my $n ( @{$dataGearVar{$codeGearName}} ) { |
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
218 # we already have it |
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
219 return 0 if ( $n eq $varname1); |
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
220 } |
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
221 push @{$dataGearVar{$codeGearName}}, $varname1; |
384
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
222 push @{$dataGearVarType{$codeGearName}}, $typeName; |
260
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
223 if ($typeName eq $implementation) { |
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
224 # get implementation |
258 | 225 $dataGearName{$codeGearName} .= "\t$typeName* $varName = ($typeName*)GearImpl(context, $interface, $varName);\n"; |
253 | 226 } else { |
259
195518ab62fc
fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
255
diff
changeset
|
227 for my $ivar (keys %{$var{$interface}}) { |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
228 # input data gear field |
253 | 229 if ($varName eq $ivar) { |
280 | 230 if ($typeName eq $var{$interface}->{$ivar}) { |
231 if ($output) { | |
466
831b7f6fd687
Fix warning pointer type
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
232 $dataGearName{$codeGearName} .= "\t$typeName$ptrType* O_$varName = &Gearef(context, $interface)->$varName;\n"; |
493
82f0c49750f1
Add codeGear for boundedBuffer example
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
482
diff
changeset
|
233 $outputVar{$codeGearName} .= "\t$typeName$ptrType $varName = *O_$varName;\n"; |
280 | 234 return 1; |
235 } | |
396
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
236 |
466
831b7f6fd687
Fix warning pointer type
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
237 $dataGearName{$codeGearName} .= "\t$typeName$ptrType $varName = Gearef(context, $interface)->$varName;\n"; |
260
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
238 return 1; |
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
239 } |
253 | 240 } |
241 } | |
259
195518ab62fc
fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
255
diff
changeset
|
242 for my $cName (keys %{$code{$interface}}) { |
195518ab62fc
fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
255
diff
changeset
|
243 if ($varName eq $cName) { |
260
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
244 # continuation field |
259
195518ab62fc
fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
255
diff
changeset
|
245 $dataGearName{$codeGearName} .= "\tenum Code $varName = Gearef(context, $interface)->$varName;\n"; |
260
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
246 return 1; |
253 | 247 } |
248 } | |
389 | 249 # global or local variable case |
250 if ($typeName eq "Code") { | |
466
831b7f6fd687
Fix warning pointer type
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
251 $dataGearName{$codeGearName} .= "\tenum $typeName$ptrType $varName = Gearef(context, $interface)->$varName;\n"; |
389 | 252 return 1; |
253 } | |
466
831b7f6fd687
Fix warning pointer type
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
254 $dataGearName{$codeGearName} .= "\t$typeName$ptrType $varName = Gearef(context, $typeName);\n"; |
260
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
255 return 1; |
253 | 256 } |
257 } | |
258 | |
194 | 259 sub generateDataGear { |
249 | 260 my ($filename) = @_; |
261 open my $in,"<",$filename or die("can't open $filename $!"); | |
254 | 262 |
263 my $fn; | |
264 if ($opt_o) { | |
396
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
265 $fn = $opt_o; |
254 | 266 } else { |
267 my $fn1 = $filename; | |
268 $fn1 =~ s/\.cbc/.c/; | |
269 my $i = 1; | |
255 | 270 $fn = "$dir/$fn1"; |
254 | 271 while ( -f $fn) { |
255 | 272 $fn = "$dir/$fn1.$i"; |
254 | 273 $i++; |
274 } | |
250 | 275 } |
259
195518ab62fc
fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
255
diff
changeset
|
276 if ( $fn =~ m=(.*)/[^/]+$= ) { |
195518ab62fc
fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
255
diff
changeset
|
277 if (! -d $1) { |
393 | 278 make_path $1; |
259
195518ab62fc
fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
255
diff
changeset
|
279 } |
195518ab62fc
fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
255
diff
changeset
|
280 } |
249 | 281 open my $fd,">",$fn or die("can't write $fn $!"); |
254 | 282 |
249 | 283 my $prevCodeGearName; |
250 | 284 my $inTypedef = 0; |
278 | 285 my $inStub = 0; |
396
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
286 my $inParGoto = 0; |
418 | 287 my $inMain = 0 ; |
250 | 288 my %stub; |
251 | 289 my $codeGearName; |
444
0c024ea61601
Using cas interface but occurred warning
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
442
diff
changeset
|
290 my %localVarType; |
254 | 291 |
249 | 292 while (<$in>) { |
418 | 293 if (! $inTypedef && ! $inStub && ! $inMain) { |
454 | 294 if (/^typedef struct (\w+) \{/) { |
249 | 295 $inTypedef = 1; |
454 | 296 } elsif (/^int main\((.*)\) \{/) { |
418 | 297 $inMain = 1; |
468
ac244346c85d
Change used interface syntax from #include to #interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
298 } elsif(/^#interface "(.*)"/) { |
462
8d7e5d48cad3
Running CPU examples
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
461
diff
changeset
|
299 my $interfaceHeader = $1; |
468
ac244346c85d
Change used interface syntax from #include to #interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
300 # #interface not write |
462
8d7e5d48cad3
Running CPU examples
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
461
diff
changeset
|
301 next unless ($interfaceHeader =~ /context.h/); |
253 | 302 } elsif (/^\_\_code (\w+)\((.*)\)(.*)/) { |
444
0c024ea61601
Using cas interface but occurred warning
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
442
diff
changeset
|
303 %localVarType = {}; |
251 | 304 $codeGearName = $1; |
253 | 305 my $args = $2; |
306 my $tail = $3; | |
250 | 307 if ($codeGearName =~ /_stub$/) { |
262 | 308 # don't touch already existing stub |
278 | 309 $inStub = 1; |
250 | 310 $stub{$codeGearName} = 1; |
311 print $fd $_; | |
312 next; | |
313 } | |
249 | 314 if (defined $prevCodeGearName) { |
262 | 315 # stub is generated just before next CodeGear |
250 | 316 if (defined $stub{$prevCodeGearName."_stub"}) { |
317 undef $prevCodeGearName; | |
278 | 318 } else { |
319 &generateStub($fd,$prevCodeGearName,$dataGearName{$prevCodeGearName}); | |
320 $stub{$prevCodeGearName."_stub"} = 1; | |
250 | 321 } |
249 | 322 } |
262 | 323 # analyzing CodeGear argument |
324 # these arguments are extract from current context's arugment DataGear Interface | |
325 # and passed to the CodeGear | |
326 # struct Implementaion needs special handling | |
327 # __code next(...) ---> enum Code next | |
253 | 328 $prevCodeGearName = $codeGearName; |
329 $dataGearVar{$codeGearName} = []; | |
260
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
330 $outputVar{$codeGearName} = ""; |
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
331 $outputArgs{$codeGearName} = {}; |
259
195518ab62fc
fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
255
diff
changeset
|
332 my $newArgs = "struct Context *context,"; |
305 | 333 if ($args=~/^struct Context\s*\*\s*context/) { |
334 $newArgs = ""; | |
335 } | |
253 | 336 while($args) { |
337 if ($args =~ s/(^\s*,\s*)//) { | |
338 $newArgs .= $1; | |
339 } | |
262 | 340 # continuation case |
280 | 341 if ($args =~ s/^(\s)*\_\_code\s+(\w+)\(([^)]*)\)//) { |
342 my $next = $2; | |
343 my @args = split(/,/,$3); | |
466
831b7f6fd687
Fix warning pointer type
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
344 if (&generateStubArgs($codeGearName, $next, "Code", "", $next, $interface,0) ) { |
260
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
345 $newArgs .= "enum Code $next"; |
258 | 346 } |
262 | 347 # analyze continuation arguments |
348 # output arguments are defined in the Interface take the pointer of these | |
349 # output arguments are put into the Interface DataGear just before the goto | |
253 | 350 for my $arg (@args) { |
351 $arg =~ s/^\s*//; | |
260
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
352 last if ($arg =~ /\.\.\./); |
497
809974b25ecb
Genrate stub for MultiDimIterator
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
493
diff
changeset
|
353 $arg =~ s/^(struct|union)?\s*(\w+)(\**)\s(\w+)//; |
253 | 354 my $structType = $1; |
355 my $typeName = $2; | |
466
831b7f6fd687
Fix warning pointer type
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
356 my $ptrType = $3; |
253 | 357 my $varName = $4; |
358 my $typeField = lcfirst($typeName); | |
260
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
359 push(@{$outputArgs{$codeGearName}->{$next}}, $varName); |
466
831b7f6fd687
Fix warning pointer type
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
360 if (&generateStubArgs($codeGearName, $varName, $typeName, $ptrType, $typeField, $interface,1)) { |
260
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
361 $newArgs .= ",$structType $typeName **O_$varName"; |
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
362 } |
253 | 363 } |
497
809974b25ecb
Genrate stub for MultiDimIterator
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
493
diff
changeset
|
364 } elsif ($args =~ s/^(struct|union)?\s*(\w+)(\**)\s(\w+)//) { |
253 | 365 my $structType = $1; |
366 my $typeName = $2; | |
466
831b7f6fd687
Fix warning pointer type
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
367 my $ptrType = $3; |
253 | 368 my $varName = $4; |
369 my $typeField = lcfirst($typeName); | |
260
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
370 $newArgs .= $&; # assuming no duplicate |
466
831b7f6fd687
Fix warning pointer type
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
371 &generateStubArgs($codeGearName, $varName, $typeName, $ptrType, $typeField, $interface,0); |
255 | 372 } elsif ($args =~ s/(.*,)//) { |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
373 $newArgs .= $1; |
255 | 374 } else { |
375 $newArgs .= $args; | |
376 last; | |
253 | 377 } |
378 } | |
262 | 379 # generate goto statement from stub to the CodeGear in the buffer |
253 | 380 $dataGearName{$codeGearName} .= "\tgoto $codeGearName(context"; |
381 for my $arg ( @{$dataGearVar{$codeGearName}}) { | |
382 $dataGearName{$codeGearName} .= ", $arg"; | |
383 } | |
384 $dataGearName{$codeGearName} .= ");"; | |
262 | 385 # generate CodeGear header with new arguments |
253 | 386 print $fd "__code $codeGearName($newArgs)$tail\n"; |
260
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
387 if ($outputVar{$codeGearName} ne "") { |
324 | 388 # output data var can be use before write |
389 # it should be initialze by gearef | |
260
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
390 print $fd $outputVar{$codeGearName}; |
6b5444bbea8a
generated stub no comiple errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
259
diff
changeset
|
391 } |
250 | 392 next; |
384
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
393 } elsif (/^(.*)goto (\w+)\-\>(\w+)\((.*)\);/) { |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
394 # handling goto statement |
384
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
395 # convert it to the meta call form with two arugments, that is context and enum Code |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
396 my $prev = $1; |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
397 my $next = $2; |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
398 my $method = $3; |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
399 my @args = split(/,/,$4); |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
400 my @types = @{$dataGearVarType{$codeGearName}}; |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
401 my $ntype; |
415 | 402 my $ftype; |
384
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
403 for my $v (@{$dataGearVar{$codeGearName}}) { |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
404 my $t = shift @types; |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
405 if ($v eq $next) { |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
406 $ntype = $t; |
415 | 407 $ftype = lcfirst($ntype); |
384
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
408 } |
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
409 } |
444
0c024ea61601
Using cas interface but occurred warning
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
442
diff
changeset
|
410 if (!defined $ntype) { |
0c024ea61601
Using cas interface but occurred warning
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
442
diff
changeset
|
411 $ntype = $localVarType{$next}; |
0c024ea61601
Using cas interface but occurred warning
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
442
diff
changeset
|
412 $ftype = lcfirst($ntype); |
0c024ea61601
Using cas interface but occurred warning
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
442
diff
changeset
|
413 } |
442
481fce540daf
Fix goto implement method of generate_stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
424
diff
changeset
|
414 print $fd "\tGearef(context, $ntype)->$ftype = (union Data*) $next;\n"; |
415 | 415 # Put interface argument |
384
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
416 my $prot = $code{$ntype}->{$method}; |
385 | 417 my $i = 1; |
384
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
418 for my $arg (@args) { |
415 | 419 my $pType; |
420 my $pName; | |
385 | 421 my $p = @$prot[$i]; |
457
2b36a1878c6f
Refactor TaskManagerImpl
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
447
diff
changeset
|
422 next if ($p eq $arg); |
387 | 423 $p =~ s/^(.*)\s(\w+)//; |
415 | 424 $pType = $1; |
425 $pName = $2; | |
387 | 426 $arg =~ s/^(\s)*(\w+)/$2/; |
427 if ($pType =~ s/\_\_code$//) { | |
444
0c024ea61601
Using cas interface but occurred warning
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
442
diff
changeset
|
428 if ($arg =~ /(\w+)\(.*\)/) { |
0c024ea61601
Using cas interface but occurred warning
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
442
diff
changeset
|
429 print $fd "\tGearef(context, $ntype)->$pName = $1;\n"; |
0c024ea61601
Using cas interface but occurred warning
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
442
diff
changeset
|
430 } else { |
0c024ea61601
Using cas interface but occurred warning
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
442
diff
changeset
|
431 print $fd "\tGearef(context, $ntype)->$pName = C_$arg;\n"; |
0c024ea61601
Using cas interface but occurred warning
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
442
diff
changeset
|
432 } |
466
831b7f6fd687
Fix warning pointer type
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
433 } elsif ($pType =~ /Data\**$/){ |
831b7f6fd687
Fix warning pointer type
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
434 print $fd "\tGearef(context, $ntype)->$pName = (union $pType) $arg;\n"; |
387 | 435 } else { |
436 print $fd "\tGearef(context, $ntype)->$pName = $arg;\n"; | |
437 } | |
385 | 438 $i++; |
384
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
439 } |
442
481fce540daf
Fix goto implement method of generate_stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
424
diff
changeset
|
440 print $fd "${prev}goto meta(context, $next->$method);\n"; |
384
ee5d2b1685d7
Fix perlscript
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
383
diff
changeset
|
441 next; |
396
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
442 } elsif(/^(.*)par goto (\w+)\((.*)\);/) { |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
443 # handling par goto statement |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
444 # convert it to the parallel |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
445 my $prev = $1; |
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
446 my $codeGearName = $2; |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
447 my $args = $3; |
401
408b4aab7610
Supported par goto iterate statement for perl script
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
400
diff
changeset
|
448 my $inputCount = $codeGear{$codeGearName}->{'input'}; |
408b4aab7610
Supported par goto iterate statement for perl script
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
400
diff
changeset
|
449 my $outputCount = $codeGear{$codeGearName}->{'output'}; |
403
83c9aeb1fe3e
Generate MultiDimIterator by perl script
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
402
diff
changeset
|
450 my @iterateCounts; |
401
408b4aab7610
Supported par goto iterate statement for perl script
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
400
diff
changeset
|
451 # parse examples 'par goto(.., iterate(10), exit);' |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
452 if ($args =~ /iterate\((.*)?\),/) { |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
453 @iterateCounts = split(/,/,$1);; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
454 $inputCount--; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
455 } |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
456 # replace iterate keyword |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
457 $args =~ s/iterate\((.*)?\),//; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
458 my @dataGears = split(/,\s*/, $args); |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
459 my $nextCodeGear = pop(@dataGears); |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
460 if (! $inParGoto) { |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
461 $inParGoto = 1; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
462 print $fd "${prev}struct Element* element;\n"; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
463 } |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
464 my $initTask = << "EOFEOF"; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
465 ${prev}context->task = NEW(struct Context); |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
466 ${prev}initContext(context->task); |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
467 ${prev}context->task->next = C_$codeGearName; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
468 ${prev}context->task->idgCount = $inputCount; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
469 ${prev}context->task->idg = context->task->dataNum; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
470 ${prev}context->task->maxIdg = context->task->idg + $inputCount; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
471 ${prev}context->task->odg = context->task->maxIdg; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
472 ${prev}context->task->maxOdg = context->task->odg + $outputCount; |
396
bba401f93dcd
Add handle par goto statement
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
393
diff
changeset
|
473 EOFEOF |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
474 print $fd $initTask; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
475 if (@iterateCounts) { |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
476 print $fd "${prev}context->task->iterate = 0;\n"; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
477 my $len = @iterateCounts; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
478 if ($len == 1) { |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
479 print $fd "${prev}context->task->iterator = createMultiDimIterator(context, $iterateCounts[0], 1, 1);\n"; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
480 } elsif ($len == 2) { |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
481 print $fd "${prev}context->task->iterator = createMultiDimIterator(context, $iterateCounts[0], $iterateCounts[1], 1);\n"; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
482 } elsif ($len == 3) { |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
483 print $fd "${prev}context->task->iterator = createMultiDimIterator(context, $iterateCounts[0], $iterateCounts[1], $iterateCounts[2]);\n"; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
484 } |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
485 } |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
486 for my $dataGear (@dataGears) { |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
487 print $fd "${prev}GET_META($dataGear)->wait = createSynchronizedQueue(context);\n"; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
488 } |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
489 for my $i (0..$inputCount-1) { |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
490 print $fd "${prev}context->task->data[context->task->idg+$i] = (union Data*)@dataGears[$i];\n"; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
491 } |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
492 for my $i (0..$outputCount-1) { |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
493 print $fd "${prev}context->task->data[context->task->odg+$i] = (union Data*)@dataGears[$inputCount+$i];\n"; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
494 } |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
495 my $putTask = << "EOFEOF"; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
496 ${prev}element = &ALLOCATE(context, Element)->Element; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
497 ${prev}element->data = (union Data*)context->task; |
482
5859bed4edff
Refactoring spawnTasks method
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
498 ${prev}element->next = context->taskList; |
5859bed4edff
Refactoring spawnTasks method
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
499 ${prev}context->taskList = element; |
398
fc4fcd441700
Fix spanwTasks
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
397
diff
changeset
|
500 EOFEOF |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
501 print $fd $putTask; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
502 next; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
503 } elsif (/^(.*)goto (\w+)\((.*)\);/) { |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
504 # handling goto statement |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
505 # convert it to the meta call form with two arugments, that is context and enum Code |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
506 my $prev = $1; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
507 my $next = $2; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
508 my @args = split(/, /,$3); |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
509 my $v = 0; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
510 for my $n ( @{$dataGearVar{$codeGearName}} ) { |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
511 # continuation arguments |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
512 $v = 1 if ( $n eq $next); |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
513 } |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
514 if ($v || defined $code{$interface}->{$next}) { |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
515 # write continuation's arguments into the interface arguments |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
516 # we may need a commit for a shared DataGear |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
517 for my $arg ( @{$outputArgs{$codeGearName}->{$next}} ) { |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
518 my $v = shift(@args); |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
519 print $fd "\t*O_$arg = $v;\n"; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
520 } |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
521 if ($inParGoto) { |
482
5859bed4edff
Refactoring spawnTasks method
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
522 print $fd "${prev}Gearef(context, TaskManager)->taskList = context->taskList;\n"; |
467
4ec61e201c19
Fix segmentation fault for calc.cbc
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
466
diff
changeset
|
523 print $fd "${prev}Gearef(context, TaskManager)->next1 = C_$next;\n"; |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
524 print $fd "${prev}goto meta(context, C_$next);\n"; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
525 } else { |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
526 print $fd "${prev}goto meta(context, $next);\n"; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
527 } |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
528 next; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
529 } |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
530 if ($inParGoto) { |
482
5859bed4edff
Refactoring spawnTasks method
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
531 print $fd "${prev}Gearef(context, TaskManager)->taskList = context->taskList;\n"; |
467
4ec61e201c19
Fix segmentation fault for calc.cbc
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
466
diff
changeset
|
532 print $fd "${prev}Gearef(context, TaskManager)->next1 = C_$next;\n"; |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
533 print $fd "${prev}goto meta(context, C_$next);\n"; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
534 next; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
535 } elsif ($next eq "meta") { |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
536 print $fd $_; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
537 next; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
538 } else { |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
539 print $fd "${prev}goto meta(context, C_$next);\n"; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
540 next; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
541 } |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
542 } elsif(/^.*(struct|union)?\s(\w+)\*\s(\w+)\s?[=;]/) { |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
543 my $type = $2; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
544 my $varName = $3; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
545 $localVarType{$varName} = $type; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
546 s/new\s+(\w+)\(\)/\&ALLOCATE(context, \1)->\1/g; # replacing new |
462
8d7e5d48cad3
Running CPU examples
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
461
diff
changeset
|
547 } elsif(/^}/) { |
461
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
548 $inParGoto = 0; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
549 } else { |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
550 s/new\s+(\w+)\(\)/\&ALLOCATE(context, \1)->\1/g; # replacing new |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
551 } |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
552 # gather type name and type |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
553 } elsif ($inMain) { |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
554 if (/^(.*)goto start_code\(main_context\);/) { |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
555 print $fd $_; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
556 next; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
557 } elsif (/^(.*)goto (\w+)\((.*)\);/) { |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
558 my $prev = $1; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
559 my $next = $2; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
560 print $fd "${prev}struct Context* main_context = NEW(struct Context);\n"; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
561 print $fd "${prev}initContext(main_context);\n"; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
562 print $fd "${prev}main_context->next = C_$next;\n"; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
563 print $fd "${prev}goto start_code(main_context);\n"; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
564 next; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
565 } |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
566 } |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
567 if (/^}/) { |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
568 $inStub = 0; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
569 $inTypedef = 0; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
570 $inMain = 0; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
571 } |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
572 print $fd $_; |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
573 } |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
574 if (defined $prevCodeGearName) { |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
575 if (!defined $stub{$prevCodeGearName."_stub"}) { |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
576 $stub{$prevCodeGearName."_stub"} = &generateStub($fd,$prevCodeGearName,$dataGearName{$codeGearName}); |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
577 } |
6b71cf5b1c22
Change Interface files from cbc to header
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
578 } |
194 | 579 } |
580 | |
581 # end |