AssertCmd.h revision 87f34658dec9097d987d254a990ea7f311bfc95f
1//===- AssertCmd.h --------------------------------------------------------===// 2// 3// The MCLinker Project 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9#ifndef MCLD_SCRIPT_ASSERTCMD_H 10#define MCLD_SCRIPT_ASSERTCMD_H 11#ifdef ENABLE_UNITTEST 12#include <gtest.h> 13#endif 14 15#include <mcld/Script/ScriptCommand.h> 16#include <string> 17 18namespace mcld 19{ 20 21class RpnExpr; 22class Module; 23 24/** \class AssertCmd 25 * \brief This class defines the interfaces to assert command. 26 */ 27 28class AssertCmd : public ScriptCommand 29{ 30public: 31 AssertCmd(RpnExpr& pRpnExpr, const std::string& pMessage); 32 33 ~AssertCmd(); 34 35 AssertCmd& operator=(const AssertCmd& pAssertCmd); 36 37 const RpnExpr& getRpnExpr() const { return m_RpnExpr; } 38 RpnExpr& getRpnExpr() { return m_RpnExpr; } 39 40 const std::string& message() const { return m_Message; } 41 42 void dump() const; 43 44 static bool classof(const ScriptCommand* pCmd) 45 { 46 return pCmd->getKind() == ScriptCommand::ASSERT; 47 } 48 49 void activate(Module& pModule); 50 51private: 52 RpnExpr& m_RpnExpr; 53 std::string m_Message; 54}; 55 56} // namespace of mcld 57 58#endif 59