1 //===- UnaryOp.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_UNARYOP_H_ 10 #define MCLD_SCRIPT_UNARYOP_H_ 11 12 #include "mcld/Script/Operator.h" 13 14 #include <cstddef> 15 16 namespace mcld { 17 18 class IntOperand; 19 class Module; 20 class Operand; 21 class TargetLDBackend; 22 23 /** \class UnaryOp 24 * \brief This class defines the interfaces to an unary operator token. 25 */ 26 27 template <Operator::Type TYPE> 28 class UnaryOp : public Operator { 29 private: 30 friend class Operator; 31 UnaryOp()32 UnaryOp() : Operator(Operator::UNARY, TYPE), m_pOperand(NULL) {} 33 34 public: ~UnaryOp()35 ~UnaryOp() {} 36 37 IntOperand* eval(const Module& pModule, const TargetLDBackend& pBackend); 38 appendOperand(Operand * pOperand)39 void appendOperand(Operand* pOperand) { m_pOperand = pOperand; } 40 41 private: 42 Operand* m_pOperand; 43 }; 44 45 template <> 46 IntOperand* UnaryOp<Operator::UNARY_PLUS>::eval(const Module&, 47 const TargetLDBackend&); 48 template <> 49 IntOperand* UnaryOp<Operator::UNARY_MINUS>::eval(const Module&, 50 const TargetLDBackend&); 51 template <> 52 IntOperand* UnaryOp<Operator::LOGICAL_NOT>::eval(const Module&, 53 const TargetLDBackend&); 54 template <> 55 IntOperand* UnaryOp<Operator::BITWISE_NOT>::eval(const Module&, 56 const TargetLDBackend&); 57 58 template <> 59 IntOperand* UnaryOp<Operator::ABSOLUTE>::eval(const Module&, 60 const TargetLDBackend&); 61 template <> 62 IntOperand* UnaryOp<Operator::ADDR>::eval(const Module&, 63 const TargetLDBackend&); 64 template <> 65 IntOperand* UnaryOp<Operator::ALIGNOF>::eval(const Module&, 66 const TargetLDBackend&); 67 template <> 68 IntOperand* UnaryOp<Operator::DATA_SEGMENT_END>::eval(const Module&, 69 const TargetLDBackend&); 70 template <> 71 IntOperand* UnaryOp<Operator::DEFINED>::eval(const Module&, 72 const TargetLDBackend&); 73 template <> 74 IntOperand* UnaryOp<Operator::LENGTH>::eval(const Module&, 75 const TargetLDBackend&); 76 template <> 77 IntOperand* UnaryOp<Operator::LOADADDR>::eval(const Module&, 78 const TargetLDBackend&); 79 template <> 80 IntOperand* UnaryOp<Operator::NEXT>::eval(const Module&, 81 const TargetLDBackend&); 82 template <> 83 IntOperand* UnaryOp<Operator::ORIGIN>::eval(const Module&, 84 const TargetLDBackend&); 85 template <> 86 IntOperand* UnaryOp<Operator::SIZEOF>::eval(const Module&, 87 const TargetLDBackend&); 88 89 } // namespace mcld 90 91 #endif // MCLD_SCRIPT_UNARYOP_H_ 92