Colobot
CBotExprVar.h
1 /*
2  * This file is part of the Colobot: Gold Edition source code
3  * Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
4  * http://epsitec.ch; http://colobot.info; http://github.com/colobot
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see http://gnu.org/licenses
18  */
19 
20 #pragma once
21 
22 #include "CBot/CBotDefines.h"
23 
24 #include "CBot/CBotInstr/CBotInstr.h"
25 #include "CBot/CBotVar/CBotVar.h"
26 
27 namespace CBot
28 {
29 
36 class CBotExprVar : public CBotInstr
37 {
38 public:
39  CBotExprVar();
40  ~CBotExprVar();
41 
49  static CBotInstr* Compile(CBotToken*& p, CBotCStack* pStack,
51 
58  static CBotInstr* CompileMethode(CBotToken* &p, CBotCStack* pStack);
59 
65  bool Execute(CBotStack* &pj) override;
66 
72  void RestoreState(CBotStack* &pj, bool bMain) override;
73 
82  bool ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, bool bStep);
83 
89  void RestoreStateVar(CBotStack* &pj, bool bMain) override;
90 
91 protected:
92  virtual const std::string GetDebugName() override { return "CBotExprVar"; }
93  virtual std::string GetDebugData() override;
94 
95 private:
96  long m_nIdent;
97  friend class CBotPostIncExpr;
98  friend class CBotPreIncExpr;
99 
100 };
101 
102 } // namespace CBot
Class for one CBot instruction.
Definition: CBotInstr.h:86
The execution stack.
Definition: CBotStack.h:44
bool Execute(CBotStack *&pj) override
Execute Execute, making the value of a variable.
Definition: CBotExprVar.cpp:223
bool ExecuteVar(CBotVar *&pVar, CBotStack *&pile, CBotToken *prevToken, bool bStep)
ExecuteVar Fetch a variable at runtime.
Definition: CBotExprVar.cpp:277
Post increment/decrement.
Definition: CBotPostIncExpr.h:32
Pre increment/decrement.
Definition: CBotPreIncExpr.h:32
A CBot variable.
Definition: CBotVar.h:42
virtual std::string GetDebugData() override
Returns additional data associated with this instruction for debugging purposes.
Definition: CBotExprVar.cpp:308
static CBotInstr * CompileMethode(CBotToken *&p, CBotCStack *pStack)
CompileMethode.
Definition: CBotExprVar.cpp:179
ProtectionLevel
Class member protection level (public/protected/private)
Definition: CBotVar.h:306
The CBotCStack class Management of the stack of compilation.
Definition: CBotCStack.h:35
Expression representing a variable name.
Definition: CBotExprVar.h:36
static CBotInstr * Compile(CBotToken *&p, CBotCStack *pStack, CBotVar::ProtectionLevel privat=CBotVar::ProtectionLevel::Protected)
Compile.
Definition: CBotExprVar.cpp:47
virtual const std::string GetDebugName() override
Returns the name of this class.
Definition: CBotExprVar.h:92
void RestoreState(CBotStack *&pj, bool bMain) override
RestoreState.
Definition: CBotExprVar.cpp:260
void RestoreStateVar(CBotStack *&pj, bool bMain) override
RestoreStateVar Fetch variable at runtime.
Definition: CBotExprVar.cpp:299
CBot engine.
Definition: CBotCallMethode.cpp:28
Class representing one token of a program.
Definition: CBotToken.h:80