|
1 /* |
|
2 * Copyright 1998-2006 Sun Microsystems, Inc. All Rights Reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. |
|
8 * |
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
|
13 * accompanied this code). |
|
14 * |
|
15 * You should have received a copy of the GNU General Public License version |
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 * |
|
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
20 * CA 95054 USA or visit www.sun.com if you need additional information or |
|
21 * have any questions. |
|
22 * |
|
23 */ |
|
24 |
|
25 // |
|
26 // Standard include file for ADLC parser |
|
27 // |
|
28 |
|
29 // standard library constants |
|
30 #include "stdio.h" |
|
31 #include "stdlib.h" |
|
32 #if _MSC_VER >= 1300 // Visual C++ 7.0 or later |
|
33 #include <iostream> |
|
34 #else |
|
35 #include <iostream.h> |
|
36 #endif |
|
37 #include "string.h" |
|
38 #include "ctype.h" |
|
39 #include "stdarg.h" |
|
40 #include <sys/types.h> |
|
41 |
|
42 #if _MSC_VER >= 1300 |
|
43 using namespace std; |
|
44 #endif |
|
45 |
|
46 // make sure the MSC_VER and _MSC_VER settings make sense |
|
47 #if _MSC_VER != MSC_VER && (_MSC_VER != 1400 || MSC_VER != 1399) |
|
48 #error "Something is wrong with the detection of MSC_VER in the makefiles" |
|
49 #endif |
|
50 |
|
51 #if _MSC_VER >= 1400 && !defined(_WIN64) |
|
52 #define strdup _strdup |
|
53 #endif |
|
54 |
|
55 /* Make sure that we have the intptr_t and uintptr_t definitions */ |
|
56 #ifdef _WIN32 |
|
57 #ifndef _INTPTR_T_DEFINED |
|
58 #ifdef _WIN64 |
|
59 typedef __int64 intptr_t; |
|
60 #else |
|
61 typedef int intptr_t; |
|
62 #endif |
|
63 #define _INTPTR_T_DEFINED |
|
64 #endif |
|
65 |
|
66 #ifndef _UINTPTR_T_DEFINED |
|
67 #ifdef _WIN64 |
|
68 typedef unsigned __int64 uintptr_t; |
|
69 #else |
|
70 typedef unsigned int uintptr_t; |
|
71 #endif |
|
72 #define _UINTPTR_T_DEFINED |
|
73 #endif |
|
74 #endif // _WIN32 |
|
75 |
|
76 #ifdef LINUX |
|
77 #include <inttypes.h> |
|
78 #endif // LINUX |
|
79 |
|
80 // Macros |
|
81 #define uint32 unsigned int |
|
82 #define uint unsigned int |
|
83 |
|
84 // Macros |
|
85 // Debugging note: Put a breakpoint on "abort". |
|
86 #define assert(cond, msg) { if (!(cond)) { fprintf(stderr, "assert fails %s %d: %s\n", __FILE__, __LINE__, msg); abort(); }} |
|
87 #define max(a, b) (((a)>(b)) ? (a) : (b)) |
|
88 |
|
89 // VM components |
|
90 #include "opcodes.hpp" |
|
91 |
|
92 // ADLC components |
|
93 #include "arena.hpp" |
|
94 #include "adlcVMDeps.hpp" |
|
95 #include "filebuff.hpp" |
|
96 #include "dict2.hpp" |
|
97 #include "forms.hpp" |
|
98 #include "formsopt.hpp" |
|
99 #include "formssel.hpp" |
|
100 #include "archDesc.hpp" |
|
101 #include "adlparse.hpp" |
|
102 |
|
103 // globally define ArchDesc for convenience. Alternatively every form |
|
104 // could have a backpointer to the AD but it's too complicated to pass |
|
105 // it everywhere it needs to be available. |
|
106 extern ArchDesc* globalAD; |