Colobot
Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
CBot::CBotFunction Class Reference

A function declaration in the code. More...

#include <CBotFunction.h>

Inheritance diagram for CBot::CBotFunction:
Inheritance graph
[legend]

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...
 
void AddNext (CBotFunction *p)
 AddNext. More...
 
CBotTypResult CompileCall (const std::string &name, CBotVar **ppVars, long &nIdent)
 CompileCall. More...
 
CBotFunctionFindLocalOrPublic (long &nIdent, const std::string &name, CBotVar **ppVars, CBotTypResult &TypeOrError, bool bPublic=true)
 FindLocalOrPublic Is a function according to its unique identifier if the identifier is not found, looking by name and parameters. More...
 
int DoCall (long &nIdent, const std::string &name, CBotVar **ppVars, CBotStack *pStack, CBotToken *pToken)
 DoCall Fait un appel à une fonction. More...
 
void RestoreCall (long &nIdent, const std::string &name, CBotVar **ppVars, CBotStack *pStack)
 RestoreCall. More...
 
int DoCall (long &nIdent, const std::string &name, CBotVar *pThis, CBotVar **ppVars, CBotStack *pStack, CBotToken *pToken, CBotClass *pClass)
 DoCall Makes call of a method note: this is already on the stack, the pointer pThis is just to simplify. More...
 
void RestoreCall (long &nIdent, const std::string &name, CBotVar *pThis, CBotVar **ppVars, CBotStack *pStack, CBotClass *pClass)
 RestoreCall. More...
 
bool CheckParam (CBotDefParam *pParam)
 CheckParam See if the "signature" of parameters is identical. More...
 
std::string GetName ()
 GetName. More...
 
std::string GetParams ()
 GetParams. More...
 
bool IsPublic ()
 IsPublic. More...
 
bool IsExtern ()
 IsExtern. More...
 
CBotFunctionNext ()
 Next. More...
 
bool GetPosition (int &start, int &stop, CBotGet modestart, CBotGet modestop)
 GetPosition. More...
 
- Public Member Functions inherited from CBot::CBotInstr
 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...
 
virtual bool CompCase (CBotStack *&pj, int val)
 CompCase This routine is defined only for the subclass CBotCase this allows to make the call on all instructions CompCase to see if it's a case to the desired value.. 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...
 
CBotTokenGetToken ()
 GetToken Return associated token. More...
 
void AddNext (CBotInstr *n)
 AddNext Adds the statement following the other. More...
 
CBotInstrGetNext ()
 GetNext Returns next statement. More...
 
void AddNext3 (CBotInstr *n)
 AddNext3. More...
 
CBotInstrGetNext3 ()
 GetNext3. More...
 
void AddNext3b (CBotInstr *n)
 AddNext3b. More...
 
CBotInstrGetNext3b ()
 GetNext3b. More...
 

Static Public Member Functions

static CBotFunctionCompile (CBotToken *&p, CBotCStack *pStack, CBotFunction *pFunc, bool bLocal=true)
 Compile Compiles a new function. More...
 
static CBotFunctionCompile1 (CBotToken *&p, CBotCStack *pStack, CBotClass *pClass)
 Compile1 Pre-compile a new function. More...
 
static void AddPublic (CBotFunction *pfunc)
 AddPublic. More...
 
- Static Public Member Functions inherited from CBot::CBotInstr
static CBotInstrCompile (CBotToken *&p, CBotCStack *pStack)
 Compile an instruction. More...
 
