2016-01-28 14:52:40 +01:00
|
|
|
/** @file
|
|
|
|
|
*
|
|
|
|
|
* @par History
|
|
|
|
|
*/
|
2016-02-11 22:54:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef BSCRIPT_USERFUNC_H
|
|
|
|
|
#define BSCRIPT_USERFUNC_H
|
|
|
|
|
|
2018-01-29 21:55:48 +01:00
|
|
|
#include <set>
|
2016-02-11 22:54:43 +01:00
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
2018-01-29 21:55:48 +01:00
|
|
|
|
|
|
|
|
#include "compctx.h"
|
|
|
|
|
#include "token.h"
|
2016-02-11 22:54:43 +01:00
|
|
|
|
2016-02-19 19:26:35 +01:00
|
|
|
namespace Pol
|
|
|
|
|
{
|
|
|
|
|
namespace Bscript
|
|
|
|
|
{
|
|
|
|
|
class UserParam
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
std::string name;
|
|
|
|
|
int have_default;
|
|
|
|
|
Token dflt_value;
|
|
|
|
|
bool pass_by_reference;
|
|
|
|
|
bool unused;
|
|
|
|
|
|
|
|
|
|
UserParam() : name( "" ), have_default( false ), pass_by_reference( false ), unused( false ) {}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class UserFunction
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
UserFunction();
|
2018-11-03 15:00:44 +01:00
|
|
|
~UserFunction() = default;
|
2016-02-19 19:26:35 +01:00
|
|
|
|
|
|
|
|
std::string name;
|
|
|
|
|
typedef std::vector<UserParam> Parameters;
|
|
|
|
|
Parameters parameters;
|
|
|
|
|
unsigned position;
|
|
|
|
|
typedef std::vector<unsigned> Addresses;
|
|
|
|
|
Addresses forward_callers;
|
|
|
|
|
|
|
|
|
|
CompilerContext ctx;
|
|
|
|
|
char* function_body; // FIXME: this is leaked
|
|
|
|
|
bool exported;
|
|
|
|
|
bool emitted;
|
|
|
|
|
std::string declaration;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
static unsigned int instances();
|
|
|
|
|
static void show_instances();
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
static unsigned int _instances;
|
|
|
|
|
static std::set<UserFunction*> _instancelist;
|
|
|
|
|
void register_instance();
|
|
|
|
|
void unregister_instance();
|
|
|
|
|
};
|
|
|
|
|
}
|
2016-02-11 22:54:43 +01:00
|
|
|
}
|
|
|
|
|
#endif
|