snoot: immed_and_type_for_C_intconst: properly parse "0"
[suif.git] / html / suif1_46.html
blobad31f2665a2e070df68317d582c1ff37f71ded9f
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 - Basic Symtab Features</TITLE>
7 <link href="suif1_47.html" rel=Next>
8 <link href="suif1_45.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_45.html">previous</A>, <A HREF="suif1_47.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="SEC46" HREF="suif1_toc.html#TOC46">Basic Features</A></H2>
18 <P>
19 <A NAME="IDX282"></A>
21 </P>
22 <P>
23 Symbol tables contain three different kinds of objects: types, symbols,
24 and variable definitions. The entries within a symbol table may only be
25 referenced within the corresponding scope. This includes references
26 within registered annotations. Violating this condition may lead to
27 strange and unexpected errors.
29 </P>
30 <P>
31 <A NAME="IDX283"></A>
32 <A NAME="IDX284"></A>
33 <A NAME="IDX285"></A>
34 For simplicity, the symbol table entries are stored on lists instead of
35 using hash tables. In theory, the actual implementation (lists or hash
36 tables) should not be visible in the symbol table interface.
37 Unfortunately that is not completely true for the current implementation
38 of SUIF--the lists can be accessed directly. The <CODE>types</CODE>,
39 <CODE>symbols</CODE>, and <CODE>var_defs</CODE> methods return pointers to the
40 lists. However, these lists should only be accessed to examine the
41 entries and should never be modified directly. The symbol table classes
42 provide other methods to add and remove entries from the lists and those
43 methods should always be used. If the list implementation becomes a
44 performance bottleneck, we may need to switch to hash tables, and code
45 that modifies the lists directly will be relatively hard to convert.
47 </P>
48 <P>
49 <A NAME="IDX286"></A>
50 <A NAME="IDX287"></A>
51 <A NAME="IDX288"></A>
52 To distinguish the symbol tables nested within a particular scope, each
53 table is given a name. The <CODE>name</CODE> and <CODE>set_name</CODE> methods
54 retrieve and modify this name. If a scope in the source program has a
55 name associated with it, that name may be used for the corresponding
56 symbol table. For example, the name of a procedure-level symbol table
57 should generally be the same as the name of the procedure. On the other
58 hand, nested scopes within procedures are typically unnamed, and names
59 must be generated for the corresponding symbol tables.
61 </P>
62 <P>
63 <A NAME="IDX289"></A>
64 <A NAME="IDX290"></A>
65 The symbol table names are used when printing a reference to a symbol or
66 named type. Because the symbol or type name alone may not be sufficient
67 to identify it uniquely, the <CODE>chain_name</CODE> method is used to
68 identify the symbol table. The chain name of a symbol table includes
69 the names of all of the symbol tables from the procedure-level downward,
70 separated by slashes (as in a Unix path). The file-level name is not
71 included since it should always be clear from the context. The chain
72 name for a global or file symbol table is the empty string.
74 </P>
75 <P>
76 <A NAME="IDX291"></A>
77 Duplicate names within a symbol table should be avoided whenever
78 possible. Each kind of symbol has a separate name space. A variable,
79 for example, may have the same name as a label in the same symbol table.
80 Named types and child symbol table names are also in separate name
81 spaces. Duplicate names may be temporarily introduced but to avoid
82 problems they should be renamed as soon as possible. The
83 <CODE>rename_duplicates</CODE> method is provided to check for and rename any
84 duplicates in a symbol table. This method is automatically called
85 before writing out each symbol table.
87 </P>
89 <P><HR><P>
90 <p>Go to the <A HREF="suif1_1.html">first</A>, <A HREF="suif1_45.html">previous</A>, <A HREF="suif1_47.html">next</A>, <A HREF="suif1_113.html">last</A> section, <A HREF="suif1_toc.html">table of contents</A>.
91 </BODY>
92 </HTML>