view lib/Gears/Stub.pm @ 1:9a4279c88aa7 default tip

copy from xv6 repository
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Fri, 06 Mar 2020 14:59:59 +0900
parents
children
line wrap: on
line source

package Gears::Stub;
use strict;
use warnings;
use Carp qw/croak/;
use File::Find;
use Gears::Util;

use DDP {deparse => 1};

sub new {
  my ($class, %args) = @_;

  my $self = {};
  $self->{file_name} = $args{file_name} || croak 'invalid file_name!'; 

  return bless $self, $class;
}



sub findInterfacewImpl {
  my $self     = shift;
  my $cbc_file = shift // $self->{file_name};
  my $findInterfaces = Gears::Util->extraction_dg_compile_sources([$cbc_file]);
  my $edgcs = Gears::Util->extraction_dg_compile_sources([$cbc_file]);
  my $findInterfaces = {};

  my %ifs = ();
  map { $ifs{$_}++ } keys %{$edgcs->{interfaces}};
  delete $ifs{Meta};
  delete $ifs{TaskManager};

  push(@{$findInterfaces->{interfaces}}, keys %ifs);
  push(@{$findInterfaces->{impls}}, keys %{$edgcs->{impl}});

  return $findInterfaces;
}

1;