Partial support for integer divisions in access vectors
[suif.git] / html / suif1_47.html
blobb7bd798002abcfa7285039db6724d48931a803e8
1 <HTML>
2 <HEAD>
3 <!-- This HTML file has been created by texi2html 1.54
4 from suif1.texi on 28 April 1999 -->
6 <TITLE>The SUIF Version 1 Library - Lookup Methods</TITLE>
7 <link href="suif1_48.html" rel=Next>
8 <link href="suif1_46.html" rel=Previous>
9 <link href="suif1_toc.html" rel=ToC>
11 </HEAD>
12 <BODY>
13 <p>Go to the <A HREF="suif1_1.html">first</A>, <A HREF="suif1_46.html">previous</A>, <A HREF="suif1_48.html">next</A>, <A HREF="suif1_113.html">last</A> section, <A HREF="suif1_toc.html">table of contents</A>.
14 <P><HR><P>
17 <H2><A NAME="SEC47" HREF="suif1_toc.html#TOC47">Lookup Methods</A></H2>
18 <P>
19 <A NAME="IDX292"></A>
21 </P>
22 <P>
23 SUIF symbol tables provide a number of methods to search for and
24 retrieve particular types, symbols, and variable definitions. Most of
25 these lookup methods will optionally search all the ancestor symbol
26 tables, making it easy to determine if an object is defined in the
27 current scope.
29 </P>
30 <P>
31 <A NAME="IDX293"></A>
32 The <CODE>lookup_type</CODE> method is available at all levels in the symbol
33 table hierarchy to search for SUIF types. Given an existing type, the
34 method searches for a type that is the same. It uses the <CODE>is_same</CODE>
35 method from the <CODE>type_node</CODE> class to perform these comparisons. If
36 a matching type is not found within the current symbol table,
37 <CODE>lookup_type</CODE> will continue searching in the ancestor symbol tables
38 by default. However, if the optional <CODE>up</CODE> parameter is set to
39 <CODE>FALSE</CODE>, it will give up after searching the first table.
41 </P>
42 <P>
43 <A NAME="IDX294"></A>
44 <A NAME="IDX295"></A>
45 <A NAME="IDX296"></A>
46 <A NAME="IDX297"></A>
47 Several methods are provided to lookup symbols. Each different kind of
48 symbol (variable, procedure, and label) has its own name space, so the
49 <CODE>lookup_sym</CODE> method requires that you specify both the name and the
50 kind of symbol for which to search. This method may be used with all
51 symbol tables. For convenience, other methods are defined as wrappers
52 around <CODE>lookup_sym</CODE>. Each of these wrappers searches for a
53 particular kind of symbol: <CODE>lookup_var</CODE> searches for variables,
54 <CODE>lookup_proc</CODE> searches for procedures, and <CODE>lookup_label</CODE>
55 searches for labels. Because procedure symbols may only be defined in
56 global symbol tables, the <CODE>lookup_proc</CODE> method is declared in the
57 <CODE>global_symtab</CODE> class. Similarly, the <CODE>lookup_label</CODE> method
58 is declared in the <CODE>block_symtab</CODE> class, because labels may only be
59 defined within procedures. By default, all of these methods search the
60 current symbol table and, if unsuccessful, proceed to search the
61 ancestor symbol tables. The optional <CODE>up</CODE> parameters may be set to
62 <CODE>FALSE</CODE> to turn off this default behavior and only search the
63 current symbol table.
65 </P>
66 <P>
67 <A NAME="IDX298"></A>
68 A symbol for a global variable is just a declaration of that variable
69 and does not automatically have any storage allocated. Variable
70 definitions are required to allocate storage and to specify alignment
71 requirements and any initial data for the variable. Since the variable
72 definitions are not directly connected to the variable symbols, the
73 <CODE>lookup_var_def</CODE> method is provided to search a symbol table for
74 the definition of a particular variable symbol. This method does not
75 search the parent symbol table. In general the <CODE>definition</CODE> method
76 in the <CODE>var_sym</CODE> class is a better way to locate a variable
77 definition.
79 </P>
80 <P>
81 <A NAME="IDX299"></A>
82 <A NAME="IDX300"></A>
83 Symbols and types are assigned ID numbers (see section <A HREF="suif1_50.html#SEC50">Numbering Types and Symbols</A>) that uniquely identify them within a particular context. The
84 <CODE>lookup_type_id</CODE> method searches the types defined within a symbol
85 table and its ancestors for a type with the specified ID number. The
86 <CODE>lookup_sym_id</CODE> does the same thing for symbols.
88 </P>
89 <P>
90 <A NAME="IDX301"></A>
91 Besides searching for one of the entries in a symbol table, you can also
92 search for one of its children in the symbol table hierarchy. The
93 <CODE>lookup_child</CODE> method searches through the list of children for a
94 symbol table with a given name. This may not be very useful, but it is
95 included for completeness.
97 </P>
99 <P><HR><P>
100 <p>Go to the <A HREF="suif1_1.html">first</A>, <A HREF="suif1_46.html">previous</A>, <A HREF="suif1_48.html">next</A>, <A HREF="suif1_113.html">last</A> section, <A HREF="suif1_toc.html">table of contents</A>.
101 </BODY>
102 </HTML>