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