Source code of Windows XP (NT5)
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.

202 lines
5.2 KiB

  1. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Copyright (c) 1989-1999 Microsoft Corporation
  3. Module Name:
  4. resdef.hxx
  5. Abstract:
  6. Resource related definitions.
  7. Notes:
  8. History:
  9. VibhasC Aug-14-1993 Created.
  10. ----------------------------------------------------------------------------*/
  11. #ifndef __RESDEF_HXX__
  12. #define __RESDEF_HXX__
  13. #include "stream.hxx"
  14. #include "expr.hxx"
  15. class node_id;
  16. class node_param;
  17. node_id * MakeIDNode( PNAME pName ,
  18. node_skl * pType,
  19. expr_node * pExpr = 0 );
  20. node_id * MakePtrIDNode( PNAME pName ,
  21. node_skl * pType,
  22. expr_node * pExpr = 0 );
  23. node_id * MakeIDNodeFromTypeName( PNAME pName ,
  24. PNAME pTypeName,
  25. expr_node * pExpr = 0 );
  26. node_id * MakePtrIDNodeFromTypeName( PNAME pName ,
  27. PNAME pTypeName,
  28. expr_node * pExpr = 0 );
  29. node_id * MakePtrIDNodeFromTypeNameWithCastedExpr( PNAME pName ,
  30. PNAME pTypeName,
  31. expr_node * pExpr = 0 );
  32. node_id * MakePtrIDNodeWithCastedExpr( PNAME pName,
  33. node_skl * pType,
  34. expr_node * pExpr );
  35. extern node_param * MakeParamNode( PNAME pName , node_skl * pType );
  36. extern node_param * MakePtrParamNode( PNAME pName , node_skl * pType );
  37. extern node_param * MakeParamNodeFromTypeName( PNAME pName , PNAME pTypeName );
  38. extern node_param * MakePtrParamNodeFromTypeName( PNAME pName , PNAME pTypeName );
  39. node_proc * MakeProcNodeWithNewName( PNAME pName,
  40. node_proc * pProc );
  41. typedef unsigned short RESOURCE_KIND;
  42. typedef unsigned short RESOURCE_LOCATION;
  43. //
  44. // Resource kind. The resource may be an abstract resource if it represents
  45. // an expression or a concrete resource if it is an actually declared variable
  46. // in the stub / aux routine.
  47. //
  48. #define RESOURCE_KIND_ABSTRACT 0
  49. #define RESOURCE_KIND_CONCRETE 1
  50. //
  51. // Resource location refers to the place in the stubs environment where the
  52. // resource has been declared. For example a global resource or a local or
  53. // parameter resource. Transient resources are temporary variables emitted
  54. // by the stub within code blocks. Some of these transient resources may
  55. // become local resources depending upon the optimiser's actions.
  56. //
  57. #define RESOURCE_LOCATION_GLOBAL 0
  58. #define RESOURCE_LOCATION_PARAM 1
  59. #define RESOURCE_LOCATION_LOCAL 2
  60. #define RESOURCE_LOCATION_TRANSIENT 3
  61. //
  62. // This class and the variable class may be merge-able, but I anticipate the
  63. // need for this to be a separate class just so that the post optimiser can
  64. // treat this specially and may be able to use the separation from the normal
  65. // variable class.
  66. //
  67. class RESOURCE : public expr_node
  68. {
  69. private:
  70. //
  71. // is this a concrete or abstract resource ?
  72. //
  73. unsigned short ResourceKind : 2;
  74. //
  75. // the location of the resource.
  76. //
  77. unsigned short ResourceLocation : 2;
  78. PNAME pName; // name of concrete resource.
  79. public:
  80. //
  81. // A resource is constructed by simply declaring a name and a type.
  82. //
  83. RESOURCE( PNAME p,
  84. node_skl * pT )
  85. {
  86. SetResourceName( p );
  87. SetType( pT );
  88. //
  89. // These don't seem to be used anywhere.
  90. // It's also not clear what they should be
  91. // initialized to...
  92. //
  93. // ResourceKind = ??;
  94. // ResourceLocation = ??;
  95. }
  96. virtual void CopyTo( expr_node* pExpr )
  97. {
  98. RESOURCE* lhs = (RESOURCE*) pExpr;
  99. expr_node::CopyTo( lhs );
  100. lhs->ResourceKind = ResourceKind;
  101. lhs->ResourceLocation = ResourceLocation;
  102. _STRDUP( lhs->pName, pName );
  103. }
  104. virtual expr_node* Clone() { return new RESOURCE(0,0); };
  105. //
  106. // queries.
  107. //
  108. virtual
  109. BOOL IsResource()
  110. {
  111. return TRUE;
  112. }
  113. //
  114. // set and get the Information fields.
  115. //
  116. void SetKind( unsigned short K )
  117. {
  118. ResourceKind = K;
  119. }
  120. RESOURCE_KIND GetKind()
  121. {
  122. return ResourceKind;
  123. }
  124. unsigned short GetLocation()
  125. {
  126. return ResourceLocation;
  127. }
  128. unsigned short SetLocation( unsigned short L )
  129. {
  130. return (ResourceLocation = L);
  131. }
  132. PNAME SetResourceName( PNAME p )
  133. {
  134. return (pName = p);
  135. }
  136. PNAME GetResourceName()
  137. {
  138. return pName;
  139. }
  140. //
  141. // Given an output steam, output the expression.
  142. //
  143. virtual
  144. void Print( ISTREAM * pS )
  145. {
  146. pS->Write( (char *)GetResourceName() );
  147. }
  148. virtual
  149. BOOL IsConstant()
  150. {
  151. return FALSE;
  152. }
  153. };
  154. #endif // __RESDEF_HXX__