Colobot
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
CBot::CBotInstr Class Referenceabstract

Class for one CBot instruction. More...

#include <CBotInstr.h>

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

Public Member Functions

 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 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 ()=0
 Returns the name of this class. More...
 
virtual std::string GetDebugData ()
 Returns additional data associated with this instruction for debugging purposes. More...
 
virtual std::map< std::string, CBotInstr * > GetDebugLinks ()
 

Protected Attributes

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

static int m_LoopLvl = 0
 Counter of nested loops, to determine the break and continue valid. More...
 

Friends

class CBotDebug
 
class CBotDefClass
 
class CBotDefInt
 
class CBotListArray
 

Detailed Description

Class for one CBot instruction.

For example, for program:

int x[]; x[1] = 4;
int y[x[1]][10], z;

the following structure is generated:

dot_inline_dotgraph_1.png
Todo:
More documentation

Constructor & Destructor Documentation

CBot::CBotInstr::CBotInstr ( )

Constructor.

CBot::CBotInstr::~CBotInstr ( )
virtual

Destructor.

Member Function Documentation

CBotInstr * CBot::CBotInstr::Compile ( CBotToken *&  p,
CBotCStack pStack 
)
static

Compile an instruction.

Supported instructions are:

  • while
  • do
  • try
  • throw
  • if
  • for
  • switch
  • break
  • continue
  • return
  • int
  • float
  • boolean
  • string
  • declaration of an instance of a class
  • arithmetic expression (with or without assigment)
    Parameters
    [in,out]pToken to start at, updated to point at the next token
    pStackCompilation stack
    Returns
    Compiled instruction
CBotInstr * CBot::CBotInstr::CompileArray ( CBotToken *&  p,
CBotCStack pStack,
CBotTypResult  type,
bool  first = true 
)
static

CompileArray.

Parameters
p
pStack
type
first
Returns
bool CBot::CBotInstr::Execute ( CBotStack *&  pj)
virtual
bool CBot::CBotInstr::Execute ( CBotStack *&  pj,
CBotVar pVar 
)
virtual

Execute.

Parameters
pj
pVar
Returns

Reimplemented in CBot::CBotListArray.

void CBot::CBotInstr::RestoreState ( CBotStack *&  pj,
bool  bMain 
)
virtual
bool CBot::CBotInstr::ExecuteVar ( CBotVar *&  pVar,
CBotCStack *&  pile 
)
virtual

ExecuteVar.

Parameters
pVar
pile
Returns

Reimplemented in CBot::CBotLeftExpr, CBot::CBotFieldExpr, and CBot::CBotIndexExpr.

bool CBot::CBotInstr::ExecuteVar ( CBotVar *&  pVar,
CBotStack *&  pile,
CBotToken prevToken,
bool  bStep,
bool  bExtend 
)
virtual

ExecuteVar.

Parameters
pVar
pile
prevToken
bStep
bExtend
Returns

Reimplemented in CBot::CBotInstrMethode, CBot::CBotFieldExpr, and CBot::CBotIndexExpr.

void CBot::CBotInstr::RestoreStateVar ( CBotStack *&  pile,
bool  bMain 
)
virtual

RestoreStateVar.

Parameters
pile
bMain

Reimplemented in CBot::CBotExprVar, CBot::CBotLeftExpr, CBot::CBotInstrMethode, CBot::CBotFieldExpr, and CBot::CBotIndexExpr.

bool CBot::CBotInstr::CompCase ( CBotStack *&  pj,
int  val 
)
virtual

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..

Parameters
pj
val
Returns

Reimplemented in CBot::CBotCase.

void CBot::CBotInstr::SetToken ( CBotToken p)

SetToken Set the token corresponding to the instruction.

Parameters
p
int CBot::CBotInstr::GetTokenType ( )

GetTokenType Return the type of the token assicated with the instruction.

Returns
CBotToken * CBot::CBotInstr::GetToken ( )

GetToken Return associated token.

Returns
void CBot::CBotInstr::AddNext ( CBotInstr n)

AddNext Adds the statement following the other.

Parameters
n
CBotInstr * CBot::CBotInstr::GetNext ( )

GetNext Returns next statement.

Returns
void CBot::CBotInstr::AddNext3 ( CBotInstr n)

AddNext3.

Parameters
n
CBotInstr * CBot::CBotInstr::GetNext3 ( )

GetNext3.

Returns
void CBot::CBotInstr::AddNext3b ( CBotInstr n)

AddNext3b.

Parameters
n
CBotInstr * CBot::CBotInstr::GetNext3b ( )

GetNext3b.

Returns
void CBot::CBotInstr::IncLvl ( std::string &  label)
static

IncLvl Adds a level with a label.

Parameters
label
void CBot::CBotInstr::IncLvl ( )
static

IncLvl Adds a level (switch statement).

void CBot::CBotInstr::DecLvl ( )
static

DecLvl Free a level.

bool CBot::CBotInstr::ChkLvl ( const std::string &  label,
int  type 
)
static

ChkLvl Control validity of break and continue.

Parameters
label
type
Returns
virtual const std::string CBot::CBotInstr::GetDebugName ( )
protectedpure virtual
virtual std::string CBot::CBotInstr::GetDebugData ( )
inlineprotectedvirtual
std::map< std::string, CBotInstr * > CBot::CBotInstr::GetDebugLinks ( )
protectedvirtual

Member Data Documentation

CBotToken CBot::CBotInstr::m_token
protected

Keeps the token.

CBotInstr* CBot::CBotInstr::m_next
protected

Linked command.

CBotInstr* CBot::CBotInstr::m_next2b
protected

Second list definition chain.

CBotInstr* CBot::CBotInstr::m_next3
protected

Third list for indices and fields.

CBotInstr* CBot::CBotInstr::m_next3b
protected

Necessary for reporting tables.

int CBot::CBotInstr::m_LoopLvl = 0
staticprotected

Counter of nested loops, to determine the break and continue valid.


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