# HG changeset patch # User anatofuz # Date 1612366659 -32400 # Node ID 604b0fd7f537d099a46a2a14e7068537289edc59 # Parent 78966e75194f84bee5836304822ece2f9860137f generics diff -r 78966e75194f -r 604b0fd7f537 src/parallel_execution/examples/DPP/main.cbc --- a/src/parallel_execution/examples/DPP/main.cbc Wed Feb 03 23:14:48 2021 +0900 +++ b/src/parallel_execution/examples/DPP/main.cbc Thu Feb 04 00:37:39 2021 +0900 @@ -40,11 +40,11 @@ __code createTask1(struct LoopCounter* loopCounter, struct TaskManager* taskManager) { - AtomicT* fork0 = createAtomicTImpl(contex,-1); // model checking : fork0 - AtomicT* fork1 = createAtomicTImpl(contex,-1); // model checking : fork1 - AtomicT* fork2 = createAtomicTImpl(contex,-1); // model checking : fork2 - AtomicT* fork3 = createAtomicTImpl(contex,-1); // model checking : fork3 - AtomicT* fork4 = createAtomicTImpl(contex,-1); // model checking : fork4 + AtomicT* fork0 = createAtomicTImpl(contex,-1); // model checking : fork0 + AtomicT* fork1 = createAtomicTImpl(contex,-1); // model checking : fork1 + AtomicT* fork2 = createAtomicTImpl(contex,-1); // model checking : fork2 + AtomicT* fork3 = createAtomicTImpl(contex,-1); // model checking : fork3 + AtomicT* fork4 = createAtomicTImpl(contex,-1); // model checking : fork4 Phils* phils0 = createPhilsImpl(context,0,fork0,fork1); // model checking : phils0 Phils* phils1 = createPhilsImpl(context,1,fork1,fork2); // model checking : phils1 diff -r 78966e75194f -r 604b0fd7f537 src/parallel_execution/generate_context.pl --- a/src/parallel_execution/generate_context.pl Wed Feb 03 23:14:48 2021 +0900 +++ b/src/parallel_execution/generate_context.pl Thu Feb 04 00:37:39 2021 +0900 @@ -530,7 +530,7 @@ my @types = keys %{{ map { $_->{in_type_name} => 1 } @{$file_each_instances->{$file}} }}; - my @impls = keys %{{ map { $_->{impl} => 1 } @{$file_each_instances->{$file}} }}; + my @impls = keys %{{ map { $_->{impl} => 1 } grep { exists $_->{impl} } @{$file_each_instances->{$file}} }}; if ( (scalar(@types) != 1) && (scalar(@types) != scalar(@impls))) { @@ -543,6 +543,7 @@ my @rep_types; for my $t ($type, $impl) { + next unless ($t); if (exists $typed_variables->{$t}) { push(@rep_types, grep { ($_ ne '_caller' ) && ( $_ ne '_interface' ) } keys %{$typed_variables->{$t}}); } @@ -561,40 +562,51 @@ $replaceType =~ s/$type/${type}_$defType/; my $repimpl = 0; - if (defined $typed_variables->{$impl}) { - $replaceImpls =~ s/$type/${type}_$defType/; - $targetImpl =~ s/$type/${type}_$defType/; - $replaceImpls =~ s/$/_$defType/; - $repimpl = 1; + if ($impl) { + if (defined $typed_variables->{$impl}) { + $replaceImpls =~ s/$type/${type}_$defType/; + $targetImpl =~ s/$type/${type}_$defType/; + $replaceImpls =~ s/$/_$defType/; + $repimpl = 1; + } } if ($file =~ /\.h$/) { print STDERR "[info] $file is header\n"; unless (grep { $_ eq $replaceType } map { $_->{before} } @{$modifyList->{header}->{$file}}) { push(@{$modifyList->{header}->{$file}}, { before => [$type], after => [$replaceType]}); + my $implName = $file_each_instances->{$file}->[0]->{impl}; + unless ($implName) { + print STDERR "[error] not implemented thsi case\n"; + } + push(@{$modifyList->{replace}->{$implName}}, { before => [$type], after => [$replaceType]}); } next; } - if ($impl eq $replaceImpls) { #not impl - push(@{$modifyList->{cbc}->{$file}},{before => [$type], after => [$replaceType]}); - } else { #impl - #push(@{$modifyList->{cbc}->{$file}},{before => [$type, $impl], after => [$replaceType, $replaceImpls]}); - push(@{$modifyList->{cbc}->{$file}}, - { - before => [$type], after => [$replaceType], - before_impl => [$impl], after_impl => [$replaceImpls] - } - ); + if ($impl) { + if ($impl eq $replaceImpls) { #not impl + push(@{$modifyList->{cbc}->{$file}},{before => [$type], after => [$replaceType]}); + } else { #impl + #push(@{$modifyList->{cbc}->{$file}},{before => [$type, $impl], after => [$replaceType, $replaceImpls]}); + push(@{$modifyList->{cbc}->{$file}}, + { + before => [$type], after => [$replaceType], + before_impl => [$impl], after_impl => [$replaceImpls] + } + ); + push(@{$modifyList->{replace}->{$type}}, { before => [$type], after => [$replaceType]}); + push(@{$modifyList->{replace}->{$impl}}, { before => [$impl], after => [$replaceImpls]}); + } } my @cbc_cont; open my $fh, '<', $file; while (my $line = <$fh> ){ - $line =~ s/$type(<.*>)?/$replaceType/g; + $line =~ s/$type(<.*?>)?/$replaceType/g; if ($repimpl) { - $line =~ s/${targetImpl}(<.*>)?/$replaceImpls/g; + $line =~ s/${targetImpl}(<.*?>)?/$replaceImpls/g; } $line =~ s/${type_v}([\s\*])/$defType$1/; push(@cbc_cont, $line); @@ -606,12 +618,12 @@ } } - #for my $type (keys %$typed_variables) { - # my @cfiles = grep { /\.c$/ } keys %{$typed_variables->{$type}->{_caller}}; - # for my $file (@cfiles) { - # p $type; - # } - # } + for my $type (keys %$typed_variables) { + my @cfiles = grep { /\.c$/ } keys %{$typed_variables->{$type}->{_caller}}; + for my $file (@cfiles) { + push(@{$modifyList->{replaceFiles}->{$file}}, $type); + } + } #for my $file (keys %$file2cont) { # open my $fh, '>', $file; @@ -620,6 +632,7 @@ # } # close $fh; #} + #p $modifyList; return $modifyList; } diff -r 78966e75194f -r 604b0fd7f537 src/parallel_execution/lib/Gears/Context.pm --- a/src/parallel_execution/lib/Gears/Context.pm Wed Feb 03 23:14:48 2021 +0900 +++ b/src/parallel_execution/lib/Gears/Context.pm Thu Feb 04 00:37:39 2021 +0900 @@ -78,25 +78,36 @@ if ($parsedHeader->{typed_variable_types}) { for my $generics (@generics_list) { - unless ($parsedHeader->{typed_variable_types}->{$generics}) { + if ($parsedHeader->{typed_variable_types}->{$generics}) { + push( + @{$self->{generics_list}->{typed_variable}}, + { + interface => $interface, + impl => undef, + type => $interface, + vname => $vname, + typed_variable => $generics, + caller => $cbc_file, + line_number => $line_number + } + ); + } else { #this case is defined type - } else { - push( - @{$self->{generics_list}->{typed_variable}}, - { - interface => $interface, - impl => undef, - type => $interface, - vname => $vname, - typed_variable => $generics, - caller => $cbc_file, - line_number => $line_number - } - ); - } + push( + @{$self->{generics_list}->{defined_type}}, + { + interface => $interface, + impl => undef, + type => $interface, + vname => $vname, + defined_type => $generics, + caller => $cbc_file, + line_number => $line_number + } + ); + } } } - } if ($line =~ /^\s*(\w+)(<(.*)>)\s*?\*\s*create(\w+)\(([<>,*\w\s]+)\)/) {