annotate src/gearsTools/trans_impl.pl @ 122:f6558602f31e

tweak
author anatofuz
date Mon, 02 Dec 2019 19:21:20 +0900
parents b9df8ea87b42
children 004e825f37c7 53be0626c3fa
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
102
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #!/usr/bin/env perl
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 use strict;
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 use warnings;
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 use FindBin;
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 use lib "$FindBin::Bin/lib";
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 use Gears::Util;
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8
122
anatofuz
parents: 112
diff changeset
9 use File::Spec;
102
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 use Getopt::Std;
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 my %opt;
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 getopts("w" => \%opt);
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 my $impl_file = shift or die 'require impl file';
122
anatofuz
parents: 112
diff changeset
16
anatofuz
parents: 112
diff changeset
17 use Data::Dumper;
anatofuz
parents: 112
diff changeset
18 my $impl_ir = Gears::Util->parse_with_rewrite(File::Spec->rel2abs($impl_file));
112
b9df8ea87b42 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
19 my $interface_file = Gears::Util->find_header($impl_ir->{isa},"$FindBin::Bin/..");
102
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20
112
b9df8ea87b42 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
21 my $inter_ir = Gears::Util->parse_with_rewrite($interface_file);
102
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 my $output_file = $impl_file;
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 $output_file =~ s/\.h/.cbc/;
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 open my $fh, '>', $output_file;
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 my $stdout = $fh;
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 unless ($opt{w}) {
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 $stdout = *STDOUT;
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 }
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 emit_include_part($stdout, $inter_ir->{name});
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 emit_impl_header_in_comment($stdout, $impl_file);
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 emit_constracutor($stdout,$impl_ir,$inter_ir);
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 emit_code_gears($stdout,$impl_ir,$inter_ir);
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 close $fh;
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 sub emit_include_part {
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 my ($out, $interface) = @_;
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 print $out <<"EOF"
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 #include "../context.h";
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 #interface "$interface.h";
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
44
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 EOF
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 }
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 sub emit_impl_header_in_comment {
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 my ($out, $impl_file) = @_;
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 my $line = Gears::Util->slup($impl_file);
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 print $out "// ----\n";
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 map { print $out "// $_\n" } split /\n/, $line;
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 print $out "// ----\n\n";
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 }
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
55
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 sub emit_constracutor {
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 my ($out, $impl_ir, $inter_ir) = @_;
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58
112
b9df8ea87b42 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
59 my @inter_data = @{$inter_ir->{data}};
b9df8ea87b42 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
60 my @impl_data = @{$impl_ir->{data}};
102
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 my $instance_inter = shift @inter_data;
112
b9df8ea87b42 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
62
102
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 if ($instance_inter =~ /union\s*Data\*\s*(\w+)/) {
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 $instance_inter = $1;
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 }
112
b9df8ea87b42 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
66
b9df8ea87b42 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
67 my $instance_impl = lcfirst $impl_ir->{name};
b9df8ea87b42 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
68 $instance_impl =~ s/([A-Z])/_\l$1/g;
102
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
69
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 print $out <<"EOF";
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 $impl_ir->{isa}* create$impl_ir->{name}(struct Context* cbc_context) {
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 struct $impl_ir->{isa}* $instance_inter = new $impl_ir->{isa}();
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 struct $impl_ir->{name}* $instance_impl = new $impl_ir->{name}();
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 $instance_inter->$instance_inter = (union Data*)$instance_impl;
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 EOF
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
76
109
4f9d95dc4efd fix createInstance
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 105
diff changeset
77 for my $datum (@impl_data) {
102
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 if ($datum =~ /\w+ \w+\* (\w+)/) {
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 print $out " ${instance_impl}->$1 = NULL;\n";
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 next;
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 }
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 if ($datum =~ /\w+ \w+ (\w+)/) {
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 print $out " ${instance_impl}->$1 = 0;\n";
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 }
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 }
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
86
109
4f9d95dc4efd fix createInstance
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 105
diff changeset
87 for my $datum (@inter_data) {
4f9d95dc4efd fix createInstance
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 105
diff changeset
88 if ($datum =~ /\w+ \w+\* (\w+)/) {
4f9d95dc4efd fix createInstance
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 105
diff changeset
89 print $out " ${instance_inter}->$1 = NULL;\n";
4f9d95dc4efd fix createInstance
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 105
diff changeset
90 next;
4f9d95dc4efd fix createInstance
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 105
diff changeset
91 }
4f9d95dc4efd fix createInstance
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 105
diff changeset
92 if ($datum =~ /\w+ \w+ (\w+)/) {
4f9d95dc4efd fix createInstance
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 105
diff changeset
93 print $out " ${instance_inter}->$1 = 0;\n";
4f9d95dc4efd fix createInstance
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 105
diff changeset
94 }
4f9d95dc4efd fix createInstance
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 105
diff changeset
95 }
4f9d95dc4efd fix createInstance
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 105
diff changeset
96
102
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 for my $code (@{$inter_ir->{codes}}) {
112
b9df8ea87b42 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
98 my $code_gear = $code->{name};
102
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 print $out " ${instance_inter}->$code_gear = C_$code_gear$impl_ir->{name};\n"
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 }
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
101
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 print $out " return $instance_inter;\n";
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 print $out "}\n";
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
104 }
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
105
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
106
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 sub emit_code_gears {
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
108 my ($out, $impl_ir, $inter_ir) = @_;
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
109 my $impl = $impl_ir->{name};
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
110
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
111 my @inter_data = @{$inter_ir->{data}};
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
112 my $instance_inter = shift @inter_data;
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
113 if ($instance_inter =~ /union\s*Data\*\s*(\w+)/) {
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
114 $instance_inter = $1;
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
115 }
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
116 my $instance_impl = lcfirst $impl_ir->{name};
105
f1be2d5abc8a fix camel2snake
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 104
diff changeset
117 $instance_impl =~ s/([A-Z])/_\l$1/g;
102
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
118 my $data_gear_types = {};
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
119
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
120 for my $code_ir (@{$inter_ir->{codes}}) {
112
b9df8ea87b42 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
121 my $data_gears = $code_ir->{args};
b9df8ea87b42 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
122 $data_gears =~ s/Impl/struct $impl/g;
103
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
123 while ($data_gears =~ /Type\*\s*(\w+),/g) {
102
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
124 my $target = $1;
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
125 if (exists $data_gear_types->{$target}){
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
126 $data_gears =~ s/Type\*/$data_gear_types->{$target}/;
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
127 } else {
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
128 my $td = "";
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
129 map { $td = $_ if ($_ =~ /$target/) } @inter_data;
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
130 if ($td =~ /(\w+)\s*([\w\*]+)\s*(\w+)/) {
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
131 my $tmp = "$1 $2";
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
132 $data_gears =~ s/Type\*/$tmp/;
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
133 $data_gear_types->{$target} = $tmp;
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
134 }
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
135 }
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
136 }
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
137
112
b9df8ea87b42 fix trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 109
diff changeset
138 print $out "__code $code_ir->{name}$impl(";
102
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
139 print $out "$data_gears) {\n\n";
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
140
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
141 #__code next(...), __code whenEmpty(...)
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
142 my @cg = ();
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
143 while ($data_gears =~ /__code ([\w(\.)\*\s,]+?\)),?/g) {
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 push(@cg, $1);
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
145 }
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
146
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
147 if (@cg) {
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
148 if (@cg == 2) {
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
149 print $out " if (:TODO:) {\n";
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
150 print $out " goto ",shift(@cg),";\n";
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 print $out " }\n";
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
152 print $out " goto ",shift(@cg),";\n";
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
153 } else {
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
154 print $out " goto ",shift(@cg),";\n";
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
155 }
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
156 }
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
157 print $out "}\n\n";
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
158 }
b84aac4ab529 import trans_impl.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
159 }