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