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