static CBotInstrCompileArray (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

- Protected Attributes inherited from CBot::CBotInstr
CBotToken m_token
 Keeps the token. More...
 
CBotInstrm_next
 Linked command. More...
 
CBotInstrm_next2b
 Second list definition chain. More...
 
CBotInstrm_next3
 Third list for indices and fields. More...
 
CBotInstrm_next3b
 Necessary for reporting tables. More...
 
- Static Protected Attributes inherited from CBot::CBotInstr
static int m_LoopLvl = 0
 Counter of nested loops, to determine the break and continue valid. More...
 

Detailed Description

A function declaration in the code.

Examples:

void test() { ... }
void test(int a, float b) { ... }
int test(int a, float b, string c) { ... }
public bool test(int a, float b, string c, SomeClass d) { ... }
extern void test() { ... }
void classname::test() { ... }

Member Function Documentation

CBotFunction * CBot::CBotFunction::Compile ( CBotToken *&  p,
CBotCStack pStack,
CBotFunction pFunc,
bool  bLocal = true 
)
static

Compile Compiles a new function.

Parameters
p
pStack
pFunc
bLocalallows of the declaration of parameters on the same level as the elements belonging to the class for methods.
Returns
CBotFunction * CBot::CBotFunction::Compile1 ( CBotToken *&  p,
CBotCStack pStack,
CBotClass pClass 
)
static

Compile1 Pre-compile a new function.

Parameters
p
pStack
pClass
Returns
bool CBot::CBotFunction::Execute ( CBotVar **  ppVars,
CBotStack *&  pj,
CBotVar pInstance = nullptr 
)

Execute.

Parameters
ppVars
pj
pInstance
Returns
void CBot::CBotFunction::RestoreState ( CBotVar **  ppVars,
CBotStack *&  pj,
CBotVar pInstance = nullptr 
)

RestoreState.

Parameters
ppVars
pj
pInstance
void CBot::CBotFunction::AddNext ( CBotFunction p)

AddNext.

Parameters
p
CBotTypResult CBot::CBotFunction::CompileCall ( const std::string &  name,
CBotVar **  ppVars,
long &  nIdent 
)

CompileCall.

Parameters
name
ppVars
nIdent
Returns
CBotFunction * CBot::CBotFunction::FindLocalOrPublic ( long &  nIdent,
const std::string &  name,
CBotVar **  ppVars,
CBotTypResult TypeOrError,
bool  bPublic = true 
)

FindLocalOrPublic Is a function according to its unique identifier if the identifier is not found, looking by name and parameters.

Parameters
nIdent
name
ppVars
TypeOrError
bPublic
Returns
int CBot::CBotFunction::DoCall ( long &  nIdent,
const std::string &  name,
CBotVar **  ppVars,
CBotStack pStack,
CBotToken pToken 
)

DoCall Fait un appel à une fonction.

Parameters
nIdent
name
ppVars
pStack
pToken
Returns
void CBot::CBotFunction::RestoreCall ( long &  nIdent,
const std::string &  name,
CBotVar **  ppVars,
CBotStack pStack 
)

RestoreCall.

Parameters
nIdent
name
ppVars
pStack
int CBot::CBotFunction::DoCall ( long &  nIdent,
const std::string &  name,
CBotVar pThis,
CBotVar **  ppVars,
CBotStack pStack,
CBotToken pToken,
CBotClass pClass 
)

DoCall Makes call of a method note: this is already on the stack, the pointer pThis is just to simplify.

Parameters
nIdent
name
pThis
ppVars
pStack
pToken
pClass
Returns
void CBot::CBotFunction::RestoreCall ( long &  nIdent,
const std::string &  name,
CBotVar pThis,
CBotVar **  ppVars,
CBotStack pStack,
CBotClass pClass 
)

RestoreCall.

Parameters
nIdent
name
pThis
ppVars
pStack
pClass
bool CBot::CBotFunction::CheckParam ( CBotDefParam pParam)

CheckParam See if the "signature" of parameters is identical.

Parameters
pParam
Returns
void CBot::CBotFunction::AddPublic ( CBotFunction pfunc)
static

AddPublic.

Parameters
pfunc
std::string CBot::CBotFunction::GetName ( )

GetName.

Returns
std::string CBot::CBotFunction::GetParams ( )

GetParams.

Returns
bool CBot::CBotFunction::IsPublic ( )

IsPublic.

Returns
bool CBot::CBotFunction::IsExtern ( )

IsExtern.

Returns
CBotFunction * CBot::CBotFunction::Next ( )

Next.

Returns
bool CBot::CBotFunction::GetPosition ( int &  start,
int &  stop,
CBotGet  modestart,
CBotGet  modestop 
)

GetPosition.

Parameters
start
stop
modestart
modestop
Returns
virtual const std::string CBot::CBotFunction::GetDebugName ( )
inlineoverrideprotectedvirtual

Returns the name of this class.

See also
CBotDebug

Implements CBot::CBotInstr.

std::string CBot::CBotFunction::GetDebugData ( )
overrideprotectedvirtual

Returns additional data associated with this instruction for debugging purposes.

See also
CBotDebug

Reimplemented from CBot::CBotInstr.

std::map< std::string, CBotInstr * > CBot::CBotFunction::GetDebugLinks ( )
overrideprotectedvirtual

Returns a map of all instructions connected with this one

See also
CBotDebug

Reimplemented from CBot::CBotInstr.


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