Skip to content

Document symbol table functions #791

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 10, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 49 additions & 21 deletions src/util/symbol_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ Author: Daniel Kroening, [email protected]

Function: symbol_tablet::add

Inputs:
Inputs:
symbol - The symbol to be added to the symbol table

Outputs:
Outputs: Returns a boolean indicating whether the process failed,
which should only happen if there is a symbol with the same
name already in the symbol table

Purpose:
Purpose: Add a new symbol to the symbol table

\*******************************************************************/

Expand All @@ -39,11 +42,28 @@ bool symbol_tablet::add(const symbolt &symbol)

Function: symbol_tablet::move

Inputs:

Outputs:

Purpose:
Inputs:
symbol - The symbol to be added to the symbol table
new_symbol - Pointer which the function will set to either point
to the symbol in the symbol table with the same name
or to the symbol that has been successfully moved
into the symbol table

Outputs: Returns a boolean indicating whether the process failed,
which should only happen if there is a symbol with the
same name already in the symbol table. If the process
failed then symbol is unchanged and new_symbol points to
the symbol with the same name. If the process succeeded
symbol is set to be empty and new_symbol points to its new
location in the symbol table

Purpose: Move a symbol into the symbol table. If there is already
a symbol with the same name then symbol is unchanged,
new_symbol points to the symbol with the same name and
true is returned. Otherwise, the symbol is moved into the
symbol table, symbol is set to be empty, new_symbol points
to its new location in the symbol table and false is
returned

\*******************************************************************/

Expand Down Expand Up @@ -75,11 +95,12 @@ bool symbol_tablet::move(symbolt &symbol, symbolt *&new_symbol)

Function: symbol_tablet::remove

Inputs:
Inputs:
name - The name of the symbol to remove

Outputs:
Outputs: Returns a boolean indicating whether the process failed

Purpose:
Purpose: Remove a symbol from the symbol table

\*******************************************************************/

Expand Down Expand Up @@ -121,11 +142,12 @@ bool symbol_tablet::remove(const irep_idt &name)

Function: symbol_tablet::show

Inputs:
Inputs:
out - The ostream to direct output to

Outputs:

Purpose:
Purpose: Print the contents of the symbol table

\*******************************************************************/

Expand All @@ -141,11 +163,13 @@ void symbol_tablet::show(std::ostream &out) const

Function: symbol_tablet::lookup

Inputs:
Inputs:
identifier - The name of the symbol to look for

Outputs:
Outputs: The symbol in the symbol table with the correct name

Purpose:
Purpose: Find a symbol in the symbol table. Throws a string if no
such symbol is found.

\*******************************************************************/

Expand All @@ -163,11 +187,13 @@ const symbolt &symbol_tablet::lookup(const irep_idt &identifier) const

Function: symbol_tablet::lookup

Inputs:
Inputs:
identifier - The name of the symbol to look for

Outputs:
Outputs: The symbol in the symbol table with the correct name

Purpose:
Purpose: Find a symbol in the symbol table. Throws a string if no
such symbol is found.

\*******************************************************************/

Expand All @@ -185,11 +211,13 @@ symbolt &symbol_tablet::lookup(const irep_idt &identifier)

Function: operator <<

Inputs:
Inputs:
out - The ostream to direct output to
symbol_table - The symbol table to print out

Outputs:

Purpose:
Purpose: Print the contents of the symbol table

\*******************************************************************/

Expand Down