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