Split CP up into components that can be called individually

Removed dead code.

refs #86
This commit is contained in:
Alex Lin 2015-07-21 09:09:09 -05:00
parent d7b386227a
commit 9b7a933a06
11 changed files with 0 additions and 2539 deletions

View File

@ -1,232 +0,0 @@
#!/usr/bin/perl
use FindBin qw($RealBin);
use strict ;
use Getopt::Long;
use Pod::Usage;
use Pod::Text;
use lib "$RealBin/pm" ;
use ICG ;
use trick_print ;
use trick_version ;
use get_headers ;
use Cwd 'abs_path';
##############################################################################
# Main program
##############################################################################
my $icg_operation ;
my @icg_h_files ;
my %sim ;
my $ret ;
my $help ;
my @defs ;
my ($valid_types_ref,$icg_depends_ref, $mis_entries_ref,$mis_depends_ref) ;
my ($head_depends_ref,$rcs_tags_ref) ;
# override the print format for help message
*Pod::Text::seq_i = sub { return "" . $_[1] . "" } ;
# set stdout to unbuffered so we see printout immediately.
$| = 1 ;
# set the default verbose level to 2
$sim{args}{v} = 2 ;
$sim{args}{force} = 0 ;
# default operation
$icg_operation = "full" ;
$ICG::arg_lang = 0 ;
Getopt::Long::Configure ("bundling");
GetOptions ( "D=s" => sub { my $temp = join "" , @_ ; push @defs , "-$temp" ; } ,
"U=s" => sub { my $temp = join "" , @_ ; push @defs , "-$temp" ; } ,
"cpp|p" => sub { $ICG::arg_lang = "CPP" } ,
"debug|d|g" => sub { $sim{args}{v} = 3 } ,
"help|h|?" => \$help ,
"force|f" => sub { $sim{args}{force} = 1} ,
"outfile|o=s" => \$sim{args}{o} ,
"sim_services|s" => sub { $icg_operation = "sim_services" } ,
"single" => sub { $icg_operation = "single" } ,
"s_source" => sub { $icg_operation = "s_source" } ,
"tree|t" => sub { $icg_operation = "tree" } ,
"unit_summary|u" => \&unit_summary ,
"verbose|v=i" => \$sim{args}{v}
) or pod2usage(1) ;
pod2usage(1) if $help ;
#if ( -e "S_overrides.mk" ) {
#
# open CFLAGS, "make -p -n -f S_overrides.mk fake_target 2>&1 |" ;
#
# while ( <CFLAGS> ) {
#
# if ( /^TRICK_CFLAGS\s*\:?=\s*(.*)/ ) {
# $ENV{TRICK_CFLAGS} = $1 ;
# }
# elsif ( /^TRICK_ICG_EXCLUDE\s*\:?=\s*(.*)/ ) {
# $ENV{TRICK_ICG_EXCLUDE} = $1 ;
# $ENV{TRICK_ICG_EXCLUDE} =~ s/\$[{(]([^})]+)[})]/$ENV{$1}/ge ;
# }
# }
# close CFLAGS ;
#}
$ENV{TRICK_CFLAGS} =~ s/\$[{(](\w+)[})]/$ENV{$1}/g ;
$ENV{TRICK_CFLAGS} =~ s/\"//g ;
# set and open the output file
if ( $sim{args}{o} ne "" ) {
my ($version, $thread) = get_trick_version() ;
$thread =~ s/\d+\.// ;
local *OUTFILE ;
open OUTFILE , ">$sim{args}{o}"
or warn "ICG cannot open $sim{args}{o} for writing\n" ;
$sim{fh} = *OUTFILE ;
print OUTFILE "Output for $0 version $version-$thread at " . localtime() . "\n\n" ;
}
push @icg_h_files , (grep !/(^-|(\.d|\.dd)$)/ , @ARGV) ;
#--------------------------------------------------------------
# Get all headers used by the sim and their modification dates
#if ( $icg_operation eq "s_source" ) {
# get_headers(\%sim, abs_path("S_source.hh")) ;
#}
$ret = ICG(@icg_h_files, $icg_operation, \@defs, \%sim) ;
if ($ret eq -1) {
trick_print($sim{fh},
"\nICG No files specified or found\n" ,
"normal_yellow" , $sim{args}{v}) ;
}
sub unit_summary() {
print "
Trick Measurement Units Summary
---------------------------------------------------------------------------------------------------
Standard Units |Description
---------------------------------------------------------------------------------------------------
Time: s min hr day |second, minute, hour, day
Angular Displacement: r d as am rev |radian, degree, arc-second, arc-minute, revolution
Voltage: v |volt
Amperage: amp |ampere
Resistance: ohm |ohm
Sound: dB |decibel
Unitless: -- cnt one mol |no unit, count, one, mole
|
---------------------------------------------------------------------------------------------------
English System Units |Description
---------------------------------------------------------------------------------------------------
Linear Displacement: ft kft in yd mi n.m. |foot, kilofoot, inch, yard, mile, nautical mile
Mass: sl lbm |slug, pound(mass)
Force: oz lbf |ounce, pound(force)
Temperature: R F |Rankine, Fahrenheit
Energy: BTU |British Thermal Unit
Power: hp |horsepower
Pressure: psi |pound per square inch
Volume: gal floz |gallon, fluid ounce
|
---------------------------------------------------------------------------------------------------
Metric System Units |Description
---------------------------------------------------------------------------------------------------
Linear Displacement: m |meter
Mass: g mt |gram, metric ton
Force: N |Newton
Temperature: C K |Celsius, Kelvin
Energy: J TNT |Joule, ton of TNT
Power: W |Watt
Pressure: Pa atm mHg |Pascal, atmosphere, meter of mercury
Frequency: Hz |Herz
Volume: l |liter
---------------------------------------------------------------------------------------------------
---------------------------------------------------------
You can use these prefixes for Multiples and Submultiples
(Only valid for units: r v amp ohm m g N J W Pa mHg Hz)
---------------------------------------------------------
10**-1 d 10 da
10**-2 c 10**2 h
10**-3 m 10**3 k
10**-6 u 10**6 M
10**-9 n 10**9 G
10**-12 p 10**12 T
---------------------------------------------------------
\n\n" ;
exit() ;
}
__END__
=head1 NAME
ICG - Trick Interface Code Generator
=head1 SYNOPSIS
ICG [-D B<label>] [-U B<label>] [--cpp] [--debug] [-d] [-g] [-h] [--help]
[-l] [--library] [-o I<outfile>] [--outfile=I<outfile>] [-p] [-s] [--sim_services]
[-t] [--tree] [-u] [--unit_summary] [-v I<level>] [--verbose=I<level>] [I<file> ...]
=head1 DESCRIPTION
See the Trick User's guide for B<ICG>.
=head1 OPTIONS
=over 8
=item B<-D> I<label>
Define a label
=item B<-U> I<label>
Undefine a label
=item B<-d> | B<-g> | B<--debug>
Set verbose level = 3
=item B<-h> | B<-?> | B<--help>
This help screen
=item B<-l> | B<--library>
Use this option in a SIM directory. ICG will execute on all files listed in the
S_library_list file
=item B<-o> I<outfile> | B<--outfile>=I<outfile>
Direct output of ICG to outfile. ( Note: Does not affect screen output ).
=item B<-s> | B<--sim_services>
Run ICG on all required header files in the sim_services directory
=item B<-t> | B<--tree>
Print out a hierarchical tree of all header file dependcies for B<file>
=item B<-u> | B<--unit_summary>
Print out the list of known units to ICG
=item B<-v> I<level> | B<--verbose>=I<level>
Set the verbose level. Valid entries are 0-3.
=item B<-DTRICK_VER=x.x>
Note: -DTRICK_VER=x.x is automatically used when parsing header files and the S_define file
=back
=cut

View File

@ -1,217 +0,0 @@
#!/usr/bin/perl
use strict ;
use FindBin qw($RealBin);
use lib "$RealBin/pm" ;
use Getopt::Long ;
use Pod::Usage ;
use Pod::Text ;
use File::Basename ;
use Cwd ;
use Cwd 'abs_path' ;
use mis_dep ;
use html ;
use cp_cache ;
use MIS ;
use gte ;
use trick_print ;
use trick_version ;
my $wd ;
my (@all_files , $src_dir , @c_files , @cpp_files ) ;
my $num_files ;
my $contents ;
my $curr_file ;
my $size ;
my ( @inc_paths , $subme ) ;
my @all_lines ;
my %sim ;
my $help ;
my ($vt_ref, $icg_dep_ref, $mod_ref, $md_ref, $rcs_tags_ref) ;
# override the print format for help message
*Pod::Text::seq_i = sub { return "" . $_[1] . "" } ;
# set stdout to unbuffered so we see printout immediately.
$| = 1 ;
# set the default verbose level to 2
$sim{args}{v} = 2 ;
$sim{args}{l} = 0 ;
Getopt::Long::Configure ("bundling");
GetOptions ( "debug|d|g" => sub { $sim{args}{v} = 3 } ,
"help|h|?" => \$help ,
"library|l" => \$sim{args}{l} ,
"outfile|o=s" => \$sim{args}{o} ,
"verbose|v=i" => \$sim{args}{v}
) or pod2usage(1) ;
pod2usage(1) if $help ;
if ( $sim{args}{o} ne "" ) {
my ($version, $thread) = get_trick_version() ;
$thread =~ s/\d+\.// ;
local *OUTFILE ;
open OUTFILE , ">$sim{args}{o}"
or warn "ICG cannot open $sim{args}{o} for writing\n" ;
$sim{fh} = *OUTFILE ;
print OUTFILE "Output for $0 version $version-$thread at " . localtime() . "\n\n" ;
}
$wd = abs_path(cwd()) ;
#if ( $ARGV[0] eq "-l" ) {
if ( $sim{args}{l} ) {
open FILE , "S_library_list" or die "Could not open S_library_list\n" ;
@all_lines = <FILE> ;
@c_files = grep /\.c$/ , @all_lines;
chomp @c_files ;
$wd = "" ;
} elsif ( $#ARGV eq -1 ) {
opendir thisdir, $wd or die "Could not open the directory $wd";
@all_files = grep !/^\.\.\./ , readdir thisdir;
$src_dir = grep /^src$/ , @all_files;
@c_files = grep /\.c$/ , @all_files;
@cpp_files = grep /\.C$|\.cc$|\.cxx$|\.cpp$|\.c\+\+$/ , @all_files;
$num_files = scalar @c_files ;
if ( $num_files ne 0 and $src_dir eq 1 ) {
print "\nMIS ERROR: All source files must reside in the\n" ;
print " 'src' directory. Either place all \n" ;
print " source files in the 'src' directory, \n" ;
print " OR move any source file out of 'src'\n" ;
print " into $wd and remove the 'src' directory." ;
print "\n\n";
exit(1);
}
if ( $src_dir eq 1 ) {
opendir thisdir, $wd . "/src";
@all_files = grep !/^\.\.\./ , readdir thisdir;
closedir thisdir;
@c_files = grep /\.c$/ , @all_files;
@cpp_files = grep /\.C$|\.cc$|\.cxx$|\.cpp$|\.c\+\+$/ ,
@all_files;
$wd .= "/src" ;
}
foreach (@c_files , @cpp_files ) {
$_ = "$wd/$_" if ( /^[^\/]/ ) ;
}
} else {
@c_files = grep /\.c$/ , @ARGV;
@cpp_files = grep /\.C$|\.cc$|\.cxx$|\.cpp$|\.c\+\+$/ , @ARGV;
foreach (@c_files , @cpp_files ) {
$_ = "$wd/$_" if ( /^[^\/]/ ) ;
}
$wd = "" ;
}
my @non_yacc_files ;
foreach (@c_files) {
(my $test = $_) =~ s/c$/y/ ;
if ( ! -e $test ) {
push @non_yacc_files , $_ ;
}
}
@c_files = @non_yacc_files ;
if ($#c_files eq -1 and $#cpp_files eq -1 ) {
trick_print($sim{fh},
"No files specified or found\n" ,
"normal_yellow" , $sim{args}{v});
exit(0);
}
trick_print($sim{fh}, "MIS-ing...", "title_cyan" , $sim{args}{v}) ;
trick_print($sim{fh}, "\n" , "title_white" , $sim{args}{v}) if ( $sim{args}{v} != 1 ) ;
@inc_paths = $ENV{"TRICK_CFLAGS"} =~ /-I\s*(\S+)/g ;
push @inc_paths , ("$ENV{\"TRICK_HOME\"}/trick_source" , "../include") ;
foreach (@inc_paths) {
$subme = quotemeta (abs_path(dirname($_)) . "/" . basename($_)) ;
}
($vt_ref, $icg_dep_ref, $mod_ref, $md_ref, $rcs_tags_ref ) = read_cache() ;
%{$sim{icg_types}} = %$vt_ref ;
%{$sim{all_icg_depends}} = %$icg_dep_ref ;
%{$sim{module_entries}} = %$mod_ref ;
%{$sim{all_mis_depends}} = %$md_ref ;
%{$sim{rcs_tags}} = %$rcs_tags_ref ;
push @c_files , @cpp_files ;
foreach $curr_file (@c_files ) {
open FILE, $curr_file or die "Couldn't find file: $curr_file\n";
seek FILE , 0 , 2 ;
$size = tell FILE ;
seek FILE , 0 , 0 ;
read FILE , $contents , $size;
mis_c($curr_file , $contents, \%sim) ;
}
#if ( $sim{args}{l} == 0 ) {
# write_local_cat( $wd , \@inc_paths , \%sim ) ;
#}
if ( $sim{args}{v} == 1 ) {
print " Complete\n" ;
}
trick_print($sim{fh}, "\nAll MIS complete\n\n" , "normal_green" , $sim{args}{v}) ;
__END__
=head1 NAME
MIS - Trick Module Interface Specification
=head1 SYNOPSIS
MIS [--debug] [-d] [-g] [-h] [--help] [-l] [--library]
[-o I<outfile>] [--outfile=I<outfile>]
[-v I<level>] [--verbose=I<level>] [B<file> ...]
=head1 DESCRIPTION
See the Trick User's guide for B<MIS>.
=head1 OPTIONS
=over 8
=item B<-d> | B<-g> | B<--debug>
Set verbose level = 3
=item B<-h> | B<-?> | B<--help>
This help screen
=item B<-l> | B<--library>
Use this option in a SIM directory. MIS will execute on all files listed in the
S_library_list file
=item B<-o> I<outfile> | B<--outfile>=I<outfile>
Direct output of MIS to outfile. ( Note: Does not affect screen output ).
=item B<-v> I<level> | B<--verbose>=I<level>
et the verbose level. Valid entries are 0-3.
=back
=cut

