home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 20 / AACD20.BIN / AACD / Programming / Jikes / Source / src / getclass.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-02-24  |  3.9 KB  |  158 lines

  1. // $Id: getclass.h,v 1.9 2001/01/05 09:13:20 mdejong Exp $
  2. //
  3. // This software is subject to the terms of the IBM Jikes Compiler
  4. // License Agreement available at the following URL:
  5. // http://www.ibm.com/research/jikes.
  6. // Copyright (C) 1996, 1998, International Business Machines Corporation
  7. // and others.  All Rights Reserved.
  8. // You must accept the terms of that agreement to use this software.
  9. //
  10. #ifndef getclass_INCLUDED
  11. #define getclass_INCLUDED
  12.  
  13. #include "platform.h"
  14. #include "semantic.h"
  15. #include "long.h"
  16. #include "double.h"
  17.  
  18. #ifdef    HAVE_JIKES_NAMESPACE
  19. namespace Jikes {    // Open namespace Jikes block
  20. #endif
  21.  
  22. class Cp_Info
  23. {
  24. public:
  25.     enum
  26.     {
  27.         CONSTANT_Class              = 7,
  28.         CONSTANT_Fieldref           = 9,
  29.         CONSTANT_Methodref          = 10,
  30.         CONSTANT_InterfaceMethodref = 11,
  31.         CONSTANT_String             = 8,
  32.         CONSTANT_Integer            = 3,
  33.         CONSTANT_Float              = 4,
  34.         CONSTANT_Long               = 5,
  35.         CONSTANT_Double             = 6,
  36.         CONSTANT_NameAndType        = 12,
  37.         CONSTANT_Utf8               = 1
  38.     };
  39.  
  40.     static u1 Tag(const char *buffer) { return (u1) *buffer; }
  41. };
  42.  
  43. class Constant_Utf8_info : public Cp_Info
  44. {
  45. public:
  46.     static u2 Length(const char *buffer) { return Semantic::GetU2(buffer + 1); } // skip tag
  47.     static const char *Bytes(const char *buffer) { return buffer + 3; } // skip tag and length
  48. };
  49.  
  50.  
  51. class Constant_Class_info : public Cp_Info
  52. {
  53. public:
  54.     static u2 NameIndex(const char *buffer) { return Semantic::GetU2(buffer + 1); }
  55. };
  56.  
  57.  
  58. class Constant_Fieldref_info : public Cp_Info
  59. {
  60. public:
  61.     static u2 ClassIndex(const char *buffer) { return Semantic::GetU2(buffer + 1); }
  62.     static u2 NameAndTypeIndex(const char *buffer) { return Semantic::GetU2(buffer + 3); }
  63. };
  64.  
  65.  
  66. class Constant_Methodref_info : public Cp_Info
  67. {
  68. public:
  69.     static u2 ClassIndex(const char *buffer) { return Semantic::GetU2(buffer + 1); }
  70.     static u2 NameAndTypeIndex(const char *buffer) { return Semantic::GetU2(buffer + 3); }
  71. };
  72.  
  73.  
  74. class Constant_InterfaceMethodref_info : public Cp_Info
  75. {
  76. public:
  77.     static u2 ClassIndex(const char *buffer) { return Semantic::GetU2(buffer + 1); }
  78.     static u2 NameAndTypeIndex(const char *buffer) { return Semantic::GetU2(buffer + 3); }
  79. };
  80.  
  81.  
  82. class Constant_NameAndType_info : public Cp_Info
  83. {
  84. public:
  85.     static u2 NameIndex(const char *buffer) { return Semantic::GetU2(buffer + 1); }
  86.     static u2 DescriptorIndex(const char *buffer) { return Semantic::GetU2(buffer + 3); }
  87. };
  88.  
  89.  
  90. class Constant_String_info : public Cp_Info
  91. {
  92. public:
  93.     static u2 StringIndex(const char *buffer) { return Semantic::GetU2(buffer + 1); }
  94. };
  95.  
  96.  
  97. class Constant_Integer_info : public Cp_Info
  98. {
  99. public:
  100.     static u4 Bytes(const char *buffer) { return Semantic::GetU4(buffer + 1); }
  101.  
  102.     static int Value(const char *buffer)
  103.     {
  104.         union field
  105.         {
  106.             u4 u;
  107.             int i;
  108.         } value;
  109.         value.u = Bytes(buffer);
  110.         return value.i;
  111.     }
  112. };
  113.  
  114.  
  115. class Constant_Float_info : public Cp_Info
  116. {
  117. public:
  118.     static u4 Bytes(const char *buffer) { return Semantic::GetU4(buffer + 1); }
  119.  
  120.     static IEEEfloat Value(const char *buffer)
  121.     {
  122.         return IEEEfloat(Semantic::GetU4(buffer+1));
  123.     }
  124. };
  125.  
  126.  
  127. class Constant_Long_info : public Cp_Info
  128. {
  129. public:
  130.     static u4 HighBytes(const char *buffer) { return Semantic::GetU4(buffer + 1); }
  131.     static u4 LowBytes(const char *buffer) { return Semantic::GetU4(buffer + 5); }
  132.  
  133.     static LongInt Value(const char *buffer)
  134.     {
  135.         return LongInt(HighBytes(buffer), LowBytes(buffer));
  136.     }
  137. };
  138.  
  139.  
  140. class Constant_Double_info : public Cp_Info
  141. {
  142. public:
  143.     static u4 HighBytes(const char *buffer) { return Semantic::GetU4(buffer + 1); }
  144.     static u4 LowBytes(const char *buffer) { return Semantic::GetU4(buffer + 5); }
  145.  
  146.     static IEEEdouble Value(const char *buffer)
  147.     {
  148.         return IEEEdouble(HighBytes(buffer), LowBytes(buffer));
  149.     }
  150. };
  151.  
  152. #ifdef    HAVE_JIKES_NAMESPACE
  153. }            // Close namespace Jikes block
  154. #endif
  155.  
  156. #endif
  157.  
  158.