Mercurial > hg > Gears > Gears
changeset 692:3d959f470c8b
move a method Util to Context
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 21 Aug 2020 15:57:24 +0900 |
parents | 98b9636e279e |
children | aeab4866ee36 |
files | src/parallel_execution/lib/Gears/Context.pm src/parallel_execution/lib/Gears/Util.pm |
diffstat | 2 files changed, 117 insertions(+), 121 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parallel_execution/lib/Gears/Context.pm Fri Aug 21 15:44:14 2020 +0900 +++ b/src/parallel_execution/lib/Gears/Context.pm Fri Aug 21 15:57:24 2020 +0900 @@ -30,9 +30,125 @@ sub extraction_dg_compile_sources { my ($self, $compile_sources) = @_; - return Gears::Util->extraction_dg_compile_sources($compile_sources); + my %counter; + my %include_pool = (); + for my $cbc_file (@{$compile_sources}) { + open my $fh , '<', $cbc_file; + while (my $line = <$fh>) { + if ($line =~ m|//\s*:skip|) { + next; + } + + if ($line =~ /#interface\s*"(.*)\.h"/) { + push(@{$counter{interfaces}->{$1}->{$cbc_file}},$.); + next; + } + + if ($line =~ /^\/\/\s*include\s*"(.*)\.(?:h|dg)?"/) { + push(@{$include_pool{$1}->{$cbc_file}},$.); + next; + } + + if ($line =~ m|//\s*Skip:\s*generate_context|) { + $line = <$fh>; + next; + } + + + if ($line =~ /^(\w+)\*\s*create(\w+)\(([*\w\s]+)\)/) { + my $interface = $1; + my $implementation = $2; + my $arg = $3; + if ($arg eq "") { + next; + } + push(@{$counter{interfaces}->{$interface}->{$cbc_file}},$.); + push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.); + next; + } + + if ($line =~ /Gearef\(context,\s*(\w+)\)/) { + my $implementation = $1; + push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.); + next; + } + + # ALLOCATE is generated by generate_stub.pl + # because extraction_dg_compile_sources caller after translated .cbc to .c + #Element* element = &ALLOCATE(cbc_context, Element)->Element; + if ($line =~ /ALLOCATE\w*\((?:cbc_)?context,\s*(\w+)\)/) { + my $implementation = $1; + push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.); + next; + } + + if ($line =~ /ALLOCATE_(?:PTR_)?ARRAY\((?:cbc_)?context,\s*(\w+),[\s\w]+\)/) { + my $implementation = $1; + push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.); + next; + } + + if ($line =~ /new\s+(\w+?)\([\w\s]*\);/) { + my $implementation = $1; + push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.); + next; + } + + if ($line =~ /ALLOCATE_DATA_GEAR\((\w+),\s*(\w+)\)/) { + my $implementation = $2; + push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.); + next; + } + + #TaskManagerImpl* taskManager = (TaskManagerImpl*)GearImpl(context, TaskManager, taskManager); + if ($line =~ /\((\w+)\*\)GearImpl\(context,\s*(\w+),\s*(\w+)\)/) { + my $interface = $2; + my $implementation = $1; + push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.); + push(@{$counter{interfaces}->{$interface}->{$cbc_file}},$.); + next; + } + + if ($line =~ /^__code/) { + while ($line =~ /struct (\w+)\s*\*/g) { + next if $1 eq "Context"; + next if (exists $counter{interfaces}->{$1}); + push(@{$counter{impl}->{$1}->{$cbc_file}},$.); + } + } + } + close $fh; + } + use Data::Dumper; + + for my $cg_name (keys %include_pool) { + my @tmp_cbc_file_names = keys %{$include_pool{$cg_name}}; + my $tmp_cbc_file_name = shift @tmp_cbc_file_names; + if (exists $counter{interfaces}->{$cg_name}){ + push(@{$counter{interfaces}->{$cg_name}->{$tmp_cbc_file_name}},$include_pool{$cg_name}->{$tmp_cbc_file_name}); + delete $include_pool{$cg_name}; + next; + } + + if (exists $counter{impl}->{$cg_name}){ + push(@{$counter{impl}->{$cg_name}->{$tmp_cbc_file_name}},$include_pool{$cg_name}->{$tmp_cbc_file_name}); + delete $include_pool{$cg_name}; + next; + } + push(@{$counter{interfaces}->{$cg_name}->{$tmp_cbc_file_name}},$include_pool{$cg_name}->{$tmp_cbc_file_name}); + delete $include_pool{$cg_name}; + } + + $counter{interfaces}->{Meta}++; + $counter{interfaces}->{TaskManager}++; + #print "-----------\n"; + #print Dumper \%counter; #this line is debug message + #print "-----------\n"; + return \%counter; } + + sub _docking_header_name_to_path { my ($root_path, $data_gears_name) = @_; my %res;
--- a/src/parallel_execution/lib/Gears/Util.pm Fri Aug 21 15:44:14 2020 +0900 +++ b/src/parallel_execution/lib/Gears/Util.pm Fri Aug 21 15:57:24 2020 +0900 @@ -146,124 +146,4 @@ return \@files; } -sub extraction_dg_compile_sources { - my ($class, $compile_sources) = @_; - my %counter; - my %include_pool = (); - for my $cbc_file (@{$compile_sources}) { - open my $fh , '<', $cbc_file; - while (my $line = <$fh>) { - if ($line =~ m|//\s*:skip|) { - next; - } - - if ($line =~ /#interface\s*"(.*)\.h"/) { - push(@{$counter{interfaces}->{$1}->{$cbc_file}},$.); - next; - } - - if ($line =~ /^\/\/\s*include\s*"(.*)\.(?:h|dg)?"/) { - push(@{$include_pool{$1}->{$cbc_file}},$.); - next; - } - - if ($line =~ m|//\s*Skip:\s*generate_context|) { - $line = <$fh>; - next; - } - - - if ($line =~ /^(\w+)\*\s*create(\w+)\(([*\w\s]+)\)/) { - my $interface = $1; - my $implementation = $2; - my $arg = $3; - if ($arg eq "") { - next; - } - push(@{$counter{interfaces}->{$interface}->{$cbc_file}},$.); - push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.); - next; - } - - if ($line =~ /Gearef\(context,\s*(\w+)\)/) { - my $implementation = $1; - push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.); - next; - } - - # ALLOCATE is generated by generate_stub.pl - # because extraction_dg_compile_sources caller after translated .cbc to .c - #Element* element = &ALLOCATE(cbc_context, Element)->Element; - if ($line =~ /ALLOCATE\w*\((?:cbc_)?context,\s*(\w+)\)/) { - my $implementation = $1; - push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.); - next; - } - - if ($line =~ /ALLOCATE_(?:PTR_)?ARRAY\((?:cbc_)?context,\s*(\w+),[\s\w]+\)/) { - my $implementation = $1; - push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.); - next; - } - - if ($line =~ /new\s+(\w+?)\([\w\s]*\);/) { - my $implementation = $1; - push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.); - next; - } - - if ($line =~ /ALLOCATE_DATA_GEAR\((\w+),\s*(\w+)\)/) { - my $implementation = $2; - push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.); - next; - } - - #TaskManagerImpl* taskManager = (TaskManagerImpl*)GearImpl(context, TaskManager, taskManager); - if ($line =~ /\((\w+)\*\)GearImpl\(context,\s*(\w+),\s*(\w+)\)/) { - my $interface = $2; - my $implementation = $1; - push(@{$counter{impl}->{$implementation}->{$cbc_file}},$.); - push(@{$counter{interfaces}->{$interface}->{$cbc_file}},$.); - next; - } - - if ($line =~ /^__code/) { - while ($line =~ /struct (\w+)\s*\*/g) { - next if $1 eq "Context"; - next if (exists $counter{interfaces}->{$1}); - push(@{$counter{impl}->{$1}->{$cbc_file}},$.); - } - } - } - close $fh; - } - use Data::Dumper; - - for my $cg_name (keys %include_pool) { - my @tmp_cbc_file_names = keys %{$include_pool{$cg_name}}; - my $tmp_cbc_file_name = shift @tmp_cbc_file_names; - if (exists $counter{interfaces}->{$cg_name}){ - push(@{$counter{interfaces}->{$cg_name}->{$tmp_cbc_file_name}},$include_pool{$cg_name}->{$tmp_cbc_file_name}); - delete $include_pool{$cg_name}; - next; - } - - if (exists $counter{impl}->{$cg_name}){ - push(@{$counter{impl}->{$cg_name}->{$tmp_cbc_file_name}},$include_pool{$cg_name}->{$tmp_cbc_file_name}); - delete $include_pool{$cg_name}; - next; - } - push(@{$counter{interfaces}->{$cg_name}->{$tmp_cbc_file_name}},$include_pool{$cg_name}->{$tmp_cbc_file_name}); - delete $include_pool{$cg_name}; - } - - $counter{interfaces}->{Meta}++; - $counter{interfaces}->{TaskManager}++; - #print "-----------\n"; - #print Dumper \%counter; #this line is debug message - #print "-----------\n"; - return \%counter; -} - - 1;