# HG changeset patch # User anatofuz # Date 1574825409 -32400 # Node ID d6718b5ad312348b48fabd69f3aec50a363f9476 # Parent f78ad1f8952453b3747a16ada3f2c2343fcd1a7b add gen context.h at generate_context.pl diff -r f78ad1f89524 -r d6718b5ad312 src/parallel_execution/CMakeLists.txt --- 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) diff -r f78ad1f89524 -r d6718b5ad312 src/parallel_execution/generate_context.pl --- 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/); diff -r f78ad1f89524 -r d6718b5ad312 src/parallel_execution/lib/Gears/Context.pm --- 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";