2016-01-28 14:52:40 +01:00
|
|
|
/** @file
|
|
|
|
|
*
|
|
|
|
|
* @par History
|
|
|
|
|
*/
|
2016-02-11 22:54:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef FMODULE_H
|
|
|
|
|
#define FMODULE_H
|
|
|
|
|
|
|
|
|
|
#include <map>
|
2018-01-29 21:55:48 +01:00
|
|
|
#include <stddef.h>
|
2016-02-11 22:54:43 +01:00
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
2018-01-29 21:55:48 +01:00
|
|
|
#include "../clib/boostutils.h"
|
|
|
|
|
#include "../clib/maputil.h"
|
|
|
|
|
|
2016-02-19 19:26:35 +01:00
|
|
|
namespace Pol
|
|
|
|
|
{
|
|
|
|
|
namespace Bscript
|
|
|
|
|
{
|
|
|
|
|
class UserFunction;
|
2016-02-11 22:54:43 +01:00
|
|
|
|
2016-02-19 19:26:35 +01:00
|
|
|
class ModuleFunction
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
boost_utils::function_name_flystring name;
|
|
|
|
|
unsigned nargs;
|
|
|
|
|
int funcidx; // according to the executor, what's its function index
|
2016-02-11 22:54:43 +01:00
|
|
|
|
2016-02-19 19:26:35 +01:00
|
|
|
// compiler only:
|
|
|
|
|
UserFunction* uf; // compiler only
|
|
|
|
|
bool used; // compiler only
|
2016-02-11 22:54:43 +01:00
|
|
|
|
2016-02-19 19:26:35 +01:00
|
|
|
ModuleFunction( const char* fname, int nargs, UserFunction* uf );
|
2018-11-03 15:00:44 +01:00
|
|
|
~ModuleFunction() = default;
|
2016-02-19 19:26:35 +01:00
|
|
|
};
|
2016-02-11 22:54:43 +01:00
|
|
|
|
2016-02-19 19:26:35 +01:00
|
|
|
class FunctionalityModule
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
bool have_indexes;
|
|
|
|
|
std::vector<ModuleFunction*> functions;
|
2016-02-11 22:54:43 +01:00
|
|
|
|
2016-02-19 19:26:35 +01:00
|
|
|
// compiler only:
|
|
|
|
|
typedef std::map<std::string, ModuleFunction*, Clib::ci_cmp_pred> FunctionsByName;
|
|
|
|
|
FunctionsByName functionsByName;
|
|
|
|
|
std::vector<ModuleFunction*> used_functions;
|
|
|
|
|
std::vector<UserFunction*> owned_userfuncs;
|
2016-02-11 22:54:43 +01:00
|
|
|
|
2016-02-19 19:26:35 +01:00
|
|
|
boost_utils::function_name_flystring modulename;
|
2016-02-11 22:54:43 +01:00
|
|
|
|
2016-02-19 19:26:35 +01:00
|
|
|
bool isFunc( const char* funcName, ModuleFunction** pmf, int* funcidx );
|
|
|
|
|
explicit FunctionalityModule( const char* modname );
|
|
|
|
|
~FunctionalityModule();
|
2016-02-11 22:54:43 +01:00
|
|
|
|
2018-10-09 16:36:35 +02:00
|
|
|
void addFunction( const char* funcname, int nparams, UserFunction* uf = nullptr );
|
2016-02-19 19:26:35 +01:00
|
|
|
void fillFunctionsByName();
|
2016-02-11 22:54:43 +01:00
|
|
|
|
2016-02-19 19:26:35 +01:00
|
|
|
private:
|
|
|
|
|
FunctionalityModule( const FunctionalityModule& );
|
|
|
|
|
};
|
|
|
|
|
}
|
2016-02-11 22:54:43 +01:00
|
|
|
}
|
|
|
|
|
#endif
|