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.

271 lines
9.9 KiB

  1. //
  2. // Copyright (c) 1997-2001 Microsoft Corporation, All Rights Reserved
  3. //
  4. #ifndef SIMC_PARSE_TREE_H
  5. #define SIMC_PARSE_TREE_H
  6. typedef CList<int, int> SIMCCleanOidValue;
  7. ostream& operator << (ostream& outStream, const SIMCCleanOidValue& obj);
  8. /*
  9. * SIMCParseTree - This is derived from the SIMCAbstractParseTree class
  10. * and provides implementation of all the pure virtual functions in it (the
  11. * semantic checking functions).
  12. * It uses the dll "smierrsy.dll" to hold the strings for the error messages
  13. * that it generates while checking semantics.
  14. * It uses the error container of the base class to place these messages.
  15. */
  16. class SIMCParseTree : public SIMCAbstractParseTree
  17. {
  18. // An OID tree that spans all modules.
  19. // Constructed as an aid to semantic checking
  20. SIMCOidTree _theTree;
  21. // The lowest semantic error Id
  22. static const int SEMANTIC_ERROR_BASE;
  23. // The size of the buffer used to construct an error message
  24. static const int MESSAGE_SIZE;
  25. public:
  26. // The resource-only dll with semantic error text string table
  27. static HINSTANCE semanticErrorsDll;
  28. // Accept an error container to put the error messages in.
  29. SIMCParseTree(SIMCErrorContainer * ec)
  30. : SIMCAbstractParseTree(ec)
  31. {
  32. if ( semanticErrorsDll == NULL )
  33. semanticErrorsDll = LoadLibrary(SIMCParser::semanticErrorsDllFile);
  34. }
  35. // Severity levels for the various erro messages generated
  36. // by this class
  37. enum SeverityLevel
  38. {
  39. INVALID,
  40. FATAL,
  41. WARNING,
  42. INFORMATION
  43. };
  44. // A function for constructing the error messages, to be put into
  45. // the error container
  46. void SemanticError(const char *const inputStreamName, int errorType,
  47. int lineNo,
  48. int columnNo,
  49. ...);
  50. // Resolve the forward references and the external references.
  51. // See the description in SIMCAbstractParseTree
  52. virtual BOOL Resolve(BOOL local);
  53. // Privately used functions, in Resolve()
  54. private:
  55. BOOL SetResolutionStatus();
  56. BOOL SetRootAll();
  57. BOOL SetDefVal();
  58. BOOL ResolveModule(SIMCModule *m, BOOL local);
  59. BOOL ResolveImportModule(SIMCModule *m, BOOL local);
  60. BOOL ResolveSymbol(SIMCSymbol **symbol, BOOL local);
  61. public:
  62. // Check the Semantics of the modules
  63. // See the description in SIMCAbstractParseTree
  64. virtual BOOL CheckSemantics(BOOL local = FALSE);
  65. // A user will rarely use this function. It gets him the
  66. // OID tree that spans all the modules fed into the
  67. // SIMCParseTree, till now.
  68. const SIMCOidTree *GetOidTree() const
  69. {
  70. return &_theTree;
  71. }
  72. // A user will rarely use this function. It converts an unclean
  73. // OID value (SIMCOidValue) (ie, one that has references to symbols)
  74. // to a clean OID value (SIMCCleanOidValue) (ie, one in which all the
  75. // components are integer values)
  76. SIMCResolutionStatus GetCleanOidValue( const char *const filename,
  77. SIMCOidValue * input,
  78. SIMCCleanOidValue& result,
  79. BOOL local);
  80. // Privately used functions, in CheckSemantics()
  81. // These functions check the various MIB constructs.
  82. private:
  83. // Steps thru the symbol table and calls CheckSymbol() on each function
  84. BOOL CheckModule(SIMCModule *, BOOL);
  85. // Uses RTTI to check the type of the symbol and calls
  86. // CheckBuiltInTypeRef() or CheckDefinedTypeRef() or
  87. // CheckBuiltInValueRef() or CheckDefinedValueRef() or
  88. // CheckTextualConvention().
  89. BOOL CheckSymbol(SIMCSymbol **, BOOL);
  90. // Check type references
  91. BOOL CheckBuiltInTypeRef(SIMCBuiltInTypeReference *symbol, BOOL);
  92. BOOL CheckDefinedTypeRef(SIMCDefinedTypeReference *symbol, BOOL);
  93. BOOL CheckTextualConvention(SIMCTextualConvention *symbol, BOOL local);
  94. // Check types
  95. BOOL CheckRangeTypeV0(const char *const fileName,
  96. SIMCRangeType *rangeType, BOOL);
  97. BOOL CheckRangeTypeV1(const char *const fileName,
  98. SIMCRangeType *rangeType, BOOL);
  99. BOOL CheckRangeTypeV2(const char *const fileName,
  100. SIMCRangeType *rangeType, BOOL);
  101. BOOL CheckRangeRange(const SIMCRangeList *baseList);
  102. BOOL CheckSizeTypeV1(const char *const fileName,
  103. SIMCSizeType *sizeType, BOOL);
  104. BOOL CheckSizeTypeV0(const char *const fileName,
  105. SIMCSizeType *sizeType, BOOL);
  106. BOOL CheckSizeTypeV2(const char *const fileName,
  107. SIMCSizeType *sizeType, BOOL);
  108. BOOL CheckEnumTypeV0(const char *const fileName,
  109. SIMCEnumOrBitsType *enumType, BOOL);
  110. BOOL CheckEnumTypeV1(const char *const fileName,
  111. SIMCEnumOrBitsType *enumType, BOOL);
  112. BOOL CheckEnumTypeV2(const char *const fileName,
  113. SIMCEnumOrBitsType *enumType, BOOL);
  114. BOOL CheckBitsTypeV2(const char *const fileName,
  115. SIMCEnumOrBitsType *bitsType, BOOL local);
  116. BOOL CheckSequenceOfType(const char *const fileName,
  117. SIMCSequenceOfType *sequenceOfType, BOOL);
  118. BOOL CheckSequenceType(const char *const fileName,
  119. SIMCSequenceType *sequenceType, BOOL);
  120. BOOL CheckTrapType(const char *const fileName,
  121. SIMCTrapTypeType *trapType, BOOL);
  122. BOOL CheckNotificationType(const char *const fileName,
  123. SIMCNotificationTypeType *notificationType, BOOL);
  124. BOOL CheckObjectIdentityType(const char *const fileName,
  125. SIMCObjectIdentityType *rhs, BOOL local);
  126. BOOL CheckObjectTypeV1(const char *const fileName,
  127. SIMCObjectTypeV1 *objectType, BOOL);
  128. BOOL CheckObjectTypeV2(const char *const fileName,
  129. SIMCObjectTypeV2 *objectType, BOOL);
  130. BOOL CheckObjectTypeV1Syntax(const char *const fileName,
  131. SIMCObjectTypeV1 *objectType, BOOL local);
  132. BOOL CheckObjectTypeV2Syntax(const char *const fileName,
  133. SIMCObjectTypeV2 *objectType, BOOL local);
  134. BOOL CheckObjectTypeV1Index(const char *const fileName,
  135. SIMCSymbol *objectTypeSymbol,
  136. SIMCObjectTypeV1 *objectType, BOOL local);
  137. BOOL CheckObjectTypeV2Index(const char *const fileName,
  138. SIMCSymbol *objectTypeSymbol,
  139. SIMCObjectTypeV2 *objectType, BOOL local);
  140. BOOL CheckObjectTypeDefVal(const char *const fileName,
  141. SIMCObjectTypeType *objectType, BOOL local);
  142. // Check value references
  143. BOOL CheckBuiltInValueRef(SIMCBuiltInValueReference *symbol, BOOL);
  144. BOOL CheckDefinedValueRef(SIMCDefinedValueReference *symbol, BOOL);
  145. BOOL CheckObjectTypeValueAssignmentV1(const char *const fileName,
  146. SIMCBuiltInValueReference *bvRef,
  147. SIMCBuiltInTypeReference *btRef,
  148. SIMCObjectTypeV1 *objectType,
  149. SIMCValue *value,
  150. BOOL local);
  151. BOOL CheckObjectTypeValueAssignmentV2(const char *const fileName,
  152. SIMCBuiltInValueReference *bvRef,
  153. SIMCBuiltInTypeReference *btRef,
  154. SIMCObjectTypeV2 *objectType,
  155. SIMCValue *value,
  156. BOOL local);
  157. BOOL CheckTrapTypeValueAssignment(const char *const fileName,
  158. SIMCBuiltInValueReference *bvRef,
  159. SIMCBuiltInTypeReference *btRef,
  160. SIMCTrapTypeType *trapType,
  161. SIMCValue *value,
  162. BOOL local);
  163. BOOL CheckNotificationTypeValueAssignment(const char *const fileName,
  164. SIMCBuiltInValueReference *bvRef,
  165. SIMCBuiltInTypeReference *btRef,
  166. SIMCNotificationTypeType *notificationType,
  167. SIMCValue *value,
  168. BOOL local);
  169. BOOL CheckObjectIdentityValueAssignment(const char *const fileName,
  170. SIMCBuiltInValueReference *bvRef,
  171. SIMCBuiltInTypeReference *btRef,
  172. SIMCObjectIdentityType *type,
  173. SIMCValue *value,
  174. BOOL local);
  175. BOOL CheckEnumValueAssignment(const char *const fileName,
  176. SIMCBuiltInValueReference *bvRef,
  177. SIMCBuiltInTypeReference *btRef,
  178. SIMCEnumOrBitsType *enumType,
  179. SIMCValue *value,
  180. BOOL local);
  181. BOOL CheckSubTypeValueAssignment(const char *const fileName,
  182. SIMCBuiltInValueReference *bvRef,
  183. SIMCBuiltInTypeReference *btRef,
  184. SIMCSubType *subType,
  185. SIMCValue *value,
  186. BOOL local);
  187. BOOL CheckPrimitiveValueAssignment(const char * const fileName,
  188. SIMCBuiltInValueReference *bvRef,
  189. SIMCTypeReference *btRef,
  190. SIMCValue *value,
  191. BOOL local);
  192. BOOL CheckBitsTypeValueAssignment(const char *const fileName,
  193. SIMCBuiltInValueReference *bvRef,
  194. SIMCBuiltInTypeReference *btRef,
  195. SIMCEnumOrBitsType *bitsType,
  196. SIMCValue *value,
  197. BOOL local);
  198. BOOL MatchSequenceObjectTypeSyntax(const char *const fileName,
  199. SIMCObjectTypeType *objectType,
  200. SIMCTypeReference *typeRef,
  201. SIMCSequenceItem *item,
  202. BOOL local);
  203. BOOL CheckObjectSequenceItem( const char *const fileName,
  204. SIMCSequenceItem * item,
  205. SIMCValueReference *parentObjectType,
  206. BOOL local);
  207. BOOL CheckObjectSequenceOfTypeV1(const char *const fileName,
  208. SIMCObjectTypeV1 *objType,
  209. SIMCSequenceOfType *sequenceOfType,
  210. BOOL local);
  211. BOOL CheckObjectSequenceOfTypeV2(const char *const fileName,
  212. SIMCObjectTypeV2 *objType,
  213. SIMCSequenceOfType *sequenceOfType,
  214. BOOL local);
  215. BOOL CheckObjectSequenceTypeV1(const char *const fileName,
  216. SIMCObjectTypeV1 *objType,
  217. SIMCSequenceType *sequenceType,
  218. BOOL local);
  219. BOOL CheckObjectSequenceTypeV2(const char *const fileName,
  220. SIMCObjectTypeV2 *objType,
  221. SIMCSequenceType *sequenceType,
  222. BOOL local);
  223. // Build the OID tree for all the modules.
  224. // Calls BuildModuleOidTree() on each module
  225. BOOL BuildOidTree(BOOL local);
  226. // Builds OID tree for a module
  227. BOOL BuildModuleOidTree(SIMCModule *m, BOOL);
  228. // Makes Semantic checks on the OID tree.
  229. BOOL CheckOidTree(BOOL local);
  230. // Converts TRAP-TYPEs, if any to NOTIFICATION-TYPES
  231. // Then fabricates NOTIFICATION-GROUPs from NOTIFICATION-TYPEs
  232. BOOL FabricateNotificationGroups();
  233. // The recursive routine called by GetCleanOidValue()
  234. SIMCResolutionStatus GetCleanOidValueRec( const char *const fileName,
  235. SIMCOidValue * input,
  236. SIMCCleanOidValue& result,
  237. BOOL local,
  238. SIMCSymbolList& checkedList);
  239. };
  240. #endif