1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
|
#ifndef COMPILER_COMMON_H
#define COMPILER_COMMON_H
#include "cw_common.h"
enum { CR = 13, LF = 10 };
typedef struct HashNameNode {
struct HashNameNode *next;
SInt32 id;
SInt16 hashval;
char name[1];
} HashNameNode;
#ifdef __MWERKS__
#pragma options align=mac68k
#endif
// TODO move me into CPrep.h or something?
struct CPrepFileInfo {
FSSpec textfile;
HashNameNode *nameNode;
SInt32 fileModDate;
char *textbuffer;
SInt32 textlength;
SInt32 linenumber;
SInt32 pos;
Boolean hasprepline;
SInt16 fileID;
Boolean recordbrowseinfo;
Boolean unkfield123;
Boolean unkfield124;
Boolean unkfield125;
Boolean unkfield126;
};
#ifdef __MWERKS__
#pragma options align=reset
#endif
typedef struct CInt64 {
SInt32 hi;
UInt32 lo;
} CInt64;
typedef struct Float {
double value;
} Float;
typedef union MWVector128 {
UInt8 uc[16];
UInt16 us[8];
UInt32 ul[4];
float f[4];
} MWVector128;
typedef enum AccessType {
ACCESSPUBLIC,
ACCESSPRIVATE,
ACCESSPROTECTED,
ACCESSNONE
} AccessType;
typedef enum Section {
SECT_DEFAULT = 0,
SECT_TEXT = 1,
SECT_DATA = 2,
SECT_UDATA = 3,
SECT_DATA_FAR = 4,
SECT_DATA_NEAR = 5,
SECT_INIT = 6,
SECT_OBJC_CAT_CLS_METH = 7,
SECT_OBJC_CAT_INST_METH = 8,
SECT_OBJC_STRING_OBJECT = 9,
SECT_OBJC_CSTRING_OBJECT = 10,
SECT_OBJC_MESSAGE_REFS = 11,
SECT_OBJC_SEL_FIXUP = 12,
SECT_OBJC_CLS_REFS = 13,
SECT_OBJC_CLASS = 14,
SECT_OBJC_META_CLASS = 15,
SECT_OBJC_CLS_METH = 16,
SECT_OBJC_INST_METH = 17,
SECT_OBJC_PROTOCOL = 18,
SECT_OBJC_CLASS_NAMES = 19,
SECT_OBJC_METH_VAR_TYPES = 20,
SECT_OBJC_METH_VAR_NAMES = 21,
SECT_OBJC_CATEGORY = 22,
SECT_OBJC_CLASS_VARS = 23,
SECT_OBJC_INSTANCE_VARS = 24,
SECT_OBJC_MODULE_INFO = 25,
SECT_OBJC_MSYMBOLS = 26,
SECT_TEXT_CSTRING = 27,
SECT_BACKEND_SPECIFIC = 28,
SECT_MW_EX_TABLE = 28,
SECT_MW_EX_TABLE_INDEX = 29,
SECT_MW_SWITCH = 30,
SECT_8BYTE_LITERALS = 31,
SECT_4BYTE_LITERALS = 32,
SECT_MOD_INIT_FUNC = 33,
SECT_CONST = 34,
SECT_CONST_PTR = 35,
SECT_NONLAZY_PTRS = 36,
SECT_COMMON_VARS = 37,
SECT_16BYTE_LITERALS = 38,
SECT_TEXT_COALESCE = 39,
SECT_DATA_COALESCE = 40,
SECT_UDATA_COALESCE = 41,
SECT_CONST_COALESCE = 42,
SECT_CONST_PTR_COALESCE = 43,
//SECT_CSTR_COALESCE = 44,
N_SECTIONS = 44
} Section;
typedef struct Alias Alias;
typedef struct BClassList BClassList;
typedef struct CI_FuncData CI_FuncData;
typedef struct CLabel CLabel;
typedef struct ClassLayout ClassLayout;
typedef struct ClassList ClassList;
typedef struct CompilerLinkerParamBlk CompilerLinkerParamBlk;
typedef struct CPrepFileInfo CPrepFileInfo;
typedef struct CScopeSave CScopeSave;
typedef struct DeclFucker DeclFucker;
typedef struct DeclInfo DeclInfo;
typedef struct DeclThing DeclThing; // rename me please
typedef struct DeduceInfo DeduceInfo;
typedef struct DefAction DefAction;
typedef struct DefArgCtorInfo DefArgCtorInfo;
typedef struct DepName DepName;
typedef struct EMemberInfo EMemberInfo;
typedef struct ENode ENode;
typedef struct ENodeList ENodeList;
typedef struct ExceptionAction ExceptionAction;
typedef struct ExceptSpecList ExceptSpecList;
typedef struct ExtendedParam ExtendedParam;
typedef struct FileOffsetInfo FileOffsetInfo;
typedef struct FuncArg FuncArg;
typedef struct GList GList;
typedef struct Initializer Initializer;
typedef struct InlineXRef InlineXRef;
typedef struct Macro Macro;
typedef struct MemInitializer MemInitializer;
typedef struct NameSpace NameSpace;
typedef struct NameSpaceName NameSpaceName;
typedef struct NameSpaceList NameSpaceList;
typedef struct NameSpaceLookupList NameSpaceLookupList;
typedef struct NameSpaceObjectList NameSpaceObjectList;
typedef struct ObjBase ObjBase;
typedef struct ObjEnumConst ObjEnumConst;
typedef struct ObjMemberVar ObjMemberVar;
typedef struct ObjMemberVarPath ObjMemberVarPath;
typedef struct ObjNameSpace ObjNameSpace;
typedef struct ObjType ObjType;
typedef struct ObjTypeTag ObjTypeTag;
typedef struct Object Object;
typedef struct ObjectList ObjectList;
typedef struct ObjectTemplated ObjectTemplated;
typedef struct ObjCCategory ObjCCategory;
typedef struct ObjCInfo ObjCInfo;
typedef struct ObjCMethod ObjCMethod;
typedef struct ObjCMethodArg ObjCMethodArg;
typedef struct ObjCMethodList ObjCMethodList;
typedef struct ObjCNamedArg ObjCNamedArg;
typedef struct ObjCProtocol ObjCProtocol;
typedef struct ObjCProtocolList ObjCProtocolList;
typedef struct ObjCSelector ObjCSelector;
typedef struct OLinkList OLinkList;
typedef struct Operand Operand;
typedef struct PackedDeclInfo PackedDeclInfo;
typedef struct PCode PCode;
typedef struct PCodeArg PCodeArg;
typedef struct PCodeBlock PCodeBlock;
typedef struct PCodeLabel PCodeLabel;
typedef struct PointsToFunction PointsToFunction;
typedef struct PTFList PTFList;
typedef struct SOMInfo SOMInfo;
typedef struct Statement Statement;
typedef struct StructMember StructMember;
typedef struct SwitchCase SwitchCase;
typedef struct SwitchInfo SwitchInfo;
typedef struct TemplateAction TemplateAction;
typedef struct TemplateFriend TemplateFriend;
typedef struct TemplateMember TemplateMember;
typedef struct TemplArg TemplArg;
typedef struct TemplClass TemplClass;
typedef struct TemplClassInst TemplClassInst;
typedef struct TemplateFunction TemplateFunction;
typedef struct TemplFuncInstance TemplFuncInstance;
typedef struct TemplParam TemplParam;
typedef struct TemplPartialSpec TemplPartialSpec;
typedef struct TemplStack TemplStack;
typedef struct TokenStream TokenStream;
typedef struct TStreamElement TStreamElement;
typedef struct Type Type;
typedef struct TypeBitfield TypeBitfield;
typedef struct TypeClass TypeClass;
typedef struct TypeDeduce TypeDeduce;
typedef struct TypeEnum TypeEnum;
typedef struct TypeFunc TypeFunc;
typedef struct TypeIntegral TypeIntegral;
typedef struct TypeList TypeList;
typedef struct TypeMemberPointer TypeMemberPointer;
typedef struct TypeMemberFunc TypeMemberFunc;
typedef struct TypeObjCID TypeObjCID;
typedef struct TypePointer TypePointer;
typedef struct TypeStruct TypeStruct;
typedef struct TypeTemplDep TypeTemplDep;
typedef struct VarInfo VarInfo;
typedef struct VarRecord VarRecord;
typedef struct VClassList VClassList;
// Common bits for templates
typedef enum TemplParamType {
TPT_TYPE = 0,
TPT_NONTYPE,
TPT_TEMPLATE
} TemplParamType;
typedef struct TemplParamID {
UInt16 index;
UInt8 nindex;
TemplParamType type;
} TemplParamID;
typedef enum TemplDepSubType {
TDE_PARAM,
TDE_SIZEOF,
TDE_ALIGNOF,
TDE_CAST,
TDE_QUALNAME,
TDE_OBJ,
TDE_SOURCEREF,
TDE_ADDRESS_OF
} TemplDepSubType;
/// Qualifiers
enum {
Q_CONST = 1,
Q_VOLATILE = 2,
Q_CV = Q_CONST | Q_VOLATILE,
Q_ASM = 4,
Q_PASCAL = 8,
Q_INLINE = 0x10,
Q_REFERENCE = 0x20,
Q_EXPLICIT = 0x40,
Q_MUTABLE = 0x80,
Q_VIRTUAL = 0x100,
Q_FRIEND = 0x200,
Q_IN = 0x400,
Q_OUT = 0x800,
Q_INOUT = 0x1000,
Q_BYCOPY = 0x2000,
Q_BYREF = 0x4000,
Q_ONEWAY = 0x8000,
Q_INLINE_DATA = 0x10000, // this object contains constant data in its union
Q_20000 = 0x20000,
Q_WEAK = 0x40000, // weak
Q_MANGLE_NAME = 0x80000, // adds C++ mangling info to a name
Q_IS_OBJC_ID = 0x100000, // Objective-C ID
Q_RESTRICT = 0x200000,
Q_IS_TEMPLATED = 0x400000, // is templated from another object?
Q_1000000 = 0x1000000,
Q_ALIGNED_1 = 0x2000000,
Q_ALIGNED_2 = 0x4000000,
Q_ALIGNED_4 = 0x6000000,
Q_ALIGNED_8 = 0x8000000,
Q_ALIGNED_16 = 0xA000000,
Q_ALIGNED_32 = 0xC000000,
Q_ALIGNED_64 = 0x10000000,
Q_ALIGNED_128 = 0x12000000,
Q_ALIGNED_256 = 0x14000000,
Q_ALIGNED_512 = 0x16000000,
Q_ALIGNED_1024 = 0x18000000,
Q_ALIGNED_2048 = 0x1A000000,
Q_ALIGNED_4096 = 0x1C000000,
Q_ALIGNED_8192 = 0x1E000000,
Q_ALIGNED_MASK = 0x1E000000
};
enum {
EXPORT_FLAGS_INTERNAL = 0x10,
EXPORT_FLAGS_IMPORT = 0x20,
EXPORT_FLAGS_EXPORT = 0x40
};
typedef enum RegClass {
RegClass_Invalid = -1,
RegClass_SPR = 0,
RegClass_CRFIELD = 1,
RegClass_VR = 2,
RegClass_FPR = 3,
RegClass_GPR = 4,
RegClassMax = 5,
RegClass_6 = 6,
RegClass_DCR = 7
} RegClass;
#ifdef __MWERKS__
#pragma options align=mac68k
#endif
struct CompilerLinkerParamBlk {
CWPluginContext context;
CWObjectData object;
Handle objectdata;
Handle browsedata;
SInt32 request;
SInt32 version;
FSSpec targetfile;
SInt32 numfiles;
SInt32 whichfile;
FSSpec sourcefile;
const char *sourcetext;
SInt32 sourcetextsize;
Boolean precompile;
Boolean autoprecompile;
Boolean preprocess;
Boolean SYMinfo;
Boolean caching_includes;
CWBrowseOptions browseoptions;
Boolean recordbrowseinfo;
SInt16 browserfileID;
CWDataType targetOS;
CWDataType targetCPU;
char *idetargetname;
};
#define FITS_IN_SHORT(value) ( (value) == ((short) (value)) )
#define FITS_IN_USHORT(value) ( (value) == ((unsigned short) (value)) )
#define FITS_IN_HI_SHORT(value) ( (value) == (value & 0xFFFF0000) )
#define FITS_IN_SHORT2(value) ( ((short) (value)) == (value) )
#define HIGH_PART(value) ( (short) (((value) >> 16) + (((value) >> 15) & 1)) )
#define LOW_PART(value) ( (short) (value) )
// The PowerPC code generator has a bug which breaks the PowerPC code generator,
// causing 32-bit value loads to emit "addi x, y, 0" even if the lower 16 bits are
// zero. This define simulates that behaviour on other platforms
#ifdef CW_REPLICATE_PPC_CODEGEN_BUG
#define LOW_PART_BUGGY(value) (value)
#else
#define LOW_PART_BUGGY(value) ( (short) (value) )
#endif
#ifdef __MWERKS__
#pragma options align=reset
#endif
#endif
|