Skip to content

Commit 2b76c1c

Browse files
author
Daniel Kroening
authored
Merge pull request #791 from owen-jones-diffblue/doc/symbol-table
Document symbol table functions
2 parents 31b59f8 + e7db8a3 commit 2b76c1c

File tree

1 file changed

+49
-21
lines changed

1 file changed

+49
-21
lines changed

src/util/symbol_table.cpp

Lines changed: 49 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@ Author: Daniel Kroening, [email protected]
1414
1515
Function: symbol_tablet::add
1616
17-
Inputs:
17+
Inputs:
18+
symbol - The symbol to be added to the symbol table
1819
19-
Outputs:
20+
Outputs: Returns a boolean indicating whether the process failed,
21+
which should only happen if there is a symbol with the same
22+
name already in the symbol table
2023
21-
Purpose:
24+
Purpose: Add a new symbol to the symbol table
2225
2326
\*******************************************************************/
2427

@@ -39,11 +42,28 @@ bool symbol_tablet::add(const symbolt &symbol)
3942
4043
Function: symbol_tablet::move
4144
42-
Inputs:
43-
44-
Outputs:
45-
46-
Purpose:
45+
Inputs:
46+
symbol - The symbol to be added to the symbol table
47+
new_symbol - Pointer which the function will set to either point
48+
to the symbol in the symbol table with the same name
49+
or to the symbol that has been successfully moved
50+
into the symbol table
51+
52+
Outputs: Returns a boolean indicating whether the process failed,
53+
which should only happen if there is a symbol with the
54+
same name already in the symbol table. If the process
55+
failed then symbol is unchanged and new_symbol points to
56+
the symbol with the same name. If the process succeeded
57+
symbol is set to be empty and new_symbol points to its new
58+
location in the symbol table
59+
60+
Purpose: Move a symbol into the symbol table. If there is already
61+
a symbol with the same name then symbol is unchanged,
62+
new_symbol points to the symbol with the same name and
63+
true is returned. Otherwise, the symbol is moved into the
64+
symbol table, symbol is set to be empty, new_symbol points
65+
to its new location in the symbol table and false is
66+
returned
4767
4868
\*******************************************************************/
4969

@@ -75,11 +95,12 @@ bool symbol_tablet::move(symbolt &symbol, symbolt *&new_symbol)
7595
7696
Function: symbol_tablet::remove
7797
78-
Inputs:
98+
Inputs:
99+
name - The name of the symbol to remove
79100
80-
Outputs:
101+
Outputs: Returns a boolean indicating whether the process failed
81102
82-
Purpose:
103+
Purpose: Remove a symbol from the symbol table
83104
84105
\*******************************************************************/
85106

@@ -121,11 +142,12 @@ bool symbol_tablet::remove(const irep_idt &name)
121142
122143
Function: symbol_tablet::show
123144
124-
Inputs:
145+
Inputs:
146+
out - The ostream to direct output to
125147
126148
Outputs:
127149
128-
Purpose:
150+
Purpose: Print the contents of the symbol table
129151
130152
\*******************************************************************/
131153

@@ -141,11 +163,13 @@ void symbol_tablet::show(std::ostream &out) const
141163
142164
Function: symbol_tablet::lookup
143165
144-
Inputs:
166+
Inputs:
167+
identifier - The name of the symbol to look for
145168
146-
Outputs:
169+
Outputs: The symbol in the symbol table with the correct name
147170
148-
Purpose:
171+
Purpose: Find a symbol in the symbol table. Throws a string if no
172+
such symbol is found.
149173
150174
\*******************************************************************/
151175

@@ -163,11 +187,13 @@ const symbolt &symbol_tablet::lookup(const irep_idt &identifier) const
163187
164188
Function: symbol_tablet::lookup
165189
166-
Inputs:
190+
Inputs:
191+
identifier - The name of the symbol to look for
167192
168-
Outputs:
193+
Outputs: The symbol in the symbol table with the correct name
169194
170-
Purpose:
195+
Purpose: Find a symbol in the symbol table. Throws a string if no
196+
such symbol is found.
171197
172198
\*******************************************************************/
173199

@@ -185,11 +211,13 @@ symbolt &symbol_tablet::lookup(const irep_idt &identifier)
185211
186212
Function: operator <<
187213
188-
Inputs:
214+
Inputs:
215+
out - The ostream to direct output to
216+
symbol_table - The symbol table to print out
189217
190218
Outputs:
191219
192-
Purpose:
220+
Purpose: Print the contents of the symbol table
193221
194222
\*******************************************************************/
195223

0 commit comments

Comments
 (0)