1 #ifndef TYPES_HH
2 #define TYPES_HH
3 
4 #ifdef VISUAL_CPP
5 #include <assert.h>
6 #pragma warning( disable : 4786)
7 #endif
8 
9 #include <string>
10 #include <vector>
11 #include <stddef.h>
12 
13 typedef int      int4;
14 typedef unsigned nat4;
15 
16 #if defined(__GNUC__)
17 #define INT8_DEFINED 1
18 typedef long long          int8;
19 typedef unsigned long long nat8;
20 #else
21 #if defined(_WIN32)
22 #define INT8_DEFINED 1
23 typedef __int64 int8;
24 typedef unsigned __int64 nat8;
25 #else
26 #if defined(__osf__ )
27 #define INT8_DEFINED 1
28 typedef   signed long int8;
29 typedef unsigned long nat8;
30 #endif
31 #endif
32 #endif
33 
34 #define nobreak
35 
36 typedef unsigned char  byte;
37 typedef unsigned short word;
38 
39 enum vbm_instruction_code {
40 #define JAVA_INSN(code, mnem, len) mnem,
41 #include "jlint.d"
42   last_insn
43 };
44 
45 #define   items(array) (sizeof(array)/sizeof*(array))
46 
47 enum message_category {
48   cat_deadlock        = 0x00000001,
49   cat_race_condition  = 0x00000002,
50   cat_wait_nosync     = 0x00000004,
51   cat_synchronization = 0x0000000F,
52 
53   cat_super_finalize  = 0x00000010,
54   cat_not_overridden  = 0x00000020,
55   cat_field_redefined = 0x00000040,
56   cat_shadow_local    = 0x00000080,
57   cat_inheritance     = 0x000000F0,
58 
59   cat_zero_operand    = 0x00000100,
60   cat_zero_result     = 0x00000200,
61   cat_redundant       = 0x00000400,
62   cat_overflow        = 0x00000800,
63   cat_incomp_case     = 0x00001000,
64   cat_short_char_cmp  = 0x00002000,
65   cat_string_cmp      = 0x00004000,
66   cat_weak_cmp        = 0x00008000,
67   cat_domain          = 0x00010000,
68   cat_null_reference  = 0x00020000,
69   cat_truncation      = 0x00040000,
70   cat_bounds          = 0x00080000,
71   cat_data_flow       = 0x000FFF00,
72 
73   cat_done            = 0x10000000,
74 
75   cat_all             = 0xFFFFFFFF
76 };
77 
78 enum type_tag {
79   tp_bool,
80   tp_byte,
81   tp_char,
82   tp_short,
83   tp_int,
84   tp_long,
85   tp_float,
86   tp_double,
87   tp_void,
88   tp_self,
89   tp_string,
90   tp_object
91 };
92 
93 struct int_type_range {
94   int4 min;
95   int4 max;
96 };
97 
98 struct message_descriptor {
99   message_category category;
100   const char*      format;
101   const char*      name;
102   bool             position_dependent;
103   bool             enabled;
104 };
105 
106 
107 enum message_code {
108 #define MSG(category, code, pos, text) msg_##code,
109 #include "jlint.msg"
110   msg_last
111 };
112 
113 #define MSG_LOCATION_PREFIX "%0s:%1d: " // Emacs style: "file:line_number: "
114 
115 #define MAX_MSG_LENGTH      1024
116 #define MAX_MSG_PARAMETERS  16
117 
118 const unsigned class_hash_table_size = 1987;
119 
120 struct msg_select_category_option {
121   message_category msg_cat;
122   const char*      cat_name;
123   const char*      cat_desc;
124 };
125 
126 class field_desc;
127 
128 struct vbm_operand {
129   int  type;  // type of expression/variable before it was pushed in stack
130   int4 max;   // maximal value of operand
131   int4 min;   // minimal value of operand
132   int4 mask;  // mask of possible set bits and zero value indicator for
133   // object types
134   int  index; // index of local veriable, which value was loaded in stack
135   const field_desc* equals;
136 };
137 
138 #define IS_INT_TYPE(tp) (tp <= tp_int)
139 #define IS_ARRAY_TYPE(tp) ((tp & ~0xFF) != 0)
140 
141 int_type_range const ranges[] = {
142   //   min         max
143   {0x00000000, 0x00000001}, // tp_bool
144     {0xffffff80, 0x0000007f}, // tp_byte
145       {0x00000000, 0x0000ffff}, // tp_char
146         {0xffff8000, 0x00007fff}, // tp_short
147           {0x80000000, 0x7fffffff}  // tp_int
148 };
149 
150 int const array_type[] = {
151   0,
152     0,
153     0,
154     0,
155     tp_bool,
156     tp_char,
157     tp_float,
158     tp_double,
159     tp_byte,
160     tp_short,
161     tp_int,
162     tp_long
163     };
164 
165 int const vbm_instruction_length[] = {
166 #define JAVA_INSN(code, mnem, len) len,
167 #include "jlint.d"
168   0
169     };
170 
171 char const* const vbm_instruction_mnemonic[] = {
172 #define JAVA_INSN(code, mnem, len) #mnem,
173 #include "jlint.d"
174   NULL
175     };
176 
177 #ifndef MAX_PATH
178 #define MAX_PATH 1024
179 #endif
180 
181 #ifdef INT8_DEFINED
182 #define TO_INT8(high, low)        ((nat8(high) << 32) | unsigned(low))
183 #define LOW_PART(x)               int4(x)
184 #define HIGH_PART(x)              int4(nat8(x) >> 32)
185 
186 #define LOAD_INT8(src,field)      TO_INT8((src)[0].field, (src)[1].field)
187 #define STORE_INT8(dst,field,src) (dst)[0].field = HIGH_PART(src),\
188           (dst)[1].field = LOW_PART(src)
189 
190 #ifndef INT8_MAX
191 #define INT8_MAX      ((int8)((nat8)-1 >> 1))
192 #endif
193 #ifndef INT8_MIN
194 #define INT8_MIN      ((int8)(((nat8)-1 >> 1) + 1))
195 #endif
196 #define INT8_ZERO     ((int8)0)
197 #define INT8_ALL_BITS ((int8)-1)
198 #endif
199 
200 #define MAX_ARRAY_LENGTH 0x7fffffff
201 
202 #define ALL_BITS 0xffffffff
203 #define SIGN_BIT 0x80000000
204 
205 #define NO_ASSOC_VAR -1
206 
207 #ifdef _WIN32
208 #define FILE_SEP '\\'
209 #else
210 #define FILE_SEP '/'
211 #endif
212 
213 // declared in jlint.cc:
214 extern int max_shown_paths;
215 extern char* source_file_path;
216 extern int   source_file_path_len;
217 extern bool  source_path_redefined;
218 extern int n_messages;
219 
220 #endif
221