Moving CBotExprNan class in its own header and source files.

dev-time-step
Grunaka 2015-11-11 17:47:44 +01:00
parent d70527db66
commit 85756b4da1
5 changed files with 116 additions and 44 deletions

View File

@ -46,6 +46,7 @@
#include "CBotInstr/CBotExprAlpha.h"
#include "CBotInstr/CBotExprNum.h"
#include "CBotInstr/CBotNew.h"
#include "CBotInstr/CBotExprNan.h"
// Local include
@ -2773,38 +2774,6 @@ void CBotExprNull::RestoreState(CBotStack* &pj, bool bMain)
if (bMain) pj->RestoreStack(this);
}
//////////////////////////////////////////////////////////////////////////////////////////
// management of the operand "nan"
CBotExprNan::CBotExprNan()
{
name = "CBotExprNan";
}
CBotExprNan::~CBotExprNan()
{
}
// executes, returns null pointer
bool CBotExprNan::Execute(CBotStack* &pj)
{
CBotStack* pile = pj->AddStack(this);
if (pile->IfStep()) return false;
CBotVar* var = CBotVar::Create(static_cast<CBotToken*>(nullptr), CBotTypInt);
var->SetInit(CBotVar::InitType::IS_NAN); // nan
pile->SetVar(var); // put on the stack
return pj->Return(pile); // forward below
}
void CBotExprNan::RestoreState(CBotStack* &pj, bool bMain)
{
if (bMain) pj->RestoreStack(this);
}
//////////////////////////////////////////////////////////////////////////////////////
// compile a variable name
// check that it is known on the stack

View File

@ -976,18 +976,6 @@ public:
void RestoreState(CBotStack* &pj, bool bMain) override;
};
class CBotExprNan : public CBotInstr
{
private:
public:
CBotExprNan();
~CBotExprNan();
bool Execute(CBotStack* &pj) override;
void RestoreState(CBotStack* &pj, bool bMain) override;
};
#define MAX(a,b) ((a>b) ? a : b)

View File

@ -0,0 +1,55 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://gnu.org/licenses
*/
// Modules inlcude
#include "CBotExprNan.h"
// Local include
// Global include
////////////////////////////////////////////////////////////////////////////////
CBotExprNan::CBotExprNan()
{
name = "CBotExprNan";
}
////////////////////////////////////////////////////////////////////////////////
CBotExprNan::~CBotExprNan()
{
}
////////////////////////////////////////////////////////////////////////////////
bool CBotExprNan::Execute(CBotStack* &pj)
{
CBotStack* pile = pj->AddStack(this);
if (pile->IfStep()) return false;
CBotVar* var = CBotVar::Create(static_cast<CBotToken*>(nullptr), CBotTypInt);
var->SetInit(CBotVar::InitType::IS_NAN); // nan
pile->SetVar(var); // put on the stack
return pj->Return(pile); // forward below
}
////////////////////////////////////////////////////////////////////////////////
void CBotExprNan::RestoreState(CBotStack* &pj, bool bMain)
{
if (bMain) pj->RestoreStack(this);
}

View File

@ -0,0 +1,59 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://gnu.org/licenses
*/
#pragma once
// Modules inlcude
#include "CBot.h"
// Local include
// Global include
/*!
* \brief The CBotExprNan class Management of the operand "nan".
*/
class CBotExprNan : public CBotInstr
{
public:
/*!
* \brief CBotExprNan
*/
CBotExprNan();
/*!
* \brief ~CBotExprNan
*/
~CBotExprNan();
/*!
* \brief Execute Executes, returns null pointer.
* \param pj
* \return
*/
bool Execute(CBotStack* &pj) override;
/*!
* \brief RestoreState
* \param pj
* \param bMain
*/
void RestoreState(CBotStack* &pj, bool bMain) override;
};

View File

@ -22,6 +22,7 @@ set(SOURCES
CBotInstr/CBotExprAlpha.cpp
CBotInstr/CBotExprNum.cpp
CBotInstr/CBotNew.cpp
CBotInstr/CBotExprNan.cpp
)
# Includes