CBMC
mode.cpp File Reference
#include "mode.h"
#include <list>
#include <memory>
#include <set>
#include "language.h"
#include <util/invariant.h>
#include <util/namespace.h>
#include <util/symbol.h>
+ Include dependency graph for mode.cpp:

Go to the source code of this file.

Classes

struct  language_entryt
 

Typedefs

typedef std::list< language_entrytlanguagest
 

Functions

void register_language (language_factoryt factory)
 Register a language Note: registering a language is required for using the functions in language_util.h. More...
 
std::unique_ptr< languagetget_language_from_mode (const irep_idt &mode)
 Get the language corresponding to the given mode. More...
 
const irep_idtget_mode_from_identifier (const namespacet &ns, const irep_idt &identifier)
 Get the mode of the given identifier's symbol. More...
 
std::unique_ptr< languagetget_language_from_identifier (const namespacet &ns, const irep_idt &identifier)
 Get the language corresponding to the mode of the given identifier's symbol. More...
 
std::unique_ptr< languagetget_language_from_filename (const std::string &filename)
 Get the language corresponding to the registered file name extensions. More...
 
std::unique_ptr< languagetget_default_language ()
 Returns the default language. More...
 

Variables

languagest languages
 

Typedef Documentation

◆ languagest

typedef std::list<language_entryt> languagest

Definition at line 32 of file mode.cpp.

Function Documentation

◆ get_default_language()

std::unique_ptr<languaget> get_default_language ( )

Returns the default language.

Returns
the first registered language

Definition at line 139 of file mode.cpp.

◆ get_language_from_filename()

std::unique_ptr<languaget> get_language_from_filename ( const std::string &  filename)

Get the language corresponding to the registered file name extensions.

Parameters
filenamea filename
Returns
the corresponding language or nullptr if the extension cannot be resolved to any registered language

Definition at line 102 of file mode.cpp.

◆ get_language_from_identifier()

std::unique_ptr<languaget> get_language_from_identifier ( const namespacet ns,
const irep_idt identifier 
)

Get the language corresponding to the mode of the given identifier's symbol.

Parameters
nsa namespace
identifieran identifier
Returns
the corresponding language if the mode is not ID_unknown, or the default language otherwise; Note: It is assumed as an invariant that languages of symbols in the symbol table have been registered.

Definition at line 84 of file mode.cpp.

◆ get_language_from_mode()

std::unique_ptr<languaget> get_language_from_mode ( const irep_idt mode)

Get the language corresponding to the given mode.

Parameters
modethe mode, e.g. ID_C
Returns
the language or nullptr if the language has not been registered

Definition at line 51 of file mode.cpp.

◆ get_mode_from_identifier()

const irep_idt& get_mode_from_identifier ( const namespacet ns,
const irep_idt identifier 
)

Get the mode of the given identifier's symbol.

Parameters
nsa namespace
identifieran identifier
Returns
the mode, e.g. ID_C, if the identifier is in the given symbol table, or ID_unknown otherwise

Definition at line 66 of file mode.cpp.

◆ register_language()

void register_language ( language_factoryt  factory)

Register a language Note: registering a language is required for using the functions in language_util.h.

Parameters
factorya language factory, e.g. new_ansi_c_language

Definition at line 39 of file mode.cpp.

Variable Documentation

◆ languages

languagest languages

Definition at line 33 of file mode.cpp.