Home | History | Annotate | Download | only in Script
      1 //===- Assignment.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_ASSIGNMENT_H
     10 #define MCLD_SCRIPT_ASSIGNMENT_H
     11 
     12 #include <mcld/Script/ScriptCommand.h>
     13 
     14 namespace mcld
     15 {
     16 
     17 class Module;
     18 class RpnExpr;
     19 class SymOperand;
     20 class RpnEvaluator;
     21 
     22 /** \class Assignment
     23  *  \brief This class defines the interfaces to assignment command.
     24  */
     25 
     26 class Assignment : public ScriptCommand
     27 {
     28 public:
     29   enum Level {
     30     OUTSIDE_SECTIONS, // outside SECTIONS command
     31     OUTPUT_SECTION,   // related to an output section
     32     INPUT_SECTION     // related to an input section
     33   };
     34 
     35   enum Type {
     36     DEFAULT,
     37     HIDDEN,
     38     PROVIDE,
     39     PROVIDE_HIDDEN
     40   };
     41 
     42 public:
     43   Assignment(Level pLevel,
     44              Type pType,
     45              SymOperand& pSymbol,
     46              RpnExpr& pRpnExpr);
     47 
     48   ~Assignment();
     49 
     50   Assignment& operator=(const Assignment& pAssignment);
     51 
     52   Level level() const { return m_Level; }
     53 
     54   Type type() const { return m_Type; }
     55 
     56   const SymOperand& symbol() const { return m_Symbol; }
     57   SymOperand&       symbol()       { return m_Symbol; }
     58 
     59   const RpnExpr& getRpnExpr() const { return m_RpnExpr; }
     60   RpnExpr&       getRpnExpr()       { return m_RpnExpr; }
     61 
     62   void dump() const;
     63 
     64   static bool classof(const ScriptCommand* pCmd)
     65   {
     66     return pCmd->getKind() == ScriptCommand::ASSIGNMENT;
     67   }
     68 
     69   void activate(Module& pModule);
     70 
     71   /// assign - evaluate the rhs and assign the result to lhs.
     72   bool assign(RpnEvaluator& pEvaluator);
     73 
     74 private:
     75   Level m_Level;
     76   Type m_Type;
     77   SymOperand& m_Symbol;
     78   RpnExpr& m_RpnExpr;
     79 };
     80 
     81 } // namespace of mcld
     82 
     83 #endif
     84 
     85