Mercurial > hg > GearsTemplate
changeset 565:a37ee31c76f0
add Gears.pm
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 23 Nov 2019 16:11:19 +0900 |
parents | 9cca20bcb558 |
children | dada17cba91d |
files | src/parallel_execution/lib/Gears.pm |
diffstat | 1 files changed, 51 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/parallel_execution/lib/Gears.pm Sat Nov 23 16:11:19 2019 +0900 @@ -0,0 +1,51 @@ +package Gears; + +use strict; +use warnings; + +use Gears::Util; +use DDP {deparse => 1}; + +sub new { + my ($class, %args) = @_; + p %args; + + my $self = { + interfaces => [], + data_gears_with_count => {}, + }; + + if ($args{compile_sources}) { + $self->{compile_sources} = $args{compile_sources}; + map { Gears::Util->file_checking($_); } @{$self->{compile_sources}}; + } + return bless $self, $class; +} + +sub parse_all { + my $self = shift; + for my $cbc (@{$self->{compile_sources}}) { + $self->grep_data_gears($cbc); + } +} + +sub grep_data_gears { + my ($self, $cbc_file) = @_; + open my $fh , '<', $cbc_file; + while (my $line = <$fh>) { + if ($line =~ /#interface\s*"(.*\.h)"/) { + push(@{$self->{interfaces}}, $1); + next; + } + + if ($line =~ /__code/) { + while ($line =~ /struct (\w+)*/g) { + $self->{data_gears_with_count}->{$1}++; + } + } + } + close $fh; +} + + +1;