cprover
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 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 31 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 138 of file mode.cpp.

References languages, and PRECONDITION.

Referenced by get_language_from_identifier(), json(), show_symbol_table_brief_plain(), language_uit::show_symbol_table_plain(), and show_symbol_table_plain().

◆ 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 101 of file mode.cpp.

References languages.

Referenced by cbmc_parse_optionst::doit(), jbmc_parse_optionst::doit(), lazy_goto_modelt::initialize(), initialize_goto_model(), language_uit::parse(), compilet::parse(), and cbmc_parse_optionst::preprocessing().

◆ 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 83 of file mode.cpp.

References get_default_language(), get_language_from_mode(), get_mode_from_identifier(), id2string(), and INVARIANT.

Referenced by from_expr(), from_type(), to_expr(), and type_to_name().

◆ 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 50 of file mode.cpp.

References languages.

Referenced by goto_checkt::add_guarded_claim(), get_language_from_identifier(), json(), load_java_class(), load_java_class_lazy(), rebuild_goto_start_function_baset< maybe_lazy_goto_modelt >::operator()(), compilet::parse(), show_symbol_table_brief_plain(), language_uit::show_symbol_table_plain(), and show_symbol_table_plain().

◆ 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 65 of file mode.cpp.

References dstringt::empty(), namespacet::lookup(), and symbolt::mode.

Referenced by get_language_from_identifier().

◆ register_language()

Variable Documentation

◆ languages