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

  1. // $Id: platform.h,v 1.13 2001/02/12 11:09:06 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 platform_INCLUDED
  11. #define platform_INCLUDED
  12.  
  13.  
  14. #include <config.h>
  15.  
  16. /*
  17.    undefine any symbols defined by the autotools
  18.    build process that can conflict with out symbols
  19. */
  20.  
  21. #undef PACKAGE
  22. #undef VERSION
  23.  
  24.  
  25. /* Boilerplate autoconf checking */
  26.  
  27. #include <sys/types.h>
  28. //FIXME: all stat stuff should be included in the platform.cpp file!
  29. #include <sys/stat.h>
  30. #ifdef STDC_HEADERS
  31. # include <stdlib.h>
  32. # include <stddef.h>
  33. #else
  34. # ifdef HAVE_STDLIB_H
  35. #  include <stdlib.h>
  36. # endif
  37. #endif
  38. #ifdef HAVE_STRING_H
  39. # ifndef STDC_HEADERS
  40. #  ifdef HAVE_MEMORY_H
  41. #   include <memory.h>
  42. #  endif
  43. # endif
  44. # include <string.h>
  45. #else
  46. # ifdef HAVE_STRINGS_H
  47. #  include <strings.h>
  48. # endif
  49. #endif
  50.  
  51. /*
  52. Currently, we do not use this one
  53. #ifdef HAVE_INTTYPES_H
  54. # include <inttypes.h>
  55. #endif
  56. */
  57.  
  58. #ifdef HAVE_UNISTD_H
  59. # include <unistd.h>
  60. #endif
  61.  
  62. #ifdef HAVE_WINDOWS_H
  63. # include <windows.h>
  64. #endif
  65.  
  66. #ifdef HAVE_DIRECT_H
  67. # include <direct.h>
  68. #endif
  69.  
  70. #ifdef HAVE_DIRENT_H
  71. #include <dirent.h>
  72. #endif
  73.  
  74. #ifndef HAVE_WINT_T
  75.     /* On some systems the type wint_t is not defined in wchar.h */
  76.     typedef unsigned int wint_t;
  77. #endif
  78.  
  79. #ifdef HAVE_WCHAR_H
  80. # include <wchar.h>
  81. #endif
  82.  
  83. #ifdef HAVE_CTYPE_H
  84. # include <ctype.h>
  85. #endif
  86.  
  87. #ifdef HAVE_ASSERT_H
  88. # include <assert.h>
  89. #endif
  90.  
  91. #ifdef HAVE_STDIO_H
  92. # include <stdio.h>
  93. #endif
  94.  
  95. #ifdef HAVE_LIMITS_H
  96. # include <limits.h>
  97. #endif
  98.  
  99. #ifdef HAVE_MATH_H
  100. # include <math.h>
  101. #endif
  102.  
  103. #ifdef HAVE_FLOAT_H
  104. # include <float.h>
  105. #endif
  106.  
  107. // C++ standard support
  108.  
  109. #ifdef HAVE_STD
  110. # include <iostream>
  111. # include <fstream>
  112. #else
  113. # include <iostream.h>
  114. # include <fstream.h>
  115. #endif
  116.  
  117. // VC++ pretends to support the
  118. // C++ standard, but it does not.
  119. // The set_new_handler method in
  120. // <new> is not implemented so
  121. // the _set_new_handler method
  122. // in <new.h> must be used.
  123.  
  124. #ifdef HAVE_VCPP_SET_NEW_HANDLER
  125. # include <new.h>
  126. #else
  127. # ifdef HAVE_STD
  128. #  include <new>
  129. # else
  130. #  include <new.h>
  131. # endif
  132. #endif
  133.  
  134. #ifdef HAVE_STD
  135. # ifdef HAVE_NAMESPACES
  136.    using namespace std;
  137. # endif
  138. #endif
  139.  
  140.  
  141. #ifdef HAVE_BROKEN_USHRT_MAX
  142.     /* There is a bug in mingwin's limits.h file we need to work around */
  143. # undef USHRT_MAX
  144. # ifdef SHRT_MAX
  145. #  define USHRT_MAX (2U * SHRT_MAX + 1)
  146. # else
  147. #  define USHRT_MAX 0xFFFF
  148. # endif
  149. #endif
  150.  
  151.  
  152. //
  153. // These limit definitions are correct for all the platforms that
  154. // we are currently using. When porting this code, they should
  155. // always be reviewed.
  156. //
  157.  
  158. #ifdef HAVE_32BIT_TYPES
  159.  
  160. //
  161. // FIXME: Someone with Microsoft VC++ should add __int64 support
  162. //
  163.  
  164. # ifdef HAVE_UNSIGNED_LONG_LONG
  165. // Range 0..18446744073709551615
  166. typedef unsigned long long u8;
  167.  
  168. // Range -9223372036854775808..9223372036854775807
  169. typedef signed long long i8;
  170.  
  171. # endif // HAVE_UNSIGNED_LONG_LONG
  172.  
  173. // Range 0..4294967295
  174. typedef unsigned int u4;
  175.  
  176. // Range -2147483648..+2147483647
  177. typedef signed int i4;
  178.  
  179. // Range 0..65535
  180. typedef unsigned short u2;
  181.  
  182. // Range -32768..32767
  183. typedef signed short i2;
  184.  
  185. // Range 0..255 in this system
  186. typedef unsigned char u1;
  187.  
  188. // Range -128..+127 in this system
  189. typedef signed char i1;
  190.  
  191. #endif // HAVE_32BIT_TYPES
  192.  
  193.  
  194. //
  195. // Some compilers do not correctly predefine the primitive type "bool"
  196. // and its possible values: "false" and "true"
  197. //
  198. #ifndef HAVE_BOOL
  199. //======================================================================
  200. // We define the type "bool" and the constants "false" and "true".
  201. // The type bool as well as the constants false and true are expected
  202. // to become standard C++. When that happens, these declarations should
  203. // be removed.
  204. //======================================================================
  205. typedef unsigned char bool;
  206. enum { false = 0, true = 1 };
  207. #endif
  208.  
  209.  
  210. // tuple.h needs the above typedefs first, but has it's own namespace block...
  211. // cabbey would also argue that the wsclen and family don't need to be in our
  212. // namespace, 'cuz if wee need to define them we aren't going to clash. ;)
  213. #include "tuple.h"
  214.  
  215.  
  216.  
  217. #ifdef    HAVE_JIKES_NAMESPACE
  218. namespace Jikes {    // Open namespace Jikes block
  219. #endif
  220.  
  221. //
  222. // The configure scripts check each of these to see if we need our own implementation
  223. //
  224.  
  225. #ifndef HAVE_WCSLEN
  226.     extern size_t wcslen(const wchar_t *);
  227. #endif
  228.  
  229. #ifndef HAVE_WCSCPY
  230.     extern wchar_t *wcscpy(wchar_t *, const wchar_t *);
  231. #endif
  232.  
  233. #ifndef HAVE_WCSNCPY
  234.     extern wchar_t *wcsncpy(wchar_t *, const wchar_t *, size_t);
  235. #endif
  236.  
  237. #ifndef HAVE_WCSCAT
  238.     extern wchar_t *wcscat(wchar_t *, const wchar_t *);
  239. #endif
  240.  
  241. #ifndef HAVE_WCSCMP
  242.     extern int wcscmp(const wchar_t *, const wchar_t *);
  243. #endif
  244.  
  245. #ifndef HAVE_WCSNCMP
  246.     extern int wcsncmp(const wchar_t *, const wchar_t *, size_t);
  247. #endif
  248.  
  249.  
  250.  
  251. //
  252. // If the system runs out of memory, this function is invoked.
  253. //
  254. void SetNewHandler();
  255.  
  256. #ifdef HAVE_VCPP_SET_NEW_HANDLER
  257. extern int OutOfMemory(size_t);
  258. #else
  259. extern void OutOfMemory();
  260. #endif
  261.  
  262. //
  263. // When using the ICC compiler on Win95 or OS/2, we need to disable
  264. // testing for various floating point exceptions. Default behavior
  265. // was causing problems reading some standard class files.
  266. //
  267. extern void FloatingPointCheck();
  268.  
  269.  
  270. //
  271. // variants of system functions
  272. // are declared here and defined in code.cpp
  273. //
  274. extern int SystemStat(const char *name, struct stat *stat_struct);
  275. extern FILE *SystemFopen(const char *name, const char *mode);
  276. extern size_t SystemFread(char *ptr, size_t element_size, size_t count, FILE *stream);
  277. extern int SystemIsDirectory(char *name);
  278.  
  279. //
  280. // The symbol used in this environment for separating argument in a system string. E.g., in a unix system
  281. // directories specified in the CLASSPATH are separated by a ':', whereas in win95 it is ';'.
  282. //
  283. extern char PathSeparator();
  284. extern int SystemMkdir(char *);
  285. extern int SystemMkdirhier(char *);
  286.  
  287. extern char * strcat3(const char *, const char *, const char *);
  288. extern char * wstring2string(wchar_t * in);
  289.  
  290.  
  291.  
  292.  
  293. // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  294. //
  295. // End of platform specific defines in this file, the rest of the code
  296. // in this file should work on any system
  297. //
  298. // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  299.  
  300.  
  301. enum U_chars
  302. {
  303.     U_NULL = 0,               U_NU = U_NULL,            // L'\0'
  304.     U_BACKSPACE = 8,          U_BS = U_BACKSPACE,       // L'\b'
  305.     U_HORIZONTAL_TAB = 9,     U_HT = U_HORIZONTAL_TAB,  // L'\t'
  306.     U_LINE_FEED = 10,         U_LF = U_LINE_FEED,       // L'\n'
  307.     U_FORM_FEED = 12,         U_FF = U_FORM_FEED,       // L'\f'
  308.     U_CARRIAGE_RETURN = 13,   U_CR = U_CARRIAGE_RETURN, // L'\r'
  309.  
  310.     U_CTL_Z = 26,
  311.     U_ESCAPE = 27,
  312.  
  313.     U_SPACE = 32,             U_SP = U_SPACE,             // L' '
  314.     U_EXCLAMATION = 33,       U_EX = U_EXCLAMATION,       // L'!'
  315.     U_DOUBLE_QUOTE = 34,      U_DQ = U_DOUBLE_QUOTE,      // L'"'
  316.     U_POUND = 35,             U_SH = U_POUND,             // L'#'
  317.     U_DOLLAR = 36,            U_DS = U_DOLLAR,            // L'$'
  318.     U_PERCENT = 37,           U_PE = U_PERCENT,           // L'%'
  319.     U_AMPERSAND = 38,         U_AM = U_AMPERSAND,         // L'&'
  320.     U_SINGLE_QUOTE = 39,      U_SQ = U_SINGLE_QUOTE,      // L'\''
  321.     U_LEFT_PARENTHESIS = 40,  U_LP = U_LEFT_PARENTHESIS,  // L'('
  322.     U_RIGHT_PARENTHESIS = 41, U_RP = U_RIGHT_PARENTHESIS, // L')'
  323.     U_STAR = 42,              U_ST = U_STAR,              // L'*'
  324.     U_PLUS = 43,              U_PL = U_PLUS,              // L'+'
  325.     U_MINUS = 45,             U_MI = U_MINUS,             // L'-'
  326.     U_COMMA = 44,             U_CM = U_COMMA,             // L','
  327.     U_DOT = 46,               U_DO = U_DOT,               // L'.'
  328.     U_SLASH = 47,             U_SL = U_SLASH,             // L'/'
  329.  
  330.     U_0 = 48, // L'0'
  331.     U_1 = 49, // L'1'
  332.     U_2 = 50, // L'2'
  333.     U_3 = 51, // L'3'
  334.     U_4 = 52, // L'4'
  335.     U_5 = 53, // L'5'
  336.     U_6 = 54, // L'6'
  337.     U_7 = 55, // L'7'
  338.     U_8 = 56, // L'8'
  339.     U_9 = 57, // L'9'
  340.  
  341.     U_COLON = 58,             U_CO = U_COLON,     // L':'
  342.     U_SEMICOLON = 59,         U_SC = U_SEMICOLON, // L';'
  343.     U_LESS = 60,              U_LT = U_LESS,      // L'<'
  344.     U_EQUAL = 61,             U_EQ = U_EQUAL,     // L'='
  345.     U_GREATER = 62,           U_GT = U_GREATER,   // L'>'
  346.     U_QUESTION = 63,          U_QU = U_QUESTION,  // L'?'
  347.     U_AT = 64,                                    // L'@'
  348.  
  349.     U_A = 65, // L'A'
  350.     U_B = 66, // L'B'
  351.     U_C = 67, // L'C'
  352.     U_D = 68, // L'D'
  353.     U_E = 69, // L'E'
  354.     U_F = 70, // L'F'
  355.     U_G = 71, // L'G'
  356.     U_H = 72, // L'H'
  357.     U_I = 73, // L'I'
  358.     U_J = 74, // L'J'
  359.     U_K = 75, // L'K'
  360.     U_L = 76, // L'L'
  361.     U_M = 77, // L'M'
  362.     U_N = 78, // L'N'
  363.     U_O = 79, // L'O'
  364.     U_P = 80, // L'P'
  365.     U_Q = 81, // L'Q'
  366.     U_R = 82, // L'R'
  367.     U_S = 83, // L'S'
  368.     U_T = 84, // L'T'
  369.     U_U = 85, // L'U'
  370.     U_V = 86, // L'V'
  371.     U_W = 87, // L'W'
  372.     U_X = 88, // L'X'
  373.     U_Y = 89, // L'Y'
  374.     U_Z = 90, // L'Z'
  375.  
  376.     U_LEFT_BRACKET = 91,      U_LB = U_LEFT_BRACKET,  // L'['
  377.     U_BACKSLASH = 92,         U_RS = U_BACKSLASH,     // L'\\'
  378.     U_RIGHT_BRACKET = 93,     U_RB = U_RIGHT_BRACKET, // L']'
  379.     U_CARET = 94,             U_CA = U_CARET,         // L'^'
  380.     U_UNDERSCORE = 95,        U_UN = U_UNDERSCORE,    // L'_'
  381.  
  382.     U_a = 97, // L'a'
  383.     U_b = 98, // L'b'
  384.     U_c = 99, // L'c'
  385.     U_d = 100, // L'd'
  386.     U_e = 101, // L'e'
  387.     U_f = 102, // L'f'
  388.     U_g = 103, // L'g'
  389.     U_h = 104, // L'h'
  390.     U_i = 105, // L'i'
  391.     U_j = 106, // L'j'
  392.     U_k = 107, // L'k'
  393.     U_l = 108, // L'l'
  394.     U_m = 109, // L'm'
  395.     U_n = 110, // L'n',
  396.     U_o = 111, // L'o'
  397.     U_p = 112, // L'p'
  398.     U_q = 113, // L'q'
  399.     U_r = 114, // L'r'
  400.     U_s = 115, // L's'
  401.     U_t = 116, // L't'
  402.     U_u = 117, // L'u'
  403.     U_v = 118, // L'v'
  404.     U_w = 119, // L'w'
  405.     U_x = 120, // L'x'
  406.     U_y = 121, // L'y'
  407.     U_z = 122, // L'z'
  408.  
  409.     U_LEFT_BRACE = 123,       U_OS = U_LEFT_BRACE,  // L'{'
  410.     U_BAR = 124,              U_BA = U_BAR,         // L'|'
  411.     U_RIGHT_BRACE = 125,      U_CS = U_RIGHT_BRACE, // L'}'
  412.     U_TILDE = 126,            U_TI = U_TILDE,       // L'~'
  413.  
  414.     U_BOM         = 0xfeff,
  415.     U_REVERSE_BOM = 0xfffe
  416. };
  417.  
  418.  
  419. //
  420. // Constant strings used in the program.
  421. //
  422. class StringConstant
  423. {
  424. public:
  425.     static wchar_t US_AND[], // "&"
  426.                    US_AND_AND[], // "&&"
  427.                    US_AND_EQUAL[], // "&="
  428.                    US_COLON[], // ":"
  429.                    US_COMMA[], // ","
  430.                    US_DIVIDE[], // "/"
  431.                    US_DIVIDE_EQUAL[], // "/="
  432.                    US_DOT[], // "."
  433.                    US_EMPTY[], // ""
  434.                    US_EQUAL[], // "="
  435.                    US_EQUAL_EQUAL[], // "=="
  436.                    US_GREATER[], // ">"
  437.                    US_GREATER_EQUAL[], // ">="
  438.                    US_LBRACE[], // "{"
  439.                    US_LBRACKET[], // "["
  440.                    US_LEFT_SHIFT[], // "<<"
  441.                    US_LEFT_SHIFT_EQUAL[], // "<<="
  442.                    US_LESS[], // "<"
  443.                    US_LESS_EQUAL[], // "<="
  444.                    US_LPAREN[], // "("
  445.                    US_MINUS[], // "-"
  446.                    US_MINUS_EQUAL[], // "-="
  447.                    US_MINUS_MINUS[], // "--"
  448.                    US_MULTIPLY[], // "*"
  449.                    US_MULTIPLY_EQUAL[], // "*="
  450.                    US_NOT[], // "!"
  451.                    US_NOT_EQUAL[], // "!="
  452.                    US_OR[], // "|"
  453.                    US_OR_EQUAL[], // "|="
  454.                    US_OR_OR[], // "||"
  455.                    US_PLUS[], // "+"
  456.                    US_PLUS_EQUAL[], // "+="
  457.                    US_PLUS_PLUS[], // "++"
  458.                    US_QUESTION[], // "?"
  459.                    US_RBRACE[], // "}"
  460.                    US_RBRACKET[], // "]"
  461.                    US_REMAINDER[], // "%"
  462.                    US_REMAINDER_EQUAL[], // "%="
  463.                    US_RIGHT_SHIFT[], // ">>"
  464.                    US_RIGHT_SHIFT_EQUAL[], // ">>="
  465.                    US_RPAREN[], // ")"
  466.                    US_SEMICOLON[], // ";"
  467.                    US_TWIDDLE[], // "~"
  468.                    US_UNSIGNED_RIGHT_SHIFT[], // ">>>"
  469.                    US_UNSIGNED_RIGHT_SHIFT_EQUAL[], // ">>>="
  470.                    US_XOR[], // "^"
  471.                    US_XOR_EQUAL[], // "^="
  472.  
  473.                    US_Boolean[], // "Boolean"
  474.                    US_Byte[], // "Byte"
  475.                    US_Character[], // "Character"
  476.                    US_Class[], // "Class"
  477.                    US_ClassNotFoundException[], // "ClassNotFoundException"
  478.                    US_Cloneable[], // "Cloneable"
  479.                    US_Double[], // "Double"
  480.                    US_Error[], // "Error"
  481.                    US_Exception[], // "Exception"
  482.                    US_Float[],  // "Float"
  483.                    US_Integer[], // "Integer"
  484.                    US_L[], // "L"
  485.                    US_Long[], // "Long"
  486.                    US_NoClassDefFoundError[], // "NoClassDefFoundError"
  487.                    US_Object[], // "Object"
  488.                    US_PObject[], // "PObject"
  489.                    US_RuntimeException[], // "RuntimeException"
  490.                    US_Serializable[], // "Serializable"
  491.                    US_Short[], // "Short"
  492.                    US_StringBuffer[], // "StringBuffer"
  493.                    US_String[], // "String"
  494.                    US_TYPE[], // "TYPE"
  495.                    US_Vector[], // Vector
  496.                    US_Throwable[], // "Throwable"
  497.                    US_Void[], // "Void"
  498.                    US__DO[], // "."
  499.                    US__DO__DO[], // ".."
  500.                    US__DS[], // "$"
  501.                    US__LB__RB[], // "[]"
  502.                    US__LT_clinit_GT[], // "<clinit>"
  503.                    US__LT_init_GT[], // "<init>"
  504.                    US__QU__QU[],  // "??"
  505.                    US__SC[], // ";"
  506.                    US__SL[], // "/"
  507.  
  508.                    US__zip[], // "zip"
  509.                    US__jar[], // "jar"
  510.  
  511.                    US__array[], // "array"
  512.                    US__access_DOLLAR[], // "access$"
  513.                    US__class_DOLLAR[], // "class$"
  514.                    US__constructor_DOLLAR[], // "constructor$"
  515.                    US__this_DOLLAR[], // "this$"
  516.                    US__val_DOLLAR[], // "val$"
  517.  
  518.                    US_abstract[], // "abstract"
  519.                    US_append[], // "append"
  520.                    US_block_DOLLAR[], // "block$"
  521.                    US_boolean[], // "boolean"
  522.                    US_break[], // "break"
  523.                    US_byte[], // "byte"
  524.                    US_case[], // "case"
  525.                    US_catch[], // "catch"
  526.                    US_char[], // "char"
  527.                    US_class[], // "class"
  528.                    US_clone[], // "clone"
  529.                    US_const[], // "const"
  530.                    US_continue[], // "continue"
  531.                    US_default[], // "default"
  532.                    US_do[], // "do"
  533.                    US_double[], // "double"
  534.                    US_else[], // "else"
  535.                    US_extends[], // "extends"
  536.                    US_false[], // "false"
  537.                    US_final[], // "final"
  538.                    US_finally[], // "finally"
  539.                    US_float[], // "float"
  540.                    US_for[], // "for"
  541.                    US_forName[], // "forName"
  542.                    US_getMessage[], // "getMessage"
  543.                    US_goto[], // "goto"
  544.                    US_if[], // "if"
  545.                    US_implements[], // "implements"
  546.                    US_import[], // "import"
  547.                    US_instanceof[], // "instanceof"
  548.                    US_int[], // "int"
  549.                    US_interface[], // "interface"
  550.                    US_java_SL_io[], // "java/io"
  551.                    US_java_SL_lang[], // "java/lang"
  552.                    US_java_SL_util[], // "java/util"
  553.                    US_length[], // "length"
  554.                    US_long[], // "long"
  555.                    US_native[], // "native"
  556.                    US_new[], // "new"
  557.                    US_null[], // "null"
  558.                    US_package[], // "package"
  559.                    US_private[], // "private"
  560.                    US_protected[], // "protected"
  561.                    US_public[], // "public"
  562.                    US_return[], // "return"
  563.                    US_short[], // "short"
  564.                    US_static[], // "static"
  565.                    US_strictfp[], // "strictfp"
  566.                    US_super[], // "super"
  567.                    US_switch[], // "switch"
  568.                    US_synchronized[], // "synchronized"
  569.                    US_this0[], // "this$0"
  570.                    US_this[], // "this"
  571.                    US_throw[], // "throw"
  572.                    US_throws[], // "throws"
  573.                    US_toString[], // "toString"
  574.                    US_transient[], // "transient"
  575.                    US_true[], // "true"
  576.                    US_try[], // "try"
  577.                    US_void[], // "void"
  578.                    US_volatile[], // "volatile"
  579.                    US_while[], // "while"
  580.  
  581.                    US_EOF[]; // "EOF"
  582.  
  583.     static wchar_t US_smallest_int[]; // "-2147483648"
  584.  
  585.     static char U8S_command_format[];
  586.  
  587.     static int U8S_ConstantValue_length,
  588.                U8S_Exceptions_length,
  589.                U8S_InnerClasses_length,
  590.                U8S_Synthetic_length,
  591.                U8S_Deprecated_length,
  592.                U8S_LineNumberTable_length,
  593.                U8S_LocalVariableTable_length,
  594.                U8S_Code_length,
  595.                U8S_Sourcefile_length,
  596.  
  597.                U8S_null_length,
  598.                U8S_this_length;
  599.  
  600.     static char U8S_B[], // "B"
  601.                 U8S_C[], // "C"
  602.                 U8S_Code[], // "Code"
  603.                 U8S_ConstantValue[], // "ConstantValue"
  604.                 U8S_D[], // "D"
  605.                 U8S_Exceptions[], // "Exceptions"
  606.                 U8S_F[], // "F"
  607.                 U8S_I[], // "I"
  608.                 U8S_InnerClasses[], // "InnerClasses"
  609.                 U8S_J[],  // "J"
  610.                 U8S_LP_Ljava_SL_lang_SL_String_SC_RP_Ljava_SL_lang_SL_Class_SC[], // "(Ljava/lang/String;)Ljava/lang/Class;"
  611.                 U8S_LP_Ljava_SL_lang_SL_String_SC_RP_V[], // "(Ljava/lang/String;)V"
  612.                 U8S_LP_RP_Ljava_SL_lang_SL_String_SC[], // "()Ljava/lang/String;"
  613.                 U8S_LP_RP_V[], // "()V"
  614.                 U8S_LineNumberTable[], // "LineNumberTable"
  615.                 U8S_LocalVariableTable[], // "LocalVariableTable"
  616.                 U8S_S[], // "S"
  617.                 U8S_Sourcefile[], // "Sourcefile"
  618.                 U8S_Synthetic[], // "Synthetic"
  619.                 U8S_Deprecated[], // "Deprecated"
  620.                 U8S_V[], // "V"
  621.                 U8S_Z[], // "Z"
  622.  
  623.                 U8S__DO[], // "."
  624.                 U8S__DO_class[], // ".class"
  625.                 U8S__DO_java[], // ".java"
  626.                 U8S__DO_tok[], // ".tok"
  627.                 U8S__DO_u[], // ".u"
  628.                 U8S__LP[], // "("
  629.                 U8S__RP[], // ")"
  630.                 U8S__SL[], // "/"
  631.                 U8S__ST[], // "*"
  632.  
  633.                 U8S_class[], // "class"
  634.                 U8S_java[], // "java"
  635.                 U8S_java_SL_lang_SL_ClassNotFoundException[], // "java/lang/ClassNotFoundException"
  636.                 U8S_java_SL_lang_SL_Class[], // "java/lang/Class"
  637.                 U8S_java_SL_lang_SL_InternalError[], // "java/lang/InternalError"
  638.                 U8S_java_SL_lang_SL_NoClassDefFoundError[], // "java/lang/NoClassDefFoundError"
  639.                 U8S_java_SL_lang_SL_StringBuffer[], // "java/lang/StringBuffer"
  640.                 U8S_java_SL_lang_SL_Throwable[], // "java/lang/Throwable"
  641.                 U8S_null[], // "null"
  642.                 U8S_quit[], // "quit"
  643.                 U8S_this[], // "this"
  644.  
  645.                 U8S_LP_LB_C_RP_Ljava_SL_lang_SL_StringBuffer_SC[], // "([C)Ljava/lang/StringBuffer;"
  646.                 U8S_LP_C_RP_Ljava_SL_lang_SL_StringBuffer_SC[], // "(C)Ljava/lang/StringBuffer;"
  647.                 U8S_LP_Z_RP_Ljava_SL_lang_SL_StringBuffer_SC[], // "(Z)Ljava/lang/StringBuffer;"
  648.                 U8S_LP_I_RP_Ljava_SL_lang_SL_StringBuffer_SC[], // "(I)Ljava/lang/StringBuffer;"
  649.                 U8S_LP_J_RP_Ljava_SL_lang_SL_StringBuffer_SC[], // "(J)Ljava/lang/StringBuffer;"
  650.                 U8S_LP_F_RP_Ljava_SL_lang_SL_StringBuffer_SC[], // "(F)Ljava/lang/StringBuffer;"
  651.                 U8S_LP_D_RP_Ljava_SL_lang_SL_StringBuffer_SC[], // "(D)Ljava/lang/StringBuffer;"
  652.                 U8S_LP_Ljava_SL_lang_SL_String_SC_RP_Ljava_SL_lang_SL_StringBuffer_SC[], // "(Ljava/lang/String;)Ljava/lang/StringBuffer;"
  653.                 U8S_LP_Ljava_SL_lang_SL_Object_SC_RP_Ljava_SL_lang_SL_StringBuffer_SC[]; // "(Ljava/lang/Object;)Ljava/lang/StringBuffer;"
  654.  
  655.     static char U8S_smallest_int[],      // "-2147483648"
  656.                 U8S_smallest_long_int[]; // "-9223372036854775808"
  657. };
  658.  
  659.  
  660. //
  661. // Convert an integer to its character string representation.
  662. //
  663. class IntToString
  664. {
  665. public:
  666.     IntToString(int);
  667.  
  668.     char *String() { return str; }
  669.     int Length()   { return (&info[TAIL_INDEX]) - str; }
  670.  
  671. private:
  672.     enum { TAIL_INDEX = 1 + 10 }; // 1 for sign, +10 significant digits
  673.  
  674.     char info[TAIL_INDEX + 1], // +1 for '\0'
  675.          *str;
  676. };
  677.  
  678.  
  679. //
  680. // Same as IntToString for wide strings
  681. //
  682. class IntToWstring
  683. {
  684. public:
  685.     IntToWstring(int);
  686.  
  687.     wchar_t *String() { return wstr; }
  688.     int Length()      { return (&winfo[TAIL_INDEX]) - wstr; }
  689.  
  690. private:
  691.     enum { TAIL_INDEX = 1 + 10 }; // 1 for sign, +10 significant digits
  692.  
  693.     wchar_t winfo[TAIL_INDEX + 1], // 1 for sign, +10 significant digits + '\0'
  694.             *wstr;
  695. };
  696.  
  697.  
  698. //
  699. // Convert an unsigned Long integer to its character string representation in decimal.
  700. //
  701. class ULongInt;
  702. class ULongToDecString
  703. {
  704. public:
  705.     ULongToDecString(ULongInt &);
  706.  
  707.     char *String() { return str; }
  708.     int Length()   { return (&info[TAIL_INDEX]) - str; }
  709.  
  710. private:
  711.     enum { TAIL_INDEX = 20 }; // 20 significant digits
  712.  
  713.     char info[TAIL_INDEX + 1], // +1 for '\0'
  714.          *str;
  715. };
  716.  
  717.  
  718. //
  719. // Convert a signed or unsigned Long integer to its character string representation in octal.
  720. //
  721. class BaseLong;
  722. class LongToOctString
  723. {
  724. public:
  725.     LongToOctString(BaseLong &);
  726.  
  727.     char *String() { return str + 1; } // +1 to skip initial '0'
  728.     char *StringWithBase() { return str; }
  729.     int Length()   { return (&info[TAIL_INDEX]) - str; }
  730.  
  731. private:
  732.     enum { TAIL_INDEX = 1 + 22 }; // 1 for initial '0', +22 significant digits
  733.  
  734.     char info[TAIL_INDEX + 1], // + 1 for '\0'
  735.          *str;
  736. };
  737.  
  738.  
  739. //
  740. // Convert a signed or unsigned Long integer to its character string representation in hexadecimal.
  741. //
  742. class LongToHexString
  743. {
  744. public:
  745.     LongToHexString(BaseLong &);
  746.  
  747.     char *String() { return str + 2; } // +2 to skip initial "0x"
  748.     char *StringWithBase() { return str; }
  749.     int Length()   { return (&info[TAIL_INDEX]) - str; }
  750.  
  751. private:
  752.     enum { TAIL_INDEX = 1 + 1 + 16 }; // 1 for initial '0', +1 for 'x', + 16 significant digits
  753.  
  754.     char info[TAIL_INDEX + 1], // +1 for '\0'
  755.          *str;
  756. };
  757.  
  758.  
  759. //
  760. // Convert a signed Long integer to its character string representation in decimal.
  761. //
  762. class LongInt;
  763. class LongToDecString
  764. {
  765. public:
  766.     LongToDecString(LongInt &);
  767.  
  768.     char *String() { return str; }
  769.     int Length()   { return (&info[TAIL_INDEX]) - str; }
  770.  
  771. private:
  772.     enum { TAIL_INDEX = 1 + 19 }; // 1 for sign, +19 significant digits
  773.  
  774.     char info[TAIL_INDEX + 1], // + 1 for '\0'
  775.          *str;
  776. };
  777.  
  778. //
  779. // Convert an double to its character string representation.
  780. //
  781. class IEEEdouble;
  782. class DoubleToString
  783. {
  784. public:
  785.     DoubleToString(IEEEdouble &);
  786.  
  787.     char *String() { return str; }
  788.     int Length()   { return length; }
  789.  
  790. private:
  791.     enum
  792.     {
  793.         MAXIMUM_PRECISION = 16,
  794.         MAXIMUM_STR_LENGTH = 1 + MAXIMUM_PRECISION + 1 + 4 // +1 for sign, +16 significant digits +1 for ".", +4 for exponent
  795.     };
  796.  
  797.     char str[MAXIMUM_STR_LENGTH + 1]; // +1 for '\0'
  798.     int length;
  799. };
  800.  
  801. //
  802. // Convert an float to its character string representation.
  803. //
  804. class IEEEfloat;
  805. class FloatToString
  806. {
  807. public:
  808.     FloatToString(IEEEfloat &);
  809.  
  810.     char *String() { return str; }
  811.     int Length()   { return length; }
  812.  
  813. private:
  814.     enum
  815.     {
  816.         MAXIMUM_PRECISION = 8,
  817.         MAXIMUM_STR_LENGTH = 1 + MAXIMUM_PRECISION + 1 + 4 // +1 for sign, +8 significant digits +1 for ".", +4 for exponent
  818.     };
  819.  
  820.     char str[MAXIMUM_STR_LENGTH + 1]; // +1 for '\0'
  821.     int length;
  822. };
  823.  
  824.  
  825.  
  826. class LongInt;
  827. class ULongInt;
  828. //
  829. //
  830. //
  831. class Ostream
  832. {
  833.     ostream *os;
  834.  
  835.     bool expand_wchar;
  836.  
  837. public:
  838.  
  839.     Ostream() : os(&cerr),
  840.                 expand_wchar(false)
  841.     {}
  842.  
  843.     Ostream(ostream *_os) : os(_os),
  844.                             expand_wchar(false)
  845.     {}
  846.  
  847.     void StandardOutput() { os = &cout; }
  848.     void SetExpandWchar(bool val = true) { expand_wchar = val; }
  849.     bool ExpandWchar() { return expand_wchar; }
  850.  
  851.     Ostream &operator<<(wchar_t ch)
  852.     {
  853.         if (ch >> 8 == 0)
  854.             *os << (char) ch;
  855.         else
  856.         {
  857.             if (expand_wchar == 0)
  858.                 *os << (char) U_QUESTION;
  859.             else
  860.             {
  861.                 *os << (char) U_BACKSLASH
  862.                     << (char) U_u;
  863.  
  864.                 char str[4];
  865.                 for (int i = 3; i >= 0; i--)
  866.                 {
  867.                     int d = ch % 16;
  868.                     switch(d)
  869.                     {
  870.                         case 10:
  871.                             str[i] = U_A;
  872.                             break;
  873.                         case 11:
  874.                             str[i] = U_B;
  875.                             break;
  876.                         case 12:
  877.                             str[i] = U_C;
  878.                             break;
  879.                         case 13:
  880.                             str[i] = U_D;
  881.                             break;
  882.                         case 14:
  883.                             str[i] = U_E;
  884.                             break;
  885.                         case 15:
  886.                             str[i] = U_F;
  887.                             break;
  888.                         default:
  889.                             str[i] = U_0 + d;
  890.                             break;
  891.                     }
  892.                     ch /= 16;
  893.                 }
  894.                 *os << str[0];
  895.                 *os << str[1];
  896.                 *os << str[2];
  897.                 *os << str[3];
  898.             }
  899.         }
  900.  
  901.         return *this;
  902.     }
  903.  
  904.     Ostream &operator<<(const wchar_t *str)
  905.     {
  906.         for (; *str; str++)
  907.             (*this) << *str;
  908.         return *this;
  909.     }
  910.  
  911.  
  912.     Ostream &operator<<(char c)
  913.     {
  914.         *os << c;
  915.         return *this;
  916.     }
  917.  
  918.     Ostream &operator<<(signed char c)
  919.     {
  920.         *os << c;
  921.         return *this;
  922.     }
  923.  
  924.     Ostream &operator<<(unsigned char c)
  925.     {
  926.         *os << c;
  927.         return *this;
  928.     }
  929.  
  930.     Ostream &operator<<(const char *c)
  931.     {
  932.         *os << c;
  933.         return *this;
  934.     }
  935.  
  936.     Ostream &operator<<(const signed char *c)
  937.     {
  938.         *os << c;
  939.         return *this;
  940.     }
  941.  
  942.     Ostream &operator<<(const unsigned char *c)
  943.     {
  944.         *os << c;
  945.         return *this;
  946.     }
  947.  
  948.     Ostream &operator<<(int a)
  949.     {
  950.         *os << a;
  951.         return *this;
  952.     }
  953.  
  954.     Ostream &operator<<(unsigned int a)
  955.     {
  956.         *os << a;
  957.         return *this;
  958.     }
  959.  
  960.     Ostream &operator<<(LongInt);
  961.     Ostream &operator<<(ULongInt);
  962.  
  963.     Ostream &operator<<(float f)
  964.     {
  965.         *os << f;
  966.         return *this;
  967.     }
  968.  
  969.     Ostream &operator<<(double d)
  970.     {
  971.         *os << d;
  972.         return *this;
  973.     }
  974.  
  975.     char fill(char c) { return os -> fill(c); }
  976.  
  977.     Ostream &flush()
  978.     {
  979.         os -> flush();
  980.         return *this;
  981.     }
  982.  
  983.     int width(int w)
  984.     {
  985.         return os -> width(w);
  986.     }
  987.  
  988.     Ostream &operator<<(ios &(*f)(ios&))
  989.     {
  990.         (*f)(*os);
  991.         return *this;
  992.     }
  993. };
  994.  
  995. extern Ostream Coutput;
  996.  
  997. //
  998. // From now on, DO NOT USE cout or cerr !
  999. // You should wrap cout and cerr in an instance of the Ostream class so that unicode
  1000. // output is translated properly. If you try to use cerr or cout this define will
  1001. // create an undefined symbol and give you a linker error.
  1002. //
  1003. #define cout Please_Do_Not_Use_cout_Directly_But_use_an_instance_of_Ostream_with_cout_as_argument
  1004. #define cerr Please_Do_Not_Use_cerr_Directly_But_use_an_instance_of_Ostream_with_cerr_as_argument
  1005.  
  1006. // This is temporary solution.
  1007. // In future basic_ostringstream<wchar_t> will be used.
  1008. // But now it is not supported by libg++.
  1009. // (lord).
  1010. class ErrorString: public ConvertibleArray<wchar_t> 
  1011.  public:
  1012.     ErrorString(); 
  1013.     
  1014.     ErrorString &operator<<(const wchar_t *s);
  1015.     ErrorString &operator<<(const wchar_t c );
  1016.     ErrorString &operator<<(const char    *s);
  1017.     ErrorString &operator<<(const char    c );
  1018.     ErrorString &operator<<(int n);
  1019.  
  1020.     void width(int w);
  1021.     void fill(const char c);
  1022.     
  1023.     wchar_t *Array();
  1024.  
  1025.  private:
  1026.  
  1027.     void do_fill(int n);
  1028.     char fill_char   ;
  1029.     int  field_width ;
  1030. };
  1031.  
  1032. #ifdef    HAVE_JIKES_NAMESPACE
  1033. }            // Close namespace Jikes block
  1034. #endif
  1035.  
  1036. #endif // #ifndef platform_INCLUDED
  1037.  
  1038.