mirror of
https://git.wuffs.org/MWCC
synced 2025-12-12 06:45:17 +00:00
a bunch of compiler stuff
This commit is contained in:
364
includes/compiler/CError.h
Normal file
364
includes/compiler/CError.h
Normal file
@@ -0,0 +1,364 @@
|
||||
#ifndef COMPILER_CERROR_H
|
||||
#define COMPILER_CERROR_H
|
||||
|
||||
#include "compiler/common.h"
|
||||
|
||||
#define CError_ASSERT(cond) if (!(cond)) { CError_Internal(__FILE__, __LINE__); }
|
||||
#define CError_FAIL(cond) if (cond) { CError_Internal(__FILE__, __LINE__); }
|
||||
#define CError_FATAL() do { CError_Internal(__FILE__, __LINE__); } while (0)
|
||||
|
||||
enum {
|
||||
CErrorStr100 = 100,
|
||||
CErrorStr101 = 101,
|
||||
CErrorStr102 = 102,
|
||||
CErrorStr103 = 103,
|
||||
CErrorStr104 = 104,
|
||||
CErrorStr105 = 105,
|
||||
CErrorStr106 = 106,
|
||||
CErrorStr107 = 107,
|
||||
CErrorStr108 = 108,
|
||||
CErrorStr109 = 109,
|
||||
CErrorStr110 = 110,
|
||||
CErrorStr111 = 111,
|
||||
CErrorStr112 = 112,
|
||||
CErrorStr113 = 113,
|
||||
CErrorStr114 = 114,
|
||||
CErrorStr115 = 115,
|
||||
CErrorStr116 = 116,
|
||||
CErrorStr117 = 117,
|
||||
CErrorStr118 = 118,
|
||||
CErrorStr119 = 119,
|
||||
CErrorStr120 = 120,
|
||||
CErrorStr121 = 121,
|
||||
CErrorStr122 = 122,
|
||||
CErrorStr123 = 123,
|
||||
CErrorStr124 = 124,
|
||||
CErrorStr125 = 125,
|
||||
CErrorStr126 = 126,
|
||||
CErrorStr127 = 127,
|
||||
CErrorStr128 = 128,
|
||||
CErrorStr129 = 129,
|
||||
CErrorStr130 = 130,
|
||||
CErrorStr131 = 131,
|
||||
CErrorStr132 = 132,
|
||||
CErrorStr133 = 133,
|
||||
CErrorStr134 = 134,
|
||||
CErrorStr135 = 135,
|
||||
CErrorStr136 = 136,
|
||||
CErrorStr137 = 137,
|
||||
CErrorStr138 = 138,
|
||||
CErrorStr139 = 139,
|
||||
CErrorStr140 = 140,
|
||||
CErrorStr141 = 141,
|
||||
CErrorStr142 = 142,
|
||||
CErrorStr143 = 143,
|
||||
CErrorStr144 = 144,
|
||||
CErrorStr145 = 145,
|
||||
CErrorStr146 = 146,
|
||||
CErrorStr147 = 147,
|
||||
CErrorStr148 = 148,
|
||||
CErrorStr149 = 149,
|
||||
CErrorStr150 = 150,
|
||||
CErrorStr151 = 151,
|
||||
CErrorStr152 = 152,
|
||||
CErrorStr153 = 153,
|
||||
CErrorStr154 = 154,
|
||||
CErrorStr155 = 155,
|
||||
CErrorStr156 = 156,
|
||||
CErrorStr157 = 157,
|
||||
CErrorStr158 = 158,
|
||||
CErrorStr159 = 159,
|
||||
CErrorStr160 = 160,
|
||||
CErrorStr161 = 161,
|
||||
CErrorStr162 = 162,
|
||||
CErrorStr163 = 163,
|
||||
CErrorStr164 = 164,
|
||||
CErrorStr165 = 165,
|
||||
CErrorStr166 = 166,
|
||||
CErrorStr167 = 167,
|
||||
CErrorStr168 = 168,
|
||||
CErrorStr169 = 169,
|
||||
CErrorStr170 = 170,
|
||||
CErrorStr171 = 171,
|
||||
CErrorStr172 = 172,
|
||||
CErrorStr173 = 173,
|
||||
CErrorStr174 = 174,
|
||||
CErrorStr175 = 175,
|
||||
CErrorStr176 = 176,
|
||||
CErrorStr177 = 177,
|
||||
CErrorStr178 = 178,
|
||||
CErrorStr179 = 179,
|
||||
CErrorStr180 = 180,
|
||||
CErrorStr181 = 181,
|
||||
CErrorStr182 = 182,
|
||||
CErrorStr183 = 183,
|
||||
CErrorStr184 = 184,
|
||||
CErrorStr185 = 185,
|
||||
CErrorStr186 = 186,
|
||||
CErrorStr187 = 187,
|
||||
CErrorStr188 = 188,
|
||||
CErrorStr189 = 189,
|
||||
CErrorStr190 = 190,
|
||||
CErrorStr191 = 191,
|
||||
CErrorStr192 = 192,
|
||||
CErrorStr193 = 193,
|
||||
CErrorStr194 = 194,
|
||||
CErrorStr195 = 195,
|
||||
CErrorStr196 = 196,
|
||||
CErrorStr197 = 197,
|
||||
CErrorStr198 = 198,
|
||||
CErrorStr199 = 199,
|
||||
CErrorStr200 = 200,
|
||||
CErrorStr201 = 201,
|
||||
CErrorStr202 = 202,
|
||||
CErrorStr203 = 203,
|
||||
CErrorStr204 = 204,
|
||||
CErrorStr205 = 205,
|
||||
CErrorStr206 = 206,
|
||||
CErrorStr207 = 207,
|
||||
CErrorStr208 = 208,
|
||||
CErrorStr209 = 209,
|
||||
CErrorStr210 = 210,
|
||||
CErrorStr211 = 211,
|
||||
CErrorStr212 = 212,
|
||||
CErrorStr213 = 213,
|
||||
CErrorStr214 = 214,
|
||||
CErrorStr215 = 215,
|
||||
CErrorStr216 = 216,
|
||||
CErrorStr217 = 217,
|
||||
CErrorStr218 = 218,
|
||||
CErrorStr219 = 219,
|
||||
CErrorStr220 = 220,
|
||||
CErrorStr221 = 221,
|
||||
CErrorStr222 = 222,
|
||||
CErrorStr223 = 223,
|
||||
CErrorStr224 = 224,
|
||||
CErrorStr225 = 225,
|
||||
CErrorStr226 = 226,
|
||||
CErrorStr227 = 227,
|
||||
CErrorStr228 = 228,
|
||||
CErrorStr229 = 229,
|
||||
CErrorStr230 = 230,
|
||||
CErrorStr231 = 231,
|
||||
CErrorStr232 = 232,
|
||||
CErrorStr233 = 233,
|
||||
CErrorStr234 = 234,
|
||||
CErrorStr235 = 235,
|
||||
CErrorStr236 = 236,
|
||||
CErrorStr237 = 237,
|
||||
CErrorStr238 = 238,
|
||||
CErrorStr239 = 239,
|
||||
CErrorStr240 = 240,
|
||||
CErrorStr241 = 241,
|
||||
CErrorStr242 = 242,
|
||||
CErrorStr243 = 243,
|
||||
CErrorStr244 = 244,
|
||||
CErrorStr245 = 245,
|
||||
CErrorStr246 = 246,
|
||||
CErrorStr247 = 247,
|
||||
CErrorStr248 = 248,
|
||||
CErrorStr249 = 249,
|
||||
CErrorStr250 = 250,
|
||||
CErrorStr251 = 251,
|
||||
CErrorStr252 = 252,
|
||||
CErrorStr253 = 253,
|
||||
CErrorStr254 = 254,
|
||||
CErrorStr255 = 255,
|
||||
CErrorStr256 = 256,
|
||||
CErrorStr257 = 257,
|
||||
CErrorStr258 = 258,
|
||||
CErrorStr259 = 259,
|
||||
CErrorStr260 = 260,
|
||||
CErrorStr261 = 261,
|
||||
CErrorStr262 = 262,
|
||||
CErrorStr263 = 263,
|
||||
CErrorStr264 = 264,
|
||||
CErrorStr265 = 265,
|
||||
CErrorStr266 = 266,
|
||||
CErrorStr267 = 267,
|
||||
CErrorStr268 = 268,
|
||||
CErrorStr269 = 269,
|
||||
CErrorStr270 = 270,
|
||||
CErrorStr271 = 271,
|
||||
CErrorStr272 = 272,
|
||||
CErrorStr273 = 273,
|
||||
CErrorStr274 = 274,
|
||||
CErrorStr275 = 275,
|
||||
CErrorStr276 = 276,
|
||||
CErrorStr277 = 277,
|
||||
CErrorStr278 = 278,
|
||||
CErrorStr279 = 279,
|
||||
CErrorStr280 = 280,
|
||||
CErrorStr281 = 281,
|
||||
CErrorStr282 = 282,
|
||||
CErrorStr283 = 283,
|
||||
CErrorStr284 = 284,
|
||||
CErrorStr285 = 285,
|
||||
CErrorStr286 = 286,
|
||||
CErrorStr287 = 287,
|
||||
CErrorStr288 = 288,
|
||||
CErrorStr289 = 289,
|
||||
CErrorStr290 = 290,
|
||||
CErrorStr291 = 291,
|
||||
CErrorStr292 = 292,
|
||||
CErrorStr293 = 293,
|
||||
CErrorStr294 = 294,
|
||||
CErrorStr295 = 295,
|
||||
CErrorStr296 = 296,
|
||||
CErrorStr297 = 297,
|
||||
CErrorStr298 = 298,
|
||||
CErrorStr299 = 299,
|
||||
CErrorStr300 = 300,
|
||||
CErrorStr301 = 301,
|
||||
CErrorStr302 = 302,
|
||||
CErrorStr303 = 303,
|
||||
CErrorStr304 = 304,
|
||||
CErrorStr305 = 305,
|
||||
CErrorStr306 = 306,
|
||||
CErrorStr307 = 307,
|
||||
CErrorStr308 = 308,
|
||||
CErrorStr309 = 309,
|
||||
CErrorStr310 = 310,
|
||||
CErrorStr311 = 311,
|
||||
CErrorStr312 = 312,
|
||||
CErrorStr313 = 313,
|
||||
CErrorStr314 = 314,
|
||||
CErrorStr315 = 315,
|
||||
CErrorStr316 = 316,
|
||||
CErrorStr317 = 317,
|
||||
CErrorStr318 = 318,
|
||||
CErrorStr319 = 319,
|
||||
CErrorStr320 = 320,
|
||||
CErrorStr321 = 321,
|
||||
CErrorStr322 = 322,
|
||||
CErrorStr323 = 323,
|
||||
CErrorStr324 = 324,
|
||||
CErrorStr325 = 325,
|
||||
CErrorStr326 = 326,
|
||||
CErrorStr327 = 327,
|
||||
CErrorStr328 = 328,
|
||||
CErrorStr329 = 329,
|
||||
CErrorStr330 = 330,
|
||||
CErrorStr331 = 331,
|
||||
CErrorStr332 = 332,
|
||||
CErrorStr333 = 333,
|
||||
CErrorStr334 = 334,
|
||||
CErrorStr335 = 335,
|
||||
CErrorStr336 = 336,
|
||||
CErrorStr337 = 337,
|
||||
CErrorStr338 = 338,
|
||||
CErrorStr339 = 339,
|
||||
CErrorStr340 = 340,
|
||||
CErrorStr341 = 341,
|
||||
CErrorStr342 = 342,
|
||||
CErrorStr343 = 343,
|
||||
CErrorStr344 = 344,
|
||||
CErrorStr345 = 345,
|
||||
CErrorStr346 = 346,
|
||||
CErrorStr347 = 347,
|
||||
CErrorStr348 = 348,
|
||||
CErrorStr349 = 349,
|
||||
CErrorStr350 = 350,
|
||||
CErrorStr351 = 351,
|
||||
CErrorStr352 = 352,
|
||||
CErrorStr353 = 353,
|
||||
CErrorStr354 = 354,
|
||||
CErrorStr355 = 355,
|
||||
CErrorStr356 = 356,
|
||||
CErrorStr357 = 357,
|
||||
CErrorStr358 = 358,
|
||||
CErrorStr359 = 359,
|
||||
CErrorStr360 = 360,
|
||||
CErrorStr361 = 361,
|
||||
CErrorStr362 = 362,
|
||||
CErrorStr363 = 363,
|
||||
CErrorStr364 = 364,
|
||||
CErrorStr365 = 365,
|
||||
CErrorStr366 = 366,
|
||||
CErrorStr367 = 367,
|
||||
CErrorStr368 = 368,
|
||||
CErrorStr369 = 369,
|
||||
CErrorStr370 = 370,
|
||||
CErrorStr371 = 371,
|
||||
CErrorStr372 = 372,
|
||||
CErrorStr373 = 373,
|
||||
CErrorStr374 = 374,
|
||||
CErrorStr375 = 375,
|
||||
CErrorStr376 = 376,
|
||||
CErrorStr377 = 377,
|
||||
CErrorStr378 = 378,
|
||||
CErrorStr379 = 379,
|
||||
CErrorStr380 = 380,
|
||||
CErrorStr381 = 381,
|
||||
CErrorStr382 = 382,
|
||||
CErrorStr383 = 383,
|
||||
CErrorStr384 = 384,
|
||||
CErrorStr385 = 385,
|
||||
CErrorStr386 = 386,
|
||||
CErrorStr387 = 387,
|
||||
CErrorStr388 = 388,
|
||||
CErrorStr389 = 389,
|
||||
CErrorStr390 = 390,
|
||||
CErrorStr391 = 391,
|
||||
CErrorStr392 = 392,
|
||||
CErrorStrMAX = 393
|
||||
};
|
||||
|
||||
typedef struct _CErrorBuffer {
|
||||
char *start;
|
||||
char *end;
|
||||
UInt32 size;
|
||||
UInt32 remaining;
|
||||
} CErrorBuffer;
|
||||
|
||||
extern void CError_Init();
|
||||
extern void CError_SetErrorToken(TStreamElement *token);
|
||||
extern void CError_SetNullErrorToken();
|
||||
extern void CError_LockErrorPos(TStreamElement *token, TStreamElement **saved);
|
||||
extern void CError_UnlockErrorPos(TStreamElement **saved);
|
||||
extern void CError_ResetErrorSkip();
|
||||
extern void CError_GetErrorString(char *buf, short code);
|
||||
extern void CError_BufferInit(CErrorBuffer *eb, char *buf, SInt32 bufSize);
|
||||
extern void CError_BufferGrow(CErrorBuffer *eb, SInt32 amount);
|
||||
extern void CError_BufferAppendChar(CErrorBuffer *eb, char ch);
|
||||
extern void CError_BufferAppendString(CErrorBuffer *eb, const char *str);
|
||||
extern void CError_BufferTerminate(CErrorBuffer *eb);
|
||||
extern void CError_BufferAppendQualifier(CErrorBuffer *eb, UInt32 qual);
|
||||
extern void CError_BufferAppendTemplArgExpr(CErrorBuffer *eb, ENode *node);
|
||||
extern void CError_BufferAppendTemplArg(CErrorBuffer *eb, TemplArg *targ);
|
||||
extern void CError_BufferAppendTemplArgs(CErrorBuffer *eb, TemplArg *targs);
|
||||
extern void CError_BufferAppendNameSpace(CErrorBuffer *eb, NameSpace *nspace);
|
||||
extern void CError_BufferAppendPType(CErrorBuffer *eb, Type *ty);
|
||||
extern void CError_BufferAppendTemplDepType(CErrorBuffer *eb, TypeTemplDep *type);
|
||||
extern void CError_BufferAppendFuncArgs(CErrorBuffer *eb, TypeFunc *tfunc, Boolean isMethod);
|
||||
extern void CError_BufferAppendType(CErrorBuffer *eb, Type *ty, UInt32 qual);
|
||||
extern char *CError_GetTypeName(Type *ty, UInt32 qual, Boolean useGlobalHeap);
|
||||
extern void CError_AppendUnqualFunctionName(CErrorBuffer *eb, NameSpace *nspace, HashNameNode *name, TypeFunc *tfunc);
|
||||
extern void CError_AppendFunctionName(CErrorBuffer *eb, NameSpace *nspace, HashNameNode *name, TemplArg *templargs, TypeFunc *tfunc);
|
||||
extern void CError_AppendObjectName(CErrorBuffer *eb, Object *obj);
|
||||
extern void CError_AppendMethodName(CErrorBuffer *eb, ObjCMethod *meth);
|
||||
extern char *CError_GetQualifiedName(NameSpace *nspace, HashNameNode *name);
|
||||
extern char *CError_GetFunctionName(NameSpace *nspace, HashNameNode *name, TypeFunc *tfunc);
|
||||
extern char *CError_GetObjectName(Object *obj);
|
||||
extern char *CError_GetNameString(NameSpace *nspace, HashNameNode *operatorName);
|
||||
extern void CError_ErrorMessage(int errTable, char *buf, Boolean flag1, Boolean flag2);
|
||||
extern void CError_BufferAppendTemplateStack(CErrorBuffer *eb);
|
||||
extern void CError_ErrorMessageVA(int code, const char *format, va_list list, Boolean flag1, Boolean flag2);
|
||||
extern void CError_VAErrorMessage(int code, va_list list, Boolean flag1, Boolean flag2);
|
||||
extern void CError_Error(int code, ...);
|
||||
extern void CError_ErrorTerm(short code);
|
||||
extern void CError_ErrorSkip(int code, ...);
|
||||
extern void CError_ErrorFuncCall(short code, NameSpaceObjectList *args, ENodeList *argNodes);
|
||||
extern void CError_OverloadedFunctionError2(Object *obj, ObjectList *olst, ENodeList *argNodes);
|
||||
extern void CError_OverloadedFunctionError(Object *obj, ObjectList *olst);
|
||||
extern void CError_AbstractClassError(TypeClass *tclass);
|
||||
extern void CError_Warning(int code, ...);
|
||||
extern void CError_BreakPoint(const char *a, const char *b);
|
||||
extern void CError_Internal();
|
||||
extern void CError_ExpressionTooComplex();
|
||||
extern void CError_NoMem();
|
||||
extern void CError_UserBreak();
|
||||
extern void CError_CannotOpen();
|
||||
extern void CError_QualifierCheck(UInt32 qual);
|
||||
|
||||
#endif
|
||||
88
includes/compiler/CInt64.h
Normal file
88
includes/compiler/CInt64.h
Normal file
@@ -0,0 +1,88 @@
|
||||
#ifndef COMPILER_CINT64_H
|
||||
#define COMPILER_CINT64_H
|
||||
|
||||
#include "compiler/common.h"
|
||||
|
||||
// make sure this is in the right place
|
||||
extern const CInt64 cint64_negone;
|
||||
extern const CInt64 cint64_zero;
|
||||
extern const CInt64 cint64_one;
|
||||
extern const CInt64 cint64_max;
|
||||
extern const CInt64 cint64_min;
|
||||
|
||||
inline int CInt64_IsNegative(const CInt64 *n) {
|
||||
return (n->hi & 0x80000000) != 0;
|
||||
}
|
||||
inline void CInt64_SetLong(CInt64 *pN, SInt32 n) {
|
||||
pN->lo = n;
|
||||
pN->hi = (n < 0) ? 0xFFFFFFFF : 0;
|
||||
}
|
||||
inline void CInt64_SetULong(CInt64 *pN, UInt32 n) {
|
||||
pN->lo = n;
|
||||
pN->hi = 0;
|
||||
}
|
||||
|
||||
inline int CInt64_IsZero(CInt64 *n) {
|
||||
//if (n->hi == 0 && n->lo == 0)
|
||||
// return 1;
|
||||
//else
|
||||
// return 0;
|
||||
return n->hi == 0 && n->lo == 0;
|
||||
}
|
||||
inline void CInt64_Extend32(CInt64 *n) { // assumed name
|
||||
n->hi = (n->lo >> 31) ? 0xFFFFFFFF : 0;
|
||||
}
|
||||
|
||||
extern void CInt64_Init();
|
||||
extern CInt64 CInt64_Not(CInt64 input);
|
||||
extern CInt64 CInt64_Inv(CInt64 input);
|
||||
extern CInt64 CInt64_Add(CInt64 lhs, CInt64 rhs);
|
||||
extern CInt64 CInt64_Neg(CInt64 input);
|
||||
extern CInt64 CInt64_Sub(CInt64 lhs, CInt64 rhs);
|
||||
extern CInt64 CInt64_MulU(CInt64 lhs, CInt64 rhs);
|
||||
extern CInt64 CInt64_Mul(CInt64 lhs, CInt64 rhs);
|
||||
extern void CInt64_DivMod(const CInt64 *lhs, const CInt64 *rhs, CInt64 *pDiv, CInt64 *pMod);
|
||||
extern CInt64 CInt64_Div(CInt64 lhs, CInt64 rhs);
|
||||
extern CInt64 CInt64_DivU(CInt64 lhs, CInt64 rhs);
|
||||
extern CInt64 CInt64_Mod(CInt64 lhs, CInt64 rhs);
|
||||
extern CInt64 CInt64_ModU(CInt64 lhs, CInt64 rhs);
|
||||
extern CInt64 CInt64_Shl(CInt64 lhs, CInt64 rhs);
|
||||
extern CInt64 CInt64_Shr(CInt64 lhs, CInt64 rhs);
|
||||
extern CInt64 CInt64_ShrU(CInt64 lhs, CInt64 rhs);
|
||||
extern int CInt64_UnsignedCompare(const CInt64 *lhs, const CInt64 *rhs);
|
||||
extern int CInt64_SignedCompare(const CInt64 *lhs, const CInt64 *rhs);
|
||||
extern Boolean CInt64_Less(CInt64 lhs, CInt64 rhs);
|
||||
extern Boolean CInt64_LessU(CInt64 lhs, CInt64 rhs);
|
||||
extern Boolean CInt64_Greater(CInt64 lhs, CInt64 rhs);
|
||||
extern Boolean CInt64_GreaterU(CInt64 lhs, CInt64 rhs);
|
||||
extern Boolean CInt64_LessEqual(CInt64 lhs, CInt64 rhs);
|
||||
extern Boolean CInt64_LessEqualU(CInt64 lhs, CInt64 rhs);
|
||||
extern Boolean CInt64_GreaterEqual(CInt64 lhs, CInt64 rhs);
|
||||
extern Boolean CInt64_GreaterEqualU(CInt64 lhs, CInt64 rhs);
|
||||
extern Boolean CInt64_Equal(CInt64 lhs, CInt64 rhs);
|
||||
extern Boolean CInt64_NotEqual(CInt64 lhs, CInt64 rhs);
|
||||
extern Boolean CInt64_IsInRange(CInt64 value, short len);
|
||||
extern Boolean CInt64_IsInURange(CInt64 value, short len);
|
||||
extern CInt64 CInt64_And(CInt64 lhs, CInt64 rhs);
|
||||
extern CInt64 CInt64_Xor(CInt64 lhs, CInt64 rhs);
|
||||
extern CInt64 CInt64_Or(CInt64 lhs, CInt64 rhs);
|
||||
extern void CInt64_ConvertInt32(CInt64 *i);
|
||||
extern void CInt64_ConvertUInt32(CInt64 *i);
|
||||
extern void CInt64_ConvertInt16(CInt64 *i);
|
||||
extern void CInt64_ConvertUInt16(CInt64 *i);
|
||||
extern void CInt64_ConvertInt8(CInt64 *i);
|
||||
extern void CInt64_ConvertUInt8(CInt64 *i);
|
||||
extern void CInt64_ConvertUFromLongDouble(CInt64 *pResult, double value);
|
||||
extern void CInt64_ConvertFromLongDouble(CInt64 *pResult, double value);
|
||||
extern double CInt64_ConvertUToLongDouble(const CInt64 *value);
|
||||
extern double CInt64_ConvertToLongDouble(const CInt64 *value);
|
||||
extern char *CInt64_ScanOctString(CInt64 *pResult, char *str, Boolean *pFail);
|
||||
extern char *CInt64_ScanDecString(CInt64 *pResult, char *str, Boolean *pFail);
|
||||
extern char *CInt64_ScanHexString(CInt64 *pResult, char *str, Boolean *pFail);
|
||||
extern char *CInt64_ScanBinString(CInt64 *pResult, char *str, Boolean *pFail);
|
||||
extern char *CInt64_ScanAsmNumber(CInt64 *pResult, char *str, Boolean *pFail);
|
||||
extern int CInt64_PrintDec(char *output, CInt64 value);
|
||||
extern int CInt64_PrintHex(char *output, CInt64 value);
|
||||
extern int CInt64_PrintBin(char *output, CInt64 value);
|
||||
|
||||
#endif
|
||||
129
includes/compiler/CompilerTools.h
Normal file
129
includes/compiler/CompilerTools.h
Normal file
@@ -0,0 +1,129 @@
|
||||
#ifndef COMPILER_COMPILERTOOLS_H
|
||||
#define COMPILER_COMPILERTOOLS_H
|
||||
|
||||
#include "compiler/common.h"
|
||||
|
||||
extern void CompilerGetPString(short index, unsigned char *string);
|
||||
extern void CompilerGetCString(short index, char *string);
|
||||
extern unsigned char *CTool_CtoPstr(char *cstr);
|
||||
|
||||
typedef struct HeapBlock {
|
||||
struct HeapBlock *next;
|
||||
Handle blockhandle;
|
||||
SInt32 blocksize;
|
||||
SInt32 blockfree;
|
||||
} HeapBlock;
|
||||
|
||||
typedef struct HeapMem {
|
||||
HeapBlock *blocks;
|
||||
/// The minimum size for a new block
|
||||
SInt32 allocsize;
|
||||
HeapBlock *curblock;
|
||||
char *curfreep;
|
||||
SInt32 curfree;
|
||||
} HeapMem;
|
||||
|
||||
typedef struct _HeapInfo {
|
||||
/// The amount of blocks in this heap
|
||||
SInt32 blocks;
|
||||
/// The value of allocsize for the heap
|
||||
SInt32 allocsize;
|
||||
/// The total amount of bytes across all blocks
|
||||
SInt32 total_size;
|
||||
/// The amount of free bytes across all blocks
|
||||
SInt32 total_free;
|
||||
/// The average size of a block
|
||||
SInt32 average_block_size;
|
||||
/// The average amount of free space in a block
|
||||
SInt32 average_block_free;
|
||||
/// The amount of bytes in the largest contiguous section of free space
|
||||
SInt32 largest_free_block;
|
||||
} HeapInfo;
|
||||
|
||||
typedef struct GList {
|
||||
char **data;
|
||||
SInt32 size;
|
||||
SInt32 hndlsize;
|
||||
SInt32 growsize;
|
||||
} GList;
|
||||
|
||||
extern long hash_name_id;
|
||||
extern HashNameNode **name_hash_nodes;
|
||||
extern void (*GListErrorProc)();
|
||||
|
||||
extern short InitGList(GList *gl, SInt32 size);
|
||||
extern void FreeGList(GList *gl);
|
||||
extern void LockGList(GList *gl);
|
||||
extern void UnlockGList(GList *gl);
|
||||
extern void ShrinkGList(GList *gl);
|
||||
extern void AppendGListData(GList *gl, const void *data, SInt32 size);
|
||||
extern void AppendGListNoData(GList *gl, SInt32 size);
|
||||
extern void AppendGListByte(GList *gl, SInt8 thebyte);
|
||||
extern void AppendGListWord(GList *gl, SInt16 theword);
|
||||
extern void AppendGListTargetEndianWord(GList *gl, SInt16 theword);
|
||||
extern void AppendGListLong(GList *gl, SInt32 theword);
|
||||
extern void AppendGListTargetEndianLong(GList *gl, SInt32 theword);
|
||||
extern void AppendGListID(GList *gl, const char *name);
|
||||
extern void AppendGListName(GList *gl, const char *name);
|
||||
extern void RemoveGListData(GList *gl, SInt32 size);
|
||||
extern SInt16 GetGListByte(GList *gl);
|
||||
extern SInt16 GetGListWord(GList *gl);
|
||||
extern SInt32 GetGListLong(GList *gl);
|
||||
extern short GetGListID(GList *gl, char *name);
|
||||
extern void GetGListData(GList *gl, char *where, SInt32 size);
|
||||
|
||||
extern SInt16 CHash(const char *string);
|
||||
extern HashNameNode *GetHashNameNode(const char *name);
|
||||
extern HashNameNode *GetHashNameNodeHash(const char *name, SInt16 hashval);
|
||||
extern HashNameNode *GetHashNameNodeHash2(const char *name, SInt16 hashval);
|
||||
extern HashNameNode *GetHashNameNodeExport(const char *name);
|
||||
extern SInt32 GetHashNameNodeExportID(HashNameNode *node);
|
||||
extern HashNameNode *GetHashNameNodeByID(SInt32 id);
|
||||
extern void NameHashExportReset();
|
||||
extern void NameHashWriteNameTable(GList *glist);
|
||||
extern void NameHashWriteTargetEndianNameTable(GList *glist);
|
||||
extern void InitNameHash();
|
||||
|
||||
typedef void (*heaperror_t)();
|
||||
|
||||
extern SInt32 CTool_TotalHeapSize();
|
||||
extern void CTool_GetHeapInfo(HeapInfo *result, unsigned char heapID);
|
||||
extern short initheaps(heaperror_t heaperrorproc);
|
||||
extern short initgheap(heaperror_t heaperrorproc);
|
||||
extern heaperror_t getheaperror();
|
||||
extern void setheaperror(heaperror_t heaperrorproc);
|
||||
extern void releaseheaps();
|
||||
extern void releasegheap();
|
||||
extern void releaseoheap();
|
||||
extern void *galloc(SInt32 s);
|
||||
extern void *lalloc(SInt32 s);
|
||||
extern void *aalloc(SInt32 s);
|
||||
extern void *oalloc(SInt32 s);
|
||||
extern void *balloc(SInt32 s);
|
||||
|
||||
extern void locklheap();
|
||||
extern void unlocklheap();
|
||||
extern void freelheap();
|
||||
extern void freeaheap();
|
||||
extern void freeoheap();
|
||||
extern void freebheap();
|
||||
|
||||
extern char *ScanHex(char *string, UInt32 *result, Boolean *overflow);
|
||||
extern char *ScanOct(char *string, UInt32 *result, Boolean *overflow);
|
||||
extern char *ScanDec(char *string, UInt32 *result, Boolean *overflow);
|
||||
|
||||
extern void OldUnmangle(char *name, char *out, Boolean full);
|
||||
|
||||
extern short hash(char *a);
|
||||
extern void memclr(void *ptr, SInt32 size);
|
||||
extern void memclrw(void *ptr, SInt32 size);
|
||||
extern void CToLowercase(char *a, char *b);
|
||||
extern short getbit(SInt32 l);
|
||||
extern void CTool_EndianConvertWord64(CInt64 ci, char *result);
|
||||
extern UInt16 CTool_EndianConvertInPlaceWord16Ptr(UInt16 *x);
|
||||
extern UInt32 CTool_EndianConvertInPlaceWord32Ptr(UInt32 *x);
|
||||
extern void CTool_EndianConvertVector128(); // not correct but idc
|
||||
extern HashNameNode *CTool_GetPathName(const FSSpec *fss, SInt32 *moddateptr);
|
||||
extern int strcat_safe(char *dest, const char *src, SInt32 len);
|
||||
|
||||
#endif
|
||||
283
includes/compiler/common.h
Normal file
283
includes/compiler/common.h
Normal file
@@ -0,0 +1,283 @@
|
||||
#ifndef COMPILER_COMMON_H
|
||||
#define COMPILER_COMMON_H
|
||||
|
||||
#include "cw_common.h"
|
||||
|
||||
typedef struct HashNameNode {
|
||||
struct HashNameNode *next;
|
||||
SInt32 id;
|
||||
SInt16 hashval;
|
||||
char name[1];
|
||||
} HashNameNode;
|
||||
|
||||
typedef struct CPrepFileInfo CPrepFileInfo;
|
||||
|
||||
#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_MOD_TERM_FUNC = 34,
|
||||
SECT_CONST = 35,
|
||||
SECT_CONST_PTR = 36,
|
||||
SECT_NONLAZY_PTRS = 37,
|
||||
SECT_COMMON_VARS = 38,
|
||||
SECT_16BYTE_LITERALS = 39,
|
||||
SECT_TEXT_COALESCE = 40,
|
||||
SECT_DATA_COALESCE = 41,
|
||||
SECT_UDATA_COALESCE = 42,
|
||||
SECT_CONST_COALESCE = 43,
|
||||
SECT_CONST_PTR_COALESCE = 44,
|
||||
SECT_CSTR_COALESCE = 45,
|
||||
N_SECTIONS = 46
|
||||
} Section;
|
||||
|
||||
typedef struct BClassList BClassList;
|
||||
typedef struct CI_FuncData CI_FuncData;
|
||||
typedef struct CLabel CLabel;
|
||||
typedef struct DefArgCtorInfo DefArgCtorInfo;
|
||||
typedef struct DepName DepName;
|
||||
typedef struct ENode ENode;
|
||||
typedef struct ENodeList ENodeList;
|
||||
typedef struct ExceptionAction ExceptionAction;
|
||||
typedef struct ExtendedParam ExtendedParam;
|
||||
typedef struct FuncArg FuncArg;
|
||||
typedef struct Initializer Initializer;
|
||||
typedef struct InlineXRef InlineXRef;
|
||||
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 ObjCInfo ObjCInfo;
|
||||
typedef struct ObjCMethod ObjCMethod;
|
||||
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 Template Template;
|
||||
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 TemplInstance TemplInstance;
|
||||
typedef struct TemplParam TemplParam;
|
||||
typedef struct TemplPartialSpec TemplPartialSpec;
|
||||
typedef struct TemplStack TemplStack;
|
||||
typedef struct TStream TStream;
|
||||
typedef struct TStreamElement TStreamElement;
|
||||
typedef struct Type Type;
|
||||
typedef struct TypeBitfield TypeBitfield;
|
||||
typedef struct TypeClass TypeClass;
|
||||
typedef struct TypeEnum TypeEnum;
|
||||
typedef struct TypeFunc TypeFunc;
|
||||
typedef struct TypeIntegral TypeIntegral;
|
||||
typedef struct TypeMemberPointer TypeMemberPointer;
|
||||
typedef struct TypeMethod TypeMethod;
|
||||
typedef struct TypePointer TypePointer;
|
||||
typedef struct TypeStruct TypeStruct;
|
||||
typedef struct TypeTemplDep TypeTemplDep;
|
||||
typedef struct VarInfo VarInfo;
|
||||
typedef struct VarRecord VarRecord;
|
||||
|
||||
// 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_TYPEEXPR,
|
||||
TDE_CAST,
|
||||
TDE_QUALNAME,
|
||||
TDE_QUALTEMPL,
|
||||
TDE_OBJACCESS,
|
||||
TDE_SOURCEREF,
|
||||
TDE_FUNCCALL,
|
||||
TDE_LOCAL,
|
||||
TDE_MONAND,
|
||||
TDE_MONPLUS,
|
||||
TDE_MONMUL,
|
||||
TDE_NEW,
|
||||
TDE_DELETE,
|
||||
TDE_ARRAY,
|
||||
TDE_DYNAMIC_CAST,
|
||||
TDE_STATIC_CAST,
|
||||
TDE_REINTERPRET_CAST,
|
||||
TDE_CONST_CAST,
|
||||
TDE_TYPEID,
|
||||
TDE_MEMBERACCESS,
|
||||
TDE_THROW,
|
||||
TDE_EXCEPTIONINIT,
|
||||
TDE_LOCALINIT,
|
||||
TDE_STATICINIT,
|
||||
TDE_LOCALDESTROY,
|
||||
TDE_ILLEGAL
|
||||
} TemplDepSubType;
|
||||
|
||||
/// Things that can be applied to a type expression
|
||||
typedef enum TEFuncSel {
|
||||
TEFS_SIZEOF,
|
||||
TEFS_ALIGNOF,
|
||||
TEFS_UUIDOF,
|
||||
TEFS_BI_ALIGN,
|
||||
TEFS_BI_TYPE,
|
||||
TEFS_BI_VTYPE,
|
||||
TEFS_BI_CTYPE
|
||||
} TEFuncSel;
|
||||
|
||||
/// How to access an object
|
||||
/// this might not actually be in Pro7 lol
|
||||
typedef struct ObjAccess {
|
||||
NameSpaceObjectList *list;
|
||||
TypeClass *naming;
|
||||
TypeClass *member;
|
||||
TemplArg *targs;
|
||||
HashNameNode *name;
|
||||
ENode *expr;
|
||||
Boolean is_qualified;
|
||||
Boolean is_member;
|
||||
Boolean is_ambig : 1;
|
||||
Boolean is_ptm : 1;
|
||||
Boolean ext_only : 1;
|
||||
} ObjAccess;
|
||||
|
||||
/// Qualifiers
|
||||
enum {
|
||||
Q_CONST = 1,
|
||||
Q_VOLATILE = 2,
|
||||
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_RESTRICT = 0x200000,
|
||||
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
|
||||
};
|
||||
|
||||
#endif
|
||||
264
includes/compiler/enode.h
Normal file
264
includes/compiler/enode.h
Normal file
@@ -0,0 +1,264 @@
|
||||
#ifndef COMPILER_ENODE_H
|
||||
#define COMPILER_ENODE_H
|
||||
|
||||
#include "compiler/common.h"
|
||||
|
||||
#ifdef __MWERKS__
|
||||
#pragma options align=mac68k
|
||||
#endif
|
||||
|
||||
typedef enum ENodeType {
|
||||
EPOSTINC,
|
||||
EPOSTDEC,
|
||||
EPREINC,
|
||||
EPREDEC,
|
||||
EINDIRECT,
|
||||
EMONMIN,
|
||||
EBINNOT,
|
||||
ELOGNOT,
|
||||
EFORCELOAD,
|
||||
EMUL,
|
||||
EMULV,
|
||||
EDIV,
|
||||
EMODULO,
|
||||
EADDV,
|
||||
ESUBV,
|
||||
EADD,
|
||||
ESUB,
|
||||
ESHL,
|
||||
ESHR,
|
||||
ELESS,
|
||||
EGREATER,
|
||||
ELESSEQU,
|
||||
EGREATEREQU,
|
||||
EEQU,
|
||||
ENOTEQU,
|
||||
EAND,
|
||||
EXOR,
|
||||
EOR,
|
||||
ELAND,
|
||||
ELOR,
|
||||
EASS,
|
||||
EMULASS,
|
||||
EDIVASS,
|
||||
EMODASS,
|
||||
EADDASS,
|
||||
ESUBASS,
|
||||
ESHLASS,
|
||||
ESHRASS,
|
||||
EANDASS,
|
||||
EXORASS,
|
||||
EORASS,
|
||||
ECOMMA,
|
||||
EPMODULO,
|
||||
EROTL,
|
||||
EROTR,
|
||||
EBCLR,
|
||||
EBTST,
|
||||
EBSET,
|
||||
ETYPCON,
|
||||
EBITFIELD,
|
||||
EINTCONST,
|
||||
EFLOATCONST,
|
||||
ESTRINGCONST,
|
||||
ECOND,
|
||||
EFUNCCALL,
|
||||
EFUNCCALLP,
|
||||
EOBJREF,
|
||||
EMFPOINTER,
|
||||
ENULLCHECK,
|
||||
EPRECOMP,
|
||||
ETEMP,
|
||||
EARGOBJ,
|
||||
ELOCOBJ,
|
||||
ELABEL,
|
||||
ESETCONST,
|
||||
ENEWEXCEPTION,
|
||||
ENEWEXCEPTIONARRAY,
|
||||
EOBJLIST,
|
||||
EMEMBER,
|
||||
ETEMPLDEP,
|
||||
EINSTRUCTION,
|
||||
EDEFINE,
|
||||
EREUSE,
|
||||
EASSBLK,
|
||||
EVECTOR128CONST,
|
||||
ECONDASS,
|
||||
MAXEXPR
|
||||
} ENodeType;
|
||||
|
||||
|
||||
struct ENodeList {
|
||||
ENodeList *next;
|
||||
ENode *node;
|
||||
};
|
||||
|
||||
|
||||
typedef union ENodeUnion {
|
||||
CInt64 intval;
|
||||
Float floatval;
|
||||
SInt32 longval;
|
||||
ENode *monadic;
|
||||
Object *objref;
|
||||
CLabel *label;
|
||||
MWVector128 vector128val;
|
||||
struct {
|
||||
ENode *left;
|
||||
ENode *right;
|
||||
} diadic;
|
||||
struct {
|
||||
ENode *cond;
|
||||
ENode *expr1;
|
||||
ENode *expr2;
|
||||
} cond;
|
||||
struct {
|
||||
ENode *funcref;
|
||||
ENodeList *args;
|
||||
TypeFunc *functype;
|
||||
} funccall;
|
||||
ObjAccess objaccess;
|
||||
struct {
|
||||
ENode *accessnode;
|
||||
ENode *mfpointer;
|
||||
} mfpointer;
|
||||
struct {
|
||||
ENode *nullcheckexpr;
|
||||
ENode *condexpr;
|
||||
SInt32 precompid;
|
||||
} nullcheck;
|
||||
SInt32 precompid;
|
||||
struct {
|
||||
Type *type;
|
||||
SInt32 uniqueid;
|
||||
Boolean needs_dtor;
|
||||
} temp;
|
||||
struct {
|
||||
SInt32 size;
|
||||
char *data;
|
||||
SInt32 segnum;
|
||||
char ispascal;
|
||||
char ispacked;
|
||||
} string;
|
||||
struct {
|
||||
SInt32 size;
|
||||
char *data;
|
||||
} set;
|
||||
struct {
|
||||
ENode *initexpr;
|
||||
ENode *tryexpr;
|
||||
Object *pointertemp;
|
||||
Object *deletefunc;
|
||||
} newexception;
|
||||
struct {
|
||||
ENode *initexpr;
|
||||
ENode *tryexpr;
|
||||
ENode *catchexpr;
|
||||
ENode *result;
|
||||
} itc;
|
||||
struct {
|
||||
Object *objref;
|
||||
SInt32 offset;
|
||||
} addr;
|
||||
void *inst;
|
||||
MemInitializer *ctorinit;
|
||||
Statement *stmt;
|
||||
struct {
|
||||
union {
|
||||
TemplParamID pid;
|
||||
struct {
|
||||
union {
|
||||
Type *type;
|
||||
ENode *expr;
|
||||
} u;
|
||||
TEFuncSel sel;
|
||||
Boolean is_expr;
|
||||
} typeexpr;
|
||||
struct {
|
||||
ENodeList *args;
|
||||
Type *type;
|
||||
UInt32 qual;
|
||||
} cast;
|
||||
struct {
|
||||
TypeTemplDep *type;
|
||||
HashNameNode *name;
|
||||
} qual;
|
||||
struct {
|
||||
TypeTemplDep *type;
|
||||
HashNameNode *name;
|
||||
TemplArg *args;
|
||||
} qualtempl;
|
||||
ObjAccess objaccess;
|
||||
struct {
|
||||
ENode *expr;
|
||||
TStreamElement *token;
|
||||
} sourceref;
|
||||
ENode *monadic;
|
||||
struct {
|
||||
ENode *expr;
|
||||
ENodeList *args;
|
||||
} funccall;
|
||||
struct {
|
||||
Type *type;
|
||||
UInt32 qual;
|
||||
ENode *arraydim;
|
||||
ENodeList *placement;
|
||||
ENodeList *initlist;
|
||||
Boolean is_global;
|
||||
Boolean has_init;
|
||||
} nw;
|
||||
struct {
|
||||
ENode *expr;
|
||||
Boolean is_global;
|
||||
Boolean is_array;
|
||||
} del;
|
||||
struct {
|
||||
ENode *left;
|
||||
ENode *right;
|
||||
} dyadic;
|
||||
struct {
|
||||
ENode *expr;
|
||||
Type *type;
|
||||
UInt32 qual;
|
||||
} newcast;
|
||||
struct {
|
||||
ENode *expr;
|
||||
DepName *dname;
|
||||
Boolean is_pointer;
|
||||
} member;
|
||||
struct {
|
||||
Object *object;
|
||||
Object *info;
|
||||
} exinit;
|
||||
struct {
|
||||
Object *obj;
|
||||
Initializer *init;
|
||||
} varinit;
|
||||
Object *obj;
|
||||
} u;
|
||||
TemplDepSubType subtype;
|
||||
} templdep;
|
||||
} ENodeUnion;
|
||||
|
||||
struct ENode {
|
||||
ENodeType type;
|
||||
UInt8 cost;
|
||||
UInt16 flags; // &1, &2 correspond to quals
|
||||
Boolean ignored;
|
||||
Boolean hascall;
|
||||
// void *loc; - might not be in pro7?
|
||||
Type *rtype;
|
||||
PointsToFunction *pointsTo;
|
||||
ENodeUnion data;
|
||||
};
|
||||
|
||||
enum {
|
||||
ENODE_FLAG_CONST = Q_CONST,
|
||||
ENODE_FLAG_VOLATILE = Q_VOLATILE,
|
||||
ENODE_FLAG_QUALS = Q_CONST | Q_VOLATILE
|
||||
};
|
||||
|
||||
#ifdef __MWERKS__
|
||||
#pragma options align=reset
|
||||
#endif
|
||||
|
||||
#endif
|
||||
80
includes/compiler/objc.h
Normal file
80
includes/compiler/objc.h
Normal file
@@ -0,0 +1,80 @@
|
||||
#ifndef COMPILER_OBJC_H
|
||||
#define COMPILER_OBJC_H
|
||||
|
||||
#include "compiler/common.h"
|
||||
|
||||
#ifdef __MWERKS__
|
||||
#pragma options align=mac68k
|
||||
#endif
|
||||
|
||||
typedef struct ObjCMethodArg { // bigger in v7 (0x20 vs 0x14)
|
||||
struct ObjCMethodArg *next;
|
||||
HashNameNode *selector;
|
||||
HashNameNode *name;
|
||||
Type *type;
|
||||
UInt32 qual;
|
||||
UInt32 unk14;
|
||||
UInt32 unk18;
|
||||
UInt32 unk1C;
|
||||
} ObjCMethodArg;
|
||||
|
||||
typedef struct ObjCMethodList { // verified via CPrec
|
||||
struct ObjCMethodList *next;
|
||||
struct ObjCMethod *method;
|
||||
} ObjCMethodList;
|
||||
|
||||
typedef struct ObjCSelector { // verified via CPrec
|
||||
struct ObjCSelector *next;
|
||||
Object *selobject;
|
||||
HashNameNode *name;
|
||||
struct ObjCMethodList *methods;
|
||||
} ObjCSelector;
|
||||
|
||||
typedef struct ObjCMethod { // verified via CPrec
|
||||
struct ObjCMethod *next;
|
||||
Object *object;
|
||||
TypeFunc *functype;
|
||||
ObjCSelector *selector;
|
||||
Type *return_type;
|
||||
UInt32 return_qual;
|
||||
ObjCMethodArg *selector_args;
|
||||
Boolean has_valist;
|
||||
Boolean is_class_method;
|
||||
Boolean is_defined;
|
||||
} ObjCMethod;
|
||||
|
||||
typedef struct ObjCProtocol { // verified via CPrec
|
||||
struct ObjCProtocol *next;
|
||||
HashNameNode *name;
|
||||
struct ObjCProtocolList *protocols;
|
||||
ObjCMethod *methods;
|
||||
Object *object;
|
||||
} ObjCProtocol;
|
||||
|
||||
typedef struct ObjCProtocolList { // verified via CPrec
|
||||
struct ObjCProtocolList *next;
|
||||
ObjCProtocol *protocol;
|
||||
} ObjCProtocolList;
|
||||
|
||||
typedef struct ObjCCategory { // verified via CPrec
|
||||
struct ObjCCategory *next;
|
||||
HashNameNode *name;
|
||||
ObjCProtocolList *protocols;
|
||||
ObjCMethod *methods;
|
||||
} ObjCCategory;
|
||||
|
||||
struct ObjCInfo { // verified via CPrec
|
||||
Object *classobject;
|
||||
Object *metaobject;
|
||||
Object *classrefobj;
|
||||
ObjCMethod *methods;
|
||||
ObjCProtocolList *protocols;
|
||||
ObjCCategory *categories;
|
||||
Boolean is_implemented;
|
||||
};
|
||||
|
||||
#ifdef __MWERKS__
|
||||
#pragma options align=reset
|
||||
#endif
|
||||
|
||||
#endif
|
||||
200
includes/compiler/objects.h
Normal file
200
includes/compiler/objects.h
Normal file
@@ -0,0 +1,200 @@
|
||||
#ifndef COMPILER_OBJECTS_H
|
||||
#define COMPILER_OBJECTS_H
|
||||
|
||||
#include "compiler/common.h"
|
||||
|
||||
#ifdef __MWERKS__
|
||||
#pragma options align=mac68k
|
||||
#endif
|
||||
|
||||
typedef enum ObjectType {
|
||||
OT_ENUMCONST,
|
||||
OT_TYPE,
|
||||
OT_TYPETAG,
|
||||
OT_NAMESPACE,
|
||||
OT_MEMBERVAR,
|
||||
OT_OBJECT,
|
||||
OT_ILLEGAL
|
||||
} ObjectType;
|
||||
|
||||
|
||||
struct ObjectList {
|
||||
ObjectList *next;
|
||||
Object *object;
|
||||
};
|
||||
|
||||
|
||||
/// General structure with all shared fields for all kinds of objects
|
||||
struct ObjBase {
|
||||
ObjectType otype;
|
||||
AccessType access;
|
||||
};
|
||||
|
||||
|
||||
/// Type 0 (OT_ENUMCONST)
|
||||
struct ObjEnumConst {
|
||||
ObjectType otype;
|
||||
AccessType access;
|
||||
ObjEnumConst *next;
|
||||
HashNameNode *name;
|
||||
Type *type;
|
||||
CInt64 val;
|
||||
};
|
||||
|
||||
|
||||
/// Type 1 (OT_TYPE)
|
||||
struct ObjType {
|
||||
ObjectType otype;
|
||||
AccessType access;
|
||||
Type *type;
|
||||
void *unk6;
|
||||
};
|
||||
|
||||
|
||||
/// Type 2 (OT_TYPETAG)
|
||||
struct ObjTypeTag {
|
||||
ObjectType otype;
|
||||
AccessType access;
|
||||
Type *type;
|
||||
};
|
||||
|
||||
|
||||
/// Type 3 (OT_NAMESPACE)
|
||||
struct ObjNameSpace {
|
||||
ObjectType otype;
|
||||
AccessType access;
|
||||
NameSpace *nspace;
|
||||
};
|
||||
|
||||
|
||||
/// Type 4 (OT_MEMBERVAR)
|
||||
struct ObjMemberVar {
|
||||
ObjectType otype;
|
||||
AccessType access;
|
||||
Boolean anonunion;
|
||||
Boolean has_path;
|
||||
struct ObjMemberVar *next;
|
||||
HashNameNode *name;
|
||||
Type *type;
|
||||
UInt32 qual;
|
||||
UInt32 offset;
|
||||
};
|
||||
struct ObjMemberVarPath {
|
||||
ObjectType otype;
|
||||
AccessType access;
|
||||
Boolean anonunion;
|
||||
Boolean has_path;
|
||||
struct ObjMemberVar *next;
|
||||
HashNameNode *name;
|
||||
Type *type;
|
||||
UInt32 qual;
|
||||
UInt32 offset;
|
||||
BClassList *path;
|
||||
};
|
||||
|
||||
|
||||
typedef enum DataType {
|
||||
DDATA,
|
||||
DLOCAL,
|
||||
DABSOLUTE,
|
||||
DFUNC,
|
||||
DVFUNC,
|
||||
DINLINEFUNC,
|
||||
DALIAS,
|
||||
DEXPR,
|
||||
DNONLAZYPTR,
|
||||
DLABEL,
|
||||
DUNUSED
|
||||
} DataType;
|
||||
|
||||
/// Type 5 (OT_OBJECT)
|
||||
struct Object {
|
||||
ObjectType otype;
|
||||
AccessType access;
|
||||
DataType datatype;
|
||||
Section section;
|
||||
NameSpace *nspace;
|
||||
HashNameNode *name;
|
||||
Type *type;
|
||||
UInt32 qual;
|
||||
SInt16 sclass;
|
||||
UInt8 flags;
|
||||
ExtendedParam *extParam;
|
||||
Object *toc;
|
||||
void *any;
|
||||
//char reg; // notsure?
|
||||
//VarRecord *varptr; // notsure?
|
||||
// union starts at 0x24 in v7
|
||||
union {
|
||||
struct {
|
||||
union {
|
||||
CInt64 intconst;
|
||||
Float *floatconst;
|
||||
MWVector128 *vector128const;
|
||||
char *string;
|
||||
struct {
|
||||
char *data;
|
||||
SInt32 size;
|
||||
} switchtable;
|
||||
} u;
|
||||
VarInfo *info;
|
||||
HashNameNode *linkname;
|
||||
Boolean islocalstatic;
|
||||
} data;
|
||||
UInt32 address;
|
||||
struct {
|
||||
VarInfo *info;
|
||||
HashNameNode *linkname;
|
||||
Object *over_load;
|
||||
} toc;
|
||||
struct {
|
||||
union {
|
||||
TemplateFunction *templ;
|
||||
CI_FuncData *ifuncdata;
|
||||
SInt32 intrinsicid;
|
||||
} u;
|
||||
DefArgCtorInfo *defargdata;
|
||||
HashNameNode *linkname;
|
||||
TemplFuncInstance *inst;
|
||||
PTFList *ptfList;
|
||||
ObjectList *argList;
|
||||
} func;
|
||||
struct {
|
||||
char *data;
|
||||
SInt32 size;
|
||||
InlineXRef *xrefs;
|
||||
} ifunc;
|
||||
struct {
|
||||
VarInfo *info;
|
||||
SInt32 uid;
|
||||
SInt32 offset;
|
||||
Object *realObj;
|
||||
} var;
|
||||
struct {
|
||||
Object *object;
|
||||
//TypeClass *member;
|
||||
BClassList *member; // ???
|
||||
SInt32 offset;
|
||||
} alias;
|
||||
struct {
|
||||
Object *function;
|
||||
HashNameNode *labelname;
|
||||
} label;
|
||||
ENode *expr;
|
||||
} u;
|
||||
};
|
||||
|
||||
#define OBJ_BASE(obj) ((ObjBase *) (obj))
|
||||
#define OBJ_ENUM_CONST(obj) ((ObjEnumConst *) (obj))
|
||||
#define OBJ_TYPE(obj) ((ObjType *) (obj))
|
||||
#define OBJ_TYPE_TAG(obj) ((ObjTypeTag *) (obj))
|
||||
#define OBJ_NAMESPACE(obj) ((ObjNameSpace *) (obj))
|
||||
#define OBJ_MEMBER_VAR(obj) ((ObjMemberVar *) (obj))
|
||||
#define OBJ_MEMBER_VAR_PATH(obj) ((ObjMemberVarPath *) (obj))
|
||||
#define OBJECT(obj) ((Object *) (obj))
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __MWERKS__
|
||||
#pragma options align=reset
|
||||
#endif
|
||||
53
includes/compiler/scopes.h
Normal file
53
includes/compiler/scopes.h
Normal file
@@ -0,0 +1,53 @@
|
||||
#ifndef COMPILER_SCOPES_H
|
||||
#define COMPILER_SCOPES_H
|
||||
|
||||
#include "compiler/common.h"
|
||||
|
||||
#ifdef __MWERKS__
|
||||
#pragma options align=mac68k
|
||||
#endif
|
||||
|
||||
struct NameSpace {
|
||||
NameSpace *parent;
|
||||
HashNameNode *name;
|
||||
NameSpaceList *usings;
|
||||
TypeClass *theclass;
|
||||
NameSpaceName *tparams;
|
||||
union {
|
||||
NameSpaceName **hash;
|
||||
NameSpaceName *list;
|
||||
} data;
|
||||
UInt32 names;
|
||||
Boolean is_hash;
|
||||
Boolean is_global;
|
||||
Boolean is_unnamed;
|
||||
Boolean is_templ;
|
||||
};
|
||||
|
||||
struct NameSpaceList {
|
||||
NameSpaceList *next;
|
||||
NameSpace *nspace;
|
||||
};
|
||||
|
||||
struct NameSpaceObjectList {
|
||||
NameSpaceObjectList *next;
|
||||
ObjBase *object;
|
||||
};
|
||||
|
||||
struct NameSpaceName {
|
||||
NameSpaceName *next;
|
||||
HashNameNode *name;
|
||||
NameSpaceObjectList first;
|
||||
};
|
||||
|
||||
struct NameSpaceLookupList { // assumed name
|
||||
NameSpaceLookupList *next;
|
||||
NameSpace *nspace;
|
||||
NameSpaceList *namespaces;
|
||||
};
|
||||
|
||||
#ifdef __MWERKS__
|
||||
#pragma options align=reset
|
||||
#endif
|
||||
|
||||
#endif
|
||||
35
includes/compiler/som.h
Normal file
35
includes/compiler/som.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifndef COMPILER_SOM_H
|
||||
#define COMPILER_SOM_H
|
||||
|
||||
#include "compiler/common.h"
|
||||
|
||||
#ifdef __MWERKS__
|
||||
#pragma options align=mac68k
|
||||
#endif
|
||||
|
||||
typedef enum SOMMethodState {
|
||||
SOMMS_Deleted,
|
||||
SOMMS_Method,
|
||||
SOMMS_Migrated
|
||||
} SOMMethodState;
|
||||
|
||||
typedef struct SOMReleaseOrder { // checked via CPrec
|
||||
struct SOMReleaseOrder *next;
|
||||
HashNameNode *name;
|
||||
SOMMethodState state;
|
||||
} SOMReleaseOrder;
|
||||
|
||||
struct SOMInfo { // checked via CPrec
|
||||
TypeClass *metaclass;
|
||||
Object *classdataobject;
|
||||
SOMReleaseOrder *order;
|
||||
UInt32 majorversion;
|
||||
UInt32 minorversion;
|
||||
UInt8 oidl_callstyle;
|
||||
};
|
||||
|
||||
#ifdef __MWERKS__
|
||||
#pragma options align=reset
|
||||
#endif
|
||||
|
||||
#endif
|
||||
237
includes/compiler/templates.h
Normal file
237
includes/compiler/templates.h
Normal file
@@ -0,0 +1,237 @@
|
||||
#ifndef COMPILER_TEMPLATES_H
|
||||
#define COMPILER_TEMPLATES_H
|
||||
|
||||
#include "compiler/common.h"
|
||||
#include "compiler/types.h"
|
||||
#include "compiler/tokens.h"
|
||||
|
||||
#ifdef __MWERKS__
|
||||
#pragma options align=mac68k
|
||||
#endif
|
||||
|
||||
typedef struct PackedDeclInfo { // ok
|
||||
Type *thetype;
|
||||
UInt32 qual;
|
||||
NameSpace *nspace;
|
||||
HashNameNode *name;
|
||||
TemplArg *expltargs;
|
||||
SInt16 storageclass;
|
||||
Section section;
|
||||
UInt8 exportflags;
|
||||
Boolean has_expltargs;
|
||||
} PackedDeclInfo;
|
||||
|
||||
struct Template {
|
||||
Template *parent;
|
||||
TemplInstance *parentinst;
|
||||
TemplParam *params;
|
||||
Boolean is_class;
|
||||
};
|
||||
|
||||
struct TemplateFriend { // verified via CPrec
|
||||
PackedDeclInfo decl;
|
||||
FileOffsetInfo fileoffset;
|
||||
TStream stream;
|
||||
};
|
||||
|
||||
struct TemplateMember { // verified via CPrec
|
||||
struct TemplateMember *next;
|
||||
TemplParam *params;
|
||||
Object *object;
|
||||
FileOffsetInfo fileoffset;
|
||||
TStream stream;
|
||||
CPrepFileInfo *srcfile;
|
||||
SInt32 startoffset;
|
||||
SInt32 endoffset;
|
||||
};
|
||||
|
||||
struct TemplInstance {
|
||||
// Template *templ;
|
||||
TemplInstance *parent;
|
||||
TemplArg *args;
|
||||
Boolean is_instantiated;
|
||||
Boolean is_specialized;
|
||||
Boolean is_extern;
|
||||
Boolean static_instantiated;
|
||||
};
|
||||
/*
|
||||
struct __attribute__((packed)) TemplInstance
|
||||
{
|
||||
Template *templ;
|
||||
TemplInstance *parent;
|
||||
TemplArg *args;
|
||||
unsigned __int8 is_instantiated;
|
||||
unsigned __int8 is_specialized;
|
||||
unsigned __int8 is_extern;
|
||||
unsigned __int8 static_instantiated;
|
||||
};
|
||||
|
||||
*/
|
||||
|
||||
struct TemplParam { // verified via CPrec
|
||||
TemplParam *next;
|
||||
HashNameNode *name;
|
||||
TemplParamID pid;
|
||||
union {
|
||||
struct {
|
||||
Type *type;
|
||||
UInt32 qual;
|
||||
} typeparam;
|
||||
struct {
|
||||
Type *type;
|
||||
UInt32 qual;
|
||||
ENode *defaultarg;
|
||||
} paramdecl;
|
||||
struct {
|
||||
TemplParam *plist;
|
||||
Type *defaultarg;
|
||||
} templparam;
|
||||
} data;
|
||||
};
|
||||
|
||||
struct TemplArg { // verified by CPrec
|
||||
TemplArg *next;
|
||||
TemplParamID pid;
|
||||
union {
|
||||
struct {
|
||||
Type *type;
|
||||
UInt32 qual;
|
||||
} typeparam;
|
||||
struct {
|
||||
ENode *expr;
|
||||
Boolean is_ref;
|
||||
} paramdecl;
|
||||
Type *ttargtype;
|
||||
} data;
|
||||
Boolean is_deduced;
|
||||
};
|
||||
|
||||
struct TemplPartialSpec { // confirmed via CPrec (but templ might be a different type?)
|
||||
TemplPartialSpec *next;
|
||||
TemplClass *templ;
|
||||
TemplArg *args;
|
||||
};
|
||||
|
||||
struct TemplStack {
|
||||
TemplStack *next;
|
||||
union {
|
||||
Object *func;
|
||||
TypeClass *theclass;
|
||||
} u;
|
||||
Boolean is_func;
|
||||
Boolean is_poi;
|
||||
};
|
||||
|
||||
/***********/
|
||||
/* Classes */
|
||||
/***********/
|
||||
|
||||
struct TemplClass {
|
||||
TypeClass theclass;
|
||||
TemplClass *next;
|
||||
TemplClass *templ__parent;
|
||||
Type *x3A_maybe_parentinst;
|
||||
TemplParam *templ__params;
|
||||
TemplateMember *members;
|
||||
TemplClassInst *instances;
|
||||
TemplClass *pspec_owner;
|
||||
TemplPartialSpec *pspecs;
|
||||
TemplateAction *actions;
|
||||
// not confirmed these last 3 fields yet but there is space for them
|
||||
UInt16 lex_order_count;
|
||||
SInt8 align;
|
||||
UInt8 flags;
|
||||
};
|
||||
|
||||
struct TemplClassInst {
|
||||
TypeClass theclass;
|
||||
TemplClassInst *next;
|
||||
Type *x36; // not sure what this represents
|
||||
TemplClass *templ;
|
||||
TemplArg *inst_args;
|
||||
TemplArg *oargs;
|
||||
void *x46;
|
||||
};
|
||||
|
||||
#define TEMPL_CLASS(ty) ( (TemplClass *) (ty) )
|
||||
#define TEMPL_CLASS_INST(ty) ( (TemplClassInst *) (ty) )
|
||||
|
||||
/*************/
|
||||
/* Functions */
|
||||
/*************/
|
||||
|
||||
struct TemplateFunction { // verified via CPrec
|
||||
TemplateFunction *next;
|
||||
TemplateFunction *unk4; // parent?
|
||||
HashNameNode *name;
|
||||
TemplParam *params;
|
||||
TStream stream;
|
||||
TStreamElement deftoken;
|
||||
Object *tfunc;
|
||||
TemplFuncInstance *instances;
|
||||
CPrepFileInfo *srcfile;
|
||||
SInt32 startoffset;
|
||||
SInt32 endoffset;
|
||||
};
|
||||
|
||||
struct TemplFuncInstance { // verified via CPrec
|
||||
TemplFuncInstance *next;
|
||||
Object *object;
|
||||
TemplArg *args;
|
||||
Boolean is_instantiated;
|
||||
Boolean is_specialized;
|
||||
Boolean is_extern;
|
||||
Boolean static_instantiated;
|
||||
};
|
||||
|
||||
/***********/
|
||||
/* Actions */
|
||||
/***********/
|
||||
|
||||
typedef enum TemplateActionType {
|
||||
TAT_NESTEDCLASS,
|
||||
TAT_ENUMTYPE,
|
||||
TAT_FRIEND,
|
||||
TAT_ENUMERATOR, // in pro7 but not pro8
|
||||
TAT_BASE,
|
||||
TAT_OBJECTINIT,
|
||||
TAT_USINGDECL,
|
||||
TAT_OBJECTDEF,
|
||||
TAT_ILLEGAL
|
||||
} TemplateActionType;
|
||||
|
||||
struct TemplateAction { // verified via CPrec
|
||||
TemplateAction *next;
|
||||
TStreamElement source_ref;
|
||||
union {
|
||||
TemplClass *tclasstype;
|
||||
TypeEnum *enumtype;
|
||||
TemplateFriend *tfriend;
|
||||
struct {
|
||||
ObjEnumConst *objenumconst;
|
||||
ENode *initexpr;
|
||||
} enumerator;
|
||||
struct {
|
||||
Type *type;
|
||||
ClassList *insert_after;
|
||||
AccessType access;
|
||||
Boolean is_virtual;
|
||||
} base;
|
||||
struct {
|
||||
Object *object;
|
||||
ENode *initexpr;
|
||||
} objectinit;
|
||||
struct {
|
||||
TypeTemplDep *type;
|
||||
AccessType access;
|
||||
} usingdecl;
|
||||
ObjBase *refobj;
|
||||
} u;
|
||||
TemplateActionType type;
|
||||
};
|
||||
|
||||
#ifdef __MWERKS__
|
||||
#pragma options align=reset
|
||||
#endif
|
||||
|
||||
#endif
|
||||
182
includes/compiler/tokens.h
Normal file
182
includes/compiler/tokens.h
Normal file
@@ -0,0 +1,182 @@
|
||||
#ifndef COMPILER_TOKENS_H
|
||||
#define COMPILER_TOKENS_H
|
||||
|
||||
#include "compiler/common.h"
|
||||
|
||||
#ifdef __MWERKS__
|
||||
#pragma options align=mac68k
|
||||
#endif
|
||||
|
||||
#define TKD_OPERATOR 328
|
||||
#define TKD_TEMPLATE 332
|
||||
#define TKD_IDENTIFIER -3
|
||||
#define TKD_COLON_COLON 372
|
||||
|
||||
typedef enum EToken {
|
||||
TK_INTCONST = -1,
|
||||
TK_FLOATCONST = -2,
|
||||
TK_IDENTIFIER = -3,
|
||||
TK_STRING = -4,
|
||||
TK_STRING_WIDE = -5,
|
||||
TK_NEG6 = -6,
|
||||
TK_NEG7 = -7,
|
||||
TK_AUTO = 256,
|
||||
TK_REGISTER,
|
||||
TK_STATIC,
|
||||
TK_EXTERN,
|
||||
TK_TYPEDEF,
|
||||
TK_INLINE,
|
||||
TK_VOID,
|
||||
TK_CHAR,
|
||||
TK_SHORT,
|
||||
TK_INT,
|
||||
TK_LONG,
|
||||
TK_FLOAT,
|
||||
TK_DOUBLE,
|
||||
TK_SIGNED,
|
||||
TK_UNSIGNED,
|
||||
TK_STRUCT,
|
||||
TK_UNION,
|
||||
TK_ENUM,
|
||||
TK_CLASS,
|
||||
TK_UU_VECTOR = 283,
|
||||
TK_UU_TYPEOF_UU,
|
||||
TK_BOOL,
|
||||
TK_WCHAR_T,
|
||||
TK_U_COMPLEX,
|
||||
TK_U_IMAGINARY,
|
||||
TK_TYPENAME,
|
||||
TK_CONST,
|
||||
TK_VOLATILE,
|
||||
TK_PASCAL,
|
||||
TK_UU_DECLSPEC,
|
||||
TK_UU_STDCALL,
|
||||
TK_UU_CDECL,
|
||||
TK_UU_FASTCALL,
|
||||
TK_UU_FAR,
|
||||
TK_EXPLICIT,
|
||||
TK_MUTABLE,
|
||||
TK_ONEWAY,
|
||||
TK_IN,
|
||||
TK_INOUT,
|
||||
TK_OUT,
|
||||
TK_BYCOPY,
|
||||
TK_BYREF,
|
||||
TK_ASM = 310,
|
||||
TK_CASE,
|
||||
TK_DEFAULT,
|
||||
TK_IF,
|
||||
TK_ELSE,
|
||||
TK_SWITCH,
|
||||
TK_WHILE,
|
||||
TK_DO,
|
||||
TK_FOR,
|
||||
TK_GOTO,
|
||||
TK_CONTINUE,
|
||||
TK_BREAK,
|
||||
TK_RETURN,
|
||||
TK_SIZEOF,
|
||||
TK_CATCH,
|
||||
TK_DELETE,
|
||||
TK_FRIEND,
|
||||
TK_NEW,
|
||||
TK_OPERATOR,
|
||||
TK_PRIVATE,
|
||||
TK_PROTECTED,
|
||||
TK_PUBLIC,
|
||||
TK_TEMPLATE,
|
||||
TK_THIS,
|
||||
TK_THROW,
|
||||
TK_TRY,
|
||||
TK_VIRTUAL,
|
||||
TK_INHERITED,
|
||||
TK_CONST_CAST,
|
||||
TK_DYNAMIC_CAST,
|
||||
TK_NAMESPACE,
|
||||
TK_REINTERPRET_CAST,
|
||||
TK_STATIC_CAST,
|
||||
TK_USING,
|
||||
TK_TRUE,
|
||||
TK_FALSE,
|
||||
TK_TYPEID,
|
||||
TK_EXPORT,
|
||||
TK_MULT_ASSIGN,
|
||||
TK_DIV_ASSIGN,
|
||||
TK_MOD_ASSIGN,
|
||||
TK_ADD_ASSIGN,
|
||||
TK_SUB_ASSIGN,
|
||||
TK_SHL_ASSIGN,
|
||||
TK_SHR_ASSIGN,
|
||||
TK_AND_ASSIGN,
|
||||
TK_XOR_ASSIGN,
|
||||
TK_OR_ASSIGN,
|
||||
TK_LOGICAL_OR,
|
||||
TK_LOGICAL_AND,
|
||||
TK_LOGICAL_EQ,
|
||||
TK_LOGICAL_NE,
|
||||
TK_LESS_EQUAL,
|
||||
TK_GREATER_EQUAL,
|
||||
TK_SHL,
|
||||
TK_SHR,
|
||||
TK_INCREMENT,
|
||||
TK_DECREMENT,
|
||||
TK_ARROW,
|
||||
TK_ELLIPSIS,
|
||||
TK_DOT_STAR,
|
||||
TK_ARROW_STAR,
|
||||
TK_COLON_COLON,
|
||||
TK_AT_INTERFACE,
|
||||
TK_AT_IMPLEMENTATION,
|
||||
TK_AT_PROTOCOL,
|
||||
TK_AT_END,
|
||||
TK_AT_PRIVATE,
|
||||
TK_AT_PROTECTED,
|
||||
TK_AT_PUBLIC,
|
||||
TK_AT_CLASS,
|
||||
TK_AT_SELECTOR,
|
||||
TK_AT_ENCODE,
|
||||
TK_AT_DEFS,
|
||||
TK_SELF,
|
||||
TK_SUPER,
|
||||
TK_UU_ALIGNOF_UU = 388,
|
||||
TK_RESTRICT,
|
||||
TK_UU_ATTRIBUTE_UU,
|
||||
TK_UU_UUIDOF
|
||||
} EToken;
|
||||
|
||||
typedef struct FileOffsetInfo {
|
||||
CPrepFileInfo *file;
|
||||
SInt32 offset;
|
||||
SInt32 tokenoffset;
|
||||
Boolean is_inline;
|
||||
} FileOffsetInfo;
|
||||
|
||||
typedef union TData {
|
||||
HashNameNode *tkidentifier;
|
||||
CInt64 tkintconst;
|
||||
Float tkfloatconst;
|
||||
struct {
|
||||
char *data;
|
||||
SInt32 size;
|
||||
} tkstring;
|
||||
} TData;
|
||||
|
||||
struct TStreamElement {
|
||||
SInt16 tokentype;
|
||||
SInt16 subtype;
|
||||
CPrepFileInfo *tokenfile;
|
||||
SInt32 tokenoffset;
|
||||
SInt32 tokenline;
|
||||
TData data;
|
||||
};
|
||||
|
||||
struct TStream {
|
||||
SInt32 tokens;
|
||||
TStreamElement *firsttoken;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __MWERKS__
|
||||
#pragma options align=reset
|
||||
#endif
|
||||
324
includes/compiler/types.h
Normal file
324
includes/compiler/types.h
Normal file
@@ -0,0 +1,324 @@
|
||||
#ifndef COMPILER_TYPES_H
|
||||
#define COMPILER_TYPES_H
|
||||
|
||||
#include "compiler/common.h"
|
||||
|
||||
#ifdef __MWERKS__
|
||||
#pragma options align=mac68k
|
||||
#endif
|
||||
|
||||
typedef enum TypeType {
|
||||
TYPEVOID = 0,
|
||||
TYPEINT,
|
||||
TYPEFLOAT,
|
||||
TYPEENUM,
|
||||
TYPESTRUCT,
|
||||
TYPECLASS,
|
||||
TYPEFUNC,
|
||||
TYPEBITFIELD,
|
||||
TYPELABEL,
|
||||
TYPETEMPLATE,
|
||||
TYPEMEMBERPOINTER,
|
||||
TYPEPOINTER,
|
||||
TYPEARRAY,
|
||||
TYPEOBJCID,
|
||||
TYPETEMPLDEPEXPR,
|
||||
TYPEILLEGAL = -1
|
||||
} TypeType;
|
||||
|
||||
|
||||
/// Common fields across all kinds of types
|
||||
struct Type {
|
||||
TypeType type;
|
||||
SInt32 size;
|
||||
};
|
||||
|
||||
|
||||
typedef enum IntegralType {
|
||||
IT_BOOL = 0,
|
||||
IT_CHAR = 1,
|
||||
IT_SCHAR = 2,
|
||||
IT_UCHAR = 3,
|
||||
IT_WCHAR_T = 4,
|
||||
IT_SHORT = 5,
|
||||
IT_USHORT = 6,
|
||||
IT_INT = 7,
|
||||
IT_UINT = 8,
|
||||
IT_LONG = 9,
|
||||
IT_ULONG = 10,
|
||||
IT_LONGLONG = 11,
|
||||
IT_ULONGLONG = 12,
|
||||
IT_FLOAT = 13,
|
||||
IT_SHORTDOUBLE = 14,
|
||||
IT_DOUBLE = 15,
|
||||
IT_LONGDOUBLE = 16
|
||||
} IntegralType;
|
||||
|
||||
struct TypeIntegral {
|
||||
TypeType type;
|
||||
SInt32 size;
|
||||
unsigned char integral;
|
||||
};
|
||||
|
||||
|
||||
struct TypeEnum { // checked via CPrec
|
||||
TypeType type;
|
||||
SInt32 size;
|
||||
NameSpace *nspace;
|
||||
ObjEnumConst *enumlist;
|
||||
Type *enumtype;
|
||||
HashNameNode *enumname;
|
||||
};
|
||||
|
||||
|
||||
struct TypeStruct {
|
||||
TypeType type;
|
||||
SInt32 size;
|
||||
HashNameNode *name;
|
||||
StructMember *members;
|
||||
char stype;
|
||||
SInt16 align;
|
||||
};
|
||||
struct StructMember {
|
||||
StructMember *next;
|
||||
Type *type;
|
||||
HashNameNode *name;
|
||||
SInt32 offset;
|
||||
UInt32 qual;
|
||||
};
|
||||
|
||||
enum {
|
||||
STRUCT_TYPE_STRUCT = 0,
|
||||
STRUCT_TYPE_UNION = 1,
|
||||
STRUCT_TYPE_4 = 4,
|
||||
STRUCT_TYPE_5 = 5,
|
||||
STRUCT_TYPE_6 = 6,
|
||||
STRUCT_TYPE_7 = 7,
|
||||
STRUCT_TYPE_8 = 8,
|
||||
STRUCT_TYPE_9 = 9,
|
||||
STRUCT_TYPE_A = 10,
|
||||
STRUCT_TYPE_B = 11,
|
||||
STRUCT_TYPE_C = 12,
|
||||
STRUCT_TYPE_D = 13,
|
||||
STRUCT_TYPE_E = 14
|
||||
};
|
||||
|
||||
|
||||
typedef struct ClassList { // checked via CPrec
|
||||
struct ClassList *next;
|
||||
TypeClass *base;
|
||||
SInt32 offset;
|
||||
SInt32 voffset;
|
||||
AccessType access;
|
||||
Boolean is_virtual;
|
||||
} ClassList;
|
||||
|
||||
typedef struct VClassList { // checked via CPrec
|
||||
struct VClassList *next;
|
||||
TypeClass *base;
|
||||
SInt32 offset;
|
||||
SInt32 voffset;
|
||||
Boolean has_override;
|
||||
char alignsave;
|
||||
} VClassList;
|
||||
|
||||
typedef struct ClassFriend { // checked via CPrec
|
||||
struct ClassFriend *next;
|
||||
union {
|
||||
TypeClass *theclass;
|
||||
Object *obj;
|
||||
} u;
|
||||
Boolean isclass;
|
||||
} ClassFriend;
|
||||
|
||||
struct BClassList { // checked via CPrec
|
||||
struct BClassList *next;
|
||||
Type *type;
|
||||
};
|
||||
|
||||
typedef struct VTable { // checked via CPrec
|
||||
Object *object;
|
||||
TypeClass *owner;
|
||||
SInt32 offset;
|
||||
SInt32 size;
|
||||
} VTable;
|
||||
|
||||
struct TypeClass {
|
||||
TypeType type;
|
||||
SInt32 size;
|
||||
NameSpace *nspace;
|
||||
HashNameNode *classname;
|
||||
ClassList *bases;
|
||||
VClassList *vbases;
|
||||
ObjMemberVar *ivars;
|
||||
ClassFriend *friends;
|
||||
VTable *vtable;
|
||||
SOMInfo *sominfo;
|
||||
ObjCInfo *objcinfo;
|
||||
UInt16 flags;
|
||||
SInt8 mode;
|
||||
SInt8 action;
|
||||
SInt16 align;
|
||||
UInt8 eflags;
|
||||
};
|
||||
|
||||
enum {
|
||||
CLASS_FLAGS_2 = 2,
|
||||
CLASS_FLAGS_20 = 0x20,
|
||||
CLASS_FLAGS_100 = 0x100, // is TemplClass
|
||||
CLASS_FLAGS_800 = 0x800, // is TemplClassInst
|
||||
CLASS_FLAGS_900 = 0x900
|
||||
};
|
||||
|
||||
|
||||
typedef struct ExceptSpecList {
|
||||
struct ExceptSpecList *next;
|
||||
Type *type;
|
||||
UInt32 qual;
|
||||
} ExceptSpecList;
|
||||
|
||||
struct FuncArg { // ok
|
||||
struct FuncArg *next;
|
||||
HashNameNode *name;
|
||||
ENode *dexpr;
|
||||
Type *type;
|
||||
UInt32 qual;
|
||||
SInt16 sclass;
|
||||
Boolean is_array;
|
||||
Boolean has_defdefarg;
|
||||
};
|
||||
|
||||
struct TypeFunc {
|
||||
TypeType type;
|
||||
SInt32 size;
|
||||
FuncArg *args;
|
||||
ExceptSpecList *exspecs;
|
||||
Type *functype;
|
||||
UInt32 qual;
|
||||
UInt32 flags;
|
||||
};
|
||||
enum {
|
||||
FUNC_FLAGS_PASCAL = 1, // on TypeFunc::flags
|
||||
FUNC_FLAGS_METHOD = 0x10,
|
||||
FUNC_FLAGS_40 = 0x40, // func that's like "operator SomeOtherType()"
|
||||
FUNC_FLAGS_1000 = 0x1000,
|
||||
FUNC_FLAGS_2000 = 0x2000,
|
||||
FUNC_FLAGS_100000 = 0x100000,
|
||||
FUNC_FLAGS_900000 = 0x900000
|
||||
};
|
||||
|
||||
// There seems to be a version of this which adds a class pointer at the end
|
||||
struct TypeMethod {
|
||||
TypeType type;
|
||||
SInt32 size;
|
||||
FuncArg *args;
|
||||
ExceptSpecList *exspecs;
|
||||
Type *functype;
|
||||
UInt32 qual;
|
||||
UInt32 flags;
|
||||
TypeClass *theclass;
|
||||
void *x1E;
|
||||
void *x22;
|
||||
Boolean x26;
|
||||
};
|
||||
|
||||
|
||||
struct TypeBitfield {
|
||||
TypeType type;
|
||||
SInt32 size;
|
||||
Type *bitfieldtype;
|
||||
unsigned char unkA;
|
||||
char unkB;
|
||||
};
|
||||
|
||||
|
||||
// Label
|
||||
|
||||
|
||||
typedef enum TypeTemplDepType {
|
||||
TEMPLDEP_ARGUMENT,
|
||||
TEMPLDEP_QUALNAME,
|
||||
TEMPLDEP_TEMPLATE,
|
||||
TEMPLDEP_ARRAY,
|
||||
TEMPLDEP_QUALTEMPL,
|
||||
TEMPLDEP_BITFIELD,
|
||||
TEMPLDEP_VALUEDEP, // not in v7?
|
||||
TEMPLDEP_ENUMVAL, // not in v7?
|
||||
TEMPLDEP_TYPEOF // not in v7?
|
||||
} TypeTemplDepType;
|
||||
|
||||
struct TypeTemplDep {
|
||||
TypeType type;
|
||||
SInt32 size;
|
||||
TypeTemplDepType dtype;
|
||||
union {
|
||||
TemplParamID pid;
|
||||
struct {
|
||||
TypeTemplDep *type;
|
||||
HashNameNode *name;
|
||||
} qual;
|
||||
struct {
|
||||
TemplClass *templ;
|
||||
TemplArg *args;
|
||||
} templ;
|
||||
struct {
|
||||
Type *type;
|
||||
ENode *index;
|
||||
} array;
|
||||
struct {
|
||||
TypeTemplDep *type;
|
||||
TemplArg *args;
|
||||
} qualtempl;
|
||||
struct {
|
||||
Type *type;
|
||||
ENode *size;
|
||||
} bitfield;
|
||||
// the following ones may not be in v7
|
||||
Type *vdep;
|
||||
ENode *tof;
|
||||
struct {
|
||||
TypeEnum *etype;
|
||||
ENode *expr;
|
||||
} enumval;
|
||||
} u;
|
||||
};
|
||||
|
||||
|
||||
struct TypeMemberPointer {
|
||||
TypeType type;
|
||||
SInt32 size;
|
||||
Type *ty1;
|
||||
Type *ty2;
|
||||
UInt32 qual;
|
||||
};
|
||||
|
||||
|
||||
/// Used for TYPEPOINTER and TYPEARRAY
|
||||
struct TypePointer {
|
||||
TypeType type;
|
||||
SInt32 size;
|
||||
Type *target;
|
||||
UInt32 qual;
|
||||
};
|
||||
|
||||
|
||||
// ObjCID
|
||||
|
||||
|
||||
// Not sure if these existed originally, but they'll help
|
||||
#define TYPE_INTEGRAL(ty) ((TypeIntegral *) (ty))
|
||||
#define TYPE_ENUM(ty) ((TypeEnum *) (ty))
|
||||
#define TYPE_STRUCT(ty) ((TypeStruct *) (ty))
|
||||
#define TYPE_CLASS(ty) ((TypeClass *) (ty))
|
||||
#define TYPE_FUNC(ty) ((TypeFunc *) (ty))
|
||||
#define TYPE_METHOD(ty) ((TypeMethod *) (ty))
|
||||
#define TYPE_BITFIELD(ty) ((TypeBitfield *) (ty))
|
||||
#define TYPE_TEMPLATE(ty) ((TypeTemplDep *) (ty))
|
||||
#define TYPE_MEMBER_POINTER(ty) ((TypeMemberPointer *) (ty))
|
||||
#define TYPE_POINTER(ty) ((TypePointer *) (ty))
|
||||
|
||||
#ifdef __MWERKS__
|
||||
#pragma options align=reset
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user