Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

215 lines
4.6 KiB

  1. //
  2. // Copyright (c) 1997-2001 Microsoft Corporation, All Rights Reserved
  3. //
  4. #ifndef SIMC_SYMBOL_H
  5. #define SIMC_SYMBOL_H
  6. // These are the status for objects of classes SIMCDefinedValueReference
  7. // and SIMCDefinedTypeReference
  8. enum SIMCResolutionStatus
  9. {
  10. RESOLVE_UNSET, // Haven't resolved it yet
  11. RESOLVE_UNDEFINED, // Could not resolve it
  12. RESOLVE_IMPORT, // Resolved to IMPORTS
  13. RESOLVE_CORRECT, // Resolved properly, to the type expected
  14. RESOLVE_FALSE // Resolved properly, but not to the type expected
  15. };
  16. class SIMCModule;
  17. // The base class for all the symbols that can occur in a module.
  18. // It is an abstract class. See the files "typeRef.hpp" and "valueRef.hpp"
  19. // for classes derived from this
  20. class SIMCSymbol
  21. {
  22. public:
  23. enum SymbolType
  24. {
  25. PRIMITIVE, // Primitive ASN.1 type
  26. LOCAL, // Locally defined in this module
  27. IMPORTED, // From another module. The Internet SMI
  28. // definitions that the compiler 'knows' about,
  29. // lie in the IMPORTED category.
  30. MODULE_NAME
  31. };
  32. private:
  33. // Various charcteristics of a symbol
  34. char *_symbolName;
  35. SymbolType _symbolType;
  36. SIMCModule *_module; // Null for a PRIMITIVE, LOCAL or MODULE_NAME symbol
  37. long _lineNumber, _columnNumber;
  38. long _referenceCount;
  39. // Used in mostly in the destructors of the derived classes.
  40. // Says whether the _referenceCount value should be uses at all
  41. BOOL _useReferenceCount;
  42. protected:
  43. SIMCSymbol(const char * const symbolName,
  44. SymbolType symbolType = LOCAL,
  45. SIMCModule *module = NULL,
  46. long _lineNumber = 0, long _columnNumber = 0,
  47. long _referenceCount = 0);
  48. SIMCSymbol(const SIMCSymbol& rhs);
  49. public:
  50. virtual ~SIMCSymbol();
  51. BOOL operator == (const SIMCSymbol& rhs) const;
  52. const char* GetSymbolName() const
  53. {
  54. return (_symbolName)? _symbolName : "";
  55. }
  56. SymbolType GetSymbolType() const
  57. {
  58. return _symbolType;
  59. }
  60. SIMCModule *GetModule() const
  61. {
  62. return _module;
  63. }
  64. long GetLineNumber() const
  65. {
  66. return _lineNumber;
  67. }
  68. long GetColumnNumber() const
  69. {
  70. return _columnNumber;
  71. }
  72. void SetLineNumber( long line)
  73. {
  74. _lineNumber = line;
  75. }
  76. void SetColumnNumber( long col)
  77. {
  78. _columnNumber = col;
  79. }
  80. BOOL SetSymbolName(const char * name)
  81. {
  82. if( _symbolName )
  83. {
  84. delete []_symbolName;
  85. _symbolName = NULL;
  86. }
  87. return (_symbolName = NewString(name)) != NULL;
  88. }
  89. void SetSymbolType ( SymbolType x )
  90. {
  91. _symbolType = x;
  92. }
  93. void SetModule(SIMCModule * module)
  94. {
  95. _module = module;
  96. }
  97. long GetReferenceCount() const
  98. {
  99. return _referenceCount;
  100. }
  101. void SetReferenceCount(long refCount)
  102. {
  103. /*
  104. if( _symbolType == PRIMITIVE)
  105. return;
  106. */
  107. _referenceCount = refCount;
  108. /*
  109. if( refCount == 0 )
  110. delete this;
  111. */
  112. }
  113. long IncrementReferenceCount()
  114. {
  115. return ++_referenceCount;
  116. }
  117. long DecrementReferenceCount ()
  118. {
  119. return --_referenceCount;
  120. }
  121. void SetUseReferenceCount(BOOL val)
  122. {
  123. _useReferenceCount = val;
  124. }
  125. BOOL UseReferenceCount() const
  126. {
  127. return _useReferenceCount;
  128. }
  129. virtual void WriteSymbol(ostream&) const;
  130. friend ostream& operator << (ostream& outStream, const SIMCSymbol& symbol)
  131. {
  132. symbol.WriteSymbol(outStream);
  133. return outStream;
  134. }
  135. void WriteBrief(ostream& outStream) const;
  136. };
  137. // A forward-referenced symbol, whose details are
  138. // not known presently
  139. class SIMCUnknown : public SIMCSymbol
  140. {
  141. public:
  142. SIMCUnknown(const char * const symbolName,
  143. SymbolType symbolType = LOCAL,
  144. SIMCModule *module = NULL,
  145. long _lineNumber = 0, long _columnNumber = 0,
  146. long _referenceCount = 0)
  147. : SIMCSymbol( symbolName, symbolType,module,
  148. _lineNumber, _columnNumber, _referenceCount)
  149. {}
  150. virtual void WriteSymbol( ostream& outStream ) const
  151. {
  152. outStream << "UNKNOWN " ;
  153. SIMCSymbol::WriteSymbol(outStream);
  154. }
  155. };
  156. // An imported symbol, whose details are
  157. // not known presently
  158. class SIMCImport : public SIMCSymbol
  159. {
  160. public:
  161. SIMCImport(const char * const symbolName,
  162. SymbolType symbolType = LOCAL,
  163. SIMCModule *module = NULL,
  164. long _lineNumber = 0, long _columnNumber = 0,
  165. long _referenceCount = 0)
  166. : SIMCSymbol( symbolName, symbolType,module,
  167. _lineNumber, _columnNumber, _referenceCount)
  168. {}
  169. virtual void WriteSymbol( ostream& outStream ) const
  170. {
  171. outStream << "IMPORT " ;
  172. SIMCSymbol::WriteSymbol(outStream);
  173. }
  174. };
  175. #endif // SIMC_SYMBOL_H