Assignment.h revision 87f34658dec9097d987d254a990ea7f311bfc95f
1//===- Assignment.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_ASSIGNMENT_H 10#define MCLD_SCRIPT_ASSIGNMENT_H 11#ifdef ENABLE_UNITTEST 12#include <gtest.h> 13#endif 14 15#include <mcld/Script/ScriptCommand.h> 16 17namespace mcld 18{ 19 20class Module; 21class RpnExpr; 22class SymOperand; 23class RpnEvaluator; 24 25/** \class Assignment 26 * \brief This class defines the interfaces to assignment command. 27 */ 28 29class Assignment : public ScriptCommand 30{ 31public: 32 enum Level { 33 OUTSIDE_SECTIONS, // outside SECTIONS command 34 OUTPUT_SECTION, // related to an output section 35 INPUT_SECTION // related to an input section 36 }; 37 38 enum Type { 39 DEFAULT, 40 HIDDEN, 41 PROVIDE, 42 PROVIDE_HIDDEN 43 }; 44 45public: 46 Assignment(Level pLevel, 47 Type pType, 48 SymOperand& pSymbol, 49 RpnExpr& pRpnExpr); 50 51 ~Assignment(); 52 53 Assignment& operator=(const Assignment& pAssignment); 54 55 Level level() const { return m_Level; } 56 57 Type type() const { return m_Type; } 58 59 const SymOperand& symbol() const { return m_Symbol; } 60 SymOperand& symbol() { return m_Symbol; } 61 62 const RpnExpr& getRpnExpr() const { return m_RpnExpr; } 63 RpnExpr& getRpnExpr() { return m_RpnExpr; } 64 65 void dump() const; 66 67 static bool classof(const ScriptCommand* pCmd) 68 { 69 return pCmd->getKind() == ScriptCommand::ASSIGNMENT; 70 } 71 72 void activate(Module& pModule); 73 74 /// assign - evaluate the rhs and assign the result to lhs. 75 bool assign(RpnEvaluator& pEvaluator); 76 77private: 78 Level m_Level; 79 Type m_Type; 80 SymOperand& m_Symbol; 81 RpnExpr& m_RpnExpr; 82}; 83 84} // namespace of mcld 85 86#endif 87 88