Colobot
|
A function declaration in the code. More...
#include <src/CBot/CBotInstr/CBotFunction.h>
Public Member Functions | |
bool | Execute (CBotVar **ppVars, CBotStack *&pj, CBotVar *pInstance=nullptr) |
Execute. More... | |
void | RestoreState (CBotVar **ppVars, CBotStack *&pj, CBotVar *pInstance=nullptr) |
RestoreState. More... | |
bool | CheckParam (CBotDefParam *pParam) |
CheckParam See if the "signature" of parameters is identical. More... | |
const std::string & | GetName () |
GetName. More... | |
std::string | GetParams () |
GetParams. More... | |
const std::string & | GetClassName () const |
Get the name of the class for a method. More... | |
bool | IsPublic () |
IsPublic. More... | |
bool | IsProtected () const |
Check if a method is protected. More... | |
bool | IsPrivate () const |
Check if a method is private. More... | |
bool | IsExtern () |
IsExtern. More... | |
bool | GetPosition (int &start, int &stop, CBotGet modestart, CBotGet modestop) |
GetPosition. More... | |
bool | HasReturn () override |
Check if the function has a return statment that will execute. More... | |
virtual bool | Execute (CBotStack *&pj) |
Execute. More... | |
virtual bool | Execute (CBotStack *&pj, CBotVar *pVar) |
Execute. More... | |
virtual void | RestoreState (CBotStack *&pj, bool bMain) |
RestoreState. More... | |
![]() | |
CBotInstr () | |
Constructor. More... | |
virtual | ~CBotInstr () |
Destructor. More... | |
virtual bool | Execute (CBotStack *&pj) |
Execute. More... | |
virtual bool | Execute (CBotStack *&pj, CBotVar *pVar) |
Execute. More... | |
virtual void | RestoreState (CBotStack *&pj, bool bMain) |
RestoreState. More... | |
virtual bool | ExecuteVar (CBotVar *&pVar, CBotCStack *&pile) |
ExecuteVar. More... | |
virtual bool | ExecuteVar (CBotVar *&pVar, CBotStack *&pile, CBotToken *prevToken, bool bStep, bool bExtend) |
ExecuteVar. More... | |
virtual void | RestoreStateVar (CBotStack *&pile, bool bMain) |
RestoreStateVar. More... | |
void | SetToken (CBotToken *p) |
SetToken Set the token corresponding to the instruction. More... | |
int | GetTokenType () |
GetTokenType Return the type of the token assicated with the instruction. More... | |
CBotToken * | GetToken () |
GetToken Return associated token. More... | |
void | AddNext (CBotInstr *n) |
AddNext Adds the statement following the other. More... | |
CBotInstr * | GetNext () |
GetNext Returns next statement. More... | |
void | AddNext3 (CBotInstr *n) |
AddNext3. More... | |
CBotInstr * | GetNext3 () |
GetNext3. More... | |
void | AddNext3b (CBotInstr *n) |
AddNext3b. More... | |
CBotInstr * | GetNext3b () |
GetNext3b. More... | |
Static Public Member Functions | |
static CBotFunction * | Compile (CBotToken *&p, CBotCStack *pStack, CBotFunction *pFunc, bool bLocal=true) |
Compile Compiles a new function. More... | |
static CBotFunction * | Compile1 (CBotToken *&p, CBotCStack *pStack, CBotClass *pClass) |
Pre-compile a new function. More... | |
static CBotTypResult | CompileCall (const std::string &name, CBotVar **ppVars, long &nIdent, CBotProgram *program) |
Compile a function call. More... | |
static CBotFunction * | FindLocalOrPublic (const std::list< CBotFunction * > &localFunctionList, long &nIdent, const std::string &name, CBotVar **ppVars, CBotTypResult &TypeOrError, CBotProgram *baseProg) |
Finds a local or public function. More... | |
static void | SearchList (const std::list< CBotFunction * > &functionList, const std::string &name, CBotVar **ppVars, CBotTypResult &TypeOrError, std::map< CBotFunction *, int > &funcMap, CBotClass *pClass=nullptr) |
Find all functions that match the name and arguments. More... | |
static void | SearchPublic (const std::string &name, CBotVar **ppVars, CBotTypResult &TypeOrError, std::map< CBotFunction *, int > &funcMap, CBotClass *pClass=nullptr) |
Find all public functions that match the name and arguments. More... | |
static CBotFunction * | BestFunction (std::map< CBotFunction *, int > &funcMap, long &nIdent, CBotTypResult &TypeOrError) |
Find the function with the lowest signature value. If there is more than one of the same signature value, TypeOrError is set to CBotErrAmbiguousCall. More... | |
static int | DoCall (CBotProgram *program, const std::list< CBotFunction * > &localFunctionList, long &nIdent, const std::string &name, CBotVar **ppVars, CBotStack *pStack, CBotToken *pToken) |
DoCall Fait un appel à une fonction. More... | |
static void | RestoreCall (const std::list< CBotFunction * > &localFunctionList, long &nIdent, const std::string &name, CBotVar **ppVars, CBotStack *pStack) |
RestoreCall. More... | |
static CBotTypResult | CompileMethodCall (const std::string &name, CBotVar **ppVars, long &nIdent, CBotCStack *pStack, CBotClass *pClass) |
Find a method matching the name and arguments. More... | |
static CBotFunction * | FindMethod (long &nIdent, const std::string &name, CBotVar **ppVars, CBotTypResult &TypeOrError, CBotClass *pClass, CBotProgram *program) |
Find a method by its unique identifier or by name and parameters. More... | |
static int | DoCall (long &nIdent, const std::string &name, CBotVar *pThis, CBotVar **ppVars, CBotStack *pStack, CBotToken *pToken, CBotClass *pClass) |
DoCall Makes call of a method. More... | |
static bool | RestoreCall (long &nIdent, const std::string &name, CBotVar *pThis, CBotVar **ppVars, CBotStack *pStack, CBotClass *pClass) |
RestoreCall. More... | |
static void | AddPublic (CBotFunction *pfunc) |
AddPublic. More... | |
![]() | |
static CBotInstr * | Compile (CBotToken *&p, CBotCStack *pStack) |
Compile an instruction. More... | |
static CBotInstr * | CompileArray (CBotToken *&p, CBotCStack *pStack, CBotTypResult type, bool first=true) |
CompileArray. More... | |
static void | IncLvl (std::string &label) |
IncLvl Adds a level with a label. More... | |
static void | IncLvl () |
IncLvl Adds a level (switch statement). More... | |
static void | DecLvl () |
DecLvl Free a level. More... | |
static bool | ChkLvl (const std::string &label, int type) |
ChkLvl Control validity of break and continue. More... | |
Protected Member Functions | |
virtual const std::string | GetDebugName () override |
Returns the name of this class. More... | |
virtual std::string | GetDebugData () override |
Returns additional data associated with this instruction for debugging purposes. More... | |
virtual std::map< std::string, CBotInstr * > | GetDebugLinks () override |
Friends | |
class | CBotDebug |
class | CBotProgram |
class | CBotClass |
class | CBotCStack |
Additional Inherited Members | |
![]() | |
CBotToken | m_token |
Keeps the token. More... | |
CBotInstr * | m_next |
Linked command. More... | |
CBotInstr * | m_next2b |
Second list definition chain. More... | |
CBotInstr * | m_next3 |
Third list for indices and fields. More... | |
CBotInstr * | m_next3b |
Necessary for reporting tables. More... | |
![]() | |
static int | m_LoopLvl = 0 |
Counter of nested loops, to determine the break and continue valid. More... | |
A function declaration in the code.
Examples:
|
static |
Compile Compiles a new function.
p | |
pStack | |
pFunc | |
bLocal | allows of the declaration of parameters on the same level as the elements belonging to the class for methods. |
|
static |
Pre-compile a new function.
p[in,out] | Pointer to first token of the function, will be updated to point to first token after the function definition |
pStack | Compile stack |
pClass | If this is a class method, pointer to class this function is part of, otherwise nullptr |
This function is used to find the beginning and end of function definition.
If any errors in the code are detected, this function will set the error on compile stack and return nullptr.
bool CBot::CBotFunction::Execute | ( | CBotVar ** | ppVars, |
CBotStack *& | pj, | ||
CBotVar * | pInstance = nullptr |
||
) |
Execute.
ppVars | |
pj | |
pInstance |
void CBot::CBotFunction::RestoreState | ( | CBotVar ** | ppVars, |
CBotStack *& | pj, | ||
CBotVar * | pInstance = nullptr |
||
) |
RestoreState.
ppVars | |
pj | |
pInstance |
|
static |
Compile a function call.
See FindLocalOrPublic for more detailed explanation
name | Name of the function |
ppVars | List of function arguments |
nIdent[in,out] | Unique identifier of the function |
program | The current program, to search for functions. |
|
static |
Finds a local or public function.
First, it looks for a function according to its unique identifier.
If the identifier is not found, looks by name and parameters.
localFunctionList | Linked list of local functions to search in, can be null |
nIdent[in,out] | Unique identifier of the function |
name | Name of the function |
ppVars | List of function arguments |
TypeOrError | Type returned by the function or error code |
baseProg | Initial program, for context of the object/bot |
|
static |
Find all functions that match the name and arguments.
functionList | List of functions to search, can be empty. |
name | Name of the function to find. |
ppVars | Arguments to compare with parameters. |
TypeOrError | Contains a CBotError when no useable function has been found. |
funcMap | Container for suitable functions and their signature values. |
pClass | Pointer to class when searching for methods. |
|
static |
Find all public functions that match the name and arguments.
name | Name of the function to find. |
ppVars | Arguments to compare with parameters. |
TypeOrError | Contains a CBotError when no useable function has been found. |
funcMap | Container for suitable functions and their signature values. |
pClass | Pointer to class when searching for methods. |
|
static |
Find the function with the lowest signature value. If there is more than one of the same signature value, TypeOrError is set to CBotErrAmbiguousCall.
funcMap | List of functions and their signature values, can be empty. | |
[out] | nIdent | Unique identifier of the function. |
TypeOrError | Type returned by the function or error code. |
|
static |
DoCall Fait un appel à une fonction.
program | |
localFunctionList | |
nIdent | |
name | |
ppVars | |
pStack | |
pToken |
|
static |
RestoreCall.
localFunctionList | |
nIdent | |
name | |
ppVars | |
pStack |
|
static |
Find a method matching the name and arguments.
name | Name of the method to find. | |
ppVars | Arguments to compare with parameters. | |
[out] | nIdent | Unique identifier of the method. |
pStack | Current compilation stack frame. | |
pClass | Pointer to the class. |
|
static |
Find a method by its unique identifier or by name and parameters.
[in,out] | nIdent | Unique identifier of the method. |
name | Name of the method to find. | |
ppVars | Arguments to compare with parameters. | |
TypeOrError | The return type for the method or a CBotError. | |
pClass | Pointer to the class. | |
program | The current program, to search for out-of-class methods. |
|
static |
DoCall Makes call of a method.
nIdent | |
name | |
pThis | |
ppVars | |
pStack | |
pToken | |
pClass |
|
static |
RestoreCall.
nIdent | |
name | |
pThis | |
ppVars | |
pStack | |
pClass |
bool CBot::CBotFunction::CheckParam | ( | CBotDefParam * | pParam | ) |
CheckParam See if the "signature" of parameters is identical.
pParam |
|
static |
AddPublic.
pfunc |
const std::string & CBot::CBotFunction::GetName | ( | ) |
GetName.
std::string CBot::CBotFunction::GetParams | ( | ) |
GetParams.
const std::string & CBot::CBotFunction::GetClassName | ( | ) | const |
Get the name of the class for a method.
bool CBot::CBotFunction::IsPublic | ( | ) |
IsPublic.
bool CBot::CBotFunction::IsProtected | ( | ) | const |
Check if a method is protected.
bool CBot::CBotFunction::IsPrivate | ( | ) | const |
Check if a method is private.
bool CBot::CBotFunction::IsExtern | ( | ) |
IsExtern.
bool CBot::CBotFunction::GetPosition | ( | int & | start, |
int & | stop, | ||
CBotGet | modestart, | ||
CBotGet | modestop | ||
) |
GetPosition.
start | |
stop | |
modestart | |
modestop |
|
overridevirtual |
Check if the function has a return statment that will execute.
Reimplemented from CBot::CBotInstr.
|
inlineoverrideprotectedvirtual |
|
overrideprotectedvirtual |
Returns additional data associated with this instruction for debugging purposes.
Reimplemented from CBot::CBotInstr.
|
overrideprotectedvirtual |
Returns a map of all instructions connected with this one
Reimplemented from CBot::CBotInstr.
bool CBot::CBotInstr::Execute |
Execute.
pj |
bool CBot::CBotInstr::Execute |
Execute.
pj | |
pVar |
void CBot::CBotInstr::RestoreState |
RestoreState.
pj | |
bMain |