Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perlmod / AnalyzeDiag / 1.07 / lib / site_perl / 5.8.0 / AnalyzeDiag / SymbolTable.pm
CommitLineData
86530b38
AT
1# ========== Copyright Header Begin ==========================================
2#
3# OpenSPARC T2 Processor File: SymbolTable.pm
4# Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved
5# 4150 Network Circle, Santa Clara, California 95054, U.S.A.
6#
7# * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8#
9# This program is free software; you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation; version 2 of the License.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program; if not, write to the Free Software
20# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21#
22# For the avoidance of doubt, and except that if any non-GPL license
23# choice is available it will apply instead, Sun elects to use only
24# the General Public License version 2 (GPLv2) at this time for any
25# software where a choice of GPL license versions is made
26# available with the language indicating that GPLv2 or any later version
27# may be used, or where a choice of which version of the GPL is applied is
28# otherwise unspecified.
29#
30# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
31# CA 95054 USA or visit www.sun.com if you need additional information or
32# have any questions.
33#
34# ========== Copyright Header End ============================================
35package AnalyzeDiag::SymbolTable;
36
37use strict;
38use warnings;
39use File::Spec;
40use IO::File;
41use Tie::IxHash;
42
43use AnalyzeDiag::Output;
44
45use fields qw(filename);
46
47###############################################################################
48
49sub create_from_dir {
50 my $class = shift;
51 my $dir = shift;
52
53 my $symtab = File::Spec->catfile($dir, 'symbol.tbl');
54 my $obj;
55 if(-e $symtab) {
56 $obj = AnalyzeDiag::SymbolTable->new();
57 $obj->filename($symtab);
58 } else {
59 script_die "Cannot find '$symtab'.\n";
60 }
61 return $obj;
62}
63
64###############################################################################
65
66sub new {
67 my $this = shift;
68
69 unless (ref $this) {
70 $this = fields::new($this);
71 }
72
73 return $this;
74}
75
76###############################################################################
77
78sub filename {
79 my $this = shift;
80 my $filename = shift;
81 $this->{filename} = $filename if defined $filename;
82 return $this->{filename};
83}
84
85###############################################################################
86
87sub get_vas_for_labels {
88 my $this = shift;
89 my $labellist = shift;
90
91 my $fh = IO::File->new($this->filename()) or
92 script_die "Can't open '". $this->filename() ."': $!\n";
93
94 tie my %labels, 'Tie::IxHash';
95 foreach my $label (@$labellist) {
96 $labels{$label} = [];
97 }
98
99 while(<$fh>) {
100 my ($full_label, $va, $ra, $pa) = split ' ';
101 next unless defined $pa;
102 foreach my $label (@$labellist) {
103 if($label eq $full_label or $full_label =~ /\.$label$/) {
104 push @{$labels{$label}}, $va;
105 }
106 }
107 }
108 return \%labels;
109}
110
111###############################################################################
1121;