View File

@ -1,50 +0,0 @@
#!/usr/bin/perl
use Cwd 'abs_path' ;
use File::Basename;
use strict ;
my $full_path ;
my $dir ;
my $dir_no_src ;
my $file_base ;
my $word ;
my $cont ;
#$full_path = abs_path(@ARGV[0]) ;
$full_path = abs_path(dirname(@ARGV[0])) . "/" . basename(@ARGV[0]) ;
$dir = dirname($full_path) ;
($dir_no_src = $dir) =~ s/\/src$// ;
$file_base = basename($full_path) ;
$file_base =~ s/\.[^\.]+$// ;
open FILE, "$dir_no_src/object_$ENV{TRICK_HOST_CPU}/${file_base}.d" or die "Could not open $dir_no_src/object_$ENV{TRICK_HOST_CPU}/${file_base}.d" ;
open OUTFILE, "> $dir_no_src/object_$ENV{TRICK_HOST_CPU}/${file_base}.dep" or die "Could not open $dir_no_src/object_$ENV{TRICK_HOST_CPU}/${file_base}.dep" ;
while ( <FILE> ) {
next if ( /^#/ ) ;
next if ( /^\s+\\/ ) ;
$cont = 0 ;
foreach $word ( split ) {
if ( $word eq "\\" ) {
$word = "\\\n" ;
$cont = 1 ;
}
else {
if ( $word !~ /^\// and $dir ne "\/" ) {
$word = "$dir/$word" ;
}
$word = abs_path($word) ;
}
print OUTFILE "$word " ;
}
if ( $cont == 0 ) {
print OUTFILE "\n" ;
}
}

View File

@ -1,57 +0,0 @@
#! /usr/bin/perl
#
# Usage: mis_dep <src file>
#
# Description: Given a source file, this program will find all library
# dependencies that this source file's object will depend on.
# The dependency tree is built using the library dependencies
# from the TRICK HEADERs in the source files. TRICK_CFLAGS
# are used to actually find all files in the dependency tree.
use lib $ENV{"TRICK_HOME"} . "/bin/pm" ;
use Cwd ;
use File::Basename ;
use strict ;
use mis_dep ;
my ($all_mis_depends, %rcs_tags) ;
my ($k , $a) ;
my @all_depends ;
my %temp_hash ;
my $wd ;
# prepend current dir name if none given
$wd = cwd() ;
foreach (@ARGV) {
$_ = $wd . "/" . $_ if ( !/^\// ) ;
}
$all_mis_depends = mis_dep(\%rcs_tags , @ARGV) ;
print "\n" ;
foreach $a ( sort keys %$all_mis_depends ) {
traverse_tree($a, 0, %{$$all_mis_depends{$a}} );
print "\n" ;
}
foreach $a ( sort keys %$all_mis_depends ) {
print "$a\n";
@all_depends = () ;
# push all depends for all files onto one array
foreach $k ( sort keys %{$$all_mis_depends{$a}} ) {
if ( $k ne "last_look" ) {
push @all_depends , @{$$all_mis_depends{$a}{$k}} ;
}
}
# remove duplicate elements
%temp_hash = {};
@all_depends = grep ++$temp_hash{$_} < 2, @all_depends ;
foreach $k ( sort @all_depends ) {
print " $k\n";
}
}

View File

@ -1,456 +0,0 @@
package ICG ;
use Exporter ();
@ISA = qw(Exporter);
use vars qw($arg_lang);
@EXPORT = qw(ICG);
use File::Basename ;
use Text::Balanced qw ( extract_bracketed );
use Cwd ;
use strict ;
use gte ;
use MIS ;
use html ;
use trick_print ;
use trick_version ;
use Cwd 'abs_path';
##############################################################################
# Important Hashes
##############################################################################
#
# VALID-TYPES HASH
# Key Value
# <type-specifier> Ref to TYPE-INFO HASH
#
# ----------------------------------------------------------------------------
# TYPE-INFO HASH
# Key Value
# value Trick parameter type as defined in parameter_types.h
# Examples: "TRICK_CHARACTER", "TRICK_INTEGER", etc.
# name C/C++ type specifier.
# Examples: "char", "int", etc.
# intrinsic 0= User-defined type. 1= Intrinsic type.
# class Parent class.
# file File where this type was declared.
# typedef 0 or 1. Whether declaration starts with struct or union.
# inherit_class @ of strings that name the classes from which this class is inherits.
# virtual Whether this class inherits virtually.
# abstract Whether this class is abstract (and therefore cannot be instantiated). 0=no, 1=yes.
# def_construct 0 or 1. Indicates whether we should create an io_src_allocate_ routine.
##############################################################################
# Global Variables
##############################################################################
# Variable: $top_file
# Description:
my $top_file ;
# Variable: all_icg_depends_ref
# Description:
my ( $all_icg_depends_ref ) ;
my $verbose ;
my %header ;
my $indent = 3 ;
my %already_processed ;
my @file_levels ;
################################################################################
# SUBROUTINE: ICG
#
# DESCRIPTION: FIXME
#
# PARAMETERS:
# temp_h_files array of strings representing the names of header files to be processed.
# operation scalar string that indicates what ICG is supposed to do.
# Recognized values are "full", "CP", "sim_services", "single", "s_source", "tree".
# user_defs array of strings (e.g.: "-DFOO" representing user defines.
# sim_ref Reference to global SIM-HASH.
#
# RETURNS: FIXME
################################################################################
sub ICG(\@$$$) {
my ($temp_h_files , $operation, $user_defs, $sim_ref) = @_ ;
my @h_files ;
my $wd ;
my $path_dir ;
my @include_paths ;
my @defines ;
my $curr_file ;
my (@file_stack , %file_contents ) ;
my ($f) ;
my $file_path_dir ;
my @inc_paths ;
my @file_order ;
my %tree ;
my @icg_exclude_dirs ;
my ($version, $thread, $year) ;
my $cc ;
@h_files = @$temp_h_files ;
# used by make_makefile
$all_icg_depends_ref = \%{$$sim_ref{all_icg_depends}} ;
$wd = cwd();
$path_dir = dirname($wd) ;
if ($path_dir eq ".") {
$path_dir = cwd();
}
($version, $thread) = get_trick_version() ;
($year) = $version =~ /^(\d+)/ ;
($cc = gte("TRICK_CC")) =~ s/\n// ;
@include_paths = $ENV{"TRICK_CFLAGS"} =~ /(-I\s*\S+)/g ; # get include paths from TRICK_CFLAGS
push @include_paths , ("-I" . $ENV{"TRICK_HOME"} . "/trick_source" , "-I../include") ;
@defines = $ENV{"TRICK_CFLAGS"} =~ /(-D\S+)/g ; # get defines from TRICK_CFLAGS
if ( $ENV{"TRICK_CFLAGS"} !~ /DTRICK_VER=/ ) {
push @defines , "-DTRICK_VER=$year" ;
}
push @defines , "-DTRICK_ICG" ;
# Break up the $TRICK_ICG_EXCLUDE string based on some delimiter (colon).
# In an array context, split returns a list of the things that were found.
@icg_exclude_dirs = split /:/ , $ENV{"TRICK_ICG_EXCLUDE"};
# See if there are any elements in the icg_exclude_dirs array
if (scalar @icg_exclude_dirs) {
@icg_exclude_dirs = sort(@icg_exclude_dirs );
# Error check - delete any element that is null
# (note: sort forced all blank names to front of array
@icg_exclude_dirs = map { s/(^\s+|\s+$)//g ; $_ } @icg_exclude_dirs ;
while ( not length @icg_exclude_dirs[0] ) {
# Delete an element from the left side of an array (element zero)
shift @icg_exclude_dirs ;
}
@icg_exclude_dirs = map { (-e $_) ? abs_path($_) : $_ } @icg_exclude_dirs ;
}
@inc_paths = $ENV{"TRICK_CFLAGS"} =~ /-I\s*(\S+)/g ; # get include paths from TRICK_CFLAGS
# Get only the include paths that exist
my @valid_inc_paths ;
foreach (@inc_paths) {
push @valid_inc_paths , $_ if ( -e $_ ) ;
}
@inc_paths = @valid_inc_paths ;
# return if no header files are to be processed
if (scalar @h_files == 0) {
return -1 ;
}
open SLIB , "build/icg_no_found" ;
while ( <SLIB> ) {
chomp ;
$$sim_ref{icg_no}{$_} = 1 ;
}
while (@h_files) {
my %temp_hash ;
my $cc_inc ;
my $curr_dir ;
#Clear out variables for new file
undef %file_contents ;
undef @file_stack ;
undef @file_levels ;
undef @file_order ;
$curr_file = shift @h_files ;
#get the absolute path to this header file... use this from now on.
$curr_file = abs_path(dirname($curr_file)) . "/" . basename($curr_file) ;
$top_file = $curr_file ;
$curr_dir = dirname($curr_file) ;
if ( $operation ne "treedep" and $operation ne "single" ) {
trick_print($$sim_ref{fh}, "ICG $curr_file\n\n" , "normal_cyan" , $$sim_ref{args}{v}) ;
}
open FILE, "$curr_file" or die "Couldn't find file: $curr_file\n";
# Use the C preprocessor to get all of the include dependencies for the current file
# This way we can properly take care of #defines with h files
# When you open a filehandle (FILE) that's already open, Perl
# implicitly closes it first.
if ( $curr_file =~ /\.h$/ ) {
open FILE, "cd $curr_dir ; $cc -E -C @include_paths @defines @$user_defs $curr_file |" ;
}
elsif ( $curr_file =~ /(\.hh|\.H|\.h\+\+|\.hxx)$/ ) {
open FILE, "cd $curr_dir ; $cc -E -C -x c++ @include_paths $cc_inc @defines @$user_defs $curr_file |" ;
}
else {
open FILE, "cd $curr_dir ; $cc -E -C -x c @include_paths $cc_inc @defines @$user_defs $curr_file |" ;
}
# read the result of the preprocessor and separate the output to individual files
while ( <FILE> ) {
# change file we are in to include dependencies
if ( /^#(\s*line)?\s*\d+\s*"(.*?)"/ ) {
$curr_file = $2 ;
$curr_file =~ s/\/(\/)+/\//g ;
# Replace directories that are symbolic links
# with real/absolute paths. Also substitute out
# /dir_a/dir_b/../file.c with /dir_a/file.c
$curr_file = abs_path(dirname($curr_file)) . "/" . basename($curr_file) ;
if ($curr_file !~ /^\/usr\/include/ and
$curr_file !~ /^\/usr\/lib/ and
($curr_file =~ /^\/usr\/local\/trick/ # Trick install PREFIX
or $curr_file !~ /^\/usr\/local/) and
$curr_file !~ /^\/usr\/X11/ and
$curr_file !~ /gcc-lib/ and
$curr_file !~ /^\/Developer/ and
$curr_file !~ /^\/Library\/Developer/ and
$curr_file !~ /^\/Applications\/Xcode.app/ and
$curr_file !~ /^\/usr\/llvm-gcc-4.2/ and
$curr_file !~ /opt\/sfw/ and
$curr_file !~ /<built-in>/ and
$curr_file !~ /^\/usr\/qnx.*?\/target/ and
$curr_file !~ /<command.line>/) {
# keep a record of the order the files were visited
push @file_order , $curr_file ;
}
}
# add line to file we are in
if ($curr_file !~ /^\/usr\/include/ and $curr_file !~ /^\/usr\/lib/ and
$curr_file !~ /^\/usr\/X11/ and $curr_file !~ /gcc-lib/ ) {
# string concatenate
$file_contents{$curr_file} .= "$_" ;
}
}
# Convert the flat file output from cc to a tree dependency hash
foreach $f ( @file_order ) {
# skip c++ .i files
next if ( $f =~ /\.i$/ ) ;
# Use absolute path
if ( $f =~ /^\// ) {
my $old_f = $f ;
$f = abs_path(dirname($f)) . "/" . basename($f) ;
if ( ! exists $file_contents{$f} ) {
$file_contents{$f} = $file_contents{$old_f} ;
}
}
else {
my $old_f = $f ;
$f = abs_path(dirname("$curr_dir/$f")) . "/" . basename($f) ;
if ( ! exists $file_contents{$f} ) {
$file_contents{$f} = $file_contents{$old_f} ;
}
}
if (! defined $file_stack[$#file_stack] or $f ne $file_stack[$#file_stack]) {
# if file name is equal to previous file on stack pop up to that file
if ($#file_stack ge 1 and $file_stack[$#file_stack - 1] eq $f) {
pop @file_stack ;
}
else {
# make sure this is not the top level file
if ( $#file_stack ge 0 ) {
# if file name does not exist in it's parent's list add it
my $temp_f = quotemeta $f ;
if ( !(grep /$temp_f/, @{$$all_icg_depends_ref{$top_file}{$file_stack[$#file_stack]}}) ) {
push @{$$all_icg_depends_ref{$top_file}{$file_stack[$#file_stack]}} , $f ;
}
# if there is no entry yet for this file make one
if (!exists $$all_icg_depends_ref{$top_file}{$f}) {
@{$$all_icg_depends_ref{$top_file}{$f}} = () ;
}
}
# push this file name onto the stack
push @file_stack, $f ;
$tree{$f} = 1 ;
if ($operation eq "tree" ) {
print $$sim_ref{fh}, " " x ($#file_stack * 3) . $f . "\n" ;
}
}
}
}
# if ICG was called with the -tree option exit here.
return %tree if ($operation eq "tree" or $operation eq "treedep" ) ;
# Get the realpath of all the files we read in from the C preprocessor
foreach $f ( keys %file_contents ) {
my $new_name = abs_path(dirname($f)) . "/" . basename($f) ;
if ( $new_name ne $f and !exists $file_contents{$new_name} ) {
$file_contents{$new_name} = $file_contents{$f};
}
}
my %all_file_names ;
@file_levels = traverse_tree_to_file_levels($top_file, \%all_file_names , \%{$$all_icg_depends_ref{$top_file}} ) ;
foreach $f (@file_levels) {
my @structs_info ;
my @enums_info ;
my $continue ;
# skip file if already processed this invocation of ICG
if ( exists $already_processed{$f} ) {
next ;
}
$already_processed{$f} = 1 ;
if ( $f =~ /\.C$|\.cc$|\.cxx$|\.cpp$|\.c\+\+$/ ) {
next ;
}
elsif ( $f =~ /\.c$/ ) {
# MIS
mis_c($f , $file_contents{$f} , $sim_ref) ;
next ;
}
elsif ( $f =~ /\.i$/ ) {
next ;
}
$continue = 1 ;
foreach my $ie ( @icg_exclude_dirs ) {
# if file location begins with $ie (an IGC exclude dir)
my $dum = $f ;
if ( $dum =~ s/^\Q$ie// ) {
if ( $dum =~ /^\// ) {
trick_print($$sim_ref{fh}, "ICG skipping $f (ICG exclude dir $ie)\n" , "normal_yellow" , $$sim_ref{args}{v}) ;
$continue = 0 ;
last ; # break out of loop
}
}
}
next if ( $continue == 0 ) ;
if ( exists $$sim_ref{icg_no}{$f} ) {
trick_print($$sim_ref{fh}, "ICG skipping $f (ICG No found)\n" , "normal_yellow" , $$sim_ref{args}{v}) ;
next ;
}
$file_path_dir = dirname($f) ;
if ($file_path_dir eq ".") {
$file_path_dir = cwd();
}
$file_path_dir =~ s/\/+$// ; # remove trailing slash
$file_path_dir =~ s/\/include$// ;
# extract the Trick header
%header = extract_trick_header( $f, $file_contents{$f}, $verbose , $indent );
$$sim_ref{python_module}{$f} = $header{python_module} ;
$$sim_ref{python_module}{$f} =~ s/\(|\)|\s+//g ;
if ( $operation eq "CP" ) {
next if ( $f =~ /$ENV{TRICK_HOME}\/include/) ;
next if ( $f =~ /$ENV{TRICK_HOME}\/trick_source/) ;
trick_print($$sim_ref{fh}, "Getting dependencies for $f\n" , "normal_white" , $$sim_ref{args}{v});
delete $$sim_ref{head_deps}{$f} ;
# add any external dependencies from an .exd file
my ($exd_file_name) = $f ;
my @exd_file_list ;
undef @exd_file_list ;
$exd_file_name =~ s/\.[^\/]*$/\.exd/ ;
if ( open EXD , "$exd_file_name" ) {
while ( <EXD> ) {
push @exd_file_list , $_ if ( /\.o\s*$/ and !/^\s*#/ ) ;
}
chomp @exd_file_list ;
}
# we have library dependencies in an h file. ( possible for c++ )
if (exists $header{libdep} or (scalar @exd_file_list != 0) ) {
my @lib_list = split /\)[ \t\n\r\*]*\(/ , $header{libdep} ;
push @lib_list , @exd_file_list ;
foreach my $l (@lib_list) {
my $found = 0 ;
$l =~ s/\(|\)|\s+//g ;
$l =~ s/\${(.+?)}/$ENV{$1}/eg ;
next if ( $l eq "" ) ;
if ( $l !~ /\.o$/ ) {
foreach my $inc ( dirname($f) , @inc_paths) {
if ( -e "$inc/$l" ) {
#print "found $inc/$l$ext\n" ;
my $f = abs_path(dirname("$inc/$l")) . "/" . basename("$inc/$l") ;
push @{$$sim_ref{mis_entry_files}} , $f ;
push @{$$sim_ref{head_deps}{$f}{files}} , $f ;
$found = 1 ;
last ;
}
}
} else {
$l =~ s/o$// ;
foreach my $inc ( $file_path_dir , @inc_paths) {
foreach my $ext ( "cpp" , "cc" , "c" , "c++" , "cxx" , "C" ) {
if ( -e "$inc/$l$ext" ) {
#print "found $inc/$l$ext\n" ;
my $f = abs_path(dirname("$inc/$l$ext")) . "/" . basename("$inc/$l$ext") ;
push @{$$sim_ref{mis_entry_files}} , $f ;
push @{$$sim_ref{head_deps}{$f}{files}} , $f ;
$found = 1 ;
last ;
}
elsif ( -e "$inc/src/$l$ext" ) {
#print "found $inc/src/$l$ext\n" ;
my $f = abs_path(dirname("$inc/src/$l$ext")) . "/" . basename("$inc/src/$l$ext") ;
push @{$$sim_ref{mis_entry_files}} , $f ;
push @{$$sim_ref{head_deps}{$f}{files}} , $f ;
$found = 1 ;
last ;
}
}
last if ( $found == 1 ) ;
}
}
if ( $found == 0 ) {
trick_print($$sim_ref{fh}, "$f: Warning: Could not find dependency $l" . "o\n" ,
"normal_yellow" , $$sim_ref{args}{v}) ;
}
}
}
next ;
}
} # End of foreach on filelevel
} # End of gigantic while loop
return 0 ;
} # end of ICG
sub traverse_tree_to_file_levels($$$$$) {
my ($file, $all_file_names_ref , $curr_tree ) = @_ ;
my $a ;
my @lower_levels ;
my $io_src_file ;
my ($ret_stat , @ret_files) ;
my $ret ;
foreach $a ( @{$$curr_tree{$file}} ) {
if ( ($a ne $file) and !(exists $$all_file_names_ref{$a}) ) {
$$all_file_names_ref{$a} = 1 ;
( @ret_files ) = &traverse_tree_to_file_levels($a, $all_file_names_ref , $curr_tree ) ;
push @lower_levels , @ret_files ;
}
}
$$all_file_names_ref{$file} = 1 ;
return ( @lower_levels , $file ) ;
}
1;

View File

@ -1,290 +0,0 @@
package MIS ;
use Exporter ();
@ISA = qw(Exporter);
@EXPORT = qw(mis_c mis_all_c process_args);
use strict ;
use lib $ENV{"TRICK_HOME"} . "/bin/pm" ;
use File::Basename ;
use Cwd ;
use Cwd 'abs_path' ;
use html ;
use mis_dep ;
use trick_print ;
use auto_doc ;
my @includes ;
my %this_dir ;
my $rel_path_curr_file ;
my @files_to_mis_dep ;
my @class_names = qw( initialization restart derivative
integration dynamic_event post_integration
automatic environment asynchronous_mustfinish asynchronous
random sensor sensor_emitter sensor_reflector
sensor_receiver scheduled effector effector_emitter
effector_receiver automatic_last malfunction
malfunction_trigger logging shutdown freeze_init freeze
unfreeze checkpoint pre_load_checkpoint
monte_master_init monte_master_pre
monte_master_post monte_master_shutdown
monte_slave_init monte_slave_pre
monte_slave_post monte_slave_shutdown
N/A) ;
sub mis_all_c($$) {
my ( $all_src_files_ref , $sim_ref ) = @_ ;
my ( @all_lines , $contents ) ;
my ( $file_path_dir , $xml_file ) ;
my ( $name , $path ) ;
my ( $xml_time , $src_time ) ;
foreach my $f ( @$all_src_files_ref ) {
# determine the xml file name
$file_path_dir = dirname($f) ;
($name, $path) = fileparse($f, ("h" , "c" , "f", "cpp" , "cxx" , "C" , "cc" , "c\\+\\+" ));
$file_path_dir =~ s/\/src$// ;
$xml_file = $file_path_dir . "/xml/" . $name . "xml" ;
# skip this file if the xml file is newer than the source file
if ( -e $xml_file ) {
$xml_time = (stat $xml_file)[9] ;
$src_time = (stat $f)[9] ;
next if ( $xml_time > $src_time ) ;
}
# read in the file and MIS parse it
open FILE , "$f" ;
@all_lines = <FILE> ;
$contents = join "" , @all_lines ;
mis_c( $f , $contents , $sim_ref ) ;
}
return ;
}
sub mis_c($$$) {
my ($curr_file , $contents, $sim_ref) = @_ ;
my ($object_file , @entry_names);
my (@comments , @entries ) ;
my ($num_valid_entries ,$num_args_left) ;
my @all_lines ;
my $nm ;
my %header ;
my $i ;
my $entry ;
my @split_args ;
my $language ;
trick_print($$sim_ref{fh}, " Processing $curr_file\n", "debug_cyan" , $$sim_ref{args}{v}) ;
($object_file = $curr_file) =~ s/(?:src\/)?(\w+)\.c$/object_$ENV{"TRICK_HOST_CPU"}\/$1.o/ ;
($rel_path_curr_file) = $curr_file =~ /([^\/]+)$/ ;
%header = extract_trick_header($curr_file , $contents , $sim_ref , 0 );
if ( exists $header{language} ) {
# if the language specified is c++ cpp cxx c<something> then set the language as cpp
if ( $header{language} =~ /c[\w\+]+/i ) {
$language = "CPP" ;
}
else {
$language = "C" ;
}
}
elsif ($curr_file =~ /\.c$/ ) {
# else if the current file ends in .c set the language to c
$language = "C" ;
}
else {
# all other extensions are cpp
$language = "CPP" ;
}
#Pull out comments
$i = 0;
while ($contents =~ /(?:\/\*(.*?)\*\/)|(?:\/\/(.*?)\n)/sg) {
push @comments , $+ ;
}
$contents =~ s/\/\*(.*?)\*\/|\/\/(.*?)(\n)/" " . $i++ . " " . $3/esg ;
@includes = $contents =~ /(#include\s*["<][^">]+[">])/g ;
# The next loop finds all of the function entry points in the file.
while ( $contents =~ /
(?:(auto|register|static|extern)\s+)? # optional keywords = $1
(?:(enum|class|struct|const|volatile|signed|unsigned|long|unsigned\s+long)\s+)? # optional keywords = $2
(\#?[A-Za-z]\w*|(?:[A-Za-z]\w*\s*<\s+[A-Za-z]\w*\s+>)) # type name = $3
([\*\s]+) # pointers or spaces = $4 (at least 1 space or pointer)
(\w[\:\-\w]*)\s* # function name = $5
\(\s* # open paren
([^)]*) # everything to close paren = $6
\) # close paren
\s*(\d+)?\s* # optional comment = $7
(?:(const|volatile)\s+)?\s* # optional const|volatile = $8
(throw\s*\(.*?\))?\s* # optional throw
(?:\d+\s*)* # extra comments discarded
{ # open brace , balance }
/sgx ) {
my $return_type = $1 ;
$return_type .= ( $return_type eq "" ) ? $2 : " $2" ;
$return_type .= ( $return_type eq "" ) ? $3 : " $3" ;
my $pointers = $4 ;
if ( $pointers ne "" ) {
$pointers =~ s/(^\s+|\s+$)//g ;# remove leading & trailing whitespaces
$pointers = " $pointers" ;
}
$return_type .= $pointers ;
my $name = $5 ;
my $raw_args = $6 ;
$raw_args .= " $7" if ( $7 ne "" ) ;
# skip this entry point because it's actulally a macro
next if ( $return_type =~ /\#/ ) ;
if ( $name eq "if" or $name eq "for" or
$name eq "while" or $name eq "switch" or
$name eq "do" or $name =~ /operator[^\w]/ ) {
next ;
}
else {
push @entries , { 'return_type' => $return_type ,
'name' => $name ,
'file_name' => $curr_file ,
'raw_args' => $raw_args ,
'language' => $language } ;
}
}
$num_valid_entries = 0 ;
foreach $entry (@entries) {
trick_print($$sim_ref{fh}, " Processing $$entry{name}\n" , "debug_cyan" , $$sim_ref{args}{v}) ;
if ( process_args ($entry, \@comments, 6 , $sim_ref) == 0 ) {
add_proto_to_cat( $entry , $sim_ref , 6 ) ;
$num_valid_entries++;
}
}
if ( $num_valid_entries eq 0 ) {
trick_print($$sim_ref{fh}, " WARNING: No entry points found\n", "debug_yellow" , $$sim_ref{args}{v});
}
else {
print_xml_mis($curr_file , \@entries , \%header, \@includes) ;
}
}
sub process_args($$$$) {
my ($entry, $comments, $indent , $sim_ref) = @_ ;
my ($entry_comment , $hdr_comment ) ;
my @arg_list ;
$hdr_comment = -1 ;
$$entry{valid} = 0 ;
# clear out leading spaces
$$entry{raw_args} =~ s/^\s+//s ;
$$entry{raw_args} =~ s/\s+(\*+)/$1 /g ;
if ($$entry{raw_args} =~ s/^\s*(\d+)\s*//s ) {
$entry_comment = $1 ;
$hdr_comment = $entry_comment - 1 ;
($$entry{units} , $$entry{desc}) =
@$comments[$entry_comment] =~ /\s*RETURN:\s*(?:((?:[-*\/\w^|\.]+)|(?:\(.*?\))))\s+\s*(.*)/six ;
}
else {
$$entry{units} = "--" ;
$$entry{desc} = "Not Specified" ;
}
$$entry{raw_args} =~ s/^\s*void\s*$// ;
$$entry{class} = "" ;
while ( $$entry{class} eq "" and $hdr_comment >= 0 ) {
($$entry{class}) = @$comments[$hdr_comment] =~ /CLASS:.*?\(\s*([\w\/]+)/si ;
$hdr_comment -= 1 ;
}
if ( !(grep /^$$entry{class}$/ , @class_names )) {
$$entry{class} = "N/A" ;
}
my $arg_count = 1 ;
while ( $$entry{raw_args} =~ s/^(?:
(?:
((?:(?:enum|class|struct|const|volatile|signed|unsigned|long|unsigned\s+long)\s+)?.*?) # argument type = $1
(<.*?>)?\s* # c++ template = $2
(\**)\s+ # argument pointers = $3
(?:(const)\s+)?\s* # c++ const keyword = $4
(\&)?\s* # c++ reference symbol = $5
(\w+)?\s* # name (optional in c++ method decl.) = $6
(\[[^,=]*\])?\s* # optional array specs = $7
(\s*=\s*[\w\.]+)?[\s,]* # optional default value = $8
)
|
(\.\.\.)\s* # variable argument spec = $9
)
(\d+)?\s* # in|inout|out comment = $10
(?:\d+\s*)* # optional extra comments discarded
//six ) {
my %func_arg ;
my $comment_index ;
$func_arg{type} = $1 ;
$func_arg{cpp_template} = ( $2 ne "" ) ? $2 : "" ;
$func_arg{pointers} = ( $3 ne "" ) ? $3 : "" ;
$func_arg{cpp_const} = $4 ;
$func_arg{cpp_ref} = $5 ;
$func_arg{name} = ( $6 ne "" ) ? $6 : "" ;
$func_arg{array} = ( $7 ne "" ) ? $7 : "" ;
$func_arg{optional} = ( $8 ne "" ) ? 1 : 0 ;
$func_arg{type} = $9 if ( $9 ne "" ) ;
$comment_index = $10 ;
if ( $comment_index ne "" ) {
($func_arg{comment} = @$comments[$comment_index]) =~ s/(IN|INOUT|OUT):\s*// ;
( $func_arg{inout} , $func_arg{unit} , $func_arg{desc} ) =
@$comments[$comment_index] =~ /^\s*(?:(IN|INOUT|OUT):)?\s*
(?:((?:[-*\/\w^|\.]+)|(?:\(.*?\))))\s+
\s*(.*)
/six ;
}
else {
$func_arg{comment} = "-- Not specified" ;
$func_arg{inout} = "" ;
$func_arg{unit} = "--" ;
$func_arg{desc} = "Not specified" ;
}
trick_print($$sim_ref{fh}, " "x($indent+3) . "Arg $arg_count\n" , "debug_white" , $$sim_ref{args}{v} ) ;
trick_print($$sim_ref{fh}, " "x($indent+6) . "type = $func_arg{type} $func_arg{pointers} $func_arg{array}\n" ,
"debug_white" , $$sim_ref{args}{v} ) ;
trick_print($$sim_ref{fh}, " "x($indent+6) . "name = $func_arg{name}\n" , "debug_white" , $$sim_ref{args}{v} ) ;
trick_print($$sim_ref{fh}, " "x($indent+6) . "comm = $func_arg{comment}\n" , "debug_white" , $$sim_ref{args}{v} ) ;
$arg_count++ ;
push @arg_list , \%func_arg ;
}
if ( $$entry{raw_args} ne "" ) {
trick_print($$sim_ref{fh}, "Could not process argument for $entry->{name}\n" , "title_red" , $$sim_ref{args}{v} ) ;
trick_print($$sim_ref{fh}, "Last Read:\n$entry->{args_list}\n" , "title_red" , $$sim_ref{args}{v} ) ;
return -1 ;
}
else {
# set the values to return
$$entry{valid} = 1 ;
@{$$entry{arg_list}} = @arg_list ;
}
return 0 ;
}
1;

View File

@ -1,412 +0,0 @@
package auto_doc;
# Note:
# Firefox 3 fails to process XSLT files if they are on the local hard drive plus
# outside of the current XML file's path (or descendant paths). Users may need
# to edit $HOME/.mozilla/firefox/*.default/prefs.js and add a new URI setting:
# - user_pref("security.fileuri.strict_origin_policy", false);
# OR
# - type about:config in the address bar
# - change security.fileuri.strict_origin_policy to false
use Exporter();
@ISA = qw(Exporter);
@EXPORT = qw(print_xml_CP print_xml_mis print_xml_icg);
use File::Basename;
use Text::Balanced qw ( extract_bracketed );
use strict;
use gte;
my(%default_data_files, %object_jobs, @object_names, %jobs, %object_structs, $vt_ref);
sub print_xml_CP($)
{
my($sim_ref) = @_;
my $title;
# Get the title of the sim from the file "Title"
if (open TITLE, "Title") {
$title = <TITLE>;
chomp $title;
} else {
$title = "No Title Specified";
}
open XML_FILE, ">S_document.xml" or die "Could not open S_document.xml\n";
# Start the xml code
print_xml_xml_header("$ENV{TRICK_HOME}/docs/trick_s_define.xsl");
print XML_FILE "<s_define>\n";
print XML_FILE " " x 4, "<title>$title</title>\n";
# Given an array of simulation objects, sort array by 'objname' values
# foreach my $o (sort { ${$a}{objname} cmp ${$b}{objname} } @{$$sim_ref{objs}}) {
#
# print XML_FILE " " x 4, "<sim_object>\n";
#
# print XML_FILE " " x 8,
# "<sim_object_name>$$o{objname}</sim_object_name>\n\n";
#
# # printout the structures found in each object
# print XML_FILE " " x 8, "<structs>\n";
# # Given an array of structures per sim_object, sort array by 'strname' values
# foreach my $s (sort { ${$a}{strname} cmp ${$b}{strname} } @{$$o{structs}}) {
# print XML_FILE " " x 12, "<struct>\n";
# print XML_FILE " " x 16, "<struct_name>$$s{strname}</struct_name>\n";
# $$sim_ref{icg_types}{$$s{strname}}{files}{$$s{file}}{xml} =~ s/^TRICK_HOME\//$ENV{TRICK_HOME}\// ;
# print XML_FILE " " x 16, "<link>$$sim_ref{icg_types}{$$s{strname}}{files}{$$s{file}}{xml}</link>\n";
# print XML_FILE " " x 16, "<default_data>\n";
# foreach my $d (sort @{$$s{def_data}}) {
# print XML_FILE " " x 20, "<file>$d</file>\n";
# }
# print XML_FILE " " x 16, "</default_data>\n";
# print XML_FILE " " x 12, "</struct>\n";
# }
# print XML_FILE " " x 8, "</structs>\n\n";
#
# # print out each job found in this object
# print XML_FILE " " x 8, "<jobs>\n";
# # Given an array of jobs per sim_object, sort array by 'jobname' values
# foreach my $j (sort { ${$a}{jobname} cmp ${$b}{jobname} } @{$$o{jobs}}) {
# my ($file_name, $model_dir, $suffix) =
# fileparse( $$j{file}, ("\.h" , "\.hh" , "\.c" , "\.f", "\.cpp" , "\.cxx" , "\.C" , "\.cc" , "\.c\\+\\+" ));
# ($model_dir = $$j{file}) =~ s/(\/src)?\/([^\/]+)$// ;
# if ($model_dir =~ m/\/include$/ ){
# $model_dir =~ s/(\/include)?\/([^\/]+)$// ;
# }
# print XML_FILE " " x 12, "<job>\n";
# print XML_FILE " " x 16, "<job_name>$$j{jobname}</job_name>\n";
# print XML_FILE " " x 16, "<link>${model_dir}/xml/${file_name}${suffix}.xml</link>\n";
# print XML_FILE " " x 12, "</job>\n";
# }
# print XML_FILE " " x 8, "</jobs>\n";
# print XML_FILE " " x 4, "</sim_object>\n\n";
# }
print XML_FILE "</s_define>\n";
close XML_FILE ;
}
sub print_xml_mis ($$$$) {
my ($curr_file , $entries , $header_ptr, $includes) = @_ ;
my ($out_file_basename , $name , $path , $suffix, $file_path_dir ) ;
my %header = %$header_ptr ;
my ($xml_file , $xml_dir , $file_version ) ;
my ($subme , @inc_paths ) ;
my $i ;
$out_file_basename = $curr_file ;
($name, $path, $suffix) =
fileparse( $curr_file, ("\.h" , "\.hh" , "\.c" , "\.f", "\.cpp" , "\.cxx" , "\.C" , "\.cc" , "\.c\\+\\+" ));
$file_path_dir = dirname($curr_file) ;
if ($file_path_dir eq ".") {
$file_path_dir = cwd();
}
$file_path_dir =~ s/\/+$// ; # remove trailing slash
$path =~ s/\/+$// ; # remove trailing slash
if ($file_path_dir !~ /sim_services\/include/ and $file_path_dir =~ s/\/src$// ) {
$xml_file = $file_path_dir . "/xml/" . $name . $suffix . ".xml" ;
$xml_dir = $file_path_dir . "/xml" ;
}
else {
$xml_file = $path . "/xml/" . $name . $suffix . ".xml" ;
$xml_dir = $path . "/xml" ;
}
if ( ! -e $xml_dir ) {
mkdir $xml_dir, 0775 ;
}
$file_version = $file_path_dir ;
foreach $subme (@inc_paths) {
if ($file_version =~ s,^$subme/,, ) { # if found break out
last ;
}
}
open XML_FILE ,">$xml_file" or die "Couldn't open file for writing $xml_file\n" ;
print_xml_xml_header( "$ENV{TRICK_HOME}/docs/trick_module.xsl") ;
print_xml_body_header();
print_xml_trick_header($curr_file, \%header);
print XML_FILE " " x 4 , "<jobs>\n" ;
foreach my $entry (@$entries) {
if ( !exists $$entry{valid} ) {
next ;
}
print XML_FILE " " x 8 , "<job>\n" ;
print_xml_child("job_name", $$entry{name}, 12);
print_xml_child("return_type", $$entry{return_type}, 12);
print_xml_child("units", $$entry{units}, 12);
print_xml_child("comment", $$entry{desc}, 12);
print XML_FILE " " x 12 , "<argument_list>\n" ;
foreach my $arg ( @{$$entry{arg_list}} ) {
print XML_FILE " " x 16 , "<arg>\n" ;
print_xml_child("arg_name", $$arg{name}, 20);
print_xml_child("type", $$arg{type}, 20);
print_xml_child("dims", "$$arg{pointers} $$arg{array}", 20);
print_xml_child("inout", ucfirst lc $$arg{inout}, 20);
print_xml_child("units", $$arg{unit}, 20);
print_xml_child("comment", $$arg{desc}, 20);
print XML_FILE " " x 16 , "</arg>\n" ;
}
print XML_FILE " " x 12 , "</argument_list>\n" ;
print XML_FILE " " x 8 , "</job>\n" ;
}
print XML_FILE " " x 4 , "</jobs>\n" ;
print XML_FILE " " x 4 , "<includes>\n" ;
foreach (@$includes) {
s/</&lt;/g;
s/>/&gt;/g;
s/"/&quot;/g;
print XML_FILE " " x 8 , "<file>$_</file>\n";
}
print XML_FILE " " x 4 , "</includes>\n" ;
print_xml_body_footer();
close XML_FILE ;
}
sub print_xml_icg ($$$$$) {
my ($file_name, $xml_file, $header, $enums_info, $structs_info) = @_ ;
open XML_FILE ,">$xml_file" or die "Couldn't open file for writing $xml_file\n" ;
print_xml_xml_header( "$ENV{TRICK_HOME}/docs/trick_struct.xsl") ;
print_xml_body_header();
print_xml_trick_header( $file_name, $header) ;
# print the enums
print XML_FILE " " x 4 , "<enumerations>\n" ;
foreach my $pe_ret ( @$enums_info ) {
foreach my $enum ( @{$$pe_ret{enum_names}} ) {
print XML_FILE " " x 8 , "<enum>\n" ;
print XML_FILE " " x 12 , "<enum_name>$enum</enum_name>\n" ;
foreach my $name_val ( @{$$pe_ret{enums}} ) {
print XML_FILE " " x 12 , "<member>\n" ;
print XML_FILE " " x 16 , "<mname>$$name_val{name}</mname>\n" ;
print XML_FILE " " x 16 , "<value>$$name_val{value}</value>\n" ;
$$name_val{comment} =~ s/&/&amp;/g ;
$$name_val{comment} =~ s/\\?"/&quot;/g ;
$$name_val{comment} =~ s/</&lt;/g ;
$$name_val{comment} =~ s/>/&gt;/g ;
print XML_FILE " " x 16 , "<comment>$$name_val{comment}</comment>\n" ;
print XML_FILE " " x 12 , "</member>\n" ;
}
print XML_FILE " " x 8 , "</enum>\n" ;
}
}
print XML_FILE " " x 4 , "</enumerations>\n\n" ;
# print the structs
print XML_FILE " " x 4 , "<structures>\n" ;
foreach my $ps_ret ( @$structs_info ) {
foreach my $str ( @{$$ps_ret{struct_names}} ) {
print XML_FILE " " x 8 , "<struct>\n" ;
print XML_FILE " " x 12 , "<struct_name>$str</struct_name>\n" ;
foreach my $param ( @{$$ps_ret{param_info}} ) {
print XML_FILE " " x 12 , "<member>\n" ;
print XML_FILE " " x 16 , "<pname>$$param{p_name}</pname>\n" ;
print XML_FILE " " x 16 , "<type>$$param{p_type}</type>\n" ;
if ( $$param{p_link} ne "" ) {
$$param{p_link} =~ s/^TRICK_HOME\//$ENV{TRICK_HOME}\// ;
print XML_FILE " " x 16 , "<link>$$param{p_link}</link>\n" ;
}
if ( $$param{p_is_enum} ) {
print XML_FILE " " x 16 , "<is_enum>$$param{p_is_enum}</is_enum>\n" ;
}
print XML_FILE " " x 16 , "<dims>$$param{p_dim_xml}</dims>\n" ;
print XML_FILE " " x 16 , "<units>$$param{p_unit}</units>\n" ;
$$param{p_desc} =~ s/&/&amp;/g ;
$$param{p_desc} =~ s/\\?"/&quot;/g ;
$$param{p_desc} =~ s/</&lt;/g ;
$$param{p_desc} =~ s/>/&gt;/g ;
print XML_FILE " " x 16 , "<comment>$$param{p_desc}</comment>\n" ;
print XML_FILE " " x 12 , "</member>\n" ;
}
print XML_FILE " " x 8 , "</struct>\n\n" ;
}
}
print XML_FILE " " x 4 , "</structures>\n\n" ;
print_xml_body_footer();
close XML_FILE ;
}
sub print_xml_xml_header($)
{
my ($xsl_file) = @_ ;
print XML_FILE "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" ;
print XML_FILE "<?xml-stylesheet type=\"text/xsl\" href=\"$xsl_file\"?>\n";
print XML_FILE "\n" ;
print XML_FILE "<!--Note:\n" ;
print XML_FILE " " x 4 , "Firefox 3 fails to process XSLT files if they are on the local hard drive\n" ;
print XML_FILE " " x 4 , "plus outside of the current XML file's path (or descendant paths). Users\n" ;
print XML_FILE " " x 4 , "may need to edit \$HOME/.mozilla/firefox/*.default/prefs.js and add a new\n" ;
print XML_FILE " " x 4 , "URI setting in order to properly view this file in a firefox browser:\n" ;
print XML_FILE " " x 4 , "- user_pref(\"security.fileuri.strict_origin_policy\", false);\n" ;
print XML_FILE " " x 4 , "OR\n" ;
print XML_FILE " " x 4 , "- type about:config in the address bar\n" ;
print XML_FILE " " x 4 , "- change security.fileuri.strict_origin_policy to false\n" ;
print XML_FILE "-->\n" ;
print XML_FILE "\n" ;
}
sub print_xml_body_header()
{
print XML_FILE "<file>\n" ;
}
sub print_xml_body_footer()
{
print XML_FILE "</file>\n" ;
}
sub print_xml_trick_header($$) {
my ($full_file_name, $header) = @_ ;
my ($tail_name, $path, $suffix) =
fileparse( $full_file_name, ("\.h" , "\.hh" , "\.c" , "\.f", "\.cpp" , "\.cxx" , "\.C" , "\.cc" , "\.c\\+\\+" ));
print_xml_child("file_name", "$tail_name$suffix", 4);
print_xml_child("full_path_file_name", $full_file_name, 4);
print XML_FILE " " x 4 , "<trick_header>\n" ;
print_xml_references($header);
print_xml_parent_children($header, "assumptions", "assumption", "assumptions and limitations");
print_xml_parent_children($header, "requirements", "requirement", "requirements");
print_xml_parent_children($header, "library_dependencies", "library_dependency", "libdep");
print_xml_parent_children($header, "purpose", "", "purpose");
print_xml_parent_children($header, "class", "", "class");
print_xml_programmers($header, "programmers", "programmer", "programmers");
print XML_FILE " " x 4 , "</trick_header>\n\n" ;
}
sub print_xml_parent_children($$$$) {
#
# Print:
# <xml parent name>
# <children xml nodes>
# </xml parent name>
my ($header_ptr, $xml_parent_name, $xml_child_name, $trick_name) = @_ ;
my %header = %$header_ptr ;
print XML_FILE " " x 8 , "<$xml_parent_name>" ;
if ( $xml_child_name ne "" ) {
print XML_FILE "\n" ;
}
foreach my $h ( keys %header ) {
my @list ;
@list = split /\)[ \t\n]*\(/ , $header{$h} ;
foreach my $ll ( @list ) {
if ( $h eq $trick_name ) {
print_xml_child($xml_child_name, $ll, 12);
}
}
}
if ( $xml_child_name ne "" ) {
print XML_FILE " " x 8 , "</$xml_parent_name>\n" ;
} else {
print XML_FILE "</$xml_parent_name>\n" ;
}
}
sub print_xml_child($$$) {
# Print a child xml node
# <child_name>
# value
# </child_name>
my ($xml_name, $value, $indent_level) = @_ ;
$value =~ s/\(|\)//g ;
$value =~ s/&/&amp;/g ;
$value =~ s/\\?"/&quot;/g ;
$value =~ s/</&lt;/g ;
$value =~ s/>/&gt;/g ;
$value =~ s/\n/ /g ;
$value =~ s/[ ]+/ /g ;
$value =~ s/\s\s+/ /g ;
if ( $xml_name ne "" ) {
print XML_FILE " " x $indent_level , "<$xml_name>" ;
}
print XML_FILE " $value " ;
if ( $xml_name ne "" ) {
print XML_FILE "</$xml_name>\n" ;
}
}
sub print_xml_references($) {
my ($header_ptr) = @_ ;
my %header = %$header_ptr ;
my $idx = 0 ;
print XML_FILE " " x 8 , "<references>\n" ;
my @list ;
my ($temp , $ref) ;
$temp = $header{"reference"} ;
$temp =~ s/^\(// ;
do {
($ref, $temp) = extract_bracketed($temp,"()");
if ( $ref ne "" ) {
@list = split /\)[ \t\n]*\(/ , $ref ;
print XML_FILE " " x 12 , "<reference>\n" ;
print_xml_child("author", @list[0], 16) ;
print_xml_child("source", @list[1], 16) ;
print_xml_child("ident", @list[2], 16) ;
print_xml_child("location", @list[3], 16) ;
print_xml_child("date", @list[4], 16) ;
print_xml_child("notes", @list[5], 16) ;
print XML_FILE " " x 12 , "</reference>\n" ;
$idx = $idx + 6 ;
}
} while ( $ref ne "" ) ;
print XML_FILE " " x 8 , "</references>\n" ;
}
sub print_xml_programmers($) {
my ($header_ptr) = @_ ;
my %header = %$header_ptr ;
my $idx = 0 ;
print XML_FILE " " x 8 , "<modifications>\n" ;
foreach my $h ( keys %header ) {
my @list ;
@list = split /\)[ \t\n]*\(/ , $header{$h} ;
if ( $h eq "programmers" ) {
while ( $idx <= $#list ) {
print XML_FILE " " x 12 , "<modification>\n" ;
print_xml_child("programmer", @list[$idx + 0], 16) ;
print_xml_child("employer", @list[$idx + 1], 16) ;
print_xml_child("date", @list[$idx + 2], 16) ;
print_xml_child("ident", @list[$idx + 3], 16) ;
print_xml_child("notes", @list[$idx + 4], 16) ;
print XML_FILE " " x 12 , "</modification>\n" ;
$idx = $idx + 5 ;
}
}
}
print XML_FILE " " x 8 , "</modifications>\n" ;
}
1;

View File

@ -1,110 +0,0 @@
package get_headers ;
use Exporter ();
@ISA = qw(Exporter);
@EXPORT = qw(get_headers);
use File::Basename ;
use strict ;
use Cwd 'abs_path';
my ( @inc_paths , @valid_inc_paths ) ;
my %immediate_includes ;
my %visited_files ;
sub parse_file($$) {
my ($file_name, $sim_ref) = @_ ;
my $curr_path ;
if ( ! exists $visited_files{$file_name} ) {
$visited_files{$file_name} = 1 ;
$curr_path = dirname($file_name) ;
open my $fh, $file_name or warn "Could not open file $file_name" ;
while ( <$fh> ) {
if ( /^\s*#\s*include\s+\"(.*)\"/ ) {
#print "$1\n" ;
my ($include_file) = $1 ;
my $include_file_full_path ;
if ( -e "$curr_path/$include_file") {
$include_file_full_path = abs_path(dirname("$curr_path/$include_file")) . "/" . basename("$include_file");
$immediate_includes{$file_name}{$include_file_full_path} = 1 ;
#print "1 $include_file_full_path\n" ;
parse_file( $include_file_full_path , $sim_ref );
} else {
my ($found) = 0 ;
foreach my $p ( @inc_paths ) {
if ( -e "$p/$include_file" || -e "$include_file" ) {
if ( -e "$p/$include_file" ) {
$include_file_full_path = abs_path(dirname("$p/$include_file")) . "/" . basename("$include_file");
} else {
$include_file_full_path = $include_file ;
}
#print "2 $include_file_full_path\n" ;
$immediate_includes{$file_name}{$include_file_full_path} = 1 ;
$found = 1 ;
parse_file( $include_file_full_path , $sim_ref );
last ;
}
}
if ( $found == 0 ) {
#print "could not file $include_file in $file_name\n" ;
}
}
} elsif ( /ICG:/i ) {
my ($line) = $_ ;
my ($next_line) ;
do {
$next_line = <$fh> ;
$line .= $next_line ;
} while ( $next_line =~ /^\s*$/ and !eof($fh) ) ;
if ( $line =~ /\(\s*No\s*\)/si ) {
#print "ICG no found in $file_name\n" ;
$$sim_ref{icg_no}{$file_name} = 1 ;
}
}
}
}
}
sub get_all_includes($$$) {
my ($sim_ref , $top_file , $curr_file ) = @_ ;
foreach my $f ( keys %{$immediate_includes{$curr_file}} ) {
if ( ! exists $$sim_ref{all_includes}{$top_file}{$f} ) {
$$sim_ref{all_includes}{$top_file}{$f} = 1 ;
get_all_includes( $sim_ref , $top_file , $f ) ;
}
}
}
sub get_headers($$) {
my ( $sim_ref, $top_file ) = @_ ;
@inc_paths = $ENV{"TRICK_CFLAGS"} =~ /-I\s*(\S+)/g ; # get include paths from TRICK_CFLAGS
push @inc_paths , "$ENV{TRICK_HOME}/trick_source" ;
push @inc_paths , "../include" ;
# Get only the include paths that exist
foreach (@inc_paths) {
push @valid_inc_paths , $_ if ( -e $_ ) ;
}
@inc_paths = @valid_inc_paths ;
parse_file($top_file, $sim_ref) ;
# make hash of all downward files that are included by $f
foreach my $f ( keys %immediate_includes ) {
get_all_includes($sim_ref , $f , $f) ;
}
# get all file modification times. The hash of $top_file plus S_source.hh constitute all include files
foreach my $f ( (keys %{$$sim_ref{all_includes}{$top_file}}) , $top_file ) {
$$sim_ref{mod_date}{$f} = (stat $f)[9] ;
}
}
1 ;

View File

@ -1,304 +0,0 @@
package mis_dep ;
use Exporter ();
@ISA = qw(Exporter);
@EXPORT = qw(mis_dep mis_catalog_dep traverse_tree);
use Cwd ;
use File::Basename ;
use strict ;
use Cwd 'abs_path';
use File::Path 'make_path';
use trick_print ;
use gte ;
my @mis_inc_paths ;
my %processed_files ;
my %mis_depends_tree ;
# Get TRICK_CFLAGS and parse out -I include paths
sub mis_dep ($@) {
my $file ;
my %all_depend_trees ;
my ($k , $a) ;
my ($sim_ref , @fileList) = @_;
@mis_inc_paths = $ENV{"TRICK_CFLAGS"} =~ /-I\s*(\S+)/g ;
push @mis_inc_paths , "../include" ;
@mis_inc_paths = grep !/trick_source/, @mis_inc_paths ;
push @mis_inc_paths , "$ENV{TRICK_HOME}/trick_source" ;
my @valid_inc_paths ;
foreach (@mis_inc_paths) {
push @valid_inc_paths , $_ if ( -e $_ ) ;
}
@mis_inc_paths = @valid_inc_paths ;
@fileList = grep !/\.h$|\.H$|\.hh$|\.h\+\+$/ , @fileList ;
#open FL, ">build/S_source.fl" ;
#foreach $file ( @fileList ) {
# if ( $file ne "" ) {
# $file = abs_path(dirname($file)) . "/" . basename($file) ;
# print FL "$file\n" ;
# }
#}
#close FL ;
foreach $file ( @fileList ) {
if ( $file ne "" ) {
undef %mis_depends_tree ;
$file = abs_path(dirname($file)) . "/" . basename($file) ;
trick_print($$sim_ref{fh}, "Getting dependencies for $file\n" , "normal_cyan" , $$sim_ref{args}{v}) ;
get_depends($file, $sim_ref);
%{$all_depend_trees{$file}} = %mis_depends_tree ;
$all_depend_trees{$file}{last_look} = time ;
#my @file_list ;
#my %temp_hash ;
#my ( $name, $path, $suffix) = fileparse($file,, qr/\.[^.]*/);
#make_path("build" . $path) ;
#open FL, ">build$path/${name}.lib_deps" ;
#@file_list = grep ++$temp_hash{$_} < 2, @{$mis_depends_tree{$file}} ;
#print FL map { "$_\n" } @file_list ;
#close FL ;
}
}
return \%all_depend_trees ;
}
sub traverse_tree {
my ($file, $level, %curr_tree) = @_ ;
my $a ;
print " " x $level , $file , "\n";
foreach $a ( @{$curr_tree{$file}} ) {
if ( $a ne $file ) {
traverse_tree($a, $level+1, %curr_tree) ;
}
}
}
# Show Depends Recursive Algorithm
sub get_depends($$) {
my $file ;
my $sim_ref ;
my @list_objects ;
my @list_libs ;
my $found_dep ;
my @lib_list ;
my $contents ;
my $size ;
my $libdep ;
my $language ;
my ( $full_path ) ;
my ($rcs_file_name, $rcs_ver, $rcs_date, $rcs_owner ) ;
($file, $sim_ref) = @_;
# If you have already seen this dependency, then don't process
# Trim the tree ! And prevent infinite circular recursion !!! Yikes ...
return if ( exists $processed_files{$file} ) ;
# Add this file to processed list, if it is a full path
$processed_files{$file} = 1 ;
open FILE, $file or die "Could not process $file\n";
seek FILE , 0 , 2 ;
$size = tell FILE ;
seek FILE , 0 , 0 ;
read FILE , $contents , $size;
close(FILE);
while ( $contents =~ /LIBRARY(\s|_)DEPENDENC(Y|IES):[^(]*(.*?)\)([A-Z \t\n\r]+:|[ \t\n\r]*\*)/gsi ) {
$libdep .= $3 ;
}
if ( $libdep =~ /#/ ) {
(my $cc = gte("TRICK_CC")) =~ s/\n// ;
my @defines = $ENV{"TRICK_CFLAGS"} =~ /(-D\S+)/g ;
my $temp ;
open FILE, "echo \"$libdep\" | cpp -P @defines |" ;
while ( <FILE> ) {
$temp .= $_ ;
}
$libdep = $temp ;
}
@lib_list = split /\)[ \t\n\r\*]*\(/ , $libdep ;
foreach (@lib_list) {
s/\(|\)|\s+//g ;
s/\${(.+?)}/$ENV{$1}/eg ;
}
@list_objects = grep /\.o$/ , @lib_list ;
@list_libs = grep /\.so$|\.a$/ , @lib_list ;
# Always add self-dependency
push @{$mis_depends_tree{$file}} , $file ;
# Now for each object, construct full path to object's src and find src file
foreach my $o (@list_objects) {
# look for object code with source
$found_dep = find_depends_file($file,$o,$sim_ref) ;
# Did not find dependency
if ( $found_dep == 0 ) {
$o =~ s/\.[\w\+]+$/\.o/ ;
trick_print($$sim_ref{fh}, "ERROR: Dependency \"$o\" not found for \"$file\"\n", "title_red" , $$sim_ref{args}{v}) ;
exit( -1 ) ;
}
}
# Now for each lib, construct full path to lib's src and add to list
foreach my $l ( @list_libs ) {
my ($rel_path , $lib_name ) ;
($rel_path , $lib_name ) = $l =~ /(?:(.*)\/)?([^\/]+)/ ;
if ($rel_path eq "") {
$found_dep = 1 ;
$lib_name =~ s,lib,,;
$lib_name =~ s,\.so$|\.a$,,;
$processed_files{"-l$lib_name"} = 1 ;
push @{$mis_depends_tree{$file}} , "-l$lib_name" ;
trick_print($$sim_ref{fh}, " $lib_name\n" , "debug_white" , $$sim_ref{args}{v}) ;
} else {
$found_dep = 0 ;
foreach my $ipath ( @mis_inc_paths ) {
# Construct possible full paths to lib dir from include paths
$full_path = $ipath . "/" . $rel_path;
if ( -s $full_path ) {
$found_dep = 1;
$lib_name = $full_path ."/object_\${TRICK_HOST_CPU}/". $lib_name ;
# remove ../
while ( $lib_name =~ s,/[^/]+/\.\.,, ) {}
push @{$mis_depends_tree{$file}} , $lib_name ;
trick_print($$sim_ref{fh}, " $lib_name\n" , "debug_white" , $$sim_ref{args}{v}) ;
$processed_files{$lib_name} = 1 ;
last;
}
}
}
# Did not find dependency
if ( $found_dep == 0 ) {
trick_print($$sim_ref{fh}, "ERROR: Dependency $l not found for $file\n", "title_red" , $$sim_ref{args}{v}) ;
exit( -1 ) ;
}
}
}
sub find_depends_file($$$) {
my ($file, $o , $sim_ref) ;
my @list_languages ;
my $lex_yacc ;
my ( $full_path , $full_path1 , $full_path2 ) ;
my ( $curr_path ) ;
my ( $dep_to_search ) ;
($file , $dep_to_search, $sim_ref) = @_;
$o = $dep_to_search ;
$curr_path = dirname($file) ;
# Decide how to search through languages
opendir THISDIR, $curr_path or die "Could not open the directory of $curr_path" ;
$lex_yacc = grep /\.[ly]$/ , readdir THISDIR ;
if ( $lex_yacc ) {
@list_languages = ("y", "l", "c", "cpp" , "cc" , "cxx" , "C" , "c\+\+");
}
else {
@list_languages = ("c", "cpp" , "cc" , "cxx" , "C" , "c\+\+", "y", "l");
}
# Otherwise use TRICK_CFLAGS and find it
if ( $dep_to_search !~ /\.o$/ ) {
foreach my $ipath ( $curr_path , @mis_inc_paths ) {
if ( -s "$ipath/$dep_to_search" ) {
my $f = "$ipath/$dep_to_search" ;
$full_path = abs_path(dirname($f)) . "/" . basename($f) ;
push @{$mis_depends_tree{$file}} , $full_path ;
trick_print($$sim_ref{fh}, " $full_path\n" , "debug_white" , $$sim_ref{args}{v}) ;
get_depends($full_path , $sim_ref);
return(1) ;
}
}
} else {
foreach my $ipath ( $curr_path , @mis_inc_paths ) {
foreach my $lang ( @list_languages ) {
my $found_dep ;
my ($file_name ) ;
my ($dir_name ) ;
my ($rspath , $rpath ) ;
$o =~ s/\.[\w\+]+$/\.$lang/ ;
#
# Construct possible full paths to src from include paths
#
$file_name = basename($o) ;
$dir_name = dirname($o) ;
# if full path sepcified (possible, but not recommended)
# don't prepend include path.
if ( $dir_name =~ /^\// ) {
$full_path1 = "$dir_name/src/$file_name" ;
$full_path2 = "$dir_name/$file_name" ;
}
else {
$full_path1 = "$ipath/$dir_name/src/$file_name" ;
$full_path2 = "$ipath/$dir_name/$file_name" ;
}
$found_dep = 0;
# Construct full path
if ( -s $full_path1 ) {
$full_path = abs_path(dirname($full_path1)) . "/" . basename($full_path1) ;
$found_dep = 1;
}
elsif ( -s $full_path2 ) {
$full_path = abs_path(dirname($full_path2)) . "/" . basename($full_path2);
$found_dep = 1;
}
if ( $found_dep == 1 ) {
push @{$mis_depends_tree{$file}} , $full_path ;
trick_print($$sim_ref{fh}, " $full_path\n" , "debug_white" , $$sim_ref{args}{v}) ;
if ( $lang eq "y" ) {
($full_path1 = $full_path ) =~ s/\.y$/\.l/ ;
push @{$mis_depends_tree{$file}} , $full_path1 ;
}
get_depends($full_path , $sim_ref);
return(1);
}
}
}
}
return(0) ;
}
sub mis_catalog_dep ($$) {
return ;
}
1;

View File

@ -12,7 +12,6 @@ use Cwd 'abs_path';
use IPC::Open3 ;
use lib $ENV{"TRICK_HOME"} . "/bin/pm" ;
use ICG ;
use edit ;
use find_module ;
use gte ;

View File

@ -1,410 +0,0 @@
package trick_units ;
%units_info = (
"s" => ["seconds", "Standard", "Time"],
"ps" => ["pico-seconds", "Standard", "Time"],
"ns" => ["nano-seconds", "Standard", "Time"],
"us" => ["micro-seconds", "Standard", "Time"],
"ms" => ["milli-seconds", "Standard", "Time"],
"cs" => ["centi-seconds", "Standard", "Time"],
"ds" => ["deci-seconds", "Standard", "Time"],
"das" => ["deca-seconds", "Standard", "Time"],
"hs" => ["hecto-seconds", "Standard", "Time"],
"ks" => ["kilo-seconds", "Standard", "Time"],
"Ms" => ["mega-seconds", "Standard", "Time"],
"Gs" => ["giga-seconds", "Standard", "Time"],
"Ts" => ["tera-seconds", "Standard", "Time"],
"min" => ["minutes", "Standard", "Time"],
"hr" => ["hours", "Standard", "Time"],
"day" => ["days", "Standard", "Time"],
"m" => ["meters", "Metric", "Length"],
"M" => ["meters", "Metric", "Length"],
"pm" => ["pico-meters", "Metric", "Length"],
"nm" => ["nano-meters", "Metric", "Length"],
"um" => ["micro-meters", "Metric", "Length"],
"mm" => ["milli-meters", "Metric", "Length"],
"cm" => ["centi-meters", "Metric", "Length"],
"dm" => ["deci-meters", "Metric", "Length"],
"dam" => ["deca-meters", "Metric", "Length"],
"hm" => ["hecto-meters", "Metric", "Length"],
"km" => ["kilo-meters", "Metric", "Length"],
"Mm" => ["mega-meters", "Metric", "Length"],
"Gm" => ["giga-meters", "Metric", "Length"],
"Tm" => ["tera-meters", "Metric", "Length"],
"ft" => ["feet", "English", "Length"],
"kft" => ["kilo-feet", "English", "Length"],
"in" => ["inches", "English", "Length"],
"yd" => ["yards", "English", "Length"],
"mi" => ["miles", "English", "Length"],
"n.m." => ["nautical-miles", "English", "Length"],
"r" => ["radians", "Standard", "Angle"],
"pr" => ["pico-radians", "Standard", "Angle"],
"nr" => ["nano-radians", "Standard", "Angle"],
"ur" => ["micro-radians", "Standard", "Angle"],
"mr" => ["milli-radians", "Standard", "Angle"],
"cr" => ["centi-radians", "Standard", "Angle"],
"dr" => ["deci-radians", "Standard", "Angle"],
"dar" => ["deca-radians", "Standard", "Angle"],
"kr" => ["kilo-radians", "Standard", "Angle"],
"Mr" => ["mega-radians", "Standard", "Angle"],
"Gr" => ["giga-radians", "Standard", "Angle"],
"Tr" => ["tera-radians", "Standard", "Angle"],
"d" => ["degrees", "Standard", "Angle"],
"as" => ["arc-seconds", "Standard", "Angle"],
"am" => ["arc-minutes", "Standard", "Angle"],
"rev" => ["revolutions", "Standard", "Angle"],
"g" => ["grams", "Metric", "Mass"],
"pg" => ["pico-grams", "Metric", "Mass"],
"ng" => ["nano-grams", "Metric", "Mass"],
"ug" => ["micro-grams", "Metric", "Mass"],
"mg" => ["milli-grams", "Metric", "Mass"],
"cg" => ["centi-grams", "Metric", "Mass"],
"dg" => ["deci-grams", "Metric", "Mass"],
"dag" => ["deca-grams", "Metric", "Mass"],
"hg" => ["hecto-grams", "Metric", "Mass"],
"kg" => ["kilo-grams", "Metric", "Mass"],
"Mg" => ["mega-grams", "Metric", "Mass"],
"Gg" => ["giga-grams", "Metric", "Mass"],
"Tg" => ["tera-grams", "Metric", "Mass"],
"mt" => ["metric-tons", "Metric", "Mass"],
"sl" => ["slugs", "English", "Mass"],
"lbm" => ["pound(mass)", "English", "Mass"],
"N" => ["newtons", "Metric", "Force"],
"pN" => ["pico-newtons", "Metric", "Force"],
"nN" => ["nano-newtons", "Metric", "Force"],
"uN" => ["micro-newtons", "Metric", "Force"],
"mN" => ["milli-newtons", "Metric", "Force"],
"cN" => ["centi-newtons", "Metric", "Force"],
"dN" => ["deci-newtons", "Metric", "Force"],
"daN" => ["deca-newtons", "Metric", "Force"],
"hN" => ["hecto-newtons", "Metric", "Force"],
"kN" => ["kilo-newtons", "Metric", "Force"],
"MN" => ["mega-newtons", "Metric", "Force"],
"GN" => ["giga-newtons", "Metric", "Force"],
"TN" => ["tera-newtons", "Metric", "Force"],
"oz" => ["ounzes", "English", "Force"],
"lbf" => ["pound(force)", "English", "Force"],
"v" => ["volts", "Standard", "Voltage"],
"pv" => ["pico-volts", "Standard", "Voltage"],
"nv" => ["nano-volts", "Standard", "Voltage"],
"uv" => ["micro-volts", "Standard", "Voltage"],
"mv" => ["milli-volts", "Standard", "Voltage"],
"cv" => ["centi-volts", "Standard", "Voltage"],
"dv" => ["deci-volts", "Standard", "Voltage"],
"dav" => ["deca-volts", "Standard", "Voltage"],
"hv" => ["hecto-volts", "Standard", "Voltage"],
"kv" => ["kilo-volts", "Standard", "Voltage"],
"Mv" => ["mega-volts", "Standard", "Voltage"],
"Gv" => ["giga-volts", "Standard", "Voltage"],
"Tv" => ["tera-volts", "Standard", "Voltage"],
"amp" => ["amperes", "Standard", "Current"],
"pamp" => ["pico-amperes", "Standard", "Current"],
"namp" => ["nano-amperes", "Standard", "Current"],
"uamp" => ["micro-amperes", "Standard", "Current"],
"mamp" => ["milli-amperes", "Standard", "Current"],
"camp" => ["centi-amperes", "Standard", "Current"],
"damp" => ["deci-amperes", "Standard", "Current"],
"daamp" => ["deca-amperes", "Standard", "Current"],
"hamp" => ["hecto-amperes", "Standard", "Current"],
"kamp" => ["kilo-amperes", "Standard", "Current"],
"Mamp" => ["mega-amperes", "Standard", "Current"],
"Gamp" => ["giga-amperes", "Standard", "Current"],
"Tamp" => ["tera-amperes", "Standard", "Current"],
"ohm" => ["ohms", "Standard", "Resistance"],
"pohm" => ["pico-ohms", "Standard", "Resistance"],
"nohm" => ["nano-ohms", "Standard", "Resistance"],
"uohm" => ["micro-ohms", "Standard", "Resistance"],
"mohm" => ["milli-ohms", "Standard", "Resistance"],
"cohm" => ["centi-ohms", "Standard", "Resistance"],
"dohm" => ["deci-ohms", "Standard", "Resistance"],
"daohm" => ["deca-ohms", "Standard", "Resistance"],
"hohm" => ["hecto-ohms", "Standard", "Resistance"],
"kohm" => ["kilo-ohms", "Standard", "Resistance"],
"Mohm" => ["mega-ohms", "Standard", "Resistance"],
"Gohm" => ["giga-ohms", "Standard", "Resistance"],
"Tohm" => ["tera-ohms", "Standard", "Resistance"],
"C" => ["degrees-celsius", "Metric", "Temperature"],
"K" => ["degrees-kelvin", "Metric", "Temperature"],
"F" => ["degrees-fahrenheit", "English", "Temperature"],
"R" => ["degrees-rankine", "English", "Temperature"],
"dB" => ["decibels", "Standard", "Sound"],
"J" => ["joule", "Metric", "Energy"],
"pJ" => ["pico-joule", "Metric", "Energy"],
"nJ" => ["nano-joule", "Metric", "Energy"],
"uJ" => ["micro-joule", "Metric", "Energy"],
"mJ" => ["milli-joule", "Metric", "Energy"],
"cJ" => ["centi-joule", "Metric", "Energy"],
"dJ" => ["deci-joule", "Metric", "Energy"],
"daJ" => ["deca-joule", "Metric", "Energy"],
"hJ" => ["hecto-joule", "Metric", "Energy"],
"kJ" => ["kilo-joule", "Metric", "Energy"],
"MJ" => ["mega-joule", "Metric", "Energy"],
"GJ" => ["giga-joule", "Metric", "Energy"],
"TJ" => ["tera-joule", "Metric", "Energy"],
"BTU" => ["british-thermal", "English", "Energy"],
"TNT" => ["ton-tnt", "English", "Energy"],"MHz" => ["mega-hertz", "Metric", "Frequency"],
"GHz" => ["giga-hertz", "Metric", "Frequency"],
"THz" => ["tera-hertz", "Metric", "Frequency"],
"W" => ["watt", "Metric", "Power"],
"pW" => ["pico-watt", "Metric", "Power"],
"nW" => ["nano-watt", "Metric", "Power"],
"uW" => ["micro-watt", "Metric", "Power"],
"mW" => ["milli-watt", "Metric", "Power"],
"cW" => ["centi-watt", "Metric", "Power"],
"dW" => ["deci-watt", "Metric", "Power"],
"daW" => ["deca-watt", "Metric", "Power"],
"hW" => ["hecto-watt", "Metric", "Power"],
"kW" => ["kilo-watt", "Metric", "Power"],
"MW" => ["mega-watt", "Metric", "Power"],
"GW" => ["giga-watt", "Metric", "Power"],
"TW" => ["tera-watt", "Metric", "Power"],
"hp" => ["horse-power", "English", "Power"],
"Pa" => ["pascal", "Metric", "Pressure"],
"pPa" => ["pico-pascal", "Metric", "Pressure"],
"nPa" => ["nano-pascal", "Metric", "Pressure"],
"uPa" => ["micro-pascal", "Metric", "Pressure"],
"mPa" => ["milli-pascal", "Metric", "Pressure"],
"cPa" => ["centi-pascal", "Metric", "Pressure"],
"dPa" => ["deci-pascal", "Metric", "Pressure"],
"daPa" => ["deca-pascal", "Metric", "Pressure"],
"hPa" => ["hecto-pascal", "Metric", "Pressure"],
"kPa" => ["kilo-pascal", "Metric", "Pressure"],
"MPa" => ["mega-pascal", "Metric", "Pressure"],
"GPa" => ["giga-pascal", "Metric", "Pressure"],
"TPa" => ["tera-pascal", "Metric", "Pressure"],
"psi" => ["pounds-sq-inch", "English", "Pressure"],
"atm" => ["atmospheres", "Metric", "Pressure"],
"mmHg" => ["milli-meters-mercury", "Metric", "Pressure"],
"inHg" => ["inches-mercury", "English", "Pressure"],
"mmWater" => ["milli-meters-water", "Metric", "Pressure"],
"inWater" => ["inches-water", "English", "Pressure"],
"l" => ["liter", "Metric", "Volume"],
"pl" => ["pico-liter", "Metric", "Volume"],
"nl" => ["nano-liter", "Metric", "Volume"],
"ul" => ["micro-liter", "Metric", "Volume"],
"ml" => ["milli-liter", "Metric", "Volume"],
"cl" => ["centi-liter", "Metric", "Volume"],
"dl" => ["deci-liter", "Metric", "Volume"],
"dal" => ["deca-liter", "Metric", "Volume"],
"hl" => ["hecto-liter", "Metric", "Volume"],
"kl" => ["kilo-liter", "Metric", "Volume"],
"Ml" => ["mega-liter", "Metric", "Volume"],
"Gl" => ["giga-liter", "Metric", "Volume"],
"Tl" => ["tera-liter", "Metric", "Volume"],
"gal" => ["gallon", "English", "Volume"],
"floz" => ["fluid-ounce", "English", "Volume"],
"--" => ["<Unitless>", "Standard", "Unitless"],
"cnt" => ["<Unitless>", "Standard", "Unitless"],
"1" => ["<Unitless>", "Standard", "Unitless"],
"one" => ["<Unitless>", "Standard", "Unitless"],
"mol" => ["<Unitless>", "Standard", "Unitless"],
"Hz" => ["hertz", "Metric", "Frequency"],
"pHz" => ["pico-hertz", "Metric", "Frequency"],
"nz" => ["nano-hertz", "Metric", "Frequency"],
"uHz" => ["micro-hertz", "Metric", "Frequency"],
"mHz" => ["milli-hertz", "Metric", "Frequency"],
"cHz" => ["centi-hertz", "Metric", "Frequency"],
"dHz" => ["deci-hertz", "Metric", "Frequency"],
"daHz" => ["deca-hertz", "Metric", "Frequency"],
"hHz" => ["hecto-hertz", "Metric", "Frequency"],
"kHz" => ["kilo-hertz", "Metric", "Frequency"],
"MHz" => ["mega-hertz", "Metric", "Frequency"],
"GHz" => ["giga-hertz", "Metric", "Frequency"],
"THz" => ["tera-hertz", "Metric", "Frequency"],
);
sub list_units {
foreach $unit_primitive ( sort ( keys %units_info ) ) {
printf ( STDOUT "\"%s\" means \"%s\", a %s unit of %s.\n",
$unit_primitive,
$units_info{$unit_primitive}[0],
$units_info{$unit_primitive}[1],
$units_info{$unit_primitive}[2]
);
}
}
sub is_valid_primitive {
my ($unit_primitive) = @_;
if ( $units_info{$unit_primitive} ) {
return 1;
} else {
return 0;
}
}
sub validate_unit_spec {
my ($unit_spec) = @_;
my $warn_msg = "" ;
my @valid_parts = ();
# If the string starts with a parenthesis, then it is a release-07 dual units spec.
if ( $unit_spec =~ /^\(/ ) {
my @part_attrs = (0,0);
my @part_class = (0,0);
# Strip out right and left parens and whitespace.
$unit_spec =~ s/^\(|\s|\)$//g ;
$unit_spec =~ s/\^//g ;
# Split the dual unit spec into its metric and english parts.
@dual_unit_parts = split /\|/, $unit_spec ;
# There should be either one or two parts.
$number_of_parts = scalar( @dual_unit_parts );
if ( $number_of_parts == 1 ) {
for (my $ii = 0 ; $ii < $number_of_parts ; $ii ++ ) {
my $unit_factor;
# Split the unit spec, using '*' and '/' as delimiters.
my @unit_factors = split /\/|\*/ , $dual_unit_parts[$ii] ;
foreach $unit_factor ( @unit_factors ) {
# Substitute out any exponents unless it is just "1" all by itself.
$unit_factor =~ s/[1-3]+$//g if ( $unit_factor ne "1" );
$unit_system = $units_info{$unit_factor}[1];
if ( $unit_system eq "Metric") {
# The ii'th part contains metric primitives.
$part_attrs[$ii] |= 1 ;
} elsif ( $unit_system eq "Standard") {
# The ii'th part contains english primitives.
$part_attrs[$ii] |= 2;
} elsif ( $unit_system eq "English") {
# The ii'th part contains standard primitives.
$part_attrs[$ii] |= 4;
} else {
# The ii'th part contains stuff we dont recognize.
# It's broke.
$part_attrs[$ii] |= 8;
}
}
if ( $part_attrs[$ii] == 2 ) {
$part_class[$ii] = 1; # pure standard
} elsif ( $part_attrs[$ii] == 1 || $part_attrs[$ii] == 3 ) {
@part_class[$ii] = 2; # metric (possibly mixed with standard )"kHz" => ["kilo-hertz", "Metric", "Frequency"],
"pHz" => ["pico-hertz", "Metric", "Frequency"],
"nHz" => ["nano-hertz", "Metric", "Frequency"],
"uHz" => ["micro-hertz", "Metric", "Frequency"],
"mHz" => ["milli-hertz", "Metric", "Frequency"],
"cHz" => ["centi-hertz", "Metric", "Frequency"],
"dHz" => ["deci-hertz", "Metric", "Frequency"],
"daHz" => ["deca-hertz", "Metric", "Frequency"],
"hHz" => ["hecto-hertz", "Metric", "Frequency"],
"kHz" => ["kilo-hertz", "Metric", "Frequency"],
"MHz" => ["mega-hertz", "Metric", "Frequency"],
"GHz" => ["giga-hertz", "Metric", "Frequency"],
"THz" => ["tera-hertz", "Metric", "Frequency"],
} elsif ( $part_attrs[$ii] == 4 || $part_attrs[$ii] == 6 ) {
$part_class[$ii] = 3; # english (possibly mixed with standard )
} else {
$part_class[$ii] = 0; # invalid
}
if ( $part_class[$ii] ) {
push @valid_parts, $dual_unit_parts[$ii];
}
}
if ( $number_of_parts == scalar ( @valid_parts )) {
if ( $number_of_parts == 2 ) {
if ( ( $part_class[0] == $part_class[1] ) && ( $part_class[0] != 1 ) ) {
@valid_parts = ();
} elsif ( ($part_class[0] == 3) || ( ($part_class[0] == 1) && ($part_class[1] == 2) ) ) {
$temp = $valid_parts[0];
$valid_parts[0] = $valid_parts[1];
$valid_parts[1] = $temp;
}
}
} else {
@valid_parts = ();
}
}
elsif ( $number_of_parts == 2 ) {
$warn_msg = "Dual units are no longer supported" ;
return ($warn_msg , @valid_parts) ;
}
} else {
my ($orig_unit_spec) = $unit_spec ;
# Pre 07, old style units
$superset_units = "sl|rev" ;
$std_units = "1|s|M|r|kg|N|v|amp|ohm|C|dB|J|W|Pa|--" ;
$derived_units = "min|hr|day|ft|in|mm|cm|km|yd|mi|nm|n\.m\.|kft|d|as|am|mr|lbm|g|mt|kN|oz|lbf|kv|mamp|K|R|F|BTU|TNT|hp|psi|atm|cnt|one|mol|pJ|nJ|uJ|mJ|cJ
|dJ|daJ|hJ|kJ|MJ|GJ|TJ|pW|nW|uW|mW|cW|dW|daW|hW|kW|MW|GW|TW|Pa|pPa|nPa|uPa|mPa|cPa|dPa|daPa|hPa|kPa|MPa|GPa|TPa|pHz|nHz|uHz|mHz|cHz|dHz|daHz|hHz|kHz|MHz|GHz|THz" ;
my $first_product = 0;
my @elements = ();
$unit_spec =~ s/\*//g; # Remove any asterisks that may incorrectly represent an exponent/power.
$unit_spec =~ s/\^//g; # Remove any "^" that may incorrectly represent an exponent/power.
if ( $unit_spec =~ s/^1?\/// ) {
$first_product = 1;
push @elements, "1";
}
while ( $unit_spec =~ s/([^\/]+)(\/|$)// ) {
$unit_product = $1 ;
if ( !$first_product ) {"pHz" => ["pico-hertz", "Metric", "Frequency"],
"nHz" => ["nano-hertz", "Metric", "Frequency"],
"uHz" => ["micro-hertz", "Metric", "Frequency"],
"mHz" => ["milli-hertz", "Metric", "Frequency"],
"cHz" => ["centi-hertz", "Metric", "Frequency"],
"dHz" => ["deci-hertz", "Metric", "Frequency"],
"daHz" => ["deca-hertz", "Metric", "Frequency"],
"hHz" => ["hecto-hertz", "Metric", "Frequency"],
"kHz" => ["kilo-hertz", "Metric", "Frequency"],
"MHz" => ["mega-hertz", "Metric", "Frequency"],
"GHz" => ["giga-hertz", "Metric", "Frequency"],
"THz" => ["tera-hertz", "Metric", "Frequency"],
$first_product = 1;
} else {
push @elements, "/";
}
$unit_product =~ s/^(($superset_units|$std_units|$derived_units)([123]?))// ;
if ( $1 ne "" ) {
if ( $1 eq "nm" ) {
$warn_msg = " Units \"nm\" assumed to be nautical miles." .
" Please clarify by using \"n.m.\" or \"(n.m.)\". Use \"(nm)\" for nanometers." ;
push @elements, "n.m.";
}
else {
push @elements, $1;
}
while ( $unit_product =~ s/^(($superset_units|$std_units|$derived_units)([123]?))// ) {
push @elements, "*", $1;
}
} else {
# Units product contains no primitives at all. Not good.
@elements = (); last;
}
if ( $unit_product ne "" ) {
@elements = (); last;
}
}
$valid_parts[0] = join '', @elements;
# convert old "M" to standard "m"
$valid_parts[0] =~ s/M/m/g ;
if ( $valid_parts[0] eq "" ) {
$warn_msg = " No valid units found. If you are using \"m\" for meters, enclose the units in parenthesis. i.e. \"(m)\"\n" ;
$warn_msg .=" Defaulting units to \"--\" instead of \"$orig_unit_spec\"" ;
# Provide a default unit for validity
$valid_parts[0] = "--" ;
}
}
return ($warn_msg , @valid_parts) ;
}