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 16namespace mcld { 17 18class IntOperand; 19class Module; 20class Operand; 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 private: 30 friend class Operator; 31 32 UnaryOp() : Operator(Operator::UNARY, TYPE), m_pOperand(NULL) {} 33 34 public: 35 ~UnaryOp() {} 36 37 IntOperand* eval(const Module& pModule, const TargetLDBackend& pBackend); 38 39 void appendOperand(Operand* pOperand) { m_pOperand = pOperand; } 40 41 private: 42 Operand* m_pOperand; 43}; 44 45template <> 46IntOperand* UnaryOp<Operator::UNARY_PLUS>::eval(const Module&, 47 const TargetLDBackend&); 48template <> 49IntOperand* UnaryOp<Operator::UNARY_MINUS>::eval(const Module&, 50 const TargetLDBackend&); 51template <> 52IntOperand* UnaryOp<Operator::LOGICAL_NOT>::eval(const Module&, 53 const TargetLDBackend&); 54template <> 55IntOperand* UnaryOp<Operator::BITWISE_NOT>::eval(const Module&, 56 const TargetLDBackend&); 57 58template <> 59IntOperand* UnaryOp<Operator::ABSOLUTE>::eval(const Module&, 60 const TargetLDBackend&); 61template <> 62IntOperand* UnaryOp<Operator::ADDR>::eval(const Module&, 63 const TargetLDBackend&); 64template <> 65IntOperand* UnaryOp<Operator::ALIGNOF>::eval(const Module&, 66 const TargetLDBackend&); 67template <> 68IntOperand* UnaryOp<Operator::DATA_SEGMENT_END>::eval(const Module&, 69 const TargetLDBackend&); 70template <> 71IntOperand* UnaryOp<Operator::DEFINED>::eval(const Module&, 72 const TargetLDBackend&); 73template <> 74IntOperand* UnaryOp<Operator::LENGTH>::eval(const Module&, 75 const TargetLDBackend&); 76template <> 77IntOperand* UnaryOp<Operator::LOADADDR>::eval(const Module&, 78 const TargetLDBackend&); 79template <> 80IntOperand* UnaryOp<Operator::NEXT>::eval(const Module&, 81 const TargetLDBackend&); 82template <> 83IntOperand* UnaryOp<Operator::ORIGIN>::eval(const Module&, 84 const TargetLDBackend&); 85template <> 86IntOperand* UnaryOp<Operator::SIZEOF>::eval(const Module&, 87 const TargetLDBackend&); 88 89} // namespace mcld 90 91#endif // MCLD_SCRIPT_UNARYOP_H_ 92