Home | History | Annotate | Download | only in Script
      1 //===- TernaryOp.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_TERNARYOP_H
     10 #define MCLD_SCRIPT_TERNARYOP_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 TernaryOP
     24  *  \brief This class defines the interfaces to an binary operator token.
     25  */
     26 
     27 template<Operator::Type TYPE>
     28 class TernaryOp : public Operator
     29 {
     30 private:
     31   friend class Operator;
     32 
     33   TernaryOp()
     34     : Operator(Operator::TERNARY, TYPE)
     35   {
     36     m_pOperand[0] = m_pOperand[1] = m_pOperand[2] = NULL;
     37   }
     38 
     39 public:
     40   ~TernaryOp()
     41   {}
     42 
     43   IntOperand* eval(const Module& pModule, const TargetLDBackend& pBackend);
     44 
     45   void appendOperand(Operand* pOperand)
     46   {
     47     m_pOperand[m_Size++] = pOperand;
     48     if (m_Size == 3)
     49       m_Size = 0;
     50   }
     51 
     52 private:
     53   size_t m_Size;
     54   Operand* m_pOperand[3];
     55 };
     56 
     57 template<>
     58 IntOperand* TernaryOp<Operator::TERNARY_IF>::eval(const Module&,
     59                                                   const TargetLDBackend&);
     60 
     61 template<>
     62 IntOperand*
     63 TernaryOp<Operator::DATA_SEGMENT_ALIGN>::eval(const Module&,
     64                                               const TargetLDBackend&);
     65 
     66 } // namespace of mcld
     67 
     68 #endif
     69