changeset 578:d6718b5ad312

add gen context.h at generate_context.pl
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Wed, 27 Nov 2019 12:30:09 +0900
parents f78ad1f89524
children fe8c04001929
files src/parallel_execution/CMakeLists.txt src/parallel_execution/generate_context.pl src/parallel_execution/lib/Gears/Context.pm
diffstat 3 files changed, 54 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/parallel_execution/CMakeLists.txt	Mon Nov 25 19:37:17 2019 +0900
+++ b/src/parallel_execution/CMakeLists.txt	Wed Nov 27 12:30:09 2019 +0900
@@ -53,7 +53,7 @@
     add_custom_command (
           OUTPUT    c/${_Gears_TARGET}-context.c
           DEPENDS   ${_Gears_CSOURCES}
-          COMMAND  "perl" "generate_context.pl" "-o" ${_Gears_TARGET} ${_Gears_CSOURCES}
+          COMMAND  "perl" "generate_context.pl" "-o" ${_Gears_TARGET} "-w" ${_Gears_CSOURCES}
     )
     add_executable(${_Gears_TARGET} ${_Gears_CSOURCES} c/${_Gears_TARGET}-context.c)
     target_link_libraries(${_Gears_TARGET} m pthread)
--- a/src/parallel_execution/generate_context.pl	Mon Nov 25 19:37:17 2019 +0900
+++ b/src/parallel_execution/generate_context.pl	Wed Nov 27 12:30:09 2019 +0900
@@ -43,8 +43,8 @@
 
 my $ddir = "c";
 
-our($opt_o,$opt_d,$opt_h);
-getopts('o:d:h');
+our($opt_o,$opt_d,$opt_h,$opt_w);
+getopts('o:d:hw');
 
 my $name = $opt_o?$opt_o:"gears";
 
@@ -65,6 +65,29 @@
 my %dataGear;
 my %constructor;
 
+{
+  use FindBin;
+  use lib "$FindBin::Bin/lib";
+
+  use File::Spec;
+
+  use Gears::Context;
+  use Getopt::Std;
+
+  my $output     = $opt_w ? "$FindBin::Bin/context.h" : "stdout";
+
+  my @cbc_files;
+  map { push(@cbc_files,File::Spec->rel2abs($_)); }  @ARGV;
+  my $gears      = Gears::Context->new(compile_sources => \@cbc_files, find_root => $FindBin::Bin, output => $output);
+  my $data_gears = $gears->extraction_dg_compile_sources();
+  my $g          = $gears->set_data_gear_header_path();
+
+  my $dg2path    = $gears->update_dg_each_header_path($data_gears,$g);
+
+  my $tree = $gears->createImplTree_from_header($dg2path);
+  $gears->tree2create_context_h($tree);
+}
+
 # gather module Information for code table initialization
 for (@ARGV) {
     next if (/context.c/);
--- a/src/parallel_execution/lib/Gears/Context.pm	Mon Nov 25 19:37:17 2019 +0900
+++ b/src/parallel_execution/lib/Gears/Context.pm	Wed Nov 27 12:30:09 2019 +0900
@@ -36,6 +36,34 @@
           next;
        }
 
+       if ($line =~ /^(\w+)(\*)+  *create(\w+)\(([^]]*)\)/) {
+          my $interface = $1;
+          my $implementation = $3;
+          $self->{data_gears_with_count}->{$interface}->{caller}->{$cbc_file}++;
+          $self->{data_gears_with_count}->{$implementation}->{caller}->{$cbc_file}++;
+          $counter{interfaces}->{$interface}++;
+          $counter{impl}->{$implementation}++;
+          next;
+       }
+
+       if ($line =~ /Gearef\(context,\s*(\w+)\)/) {
+          my $implementation = $1;
+          $counter{impl}->{$implementation}++;
+          $self->{data_gears_with_count}->{$implementation}->{caller}->{$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;
+          $self->{data_gears_with_count}->{$interface}->{caller}->{$cbc_file}++;
+          $counter{interfaces}->{$interface}++;
+          $counter{impl}->{$implementation}++;
+          next;
+       }
+
        if ($line =~ /__code/) {
          while ($line =~ /struct (\w+)*/g) {
            next if $1 eq "Context";