22 #include "CBot/CBotDefines.h" 23 #include "CBot/CBotTypResult.h" 25 #include "CBot/CBotVar/CBotVar.h" 34 class CBotExternalCall;
57 enum class IsFunction : unsigned short { NO = 0, YES = 1, EXTERNAL_CALL = 2 };
113 return m_error == CBotNoErr;
141 void SetBreak(
int val,
const std::string& name);
285 bool IfContinue(
int state,
const std::string& name);
306 bool SetState(
int n,
int lim = -10);
437 bool SaveState(FILE* pf);
438 bool RestoreState(FILE* pf,
CBotStack* &pStack);
461 void GetRunPos(std::string& functionName,
int& start,
int& end);
470 bool IsCallFinished();
492 static int m_initimer;
494 static std::string m_labelBreak;
495 static void* m_pUser;
bool Return(CBotStack *pFils)
Return to this point - copy the result from given stack, and destroy all child stacks from here...
Definition: CBotStack.cpp:185
void RestoreCall(long &nIdent, CBotToken *token, CBotVar **ppVar)
Restore a function call after the program state has been restored from a file.
Definition: CBotStack.cpp:586
void * GetUserPtr()
Get user pointer for external calls.
Definition: CBotStack.cpp:549
bool IfStep()
Check if we are in step by step execution mode.
Definition: CBotStack.cpp:251
Class for one CBot instruction.
Definition: CBotInstr.h:86
int GetState()
Return current execution state.
Definition: CBotStack.h:314
BlockVisibilityType GetBlock()
Get the block type this stack represents - instruction, code block or function.
Definition: CBotStack.cpp:179
void SetPosError(CBotToken *token)
Set error position to position of given token.
Definition: CBotStack.cpp:439
CBotVar * FindVar(CBotToken *&pToken, bool bUpdate)
Fetch a variable by its token.
Definition: CBotStack.cpp:314
bool Execute()
Resumes execution of interrupted external call.
Definition: CBotStack.cpp:457
bool IncState(int lim=-10)
Increase the execution state by one.
Definition: CBotStack.cpp:410
void SetBreak(int val, const std::string &name)
Definition: CBotStack.cpp:287
bool BreakReturn(CBotStack *pfils, const std::string &name="")
Definition: CBotStack.cpp:258
void Reset()
Reset the stack for execution resume - resets the error and timer.
Definition: CBotStack.cpp:220
bool IfContinue(int state, const std::string &name)
Definition: CBotStack.cpp:272
void GetRunPos(std::string &functionName, int &start, int &end)
Get current position in the program.
Definition: CBotStack.cpp:597
Class that manages a CBot program. This is the main entry point into the CBot engine.
Definition: CBotProgram.h:83
bool IsOk()
Check if there was an error.
Definition: CBotStack.h:111
The execution stack.
Definition: CBotStack.h:44
static int GetTimer()
Get the current configured maximum number of "timer ticks" (parts of instructions) to execute...
Definition: CBotStack.cpp:451
static CBotStack * AllocateStack()
Allocate the stack.
Definition: CBotStack.cpp:51
void AddVar(CBotVar *var)
Adds a local variable.
Definition: CBotStack.cpp:517
bool GetRetVar(bool bRet)
Definition: CBotStack.cpp:300
CBotError GetError(int &start, int &end)
Get last error.
Definition: CBotStack.h:97
Interface for external CBot calls.
Definition: CBotExternalCall.h:45
bool ReturnKeep(CBotStack *pFils)
Like Return() but doesn't destroy the stacks.
Definition: CBotStack.cpp:200
A CBot variable.
Definition: CBotVar.h:42
void SetUserPtr(void *user)
Set user pointer for external calls.
Definition: CBotStack.cpp:554
Some enum values used across the CBot engine.
void SetProgram(CBotProgram *p)
Set program this stack level is in. Additionally marks this block as function block. Note: for public functions different stack levels might be in different programs.
Definition: CBotStack.cpp:533
CBotStack * RestoreStack(CBotInstr *instr=nullptr)
Restore CBotInstr pointer after loading stack from file.
Definition: CBotStack.cpp:230
CBotStack * AddStack2(BlockVisibilityType bBlock=BlockVisibilityType::INSTRUCTION)
Creates or gets the secondary child stack.
Definition: CBotStack.cpp:155
static void SetTimer(int n)
Set the maximum number of "timer ticks" (parts of instructions) to execute.
Definition: CBotStack.cpp:446
CBotError
This enum contains possible CBot error values. Values in range 5000-5999 are compile errors...
Definition: CBotEnums.h:190
long GetVal()
Return the result variable as int.
Definition: CBotStack.cpp:510
CBotStack * AddStackExternalCall(CBotExternalCall *instr=nullptr, BlockVisibilityType bBlock=BlockVisibilityType::INSTRUCTION)
Adds special EOX stack marker.
Definition: CBotStack.cpp:141
void SetCopyVar(CBotVar *var)
Set the result variable to copy of given variable.
Definition: CBotStack.cpp:495
void SetError(CBotError n, CBotToken *token=nullptr)
Set execution error unless it's already set unless you are trying to reset it.
Definition: CBotStack.cpp:419
CBotError GetError()
Get last error.
Definition: CBotStack.h:104
BlockVisibilityType
Block type this stack represents. This determines local variable visibility (you can only see up to t...
Definition: CBotStack.h:50
CBotStack * AddStack(CBotInstr *instr=nullptr, BlockVisibilityType bBlock=BlockVisibilityType::INSTRUCTION)
Creates or gets the primary child stack.
Definition: CBotStack.cpp:113
Code block between { ... }.
CBotVar * GetStackVars(std::string &functionName, int level)
Get local variables at the given stack level.
Definition: CBotStack.cpp:632
bool StackOver()
Check for stack overflow and set error status as needed.
Definition: CBotStack.cpp:212
bool SetState(int n, int lim=-10)
Set execution state.
Definition: CBotStack.cpp:401
void ResetError(CBotError n, int start, int end)
Set execution error even if it is already set.
Definition: CBotStack.cpp:431
CBotVar * GetVar()
Return result variable.
Definition: CBotStack.cpp:504
bool ExecuteCall(long &nIdent, CBotToken *token, CBotVar **ppVar, const CBotTypResult &rettype)
Execute a function call, either external or user-defined.
Definition: CBotStack.cpp:560
CBotStack * RestoreStackEOX(CBotExternalCall *instr=nullptr)
Restores CBotExternalCall in the EOX marker after loading stack from file.
Definition: CBotStack.cpp:242
Class to define the complete type of a variable.
Definition: CBotTypResult.h:47
CBot engine.
Definition: CBotCallMethode.cpp:28
CBotProgram * GetProgram(bool bFirst=false)
Get program we are currently in.
Definition: CBotStack.cpp:540
void Delete()
Remove the current stack.
Definition: CBotStack.cpp:81
CBotVar * CopyVar(CBotToken &pToken, bool bUpdate=false)
Find variable by its token and returns a copy of it.
Definition: CBotStack.cpp:389
void SetVar(CBotVar *var)
Set the result variable.
Definition: CBotStack.cpp:487
Class representing one token of a program.
Definition: CBotToken.h:80
Function - variable visibility limit.