C-Analyzer
view release on metacpan or search on metacpan
lib/C/Analyzer.pm view on Meta::CPAN
Returns : None
Argument : None
Throws : None
Comment : None
See Also :
=cut
#################### subroutine header end ####################
sub init() {
my ($self) = @_;
&clean();
my $folder = "";
my $opt = "";
my $cppPath = "";
my $cppOpts = "";
my $funName = "";
my $cfiles;
my $ppfiles;
my $cfile;
lib/C/Analyzer.pm view on Meta::CPAN
Returns : None
Argument : Takes a reference to list of functions
Throws : None
Comment : None
See Also :
=cut
#################### subroutine header end ####################
sub calltree() {
my ( $class, $functions ) = @_;
my @funclist = ();
if ( defined($functions) ) {
@funclist = @{$functions};
}
else {
@funclist = qw(main);
}
foreach my $function (@funclist) {
&prepareCalltreeInit( \$function );
lib/C/Analyzer.pm view on Meta::CPAN
Argument : folder name and GNU C Preprocessor options
Throws : None
Comment : None
See Also :
None
=cut
#################### subroutine header end ####################
sub getListOfCFiles() {
my ( $folder, $opt ) = @_;
my @cfiles = ();
my $OS = $^O;
$$folder =~ s/\//\\/g;
if ( ( defined $OS )
&& ( $OS eq "MSWin32" )
&& ( $$opt eq "dir_and_subdir" ) )
{
@cfiles = `dir /b /s \"$$folder\*.c\"`;
}
lib/C/Analyzer.pm view on Meta::CPAN
Argument : function name
Throws : None
Comment : None
See Also :
None
=cut
#################### subroutine header end ####################
sub prepareCalltreeInit() {
my ($function) = shift;
my $localtime = localtime();
my @calls = ();
if ( exists $calls{$$function} ) {
@calls = @{ $calls{$$function} };
}
else {
print "Function does not exists\n";
return;
}
lib/C/Analyzer.pm view on Meta::CPAN
Argument : function name and tab count
Throws : None
Comment : None
See Also :
None
=cut
#################### subroutine header end ####################
sub generateCalltree() {
my ( $function, $tabcount ) = ( shift, shift );
if ( $calls{$function} ) {
push( @rec_track, $function );
my @calls = @{ $calls{$function} };
shift(@calls);
foreach my $call (@calls) {
my $curr_cnt = $tabcount;
my $temp_call = $call;
if ( $temp_call =~ /^\[/ ) {
lib/C/Analyzer.pm view on Meta::CPAN
Argument : reference of list of C files, CPP Path, Options
Throws : None
Comment : None
See Also :
None
=cut
#################### subroutine header end ####################
sub runGnuPreprocessor() {
my ( $cfiles, $cppPath, $cppOpts ) = @_;
my ( $prepfile, $prep_str );
my @ppfiles = ();
my $len = scalar(@$$cfiles);
my $cnt = 0;
foreach my $cfile (@$$cfiles) {
$cnt++;
chomp($cfile);
$cfile =~ s/\\/\//g;
&progress_bar( $cnt, $len, 50, '=' );
lib/C/Analyzer.pm view on Meta::CPAN
names.
Throws : None
Comment : None
See Also :
None
=cut
#################### subroutine header end ####################
sub identifyFunctionsAndCalls() {
my ( $ppfiles, $opt, $folder ) = @_;
my $fun_calls;
foreach my $ppfile (@$$ppfiles) {
$fun_calls = parseCFile( \$ppfile, \$$opt, \$$folder );
updateHashTable( \$fun_calls );
}
return;
}
#################### subroutine header begin ####################
lib/C/Analyzer.pm view on Meta::CPAN
Argument : reference to filename, options and foldername
Throws : None
Comment : None
See Also :
None
=cut
#################### subroutine header end ####################
sub parseCFile() {
my ( $infile, $opt_s, $FolderName ) = shift;
my @t_funs_calls = ();
my @pplines = ();
my $OpenCount = 0;
my $CloseCount = 0;
my $lno = 0;
my $fragment;
my $filename;
my $fun;
open( PPFILE, "<$$infile" ) || die("Cannot open input file $$infile\n");
lib/C/Analyzer.pm view on Meta::CPAN
Argument : None
Throws : None
Comment : None
See Also :
None
=cut
#################### subroutine header end ####################
sub updateHashTable() {
my $fun_calls = shift;
my $OpenCount = 0;
my $CloseCount = 0;
my $function;
my $FUNCTIONFOUND = 0;
my $item = -1;
my $titem;
my $cnt1 = 0;
my $call;
my $fun_remain;
lib/C/Analyzer.pm view on Meta::CPAN
Returns : trimmed string
Argument : string
Throws : None
Comment : None
See Also :
None
=cut
#################### subroutine header end ####################
sub trim($) {
my $string = shift;
$string =~ s/^\s+// if defined($string);
$string =~ s/\s+$// if defined($string);
return $string;
}
#################### subroutine header begin ####################
=head2 clean
lib/C/Analyzer.pm view on Meta::CPAN
Returns : none
Argument : none
Throws : None
Comment : None
See Also :
None
=cut
#################### subroutine header end ####################
sub clean() {
%calls = ();
@calls_table = ();
@rec_track = ();
return;
}
#################### subroutine header begin ####################
=head2 progress_bar
( run in 0.549 second using v1.01-cache-2.11-cpan-65fba6d93b7 )