Mercurial > hg > CbC > CbC_xv6
changeset 250:9e8441699711
remove_dead_code
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 04 Feb 2020 13:28:20 +0900 |
parents | 42a37a8a02c9 |
children | cabe731b1c88 |
files | src/gearsTools/trans_impl.pl |
diffstat | 1 files changed, 21 insertions(+), 61 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gearsTools/trans_impl.pl Tue Feb 04 12:30:09 2020 +0900 +++ b/src/gearsTools/trans_impl.pl Tue Feb 04 13:28:20 2020 +0900 @@ -99,32 +99,6 @@ } } - #for my $datum (@inter_data) { - # # remove macro, comment block - # $datum =~ s|//[\s\w]+||; - # if ($datum =~ /^\s+#/) { - # next; - # } - - # if ($datum =~ /\w+\s\w+\*\s(\w+)/) { - # print $out " ${instance_inter}->$1 = NULL;\n"; - # next; - # } - # if ($datum =~ /\w+\s\w+\s(\w+)/) { - # print $out " ${instance_inter}->$1 = 0;\n"; - # next; - # } - # if ($datum =~ /\w+(\*)?\s(\w+)/) { - # my $is_pointer = $1; - # my $var_name = $2; - # if ($1) { - # print $out " ${instance_inter}->$var_name = NULL;\n"; - # } else { - # print $out " ${instance_inter}->$var_name = 0;\n"; - # } - # } - #} - for my $code (@{$impl_ir->{codes}}) { my $code_gear = $code->{name}; @@ -167,24 +141,8 @@ } print $out "__code $cg->{name}$impl("; print $out "$data_gears) {\n\n"; - - #__code next(...), __code whenEmpty(...) - my @cg = (); - while ($data_gears =~ /__code ([\w(\.)\*\s,]+?\)),?/g) { - push(@cg, $1); - } + _emit_cg($out,$data_gears); - if (@cg) { - if (@cg == 2) { - print $out " if (:TODO:) {\n"; - print $out " goto ",shift(@cg),";\n"; - print $out " }\n"; - print $out " goto ",shift(@cg),";\n"; - } else { - print $out " goto ",shift(@cg),";\n"; - } - } - print $out "}\n\n"; } } @@ -198,23 +156,25 @@ print $out "__code $code_ir->{name}$impl("; print $out "$data_gears) {\n\n"; - - #__code next(...), __code whenEmpty(...) - my @cg = (); - while ($data_gears =~ /__code ([\w(\.)\*\s,]+?\)),?/g) { - push(@cg, $1); - } - - if (@cg) { - if (@cg == 2) { - print $out " if (:TODO:) {\n"; - print $out " goto ",shift(@cg),";\n"; - print $out " }\n"; - print $out " goto ",shift(@cg),";\n"; - } else { - print $out " goto ",shift(@cg),";\n"; - } - } - print $out "}\n\n"; + _emit_cg($out,$data_gears); } } + +sub _emit_cg { + my ($out, $data_gears) = @_; + my @cg = (); + while ($data_gears =~ /__code ([\w(\.)\*\s,]+?\)),?/g) { + push(@cg, $1); + } + if (@cg) { + if (@cg == 2) { + print $out " if (:TODO:) {\n"; + print $out " goto ",shift(@cg),";\n"; + print $out " }\n"; + print $out " goto ",shift(@cg),";\n"; + } else { + print $out " goto ",shift(@cg),";\n"; + } + } + print $out "}\n\n"; +}