ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
module Class Reference

#include <module.h>

Public Member Functions

 module (const std::string &name)
void add_source (std::string json_path)
 Record a JSON AST this module's contents come from.
const std::vector< std::string > & sources () const
bool hydrated () const
void mark_hydrated ()
bool readable () const
 False once hydration has run and every source failed to parse.
void set_readable (bool yes)
const std::string & name () const
void add_function (const function &func)
void add_submodule (const std::shared_ptr< module > mod)
void add_overload (const nlohmann::json &ast)
void add_class (const class_definition &cls)
class_definition get_class (const std::string &class_name) const
 Retrieve a class definition by name.
function get_function (const std::string &func_name) const
 Retrieve a function definition by name.
const FunctionsList & functions () const
const SubmodulesList & submodules () const
const OverloadList & overloads () const
const ClassesList & classes () const
void set_mentions_dunder_all ()
bool star_import_binds (const std::string &name) const
 Whether from <this module> import * binds name: a public name, and no mention of __all__, which could narrow what the import binds.

Constructor & Destructor Documentation

◆ module()

module::module ( const std::string & name)
inline

Member Function Documentation

◆ add_class()

void module::add_class ( const class_definition & cls)
inline

◆ add_function()

void module::add_function ( const function & func)
inline

◆ add_overload()

void module::add_overload ( const nlohmann::json & ast)
inline

◆ add_source()

void module::add_source ( std::string json_path)
inline

Record a JSON AST this module's contents come from.

The file is parsed on first access, not here: a run imports a handful of the modules the parser emits, and parsing the rest cost ~0.15s of every Python run.

Invariant, load-bearing for the lazy split: parsing a source may only add functions, classes and overloads. It must never add a source or a submodule, because module_manager::find_module walks submodules_ WITHOUT hydrating, so a dotted lookup traverses unhydrated nodes. Following Import nodes here would make every dotted lookup silently miss.

◆ add_submodule()

void module::add_submodule ( const std::shared_ptr< module > mod)
inline

◆ classes()

const ClassesList & module::classes ( ) const
inline

◆ functions()

const FunctionsList & module::functions ( ) const
inline

◆ get_class()

class_definition module::get_class ( const std::string & class_name) const
inline

Retrieve a class definition by name.

Parameters
class_nameThe name of the class to find
Returns
The class definition, or empty class_definition if not found @complexity O(1) average case via hash lookup

◆ get_function()

function module::get_function ( const std::string & func_name) const
inline

Retrieve a function definition by name.

Parameters
func_nameThe name of the function to find
Returns
The function definition, or empty function if not found @complexity O(1) average case via hash lookup

◆ hydrated()

bool module::hydrated ( ) const
inline

◆ mark_hydrated()

void module::mark_hydrated ( )
inline

◆ name()

const std::string & module::name ( ) const
inline

◆ overloads()

const OverloadList & module::overloads ( ) const
inline

◆ readable()

bool module::readable ( ) const
inline

False once hydration has run and every source failed to parse.

◆ set_mentions_dunder_all()

void module::set_mentions_dunder_all ( )
inline

◆ set_readable()

void module::set_readable ( bool yes)
inline

◆ sources()

const std::vector< std::string > & module::sources ( ) const
inline

◆ star_import_binds()

bool module::star_import_binds ( const std::string & name) const
inline

Whether from <this module> import * binds name: a public name, and no mention of __all__, which could narrow what the import binds.

◆ submodules()

const SubmodulesList & module::submodules ( ) const
inline

The documentation for this class was generated from the following file: