mirror of https://git.wuffs.org/MWCC
a bunch of compiler stuff
This commit is contained in:
parent
685f22a6a0
commit
d0b9848c54
319
CError.c
319
CError.c
|
@ -1,319 +0,0 @@
|
|||
#include "CError.h"
|
||||
#include "CompilerTools.h"
|
||||
|
||||
// TODO MOVE ME
|
||||
extern char *CMangler_GetOperator(StringNode *str);
|
||||
extern jmp_buf errorreturn;
|
||||
extern unsigned char cprep_nomem_exit;
|
||||
extern unsigned char anyerrors;
|
||||
extern unsigned char fatalerrors;
|
||||
extern char string[256];
|
||||
// TODO MOVE ME
|
||||
|
||||
Token *cerror_locktoken;
|
||||
static Token *cerror_token;
|
||||
static short cerror_errorcount;
|
||||
static int cerror_lasterrorline;
|
||||
// cerror_synchdata
|
||||
// cerror_synchoffset
|
||||
int CError_BreakPointcount;
|
||||
|
||||
void CError_Init() {
|
||||
cerror_errorcount = 0;
|
||||
cerror_lasterrorline = -1;
|
||||
cerror_token = 0;
|
||||
cerror_locktoken = 0;
|
||||
}
|
||||
|
||||
void CError_SetErrorToken(Token *token) {
|
||||
if (token && token->x4)
|
||||
cerror_token = token;
|
||||
}
|
||||
|
||||
void CError_SetNullErrorToken() {
|
||||
cerror_token = (Token *) -1;
|
||||
}
|
||||
|
||||
void CError_LockErrorPos(Token *token, Token **saved) {
|
||||
*saved = cerror_locktoken;
|
||||
if (token && token->x4)
|
||||
cerror_locktoken = token;
|
||||
}
|
||||
|
||||
void CError_UnlockErrorPos(Token **saved) {
|
||||
cerror_locktoken = *saved;
|
||||
}
|
||||
|
||||
void CError_ResetErrorSkip() {
|
||||
cerror_lasterrorline = -1;
|
||||
}
|
||||
|
||||
void CError_GetErrorString(char *buf, short code) {
|
||||
// This feels dirty, surely this can't have been the solution...
|
||||
int code_ = code;
|
||||
#line 142
|
||||
CError_ASSERT(code_ >= 100 && code_ < 393);
|
||||
COS_GetString(buf, 10000, (short) (code_ - 99));
|
||||
}
|
||||
|
||||
void CError_BufferInit(CErrorBuffer *eb, char *buf, long bufSize) {
|
||||
eb->start = eb->end = buf;
|
||||
eb->size = eb->remaining = bufSize - 1;
|
||||
}
|
||||
|
||||
void CError_BufferGrow(CErrorBuffer *eb, long amount) {
|
||||
char *newBuf;
|
||||
|
||||
newBuf = lalloc(eb->size + amount);
|
||||
memcpy(newBuf, eb->start, eb->size);
|
||||
eb->start = newBuf;
|
||||
eb->end = newBuf + eb->size - eb->remaining;
|
||||
eb->size += amount;
|
||||
eb->remaining += amount;
|
||||
}
|
||||
|
||||
void CError_BufferAppendChar(CErrorBuffer *eb, char ch) {
|
||||
if (eb) {
|
||||
if (!eb->remaining)
|
||||
CError_BufferGrow(eb, 256);
|
||||
*(eb->end++) = ch;
|
||||
eb->remaining--;
|
||||
}
|
||||
}
|
||||
|
||||
void CError_BufferAppendString(CErrorBuffer *eb, const char *str) {
|
||||
size_t len;
|
||||
|
||||
if (eb) {
|
||||
len = strlen(str);
|
||||
if (eb->remaining < len)
|
||||
CError_BufferGrow(eb, len);
|
||||
memcpy(eb->end, str, len);
|
||||
eb->end += len;
|
||||
eb->remaining -= len;
|
||||
}
|
||||
}
|
||||
|
||||
void CError_BufferTerminate(CErrorBuffer *eb) {
|
||||
if (eb->remaining == 0)
|
||||
CError_BufferGrow(eb, 1);
|
||||
*eb->end = 0;
|
||||
eb->remaining = 0;
|
||||
}
|
||||
|
||||
void CError_BufferAppendQualifier(CErrorBuffer *eb, int quals) {
|
||||
|
||||
}
|
||||
|
||||
void CError_BufferAppendTemplArgExpr(CErrorBuffer *eb, void *targExpr) {
|
||||
|
||||
}
|
||||
|
||||
void CError_BufferAppendTemplArg(CErrorBuffer *eb, void *targ) {
|
||||
|
||||
}
|
||||
|
||||
void CError_BufferAppendTemplArgs(CErrorBuffer *eb, void *targs) {
|
||||
|
||||
}
|
||||
|
||||
void CError_BufferAppendNameSpace(CErrorBuffer *eb, void *ns) {
|
||||
|
||||
}
|
||||
|
||||
void CError_BufferAppendPType(CErrorBuffer *eb, void *ty) {
|
||||
|
||||
}
|
||||
|
||||
void CError_BufferAppendTemplDepType(CErrorBuffer *eb, void *ty) {
|
||||
|
||||
}
|
||||
|
||||
void CError_BufferAppendFuncArgs(CErrorBuffer *eb, void *args, unsigned char flag) {
|
||||
|
||||
}
|
||||
|
||||
void CError_BufferAppendType(CErrorBuffer *eb, void *ty, int quals) {
|
||||
|
||||
}
|
||||
|
||||
char *CError_GetTypeName(void *ty, int quals, unsigned char useGlobalHeap) {
|
||||
CErrorBuffer eb;
|
||||
char buf[256];
|
||||
char *ptr;
|
||||
|
||||
CError_BufferInit(&eb, buf, sizeof(buf));
|
||||
CError_BufferAppendType(&eb, ty, quals);
|
||||
CError_BufferTerminate(&eb);
|
||||
|
||||
if (useGlobalHeap)
|
||||
ptr = galloc(eb.size + 1);
|
||||
else
|
||||
ptr = lalloc(eb.size + 1);
|
||||
|
||||
return strcpy(ptr, eb.start);
|
||||
}
|
||||
|
||||
void CError_AppendUnqualFunctionName(CErrorBuffer *eb, void *unk1, void *unk2, void *unk3) {
|
||||
|
||||
}
|
||||
|
||||
void CError_AppendFunctionName(CErrorBuffer *eb, void *unk1, void *unk2, void *unk3, void *unk4) {
|
||||
|
||||
}
|
||||
|
||||
void CError_AppendObjectName(CErrorBuffer *eb, void *obj) {
|
||||
|
||||
}
|
||||
|
||||
void CError_AppendMethodName(CErrorBuffer *eb, void *obj) {
|
||||
|
||||
}
|
||||
|
||||
char *CError_GetQualifiedName(void *ns, StringNode *name) {
|
||||
CErrorBuffer eb;
|
||||
char buf[256];
|
||||
char *ptr;
|
||||
|
||||
CError_BufferInit(&eb, buf, sizeof(buf));
|
||||
CError_BufferAppendNameSpace(&eb, ns);
|
||||
CError_BufferAppendString(&eb, name->data);
|
||||
CError_BufferTerminate(&eb);
|
||||
|
||||
ptr = lalloc(eb.size + 1);
|
||||
return strcpy(ptr, eb.start);
|
||||
}
|
||||
|
||||
char *CError_GetFunctionName(void *a, void *b, void *c) {
|
||||
CErrorBuffer eb;
|
||||
char buf[256];
|
||||
char *ptr;
|
||||
|
||||
CError_BufferInit(&eb, buf, sizeof(buf));
|
||||
CError_AppendFunctionName(&eb, a, b, 0, c);
|
||||
CError_BufferTerminate(&eb);
|
||||
|
||||
ptr = lalloc(eb.size + 1);
|
||||
return strcpy(ptr, eb.start);
|
||||
}
|
||||
|
||||
char *CError_GetObjectName(void *obj) {
|
||||
CErrorBuffer eb;
|
||||
char buf[256];
|
||||
char *ptr;
|
||||
|
||||
CError_BufferInit(&eb, buf, sizeof(buf));
|
||||
CError_AppendObjectName(&eb, obj);
|
||||
CError_BufferTerminate(&eb);
|
||||
|
||||
ptr = lalloc(eb.size + 1);
|
||||
return strcpy(ptr, eb.start);
|
||||
}
|
||||
|
||||
char *CError_GetNameString(void *obj, StringNode *operatorName) {
|
||||
CErrorBuffer eb;
|
||||
char buf[256];
|
||||
char *ptr;
|
||||
char *opStr;
|
||||
|
||||
CError_ASSERT(operatorName);
|
||||
|
||||
// TODO lolol
|
||||
CError_BufferInit(&eb, buf, sizeof(buf));
|
||||
CError_AppendObjectName(&eb, obj);
|
||||
CError_BufferTerminate(&eb);
|
||||
|
||||
ptr = lalloc(eb.size + 1);
|
||||
return strcpy(ptr, eb.start);
|
||||
}
|
||||
|
||||
void CError_ErrorMessage(int errTable, char *buf, unsigned char flag1, unsigned char flag2) {
|
||||
|
||||
}
|
||||
|
||||
void CError_BufferAppendTemplateStack(CErrorBuffer *eb) {
|
||||
|
||||
}
|
||||
|
||||
void CError_ErrorMessageVA(short code, char *buf, va_list list, unsigned char flag1, unsigned char flag2) {
|
||||
|
||||
}
|
||||
|
||||
void CError_VAErrorMessage(short code, va_list list, unsigned char flag1, unsigned char flag2) {
|
||||
char buf[256];
|
||||
|
||||
CError_GetErrorString(buf, code);
|
||||
CError_ErrorMessageVA(code + 10000, buf, list, flag1, flag2);
|
||||
}
|
||||
|
||||
void CError_Error(short code, ...) {
|
||||
|
||||
}
|
||||
|
||||
void CError_ErrorTerm(short code) {
|
||||
CError_GetErrorString(string, code);
|
||||
CError_ErrorMessage(code + 10000, string, 0, 0);
|
||||
longjmp(errorreturn, 1);
|
||||
}
|
||||
|
||||
void CError_ErrorSkip(short code, ...) {
|
||||
// TODO trychain, tk
|
||||
}
|
||||
|
||||
void CError_ErrorFuncCall(short code, void *aa, void *bb) {
|
||||
|
||||
}
|
||||
|
||||
void CError_OverloadedFunctionError2(void *aa, void *bb, void *cc) {
|
||||
|
||||
}
|
||||
|
||||
void CError_OverloadedFunctionError(void *aa, void *bb) {
|
||||
|
||||
}
|
||||
|
||||
void CError_AbstractClassError() {
|
||||
// TODO CClass
|
||||
}
|
||||
|
||||
void CError_Warning(short code, ...) {
|
||||
// TODO lol
|
||||
}
|
||||
|
||||
void CError_BreakPoint(const char *a, const char *b) {
|
||||
if (!a || !strcmp(a, b))
|
||||
CError_BreakPointcount++;
|
||||
}
|
||||
|
||||
void CError_Internal(char *filename, int line) {
|
||||
char tmp[128];
|
||||
CompilerGetCString(5, tmp);
|
||||
sprintf(string, tmp, filename, line);
|
||||
CError_ErrorMessage(10001, string, 1, 0);
|
||||
longjmp(errorreturn, 1);
|
||||
CError_BreakPoint(0, 0);
|
||||
}
|
||||
|
||||
void CError_ExpressionTooComplex() {
|
||||
CompilerGetCString(6, string);
|
||||
CError_ErrorMessage(10002, string, 1, 0);
|
||||
longjmp(errorreturn, 1);
|
||||
}
|
||||
|
||||
void CError_NoMem() {
|
||||
cprep_nomem_exit = 1;
|
||||
longjmp(errorreturn, 1);
|
||||
}
|
||||
|
||||
void CError_UserBreak() {
|
||||
CompilerGetCString(8, string);
|
||||
longjmp(errorreturn, 1);
|
||||
}
|
||||
|
||||
void CError_CannotOpen() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void CError_QualifierCheck(int quals) {
|
||||
|
||||
}
|
63
CError.h
63
CError.h
|
@ -1,63 +0,0 @@
|
|||
#include "CompilerTools.h"
|
||||
#pragma once
|
||||
|
||||
#define CError_ASSERT(cond) if (!(cond)) { CError_Internal(__FILE__, __LINE__); }
|
||||
#define CError_FAIL(cond) if (cond) { CError_Internal(__FILE__, __LINE__); }
|
||||
|
||||
typedef struct _CErrorBuffer {
|
||||
char *start;
|
||||
char *end;
|
||||
unsigned long size;
|
||||
unsigned long remaining;
|
||||
} CErrorBuffer;
|
||||
|
||||
extern void CError_Init();
|
||||
extern void CError_SetErrorToken(Token *token);
|
||||
extern void CError_SetNullErrorToken();
|
||||
extern void CError_LockErrorPos(Token *token, Token **saved);
|
||||
extern void CError_UnlockErrorPos(Token **saved);
|
||||
extern void CError_ResetErrorSkip();
|
||||
extern void CError_GetErrorString(char *buf, short code);
|
||||
extern void CError_BufferInit(CErrorBuffer *eb, char *buf, long bufSize);
|
||||
extern void CError_BufferGrow(CErrorBuffer *eb, long amount);
|
||||
extern void CError_BufferAppendChar(CErrorBuffer *eb, char ch);
|
||||
extern void CError_BufferAppendString(CErrorBuffer *eb, const char *str);
|
||||
extern void CError_BufferTerminate(CErrorBuffer *eb);
|
||||
// FIX LOTS OF THESE
|
||||
extern void CError_BufferAppendQualifier(CErrorBuffer *eb, int quals);
|
||||
extern void CError_BufferAppendTemplArgExpr(CErrorBuffer *eb, void *targExpr);
|
||||
extern void CError_BufferAppendTemplArg(CErrorBuffer *eb, void *targ);
|
||||
extern void CError_BufferAppendTemplArgs(CErrorBuffer *eb, void *targs);
|
||||
extern void CError_BufferAppendNameSpace(CErrorBuffer *eb, void *ns);
|
||||
extern void CError_BufferAppendPType(CErrorBuffer *eb, void *ty);
|
||||
extern void CError_BufferAppendTemplDepType(CErrorBuffer *eb, void *ty);
|
||||
extern void CError_BufferAppendFuncArgs(CErrorBuffer *eb, void *args, unsigned char flag);
|
||||
extern void CError_BufferAppendType(CErrorBuffer *eb, void *ty, int quals);
|
||||
extern char *CError_GetTypeName(void *ty, int quals, unsigned char useGlobalHeap);
|
||||
extern void CError_AppendUnqualFunctionName(CErrorBuffer *eb, void *unk1, void *unk2, void *unk3);
|
||||
extern void CError_AppendFunctionName(CErrorBuffer *eb, void *unk1, void *unk2, void *unk3, void *unk4);
|
||||
extern void CError_AppendObjectName(CErrorBuffer *eb, void *obj);
|
||||
extern void CError_AppendMethodName(CErrorBuffer *eb, void *obj);
|
||||
extern char *CError_GetQualifiedName(void *ns, StringNode *name);
|
||||
extern char *CError_GetFunctionName(void *a, void *b, void *c);
|
||||
extern char *CError_GetObjectName(void *obj);
|
||||
extern char *CError_GetNameString(void *obj, StringNode *operatorName);
|
||||
extern void CError_ErrorMessage(int errTable, char *buf, unsigned char flag1, unsigned char flag2);
|
||||
extern void CError_BufferAppendTemplateStack(CErrorBuffer *eb);
|
||||
extern void CError_ErrorMessageVA(short code, char *buf, va_list list, unsigned char flag1, unsigned char flag2);
|
||||
extern void CError_VAErrorMessage(short code, va_list list, unsigned char flag1, unsigned char flag2);
|
||||
extern void CError_Error(short code, ...);
|
||||
extern void CError_ErrorTerm(short code);
|
||||
extern void CError_ErrorSkip(short code, ...);
|
||||
extern void CError_ErrorFuncCall(short code, void *aa, void *bb);
|
||||
extern void CError_OverloadedFunctionError2(void *aa, void *bb, void *cc);
|
||||
extern void CError_OverloadedFunctionError(void *aa, void *bb);
|
||||
extern void CError_AbstractClassError();
|
||||
extern void CError_Warning(short 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(int quals);
|
|
@ -74,4 +74,14 @@ add_executable(mwcc
|
|||
unsorted/Arguments.c
|
||||
unsorted/Help.c
|
||||
unsorted/Option.c
|
||||
unsorted/Parameter.c unsorted/TargetOptimizer-ppc-mach.c unsorted/OptimizerHelpers.c compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/TargetWarningHelpers-ppc-cc.c)
|
||||
unsorted/Parameter.c
|
||||
unsorted/TargetOptimizer-ppc-mach.c
|
||||
unsorted/OptimizerHelpers.c
|
||||
compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/TargetWarningHelpers-ppc-cc.c
|
||||
compiler_and_linker/unsorted/CCompiler.c
|
||||
unsorted/CmdLineBuildDate.c
|
||||
compiler_and_linker/FrontEnd/C/CScope.c
|
||||
compiler_and_linker/unsorted/CPrec.c
|
||||
compiler_and_linker/unsorted/CError.c
|
||||
compiler_and_linker/unsorted/CInt64.c
|
||||
compiler_and_linker/unsorted/CMachine.c compiler_and_linker/FrontEnd/C/CPrepTokenizer.c compiler_and_linker/FrontEnd/C/CPrep.c)
|
||||
|
|
1244
CompilerTools.c
1244
CompilerTools.c
File diff suppressed because it is too large
Load Diff
134
CompilerTools.h
134
CompilerTools.h
|
@ -1,134 +0,0 @@
|
|||
#include "includes/mwcc_decomp.h"
|
||||
#pragma once
|
||||
|
||||
extern void CompilerGetPString(short index, unsigned char *str);
|
||||
extern void CompilerGetCString(short index, char *str);
|
||||
extern unsigned char *CTool_CtoPstr(char *input);
|
||||
|
||||
typedef struct _AllocatorBlock {
|
||||
struct _AllocatorBlock *nextBlock;
|
||||
char **handle;
|
||||
long size;
|
||||
long remaining;
|
||||
} AllocatorBlock;
|
||||
|
||||
typedef struct _Allocator {
|
||||
AllocatorBlock *blockList;
|
||||
long paddingSize;
|
||||
AllocatorBlock *lastBlockUsed;
|
||||
void *ptrToFreeArea;
|
||||
long remaining;
|
||||
} Allocator;
|
||||
|
||||
typedef struct _HeapInfo {
|
||||
long _0;
|
||||
long _4;
|
||||
long _8;
|
||||
long xx_C;
|
||||
long _10;
|
||||
long _14;
|
||||
long _18;
|
||||
} HeapInfo;
|
||||
|
||||
typedef struct _StringNode {
|
||||
struct _StringNode *next;
|
||||
long index;
|
||||
short hash;
|
||||
char data[1];
|
||||
} StringNode;
|
||||
|
||||
typedef struct _GList {
|
||||
char **data;
|
||||
long size;
|
||||
long capacity;
|
||||
long expansion;
|
||||
} GList;
|
||||
|
||||
extern long hash_name_id;
|
||||
extern StringNode **name_hash_nodes;
|
||||
extern void (*GListErrorProc)();
|
||||
|
||||
// extern void GListError();
|
||||
extern int InitGList(GList *list, long capacity);
|
||||
extern void FreeGList(GList *list);
|
||||
extern void LockGList(GList *list);
|
||||
extern void UnlockGList(GList *list);
|
||||
extern void ShrinkGList(GList *list);
|
||||
extern void AppendGListData(GList *list, const void *data, long size);
|
||||
extern void AppendGListNoData(GList *list, long size);
|
||||
extern void AppendGListByte(GList *list, char v);
|
||||
extern void AppendGListWord(GList *list, short v);
|
||||
extern void AppendGListTargetEndianWord(GList *list, short v);
|
||||
extern void AppendGListLong(GList *list, long v);
|
||||
extern void AppendGListTargetEndianLong(GList *list, long v);
|
||||
extern void AppendGListID(GList *list, const char *str);
|
||||
extern void AppendGListName(GList *list, const char *str);
|
||||
extern void RemoveGListData(GList *list, long size);
|
||||
extern char GetGListByte(GList *list);
|
||||
extern short GetGListWord(GList *list);
|
||||
extern long GetGListLong(GList *list);
|
||||
extern short GetGListID(GList *list, char *buf);
|
||||
extern void GetGListData(GList *list, char *buf, long size);
|
||||
// extern long hashpjw(const char *str);
|
||||
// extern short PHash(const unsigned char *str);
|
||||
extern short CHash(const char *str);
|
||||
extern StringNode *GetHashNameNode(const char *str);
|
||||
extern StringNode *GetHashNameNodeHash(const char *str, short hash);
|
||||
extern StringNode *GetHashNameNodeHash2(const char *str, short hash);
|
||||
extern StringNode *GetHashNameNodeExport(const char *str);
|
||||
extern long GetHashNameNodeExportID(StringNode *node);
|
||||
extern StringNode *GetHashNameNodeByID(long id);
|
||||
extern void NameHashExportReset();
|
||||
extern void NameHashWriteNameTable(GList *list);
|
||||
extern void NameHashWriteTargetEndianNameTable(GList *list);
|
||||
extern void InitNameHash();
|
||||
|
||||
typedef void (*heaperror_t)();
|
||||
|
||||
extern long CTool_TotalHeapSize();
|
||||
// extern void getheapinfo(HeapInfo *result, Allocator *heap);
|
||||
extern void CTool_GetHeapInfo(HeapInfo *result, unsigned char heapID);
|
||||
// extern void MoreHeapSpace(Allocator *alloc, long size);
|
||||
extern int initheaps(heaperror_t failureCallback);
|
||||
extern int initgheap(heaperror_t failureCallback);
|
||||
extern heaperror_t getheaperror();
|
||||
extern void setheaperror(heaperror_t failureCallback);
|
||||
// extern void relheap(Allocator *alloc);
|
||||
extern void releaseheaps();
|
||||
extern void releasegheap();
|
||||
extern void releaseoheap();
|
||||
extern char *galloc(long size);
|
||||
extern char *lalloc(long size);
|
||||
extern char *aalloc(long size);
|
||||
extern char *oalloc(long size);
|
||||
extern char *balloc(long size);
|
||||
|
||||
extern void locklheap();
|
||||
extern void unlocklheap();
|
||||
extern void freelheap();
|
||||
extern void freeaheap();
|
||||
extern void freeoheap();
|
||||
extern void freebheap();
|
||||
|
||||
extern char *ScanHex(char *str, long *output, Boolean *overflow);
|
||||
extern char *ScanOct(char *str, long *output, Boolean *overflow);
|
||||
extern char *ScanDec(char *str, long *output, Boolean *overflow);
|
||||
|
||||
// extern char *UnmangleClassname(char *work, char **pNameStart, short *pNameLength, char **a4, short *a5, Boolean a6);
|
||||
// extern char *UnmangleAppend(char *src, char srcLen, char **pOutput, short *pOutputLen);
|
||||
extern void OldUnmangle(char *input, char *output, Boolean flag);
|
||||
|
||||
extern short hash(char *str);
|
||||
extern void memclr(void *buffer, long size);
|
||||
extern void memclrw(void *buffer, long size);
|
||||
extern void CToLowercase(char *src, char *dst);
|
||||
extern int getbit(long v);
|
||||
typedef struct {
|
||||
unsigned long a, b;
|
||||
} WtfWord64; // this has to make sense, somehow... but how?
|
||||
extern void CTool_EndianConvertWord64(WtfWord64 value, unsigned long long *p);
|
||||
extern unsigned short CTool_EndianConvertInPlaceWord16Ptr(unsigned short *p);
|
||||
extern unsigned long CTool_EndianConvertInPlaceWord32Ptr(unsigned long *p);
|
||||
extern void CTool_EndianConvertVector128(); // not correct but idc
|
||||
extern StringNode *CTool_GetPathName(const FSSpec *spec, long *mdDat);
|
||||
extern Boolean strcat_safe(char *dst, const char *src, int maxLen);
|
|
@ -0,0 +1,921 @@
|
|||
#include "compiler.h"
|
||||
#include "compiler/CError.h"
|
||||
#include "compiler/tokens.h"
|
||||
#include "cos.h"
|
||||
|
||||
extern SInt16 *CLT_filesp;
|
||||
extern CPrepFileInfo **CLT_filestack;
|
||||
|
||||
//#define OPT_OFFSET(optname) ((short) (((char *) (&copts.optname)) - ((char *) &copts)))
|
||||
#define OPT_OFFSET(optname) ((short) ( &((COpts *)0)->optname ))
|
||||
enum {
|
||||
OPT_FLAG_2000 = 0x2000,
|
||||
OPT_FLAG_4000 = 0x4000
|
||||
};
|
||||
|
||||
struct {
|
||||
char *name;
|
||||
short bits;
|
||||
} compileroptions[138] = {
|
||||
"little_endian", OPT_FLAG_4000 | OPT_OFFSET(little_endian),
|
||||
"longlong", OPT_OFFSET(longlong),
|
||||
"traceback", OPT_OFFSET(traceback),
|
||||
"disable_registers", OPT_OFFSET(disable_registers),
|
||||
"fp_contract", OPT_OFFSET(fp_contract),
|
||||
"no_common", OPT_OFFSET(no_common),
|
||||
"no_implicit_templates", OPT_OFFSET(no_implicit_templates),
|
||||
"absolutepath", OPT_OFFSET(absolutepath),
|
||||
"debug_listing", OPT_OFFSET(debuglisting),
|
||||
"profile", OPT_OFFSET(profile),
|
||||
"optimizewithasm", OPT_OFFSET(optimizewithasm),
|
||||
"use_lmw_stmw", OPT_OFFSET(use_lmw_stmw),
|
||||
"no_register_save_helpers", OPT_OFFSET(no_register_save_helpers),
|
||||
"ppc_opt_bclr_bcctr", OPT_OFFSET(ppc_opt_bclr_bcctr),
|
||||
"misaligned_mem_access", OPT_OFFSET(misaligned_mem_access),
|
||||
"switch_tables", OPT_OFFSET(switch_tables),
|
||||
"prepare_compress", OPT_OFFSET(prepare_compress),
|
||||
"asmsemicolcomment", OPT_OFFSET(asmsemicolcomment),
|
||||
"asmpoundcomment", OPT_OFFSET(asmpoundcomment),
|
||||
"cplusplus", OPT_OFFSET(cplusplus),
|
||||
"ecplusplus", OPT_OFFSET(ecplusplus),
|
||||
"objective_c", OPT_OFFSET(objective_c),
|
||||
"objc_strict", OPT_OFFSET(objc_strict),
|
||||
"ARM_conform", OPT_OFFSET(ARM_conform),
|
||||
"ARM_scoping", OPT_OFFSET(ARM_scoping),
|
||||
"require_prototypes", OPT_OFFSET(require_prototypes),
|
||||
"trigraphs", OPT_OFFSET(trigraphs),
|
||||
"only_std_keywords", OPT_OFFSET(only_std_keywords),
|
||||
"enumsalwaysint", OPT_OFFSET(enumsalwaysint),
|
||||
"ANSI_strict", OPT_OFFSET(ANSI_strict),
|
||||
"mpwc_relax", OPT_OFFSET(mpwc_relax),
|
||||
"mpwc_newline", OPT_OFFSET(mpwc_newline),
|
||||
"ignore_oldstyle", OPT_OFFSET(ignore_oldstyle),
|
||||
"cpp_extensions", OPT_OFFSET(cpp_extensions),
|
||||
"pointercast_lvalue", OPT_OFFSET(pointercast_lvalue),
|
||||
"RTTI", OPT_OFFSET(useRTTI),
|
||||
"delete_exception", OPT_OFFSET(delete_exception),
|
||||
"oldalignment", OPT_OFFSET(oldalignment),
|
||||
"multibyteaware", OPT_OFFSET(multibyteaware),
|
||||
"unsigned_char", OPT_OFFSET(unsignedchars),
|
||||
"auto_inline", OPT_OFFSET(autoinline),
|
||||
"inline_bottom_up", OPT_OFFSET(inline_bottom_up),
|
||||
"defer_codegen", OPT_OFFSET(defer_codegen),
|
||||
"direct_to_som", OPT_OFFSET(direct_to_som),
|
||||
"SOMCheckEnvironment", OPT_OFFSET(som_env_check),
|
||||
"SOMCallOptimization", OPT_OFFSET(som_call_opt),
|
||||
"bool", OPT_OFFSET(booltruefalse),
|
||||
"old_enum_mangler", OPT_OFFSET(old_enum_mangler),
|
||||
"longlong_enums", OPT_OFFSET(longlong_enums),
|
||||
"no_tfuncinline", OPT_OFFSET(no_tfuncinline),
|
||||
"flat_include", OPT_OFFSET(flat_include),
|
||||
"syspath_once", OPT_OFFSET(syspath_once),
|
||||
"always_import", OPT_OFFSET(always_import),
|
||||
"simple_class_byval", OPT_OFFSET(simple_class_byval),
|
||||
"wchar_type", OPT_OFFSET(wchar_type),
|
||||
"vbase_ctor_offset", OPT_OFFSET(vbase_ctor_offset),
|
||||
"vbase_abi_v2", OPT_OFFSET(vbase_abi_v2),
|
||||
"def_inherited", OPT_OFFSET(def_inherited),
|
||||
"template_patch", OPT_OFFSET(template_patch),
|
||||
"template_friends", OPT_OFFSET(template_friends),
|
||||
"faster_pch_gen", OPT_OFFSET(faster_pch_gen),
|
||||
"array_new_delete", OPT_OFFSET(array_new_delete),
|
||||
"dollar_identifiers", OPT_OFFSET(dollar_identifiers),
|
||||
"def_inline_tfuncs", OPT_OFFSET(def_inline_tfuncs),
|
||||
"arg_dep_lookup", OPT_OFFSET(arg_dep_lookup),
|
||||
"simple_prepdump", OPT_OFFSET(simple_prepdump),
|
||||
"line_prepdump", OPT_OFFSET(line_prepdump),
|
||||
"fullpath_prepdump", OPT_OFFSET(fullpath_prepdump),
|
||||
"old_mtemplparser", OPT_OFFSET(old_mtemplparser),
|
||||
"suppress_init_code", OPT_OFFSET(suppress_init_code),
|
||||
"reverse_bitfields", OPT_OFFSET(reverse_bitfields),
|
||||
"c9x", OPT_OFFSET(c9x),
|
||||
"float_constants", OPT_OFFSET(float_constants),
|
||||
"no_static_dtors", OPT_OFFSET(no_static_dtors),
|
||||
"longlong_prepeval", OPT_OFFSET(longlong_prepeval),
|
||||
"const_strings", OPT_OFFSET(const_strings),
|
||||
"dumpir", OPT_OFFSET(dumpir),
|
||||
"experimental", OPT_OFFSET(experimental),
|
||||
"gcc_extensions", OPT_OFFSET(gcc_extensions),
|
||||
"stdc_fp_contract", OPT_OFFSET(stdc_fp_contract),
|
||||
"stdc_fenv_access", OPT_OFFSET(stdc_fenv_access),
|
||||
"stdc_cx_limitedr", OPT_OFFSET(stdc_cx_limitedr),
|
||||
"old_argmatch", OPT_OFFSET(old_argmatch),
|
||||
"optEH", OPT_OFFSET(optEH),
|
||||
"optEH2", OPT_OFFSET(optEH2),
|
||||
"new_mangler", OPT_OFFSET(new_mangler),
|
||||
"microsoft_exceptions", OPT_OFFSET(microsoft),
|
||||
"microsoft_RTTI", OPT_OFFSET(microsoft),
|
||||
"warning_errors", OPT_OFFSET(warningerrors),
|
||||
"extended_errorcheck", OPT_OFFSET(pedantic),
|
||||
"check_header_flags", OPT_OFFSET(check_header_flags),
|
||||
"supress_warnings", OPT_OFFSET(supress_warnings),
|
||||
"warn_illpragma", OPT_OFFSET(warn_illpragma),
|
||||
"warn_emptydecl", OPT_OFFSET(warn_emptydecl),
|
||||
"warn_possunwant", OPT_OFFSET(warn_possunwant),
|
||||
"warn_unusedvar", OPT_OFFSET(warn_unusedvar),
|
||||
"warn_unusedarg", OPT_OFFSET(warn_unusedarg),
|
||||
"warn_extracomma", OPT_OFFSET(warn_extracomma),
|
||||
"warn_hidevirtual", OPT_OFFSET(warn_hidevirtual),
|
||||
"warn_largeargs", OPT_OFFSET(warn_largeargs),
|
||||
"warn_implicitconv", OPT_OFFSET(warn_implicitconv),
|
||||
"warn_notinlined", OPT_OFFSET(warn_notinlined),
|
||||
"warn_structclass", OPT_OFFSET(warn_structclass),
|
||||
"warn_padding", OPT_OFFSET(warn_padding),
|
||||
"warn_no_side_effect", OPT_OFFSET(warn_no_side_effect),
|
||||
"warn_resultnotused", OPT_OFFSET(warn_resultnotused),
|
||||
"warn_ptr_int_conv", OPT_OFFSET(warn_ptr_int_conv),
|
||||
"align_array_members", OPT_OFFSET(align_array_members),
|
||||
"dont_reuse_strings", OPT_OFFSET(dont_reuse_strings),
|
||||
"pool_strings", OPT_OFFSET(pool_strings),
|
||||
"explicit_zero_data", OPT_OFFSET(explicit_zero_data),
|
||||
"readonly_strings", OPT_OFFSET(readonly_strings),
|
||||
"opt_common_subs", OPT_OFFSET(opt_common_subs),
|
||||
"opt_loop_invariants", OPT_OFFSET(opt_loop_invariants),
|
||||
"opt_propagation", OPT_OFFSET(opt_propagation),
|
||||
"opt_unroll_loops", OPT_OFFSET(opt_unroll_loops),
|
||||
"opt_lifetimes", OPT_OFFSET(opt_lifetimes),
|
||||
"opt_strength_reduction", OPT_OFFSET(opt_strength_reduction),
|
||||
"opt_strength_reduction_strict", OPT_OFFSET(opt_strength_reduction_strict),
|
||||
"opt_dead_code", OPT_OFFSET(opt_dead_code),
|
||||
"opt_dead_assignments", OPT_OFFSET(opt_dead_assignments),
|
||||
"opt_vectorize_loops", OPT_OFFSET(opt_vectorize_loops),
|
||||
"opt_pointer_analysis", OPT_OFFSET(opt_pointer_analysis),
|
||||
"exceptions", OPT_OFFSET(exceptions),
|
||||
"dont_inline", OPT_OFFSET(dont_inline),
|
||||
"always_inline", OPT_OFFSET(always_inline),
|
||||
"optimize_for_size", OPT_OFFSET(optimize_for_size),
|
||||
"peephole", OPT_OFFSET(peephole),
|
||||
"global_optimizer", OPT_OFFSET(global_optimizer),
|
||||
"side_effects", OPT_OFFSET(side_effects),
|
||||
"internal", OPT_FLAG_2000 | OPT_OFFSET(internal),
|
||||
"import", OPT_FLAG_2000 | OPT_OFFSET(import),
|
||||
"export", OPT_FLAG_2000 | OPT_OFFSET(export),
|
||||
"lib_export", OPT_FLAG_2000 | OPT_OFFSET(lib_export),
|
||||
"nosyminline", OPT_OFFSET(nosyminline),
|
||||
"force_active", OPT_OFFSET(force_active),
|
||||
"sym", OPT_OFFSET(isGeneratingDebugInfo),
|
||||
NULL, 0
|
||||
};
|
||||
|
||||
CParams *cparamblkptr;
|
||||
short tk;
|
||||
CInt64 tkintconst;
|
||||
Float tkfloatconst;
|
||||
char *tkstring;
|
||||
HashNameNode *tkidentifier;
|
||||
SInt32 tksize;
|
||||
short ispascalstring;
|
||||
short nlflag;
|
||||
SInt32 lines;
|
||||
Boolean spaceskip;
|
||||
Macro **macrohashtable;
|
||||
Boolean cprep_nomem_exit;
|
||||
Boolean cprep_nostring;
|
||||
Boolean cprep_eoltokens;
|
||||
static void *ifstack[100]; // TODO type+size
|
||||
static short iflevel;
|
||||
TokenStack tokenstack[128];
|
||||
short tokenstacklevel;
|
||||
SInt32 cprep_cursymfile; // might be a ptr?
|
||||
char *pos;
|
||||
char *macropos;
|
||||
char *nextcharpos;
|
||||
char CPrep_SkipNewCommentChar;
|
||||
Boolean preprocessing_only;
|
||||
Handle stringmem;
|
||||
SInt32 maxstringsize;
|
||||
char cprep_idarray[256];
|
||||
Boolean was_escchar;
|
||||
Boolean macrocheck;
|
||||
Boolean widestring;
|
||||
Boolean at_linestart;
|
||||
char *prep_file_start;
|
||||
char *prep_file_end;
|
||||
char *macrostart;
|
||||
Boolean cprep_strconcat;
|
||||
CPrepFileInfo *prep_file;
|
||||
short filesp;
|
||||
SInt32 linenumber;
|
||||
static CPrepFileInfo *filestack[32];
|
||||
static void *cprep_files; // TODO type
|
||||
static SInt32 linetick;
|
||||
static Boolean waslockedmacro;
|
||||
static Boolean include_once;
|
||||
static time_t now_time;
|
||||
static SInt32 lineoffset;
|
||||
static Boolean was_prep_error;
|
||||
static Boolean cprep_hasprepline;
|
||||
static Boolean cprep_incondexpr;
|
||||
static void *cprep_packstack[100]; // TODO type+size
|
||||
static short cprep_packstackp;
|
||||
static Macro lineM;
|
||||
static Macro fileM;
|
||||
static Macro dateM;
|
||||
static Macro timeM;
|
||||
static Macro stdcM;
|
||||
static Macro stcvM;
|
||||
static Macro stchM;
|
||||
static Macro casmM;
|
||||
static Macro cpplM;
|
||||
static Macro MWRSM;
|
||||
static Macro dtsomM;
|
||||
static Macro ecppM;
|
||||
static Macro optiM;
|
||||
static Macro trgtM;
|
||||
GList pplist;
|
||||
struct COptsPush {
|
||||
struct COptsPush *next;
|
||||
COpts opts;
|
||||
};
|
||||
static struct COptsPush *coptpushs;
|
||||
static void *coptpush; // TODO type
|
||||
static void *coptssave; // TODO type
|
||||
static Boolean dofreeaheap;
|
||||
static GList mlist;
|
||||
static Handle ts_buffer;
|
||||
static TStreamElement *ts_first;
|
||||
static TStreamElement *ts_last;
|
||||
TStreamElement *ts_current;
|
||||
static SInt32 ts_elements;
|
||||
SInt32 ts_preread_elements;
|
||||
static SInt32 gDirectiveStart;
|
||||
static SInt32 high_mem_mark;
|
||||
// static TStreamElement dummyelement; // in CPrep_CurStreamElement
|
||||
static short exprtk;
|
||||
|
||||
static void cannotopenerror(StringPtr filename, Boolean err) {
|
||||
static char fname[64];
|
||||
|
||||
short len = filename[0];
|
||||
if (len > 63)
|
||||
len = 63;
|
||||
memcpy(fname, filename + 1, len);
|
||||
fname[len] = 0;
|
||||
|
||||
CError_ResetErrorSkip();
|
||||
|
||||
if (prep_file) {
|
||||
was_prep_error = 1;
|
||||
CError_Error(151, fname);
|
||||
if (err)
|
||||
longjmp(errorreturn, 1);
|
||||
} else {
|
||||
CError_CannotOpen();
|
||||
}
|
||||
}
|
||||
|
||||
static void insertmacro(Macro *macro) {
|
||||
macro->next = macrohashtable[macro->name->hashval];
|
||||
macrohashtable[macro->name->hashval] = macro;
|
||||
macro->xF = 0;
|
||||
}
|
||||
|
||||
void CPrep_InsertSpecialMacro(Macro *macro, char *name) {
|
||||
macro->name = GetHashNameNodeExport(name);
|
||||
macro->is_special = 1;
|
||||
insertmacro(macro);
|
||||
}
|
||||
|
||||
void CPrep_InsertSpecialMacros() {
|
||||
CPrep_InsertSpecialMacro(&lineM, "__LINE__");
|
||||
CPrep_InsertSpecialMacro(&fileM, "__FILE__");
|
||||
CPrep_InsertSpecialMacro(&dateM, "__DATE__");
|
||||
CPrep_InsertSpecialMacro(&timeM, "__TIME__");
|
||||
CPrep_InsertSpecialMacro(&stdcM, "__STDC__");
|
||||
CPrep_InsertSpecialMacro(&stcvM, "__STDC_VERSION__");
|
||||
CPrep_InsertSpecialMacro(&stchM, "__STDC_HOSTED__");
|
||||
CPrep_InsertSpecialMacro(&casmM, "__CASM__");
|
||||
CPrep_InsertSpecialMacro(&cpplM, "__cplusplus");
|
||||
CPrep_InsertSpecialMacro(&MWRSM, "__MWERKS__");
|
||||
CPrep_InsertSpecialMacro(&dtsomM, "__SOM_ENABLED__");
|
||||
CPrep_InsertSpecialMacro(&ecppM, "__embedded_cplusplus");
|
||||
CPrep_InsertSpecialMacro(&optiM, "__option");
|
||||
CPrep_InsertSpecialMacro(&trgtM, "__ide_target");
|
||||
CodeGen_InsertSpecialMacros();
|
||||
}
|
||||
|
||||
void CPrep_RemoveSpecialMacros() {
|
||||
Macro **scan;
|
||||
int x;
|
||||
|
||||
for (x = 0; x < 2048; x++) {
|
||||
scan = ¯ohashtable[x];
|
||||
while (*scan) {
|
||||
if ((*scan)->is_special) {
|
||||
*scan = (*scan)->next;
|
||||
} else {
|
||||
scan = &(*scan)->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void CPrep_Reconfig() {
|
||||
cprep_idarray['$'] = copts.dollar_identifiers != 0;
|
||||
}
|
||||
|
||||
Boolean setupprep() {
|
||||
int x;
|
||||
|
||||
now_time = time(NULL);
|
||||
lineoffset = 0;
|
||||
include_once = 0;
|
||||
cprep_eoltokens = 0;
|
||||
cprep_nostring = 0;
|
||||
cprep_incondexpr = 0;
|
||||
filesp = -1;
|
||||
linetick = 0;
|
||||
lines = 0;
|
||||
dofreeaheap = 1;
|
||||
macrocheck = 1;
|
||||
maxstringsize = 256;
|
||||
iflevel = 0;
|
||||
tokenstacklevel = 0;
|
||||
cprep_cursymfile = 0;
|
||||
cprep_files = 0;
|
||||
CLT_filesp = &filesp;
|
||||
CLT_filestack = filestack;
|
||||
anyerrors = 0;
|
||||
fatalerrors = 0;
|
||||
was_prep_error = 0;
|
||||
cprep_strconcat = 0;
|
||||
|
||||
GListErrorProc = CError_NoMem;
|
||||
mlist.data = NULL;
|
||||
pplist.data = NULL;
|
||||
if (InitGList(&mlist, 10000))
|
||||
CError_NoMem();
|
||||
|
||||
stringmem = COS_NewHandle(256);
|
||||
if (!stringmem)
|
||||
CError_NoMem();
|
||||
ts_buffer = COS_NewHandle(1024 * sizeof(TStreamElement));
|
||||
if (!ts_buffer)
|
||||
CError_NoMem();
|
||||
COS_LockHandleHi(ts_buffer);
|
||||
ts_first = (TStreamElement *) *ts_buffer;
|
||||
ts_last = ts_first + 1023;
|
||||
ts_current = ts_first;
|
||||
ts_elements = 1024;
|
||||
ts_preread_elements = 0;
|
||||
|
||||
macrohashtable = galloc(sizeof(Macro *) * 2048);
|
||||
memclrw(macrohashtable, sizeof(Macro *) * 2048);
|
||||
CPrep_InsertSpecialMacros();
|
||||
|
||||
for (x = 0; x < 256; x++)
|
||||
cprep_idarray[x] = 0;
|
||||
|
||||
for (x = 'a'; ; x++) {
|
||||
cprep_idarray[x] = 1;
|
||||
if (x == 'z') break;
|
||||
}
|
||||
|
||||
for (x = 'A'; ; x++) {
|
||||
cprep_idarray[x] = 1;
|
||||
if (x == 'Z') break;
|
||||
}
|
||||
|
||||
for (x = '0'; ; x++) {
|
||||
cprep_idarray[x] = 2;
|
||||
if (x == '9') break;
|
||||
}
|
||||
|
||||
cprep_idarray['_'] = 1;
|
||||
|
||||
CPrep_Reconfig();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void cleanupprep() {
|
||||
while (filesp >= 0)
|
||||
popfile();
|
||||
|
||||
high_mem_mark = CTool_TotalHeapSize();
|
||||
releaseheaps();
|
||||
GListErrorProc = NULL;
|
||||
FreeGList(&mlist);
|
||||
FreeGList(&pplist);
|
||||
|
||||
if (stringmem) {
|
||||
COS_FreeHandle(stringmem);
|
||||
stringmem = NULL;
|
||||
}
|
||||
|
||||
if (ts_buffer) {
|
||||
COS_FreeHandle(ts_buffer);
|
||||
ts_buffer = NULL;
|
||||
}
|
||||
ts_current = NULL;
|
||||
ts_first = ts_last = NULL;
|
||||
}
|
||||
|
||||
static char *getfiledata(FSSpec *spec) {
|
||||
const char *text;
|
||||
SInt32 textlength;
|
||||
short filedatatype;
|
||||
|
||||
if (CWGetFileText(cparamblkptr->context, spec, &text, &textlength, &filedatatype) != cwNoErr) {
|
||||
Str255 filename;
|
||||
COS_FileGetFSSpecInfo(spec, NULL, NULL, filename);
|
||||
cannotopenerror(filename, 1);
|
||||
return NULL;
|
||||
} else {
|
||||
return (char *) text;
|
||||
}
|
||||
}
|
||||
|
||||
static Boolean setupfile(StringPtr filename, Boolean flag1, Boolean flag2) {
|
||||
CPrepFileInfo prepinfo;
|
||||
CWFileInfo fileinfo;
|
||||
Str255 file_filename;
|
||||
char myfilename[256];
|
||||
OSType file_type;
|
||||
SInt32 file_size;
|
||||
SInt32 file_dirid;
|
||||
CWMemHandle cache_hnd;
|
||||
void *cache;
|
||||
SInt16 refnum;
|
||||
SInt16 file_vrefnum;
|
||||
char *extpos;
|
||||
|
||||
if (filesp >= 31) {
|
||||
was_prep_error = 1;
|
||||
CError_ErrorTerm(243);
|
||||
return 0;
|
||||
}
|
||||
|
||||
memclrw(&prepinfo, sizeof(CPrepFileInfo));
|
||||
prepinfo.unkfield126 = !flag1; // may be wrong field!
|
||||
if (filename) {
|
||||
memclrw(&fileinfo, sizeof(CWFileInfo));
|
||||
fileinfo.fullsearch = flag2;
|
||||
fileinfo.dependencyType = cwNormalDependency;
|
||||
fileinfo.isdependentoffile = -1;
|
||||
memcpy(myfilename, &filename[1], filename[0]);
|
||||
myfilename[filename[0]] = 0;
|
||||
|
||||
if (CWFindAndLoadFile(cparamblkptr->context, myfilename, &fileinfo) != cwNoErr) {
|
||||
if (filename[0] + strlen(".framework/Headers") < 255) {
|
||||
if ((extpos = strchr(myfilename, '/'))) {
|
||||
// Do Me! 37D8C
|
||||
} else {
|
||||
cannotopenerror(filename, 0);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
cannotopenerror(filename, 0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ((flag2 || include_once) && fileinfo.alreadyincluded)
|
||||
return 1;
|
||||
|
||||
prepinfo.textfile = fileinfo.filespec;
|
||||
prepinfo.nameNode = CTool_GetPathName(&fileinfo.filespec, &prepinfo.fileModDate);
|
||||
if (fileinfo.filedata) {
|
||||
if (fileinfo.filedatatype == cwFileTypeText) {
|
||||
prepinfo.textbuffer = (char *) fileinfo.filedata;
|
||||
prepinfo.textlength = fileinfo.filedatalength;
|
||||
prepinfo.fileID = fileinfo.fileID;
|
||||
prepinfo.recordbrowseinfo = fileinfo.recordbrowseinfo;
|
||||
} else if (fileinfo.filedatatype == cwFileTypePrecompiledHeader) {
|
||||
PrecompilerRead(0, (void *) fileinfo.filedata);
|
||||
return 1;
|
||||
} else {
|
||||
cannotopenerror(filename, 0);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
COS_FileGetFSSpecInfo(&prepinfo.textfile, &file_vrefnum, &file_dirid, file_filename);
|
||||
if (COS_FileOpen(&prepinfo.textfile, &refnum)) {
|
||||
cannotopenerror(filename, 0);
|
||||
return 0;
|
||||
}
|
||||
if (COS_FileGetType(&prepinfo.textfile, &file_type) || COS_FileGetSize(refnum, &file_size)) {
|
||||
COS_FileClose(refnum);
|
||||
cannotopenerror(filename, 0);
|
||||
return 0;
|
||||
}
|
||||
if (file_type == copts.pchType) {
|
||||
if (cparamblkptr->isCachingPrecompiledHeaders) {
|
||||
if (CWAllocMemHandle(cparamblkptr->context, file_size, 1, &cache_hnd) != cwNoErr) {
|
||||
if (CWAllocMemHandle(cparamblkptr->context, file_size, 0, &cache_hnd) != cwNoErr) {
|
||||
COS_FileClose(refnum);
|
||||
CError_NoMem();
|
||||
}
|
||||
}
|
||||
|
||||
CWLockMemHandle(cparamblkptr->context, cache_hnd, 0, &cache);
|
||||
if (COS_FileRead(refnum, cache, file_size)) {
|
||||
COS_FileClose(refnum);
|
||||
CWFreeMemHandle(cparamblkptr->context, cache_hnd);
|
||||
cannotopenerror(filename, 0);
|
||||
return 0;
|
||||
}
|
||||
COS_FileClose(refnum);
|
||||
CWCachePrecompiledHeader(cparamblkptr->context, &prepinfo.textfile, cache_hnd);
|
||||
PrecompilerRead(0, cache);
|
||||
CWUnlockMemHandle(cparamblkptr->context, cache_hnd);
|
||||
return 1;
|
||||
} else {
|
||||
PrecompilerRead(refnum, 0);
|
||||
COS_FileClose(refnum);
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
COS_FileClose(refnum);
|
||||
cannotopenerror(filename, 0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!cparamblkptr->mainFileText) {
|
||||
COS_FileGetFSSpecInfo(&cparamblkptr->mainFileSpec, &file_vrefnum, &file_dirid, file_filename);
|
||||
cannotopenerror(file_filename, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
prepinfo.textfile = cparamblkptr->mainFileSpec;
|
||||
prepinfo.textbuffer = (char *) cparamblkptr->mainFileText;
|
||||
prepinfo.textlength = cparamblkptr->mainFileTextLength;
|
||||
prepinfo.fileID = cparamblkptr->mainFileID;
|
||||
prepinfo.recordbrowseinfo = cparamblkptr->field276;
|
||||
}
|
||||
|
||||
if (filesp >= 0) {
|
||||
filestack[filesp]->linenumber = linenumber;
|
||||
filestack[filesp]->hasprepline = cprep_hasprepline;
|
||||
filestack[filesp]->pos = pos - filestack[filesp]->textbuffer;
|
||||
}
|
||||
|
||||
pos = prepinfo.textbuffer;
|
||||
linenumber = 1;
|
||||
at_linestart = 1;
|
||||
filestack[++filesp] = galloc(sizeof(CPrepFileInfo));
|
||||
*filestack[filesp] = prepinfo;
|
||||
prep_file = filestack[filesp];
|
||||
prep_file_start = prep_file->textbuffer;
|
||||
prep_file_end = prep_file->textbuffer + prep_file->textlength;
|
||||
if (preprocessing_only && !copts.simple_prepdump)
|
||||
CPrep_PreprocessDumpFileInfo(1);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void CPrep_TSBufferGrow(int amount) {
|
||||
int current_offset = ts_current - ts_first;
|
||||
COS_UnlockHandle(ts_buffer);
|
||||
if (!COS_ResizeHandle(ts_buffer, sizeof(TStreamElement) * (ts_elements + amount)))
|
||||
CError_NoMem();
|
||||
COS_LockHandleHi(ts_buffer);
|
||||
ts_elements += amount;
|
||||
ts_first = (TStreamElement *) *ts_buffer;
|
||||
ts_last = ts_first + (ts_elements - 1);
|
||||
ts_current = ts_first + current_offset;
|
||||
}
|
||||
|
||||
void CPrep_TokenStreamGetState(SInt32 *state) {
|
||||
*state = ts_current - ts_first;
|
||||
}
|
||||
|
||||
void CPrep_TokenStreamSetState(SInt32 *state) {
|
||||
ts_preread_elements += ts_current - ts_first - *state;
|
||||
ts_current = ts_first + *state;
|
||||
}
|
||||
|
||||
void CPrep_UnLex() {
|
||||
++ts_preread_elements;
|
||||
--ts_current;
|
||||
#line 900
|
||||
CError_ASSERT(ts_current >= ts_first);
|
||||
}
|
||||
|
||||
void CPrep_TokenStreamSetCurState(SInt32 *state) {
|
||||
ts_preread_elements += ts_current - ts_first - (*state - 1);
|
||||
ts_current = ts_first + (*state - 1);
|
||||
tk = lex();
|
||||
}
|
||||
|
||||
static void CPrep_StreamSkipToBrace() {}
|
||||
static void CPrep_StreamSkipBlock() {}
|
||||
void CPrep_StreamGetBlock() {}
|
||||
void CPrep_StreamGetSemicolon() {}
|
||||
void CPrep_StreamGetTemplate() {}
|
||||
void CPrep_StreamInsert() {}
|
||||
void CPrep_StreamRemove() {}
|
||||
void CPrep_RemoveTokens() {}
|
||||
void CPrep_TokenStreamFlush() {}
|
||||
static void CPrep_TokenSize() {}
|
||||
void CPrep_CurStreamElement() {}
|
||||
|
||||
void CPrep_GetTokenContext(TStreamElement *token, CPrepFileInfo **tokenfile, SInt32 *selectionoffset, short *tokensize, SInt32 *linenumber, char *buf1, short *tokenoffset, short *tokenlength, char *buf2, short *lastarg) {
|
||||
}
|
||||
|
||||
void CPrep_Error(short code) {
|
||||
Boolean save = in_assembler;
|
||||
in_assembler = 0;
|
||||
if (code == 102 && (tokenstacklevel > 0 || pos < prep_file_end))
|
||||
code = 105;
|
||||
was_prep_error = 1;
|
||||
CError_Error(code);
|
||||
in_assembler = save;
|
||||
}
|
||||
|
||||
void CPrep_ErrorName(short code, const char *name) {
|
||||
Boolean save = in_assembler;
|
||||
in_assembler = 0;
|
||||
was_prep_error = 1;
|
||||
if (code == 102 && (tokenstacklevel > 0 || pos < prep_file_end))
|
||||
CError_Error(105, name);
|
||||
else
|
||||
CError_Error(code, name);
|
||||
in_assembler = save;
|
||||
}
|
||||
|
||||
void CPrep_Warning(short code) {
|
||||
Boolean save = in_assembler;
|
||||
in_assembler = 0;
|
||||
was_prep_error = 1;
|
||||
CError_Warning(code);
|
||||
in_assembler = save;
|
||||
}
|
||||
|
||||
void CPrep_WarningName(short code, const char *name) {
|
||||
Boolean save = in_assembler;
|
||||
in_assembler = 0;
|
||||
was_prep_error = 1;
|
||||
CError_Warning(code, name);
|
||||
in_assembler = save;
|
||||
}
|
||||
|
||||
void CPrep_ErrorMessage(int errTable, char *str, Boolean flag1, Boolean flag2) {
|
||||
Boolean save = in_assembler;
|
||||
in_assembler = 0;
|
||||
was_prep_error = 1;
|
||||
CError_ErrorMessage(errTable, str, flag1, flag2);
|
||||
in_assembler = save;
|
||||
}
|
||||
|
||||
void CPrep_ErrorMessageVA(int code, const char *format, va_list list, Boolean flag1, Boolean flag2) {
|
||||
Boolean save = in_assembler;
|
||||
in_assembler = 0;
|
||||
was_prep_error = 1;
|
||||
CError_ErrorMessageVA(code, format, list, flag1, flag2);
|
||||
in_assembler = save;
|
||||
}
|
||||
|
||||
void popfile() {
|
||||
// r5 and r6 are swapped, not sure why
|
||||
if (filesp >= 0) {
|
||||
CWReleaseFileText(cparamblkptr->context, prep_file->textbuffer);
|
||||
prep_file->textbuffer = NULL;
|
||||
if (--filesp >= 0) {
|
||||
prep_file = filestack[filesp];
|
||||
prep_file_start = prep_file->textbuffer;
|
||||
prep_file_end = prep_file->textbuffer + prep_file->textlength;
|
||||
pos = prep_file_start + prep_file->pos;
|
||||
linenumber = prep_file->linenumber;
|
||||
cprep_hasprepline = prep_file->hasprepline;
|
||||
at_linestart = 1;
|
||||
}
|
||||
if (preprocessing_only && !copts.simple_prepdump)
|
||||
CPrep_PreprocessDumpFileInfo(1);
|
||||
}
|
||||
}
|
||||
|
||||
static void prepoffset() {}
|
||||
static void prepoffset2() {}
|
||||
void CPrep_SetSourceFile() {}
|
||||
void CPrep_GetSourceFilePath() {}
|
||||
void CPrep_NewFileOffsetInfo() {}
|
||||
void CPrep_GetFileOffsetInfo() {}
|
||||
void CPrep_GetFileOffsetInfo2() {}
|
||||
void CPrep_ResetFileInfo() {}
|
||||
void CPrep_GetPrepPos() {}
|
||||
Boolean C_Compiler(CParams *param) {}
|
||||
|
||||
static void pushtokenseq(Macro *macro) {
|
||||
if (tokenstacklevel >= 128) {
|
||||
was_prep_error = 1;
|
||||
CError_ErrorTerm(111);
|
||||
} else {
|
||||
tokenstack[tokenstacklevel].pos = pos;
|
||||
tokenstack[tokenstacklevel].macrostart = macrostart;
|
||||
tokenstack[tokenstacklevel].macro = macro;
|
||||
if (macro)
|
||||
macro->xF = 1;
|
||||
tokenstack[tokenstacklevel].macrocheck = macrocheck;
|
||||
tokenstacklevel++;
|
||||
}
|
||||
}
|
||||
|
||||
void poptokenseq() {
|
||||
if (!--tokenstacklevel && dofreeaheap)
|
||||
freeaheap();
|
||||
|
||||
pos = tokenstack[tokenstacklevel].pos;
|
||||
macrostart = tokenstack[tokenstacklevel].macrostart;
|
||||
if (tokenstack[tokenstacklevel].macro)
|
||||
tokenstack[tokenstacklevel].macro->xF = 0;
|
||||
macrocheck = tokenstack[tokenstacklevel].macrocheck;
|
||||
spaceskip = 1;
|
||||
}
|
||||
|
||||
static void is_nextchar() {}
|
||||
static void ismacroname() {}
|
||||
static void ismacroname2() {}
|
||||
static void ismacroname5() {}
|
||||
static void ismacroname3() {}
|
||||
static void ismacroname4() {}
|
||||
void foundnl() {}
|
||||
void newline() {}
|
||||
static void gotonexttoken() {}
|
||||
short notendofline() {}
|
||||
static void CPrep_MacroRedefError() {}
|
||||
static void goendofline() {}
|
||||
static void CPrep_Define() {}
|
||||
static void prepundefine() {}
|
||||
static Boolean CPrep_CheckTarget() {}
|
||||
static Boolean CPrep_CheckOption() {}
|
||||
static void CPrep_XpandDefinedCheck() {}
|
||||
static void XpandString() {}
|
||||
char *CPrep_GetFileName(char *buffer, Boolean flag1, Boolean flag2) {
|
||||
}
|
||||
|
||||
static char *XpandSpecialMacro(Macro *macro) {
|
||||
char buf[512];
|
||||
char smallbuf[32];
|
||||
char *strptr;
|
||||
struct tm *tm;
|
||||
|
||||
if (macro == &optiM) {
|
||||
return CPrep_CheckOption() ? "1" : "0";
|
||||
} else if (macro == &trgtM) {
|
||||
return CPrep_CheckTarget() ? "1" : "0";
|
||||
} else if (macro == &lineM) {
|
||||
sprintf(buf, "%ld", linenumber);
|
||||
do_string:
|
||||
strptr = aalloc(strlen(buf) + 1);
|
||||
strcpy(strptr, buf);
|
||||
return strptr;
|
||||
} else if (macro == &fileM) {
|
||||
CPrep_GetFileName(buf, 0, 1);
|
||||
goto do_string;
|
||||
} else if (macro == &dateM) {
|
||||
tm = localtime(&now_time);
|
||||
strftime(buf, 64, "\"%b ", tm);
|
||||
strftime(smallbuf, 32, "%d", tm);
|
||||
if (smallbuf[0] == '0')
|
||||
smallbuf[0] = ' ';
|
||||
strcat(buf, smallbuf);
|
||||
strftime(smallbuf, 32, " %Y\"", tm);
|
||||
strcat(buf, smallbuf);
|
||||
goto do_string;
|
||||
} else if (macro == &timeM) {
|
||||
strftime(buf, 64, "\"%H:%M:%S\"", localtime(&now_time));
|
||||
goto do_string;
|
||||
} else if (macro == &stdcM) {
|
||||
return "1";
|
||||
} else if (macro == &casmM || macro == &MWRSM) {
|
||||
return "0x2405";
|
||||
} else if (macro == &cpplM) {
|
||||
return "199711L";
|
||||
} else if (macro == &dtsomM) {
|
||||
return copts.direct_to_som ? "1" : "0";
|
||||
} else if (macro == &ecppM) {
|
||||
return copts.ecplusplus ? "1" : "0";
|
||||
} else if (macro == &stcvM) {
|
||||
return copts.c9x ? "199901L" : "199409L";
|
||||
} else if (macro == &stchM) {
|
||||
return "0";
|
||||
} else {
|
||||
return CodeGen_ExpandSpecialMacro(macro);
|
||||
}
|
||||
}
|
||||
|
||||
static void XpandMacro() {}
|
||||
static void prepmacro() {}
|
||||
void macrotest() {}
|
||||
void CPrep_PragmaLex() {}
|
||||
void CPrep_PushOption() {}
|
||||
void CPrep_PopOption() {}
|
||||
static void CPrep_PragmaImExport() {}
|
||||
static void pragma_on_off_reset() {}
|
||||
static void CPrep_PragmaOnceName() {}
|
||||
static void pragma_precompile_target() {}
|
||||
static void CPrep_DefinePragmaOnceMacro() {}
|
||||
static void CPrep_PragmaOnce() {}
|
||||
static void CPrep_PragmaUnused() {}
|
||||
static void CPrep_PragmaInlineDepth() {}
|
||||
static void CPrep_PragmaInlineMaxSize() {}
|
||||
static void CPrep_PragmaInlineMaxTotalSize() {}
|
||||
|
||||
static void pragma_segment() {
|
||||
short i;
|
||||
short t;
|
||||
char name[256];
|
||||
|
||||
if (notendofline()) {
|
||||
for (i = 0; i < 255; i++) {
|
||||
spaceskip = 0;
|
||||
t = prepskipnextchar();
|
||||
if (spaceskip)
|
||||
break;
|
||||
if (t <= ' ')
|
||||
break;
|
||||
name[i] = t;
|
||||
pos = nextcharpos;
|
||||
}
|
||||
name[i] = 0;
|
||||
|
||||
if (!i || i >= 255)
|
||||
CPrep_Warning(186);
|
||||
|
||||
copts.forcedSegment = GetHashNameNodeExport(name);
|
||||
ObjGen_SegmentName();
|
||||
} else {
|
||||
if (copts.warn_illpragma)
|
||||
CPrep_Warning(186);
|
||||
}
|
||||
}
|
||||
|
||||
static void pragma_options() {}
|
||||
|
||||
static void pragma_push() {
|
||||
struct COptsPush *push;
|
||||
|
||||
push = galloc(sizeof(struct COptsPush));
|
||||
push->next = coptpushs;
|
||||
coptpushs = push;
|
||||
|
||||
push->opts = copts;
|
||||
}
|
||||
|
||||
static void pragma_pop() {
|
||||
if (coptpushs) {
|
||||
copts = coptpushs->opts;
|
||||
coptpushs = coptpushs->next;
|
||||
CMach_Configure();
|
||||
} else {
|
||||
CPrep_Error(237);
|
||||
}
|
||||
}
|
||||
|
||||
static void pragma_overload() {}
|
||||
static void pragma_optimization_level() {}
|
||||
static void pragma_opt_unroll_count() {}
|
||||
static void pragma_opt_unroll_instr_count() {}
|
||||
static void pragma_pack() {}
|
||||
static void pragma_comment() {}
|
||||
static void pragma_message() {}
|
||||
static void preppragma() {}
|
||||
static void prepinclude() {}
|
||||
static void prepline() {}
|
||||
static void CPrep_GetPrepType() {}
|
||||
static void CPrep_ParseUnary() {}
|
||||
static void CPrep_ParseBinary() {}
|
||||
static void CPrep_ParseCond() {}
|
||||
static void doevalconstexpr() {}
|
||||
static void pushifstate() {}
|
||||
static void popifstate() {}
|
||||
static void positiveif() {}
|
||||
static void negativeif() {}
|
||||
static void prepif() {}
|
||||
static void prepifdef() {}
|
||||
static void prepifndef() {}
|
||||
static void prepelif() {}
|
||||
static void prepelse() {}
|
||||
static void prependif() {}
|
||||
static void prepifskip() {}
|
||||
void preprocessor() {}
|
||||
void CPrep_BrowserTokenOffset() {}
|
||||
void CPrep_BrowserFileOffset() {}
|
||||
|
||||
void CPrep_BrowserFilePosition(CPrepFileInfo **fileinfo, SInt32 *offset) {
|
||||
CPrepFileInfo *file;
|
||||
|
||||
if (ts_first < ts_current) {
|
||||
file = ts_current[-1].tokenfile;
|
||||
*offset = ts_current[-1].tokenoffset + 1;
|
||||
} else {
|
||||
file = filestack[filesp];
|
||||
if (tokenstacklevel) {
|
||||
*offset = tokenstack[0].pos - filestack[filesp]->textbuffer;
|
||||
} else {
|
||||
*offset = pos - filestack[filesp]->textbuffer;
|
||||
}
|
||||
}
|
||||
|
||||
if (file && file->fileID > 0 && (file->recordbrowseinfo || gForceSourceLoc)) {
|
||||
*fileinfo = file;
|
||||
} else {
|
||||
*fileinfo = NULL;
|
||||
*offset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
CPrepFileInfo *CPrep_BrowserCurrentFile() {
|
||||
return prep_file;
|
||||
}
|
|
@ -0,0 +1,166 @@
|
|||
#include "compiler.h"
|
||||
#include "compiler/tokens.h"
|
||||
|
||||
static Boolean prepnextstringchar_foundnl;
|
||||
|
||||
short prepskipnextchar() {
|
||||
|
||||
}
|
||||
|
||||
short prepnextchar() {
|
||||
|
||||
}
|
||||
|
||||
short prepnextstringchar(char *str, Boolean flag) {
|
||||
|
||||
}
|
||||
|
||||
void CPrep_MatchChar(char ch, Boolean flag) {
|
||||
|
||||
}
|
||||
|
||||
char *CPrep_MatchChar2(char *str, char ch, Boolean flag) {
|
||||
|
||||
}
|
||||
|
||||
short prepcurchar() {
|
||||
|
||||
}
|
||||
|
||||
static short prepcurstringchar(char *str) {
|
||||
}
|
||||
|
||||
static void prepcurstringchar_skip() {
|
||||
}
|
||||
|
||||
char *ReadIdentifier(char *str) {
|
||||
}
|
||||
|
||||
static short intsuffix(short token, Boolean flag) {
|
||||
}
|
||||
|
||||
static short floatsuffix(short token) {
|
||||
}
|
||||
|
||||
static short tohex(short token) {
|
||||
}
|
||||
|
||||
static short nextchar(char *str) {
|
||||
}
|
||||
|
||||
char *CPrep_SkipNewComment(char *str) {
|
||||
|
||||
}
|
||||
|
||||
Boolean skipendoflinematch(char *str, Boolean flag) {
|
||||
}
|
||||
|
||||
void skipendofline() {
|
||||
}
|
||||
|
||||
void CPrep_SkipAsmComment() {
|
||||
}
|
||||
|
||||
static short tille() {}
|
||||
static short tcret() {}
|
||||
static short tapos() {}
|
||||
static short tquot() {}
|
||||
static short thash() {}
|
||||
static short tmult() {}
|
||||
static short tcolo() {}
|
||||
static short tless() {}
|
||||
static short tequa() {}
|
||||
static short tgrea() {}
|
||||
static short tatsg() {}
|
||||
static short tperc() {}
|
||||
static short texcl() {}
|
||||
static short tplus() {}
|
||||
static short tminu() {}
|
||||
static short torrr() {}
|
||||
static short tampe() {}
|
||||
static short tpowe() {}
|
||||
static short tdivi() {}
|
||||
static short tzero() {}
|
||||
static short tpoin() {}
|
||||
static short tnumb() {}
|
||||
static short tiden() {}
|
||||
static short tchrL() {}
|
||||
static short tchra() {}
|
||||
static short tchrb() {}
|
||||
static short tchrc() {}
|
||||
static short tchrd() {}
|
||||
static short tchre() {}
|
||||
static short tchrf() {}
|
||||
static short tchrg() {}
|
||||
static short tchri() {}
|
||||
static short tchrl() {}
|
||||
static short tchrm() {}
|
||||
static short tchrn() {}
|
||||
static short tchro() {}
|
||||
static short tchrp() {}
|
||||
static short tchrr() {}
|
||||
static short tchrs() {}
|
||||
static short tchrt() {}
|
||||
static short tchru() {}
|
||||
static short tchrv() {}
|
||||
static short tchrw() {}
|
||||
static short tchrx() {}
|
||||
static short tchr_() {}
|
||||
static short token() {}
|
||||
static short tdoll() {}
|
||||
static short tisid() {}
|
||||
static short tnull() {}
|
||||
static short t0x1a() {}
|
||||
|
||||
static short (*cprep_tokenize[256])() = {
|
||||
&tnull, &tille, &tille, &tille, &tisid, &tisid, &tille, &tille,
|
||||
&tille, &tille, &tille, &tille, &tille, &tcret, &tille, &tille,
|
||||
&tille, &tille, &tille, &tille, &tille, &tille, &tille, &tille,
|
||||
&tille, &tille, &t0x1a, &tille, &tille, &tille, &tille, &tille,
|
||||
&tille, &texcl, &tquot, &thash, &tdoll, &tperc, &tampe, &tapos,
|
||||
&token, &token, &tmult, &tplus, &token, &tminu, &tpoin, &tdivi,
|
||||
&tzero, &tnumb, &tnumb, &tnumb, &tnumb, &tnumb, &tnumb, &tnumb,
|
||||
&tnumb, &tnumb, &tcolo, &token, &tless, &tequa, &tgrea, &token,
|
||||
&tatsg, &tiden, &tiden, &tiden, &tiden, &tiden, &tiden, &tiden,
|
||||
&tiden, &tiden, &tiden, &tiden, &tchrL, &tiden, &tchrn, &tiden,
|
||||
&tchrp, &tiden, &tiden, &tiden, &tiden, &tiden, &tiden, &tiden,
|
||||
&tchrx, &tiden, &tiden, &token, &token, &token, &tpowe, &tchr_,
|
||||
&token, &tchra, &tchrb, &tchrc, &tchrd, &tchre, &tchrf, &tchrg,
|
||||
&tiden, &tchri, &tiden, &tiden, &tchrl, &tchrm, &tchrn, &tchro,
|
||||
&tchrp, &tiden, &tchrr, &tchrs, &tchrt, &tchru, &tchrv, &tchrw,
|
||||
&tchrx, &tiden, &tiden, &token, &torrr, &token, &token, &tille,
|
||||
&tille, &tille, &tille, &tille, &tille, &tille, &tille, &tille,
|
||||
&tille, &tille, &tille, &tille, &tille, &tille, &tille, &tille,
|
||||
&tille, &tille, &tille, &tille, &tille, &tille, &tille, &tille,
|
||||
&tille, &tille, &tille, &tille, &tille, &tille, &tille, &tille,
|
||||
&tille, &tille, &tille, &tille, &tille, &tille, &tille, &tille,
|
||||
&tille, &tille, &tille, &tille, &tille, &tille, &tille, &tille,
|
||||
&tille, &tille, &tille, &tille, &tille, &tille, &tille, &tille,
|
||||
&tille, &tille, &tille, &tille, &tille, &tille, &tille, &tille,
|
||||
&tille, &tille, &tille, &tille, &tille, &tille, &tille, &tille,
|
||||
&tille, &tille, &tille, &tille, &tille, &tille, &tille, &tille,
|
||||
&tille, &tille, &tille, &tille, &tille, &tille, &tille, &tille,
|
||||
&tille, &tille, &tille, &tille, &tille, &tille, &tille, &tille,
|
||||
&tille, &tille, &tille, &tille, &tille, &tille, &tille, &tille,
|
||||
&tille, &tille, &tille, &tille, &tille, &tille, &tille, &tille,
|
||||
&tille, &tille, &tille, &tille, &tille, &tille, &tille, &tille,
|
||||
&tille, &tille, &tille, &tille, &tille, &tille, &tille, &tille
|
||||
};
|
||||
|
||||
short lookahead() {
|
||||
}
|
||||
|
||||
short lookahead_noeol() {
|
||||
}
|
||||
|
||||
static void CPrep_StringConCat(Boolean flag) {
|
||||
}
|
||||
|
||||
short lex() {
|
||||
}
|
||||
|
||||
short plex() {
|
||||
}
|
||||
|
||||
short lexidentifier() {
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,255 @@
|
|||
#include "compiler/common.h"
|
||||
#include "compiler.h"
|
||||
#include "compiler/types.h"
|
||||
#include "pref_structs.h"
|
||||
#include "compiler/CompilerTools.h"
|
||||
|
||||
Boolean systemHandles;
|
||||
|
||||
static Boolean using_license_manager;
|
||||
Boolean crippled;
|
||||
SInt32 license_cookie;
|
||||
CParams cparams;
|
||||
|
||||
// TODO move me to CParser.c, or maybe CMachine.c?
|
||||
Type sttemplexpr = {TYPETEMPLDEPEXPR, 0};
|
||||
Type stillegal = {TYPEILLEGAL, 1};
|
||||
Type stvoid = {TYPEVOID, 0};
|
||||
TypePointer void_ptr = {TYPEPOINTER, 0, &stvoid, 0};
|
||||
TypeFunc rt_func = {TYPEFUNC, 0, NULL, NULL, &stvoid, 0, 0};
|
||||
// TODO move me to CParser.c
|
||||
|
||||
static void get_extension(ConstStringPtr src, char *dst) {
|
||||
int ep;
|
||||
|
||||
dst[0] = 0;
|
||||
for (ep = src[0]; src[ep] != '.'; ep--) {}
|
||||
|
||||
if (ep >= 2) {
|
||||
int x;
|
||||
for (x = 0; (x + ep) <= src[0]; x++)
|
||||
dst[x] = src[x + ep];
|
||||
dst[x] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int setup_param_block(CWPluginContext context) {
|
||||
static char target_name[128];
|
||||
CWTargetInfo tinfo;
|
||||
|
||||
memset(&cparams, 0, sizeof(CParams));
|
||||
cparams.context = context;
|
||||
|
||||
if (CWGetPluginRequest(context, &cparams.pluginRequest) != cwNoErr)
|
||||
return 0;
|
||||
if (CWGetAPIVersion(context, &cparams.apiVersion) != cwNoErr)
|
||||
return 0;
|
||||
if (CWGetProjectFile(context, &cparams.projectFile) != cwNoErr)
|
||||
return 0;
|
||||
if (CWGetProjectFileCount(context, &cparams.projectFileCount) != cwNoErr)
|
||||
return 0;
|
||||
if (CWGetMainFileNumber(context, &cparams.mainFileNumber) != cwNoErr)
|
||||
return 0;
|
||||
if (CWGetMainFileSpec(context, &cparams.mainFileSpec) != cwNoErr)
|
||||
return 0;
|
||||
if (CWGetMainFileText(context, &cparams.mainFileText, &cparams.mainFileTextLength) != cwNoErr)
|
||||
return 0;
|
||||
if (CWIsPrecompiling(context, &cparams.isPrecompiling) != cwNoErr)
|
||||
return 0;
|
||||
if (CWIsAutoPrecompiling(context, &cparams.isAutoPrecompiling) != cwNoErr)
|
||||
return 0;
|
||||
if (CWIsPreprocessing(context, &cparams.isPreprocessing) != cwNoErr)
|
||||
return 0;
|
||||
if (CWIsGeneratingDebugInfo(context, &cparams.isGeneratingDebugInfo) != cwNoErr)
|
||||
return 0;
|
||||
if (CWIsCachingPrecompiledHeaders(context, &cparams.isCachingPrecompiledHeaders) != cwNoErr)
|
||||
return 0;
|
||||
if (CWGetBrowseOptions(context, &cparams.browseOptions) != cwNoErr)
|
||||
return 0;
|
||||
cparams.field276 = cparams.isPreprocessing == 0;
|
||||
if (CWGetMainFileID(context, &cparams.mainFileID) != cwNoErr)
|
||||
return 0;
|
||||
if (CWGetTargetInfo(context, &tinfo) != cwNoErr)
|
||||
return 0;
|
||||
|
||||
cparams.targetOS = tinfo.targetOS;
|
||||
cparams.targetCPU = tinfo.targetCPU;
|
||||
cparams.targetName = target_name;
|
||||
return CWGetTargetName(context, target_name, sizeof(target_name)) == cwNoErr;
|
||||
}
|
||||
|
||||
static short store_compile_results() {
|
||||
CWResult result;
|
||||
|
||||
if (cparams.objectDataHandle)
|
||||
CWSecretAttachHandle(cparams.context, cparams.objectDataHandle, &cparams.objectdata.objectdata);
|
||||
if (cparams.browseDataHandle)
|
||||
CWSecretAttachHandle(cparams.context, cparams.browseDataHandle, &cparams.objectdata.browsedata);
|
||||
|
||||
if (cparams.isPreprocessing) {
|
||||
if (cparams.objectdata.objectdata) {
|
||||
CWNewTextDocumentInfo docinfo;
|
||||
memset(&docinfo, 0, sizeof(CWNewTextDocumentInfo));
|
||||
docinfo.text = cparams.objectdata.objectdata;
|
||||
cparams.objectdata.objectdata = NULL;
|
||||
result = CWCreateNewTextDocument(cparams.context, &docinfo);
|
||||
}
|
||||
} else {
|
||||
result = CWStoreObjectData(cparams.context, cparams.mainFileNumber, &cparams.objectdata);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void initialize_compiler_options(CParams *params) {
|
||||
static PFrontEndC pFrontEnd;
|
||||
PWarningC pWarningC;
|
||||
PGlobalOptimizer pGlobalOptimizer;
|
||||
Handle prefsdata;
|
||||
char extension[256];
|
||||
|
||||
memclrw(&copts, sizeof(COpts));
|
||||
|
||||
CWSecretGetNamedPreferences(cparams.context, "C/C++ Compiler", &prefsdata);
|
||||
pFrontEnd = *((PFrontEndC *) *prefsdata);
|
||||
|
||||
copts.little_endian = 0;
|
||||
copts.cplusplus = 1;
|
||||
copts.objective_c = pFrontEnd.objective_c;
|
||||
get_extension(params->mainFileSpec.name, extension);
|
||||
if (!strcmp(extension, ".c") || !strcmp(extension, ".h") || !strcmp(extension, ".pch")) {
|
||||
copts.cplusplus = pFrontEnd.cplusplus;
|
||||
} else if (!strcmp(extension, ".m")) {
|
||||
copts.cplusplus = pFrontEnd.cplusplus;
|
||||
copts.objective_c = 1;
|
||||
} else if (!strcmp(extension, ".mm") || !strcmp(extension, ".M")) {
|
||||
copts.cplusplus = 1;
|
||||
copts.objective_c = 1;
|
||||
}
|
||||
|
||||
copts.require_prototypes = pFrontEnd.checkprotos;
|
||||
copts.ARM_conform = pFrontEnd.arm;
|
||||
copts.ARM_scoping = pFrontEnd.arm;
|
||||
copts.trigraphs = pFrontEnd.trigraphs;
|
||||
copts.only_std_keywords = pFrontEnd.onlystdkeywords;
|
||||
copts.enumsalwaysint = pFrontEnd.enumsalwaysint;
|
||||
copts.mpwc_relax = pFrontEnd.mpwpointerstyle;
|
||||
copts.ANSI_strict = pFrontEnd.ansistrict;
|
||||
copts.mpwc_newline = pFrontEnd.mpwcnewline;
|
||||
copts.exceptions = pFrontEnd.enableexceptions;
|
||||
copts.dont_reuse_strings = pFrontEnd.dontreusestrings;
|
||||
copts.pool_strings = pFrontEnd.poolstrings;
|
||||
copts.dont_inline = pFrontEnd.dontinline;
|
||||
copts.useRTTI = pFrontEnd.useRTTI;
|
||||
copts.oldprefixname = pFrontEnd.oldprefixname;
|
||||
copts.multibyteaware = pFrontEnd.multibyteaware;
|
||||
copts.unsignedchars = pFrontEnd.unsignedchars;
|
||||
copts.autoinline = pFrontEnd.autoinline;
|
||||
copts.direct_to_som = pFrontEnd.direct_to_som;
|
||||
copts.som_env_check = pFrontEnd.som_env_check;
|
||||
copts.booltruefalse = pFrontEnd.booltruefalse;
|
||||
copts.always_inline = pFrontEnd.alwaysinline;
|
||||
copts.inlinelevel = pFrontEnd.inlinelevel;
|
||||
copts.wchar_type = pFrontEnd.wchar_type;
|
||||
copts.ecplusplus = pFrontEnd.ecplusplus;
|
||||
copts.defer_codegen = pFrontEnd.defer_codegen;
|
||||
copts.inline_max_size = 512;
|
||||
copts.inline_max_total_size = 100000;
|
||||
|
||||
CWSecretGetNamedPreferences(cparams.context, "C/C++ Warnings", &prefsdata);
|
||||
pWarningC = *((PWarningC *) *prefsdata);
|
||||
|
||||
copts.warn_illpragma = pWarningC.warn_illpragma;
|
||||
copts.warn_emptydecl = pWarningC.warn_emptydecl;
|
||||
copts.warn_possunwant = pWarningC.warn_possunwant;
|
||||
copts.warn_unusedvar = pWarningC.warn_unusedvar;
|
||||
copts.warn_unusedarg = pWarningC.warn_unusedarg;
|
||||
copts.warn_extracomma = pWarningC.warn_extracomma;
|
||||
copts.pedantic = pWarningC.pedantic;
|
||||
copts.warningerrors = pWarningC.warningerrors;
|
||||
copts.warn_hidevirtual = pWarningC.warn_hidevirtual;
|
||||
copts.warn_implicitconv = pWarningC.warn_implicitconv;
|
||||
copts.warn_notinlined = pWarningC.warn_notinlined;
|
||||
copts.warn_structclass = pWarningC.warn_structclass;
|
||||
|
||||
CWSecretGetNamedPreferences(cparams.context, "PPC Global Optimizer", &prefsdata);
|
||||
pGlobalOptimizer = *((PGlobalOptimizer *) *prefsdata);
|
||||
|
||||
copts.optimizationlevel = pGlobalOptimizer.optimizationlevel;
|
||||
copts.optimize_for_size = (Boolean) (pGlobalOptimizer.optfor == 1);
|
||||
|
||||
copts.crippled = crippled;
|
||||
copts.loop_unroll_count = 8;
|
||||
copts.loop_unroll_size_threshold = 100;
|
||||
copts.isGeneratingDebugInfo = params->isGeneratingDebugInfo;
|
||||
copts.pchCreator = CWFOURCHAR('C','W','I','E');
|
||||
copts.pchType = CWFOURCHAR('M','M','C','H');
|
||||
copts.text = CWFOURCHAR('T','E','X','T');
|
||||
}
|
||||
|
||||
static void GetLicense() {
|
||||
if (!license_cookie) {
|
||||
crippled = 1;
|
||||
CWCheckoutLicense(cparams.context, "MacOS_Plugins_MacOS_Unlimited", "7", 2, NULL, &license_cookie);
|
||||
if (license_cookie) {
|
||||
CWCheckinLicense(cparams.context, license_cookie);
|
||||
crippled = 0;
|
||||
}
|
||||
|
||||
CWCheckoutLicense(cparams.context, "MacOS_Plugins_MacOS_Limited", "7", 0, NULL, &license_cookie);
|
||||
using_license_manager = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void ReleaseLicense() {
|
||||
if (license_cookie && using_license_manager)
|
||||
CWCheckinLicense(cparams.context, license_cookie);
|
||||
using_license_manager = 0;
|
||||
license_cookie = 0;
|
||||
}
|
||||
|
||||
CWPLUGIN_ENTRY(MWC_main)(CWPluginContext context) {
|
||||
CWResult result;
|
||||
SInt32 request;
|
||||
|
||||
result = cwNoErr;
|
||||
CWGetPluginRequest(context, &request);
|
||||
|
||||
switch (request) {
|
||||
case reqInitialize:
|
||||
cparams.context = context;
|
||||
license_cookie = 0;
|
||||
CodeGen_InitCompiler();
|
||||
break;
|
||||
case reqTerminate:
|
||||
cparams.context = context;
|
||||
CodeGen_TermCompiler();
|
||||
ReleaseLicense();
|
||||
break;
|
||||
case reqCompile:
|
||||
setup_param_block(context);
|
||||
GetLicense();
|
||||
if (license_cookie) {
|
||||
initialize_compiler_options(&cparams);
|
||||
CodeGen_UpdateOptimizerOptions();
|
||||
CodeGen_InitBackEndOptions();
|
||||
CodeGen_UpdateOptimizerOptions();
|
||||
CodeGen_UpdateBackEndOptions();
|
||||
if (C_Compiler(&cparams))
|
||||
result = store_compile_results();
|
||||
else
|
||||
result = cwErrRequestFailed;
|
||||
} else {
|
||||
result = cwErrSilent;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return CWDonePluginRequest(context, result);
|
||||
}
|
||||
|
||||
void PrintProgressFunction(const char *str) {
|
||||
char buf[96];
|
||||
sprintf(buf, "Compiling function:\t%.64s", str);
|
||||
CWShowStatus(cparams.context, buf, "");
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,4 @@
|
|||
#include <MacHeadersMach-O>
|
||||
#include "CInt64.h"
|
||||
#include "compiler/CInt64.h"
|
||||
|
||||
const CInt64 cint64_negone = {0xFFFFFFFF, 0xFFFFFFFF};
|
||||
const CInt64 cint64_zero = {0, 0};
|
||||
|
@ -14,9 +13,9 @@ void CInt64_Init() {
|
|||
|
||||
CInt64 CInt64_Not(CInt64 input) {
|
||||
CInt64 output;
|
||||
unsigned char c;
|
||||
Boolean c;
|
||||
|
||||
c = (input.a == 0 && input.b == 0);
|
||||
c = (input.hi == 0 && input.lo == 0);
|
||||
CInt64_SetLong(&output, c);
|
||||
|
||||
return output;
|
||||
|
@ -24,31 +23,31 @@ CInt64 CInt64_Not(CInt64 input) {
|
|||
|
||||
CInt64 CInt64_Inv(CInt64 input) {
|
||||
CInt64 output;
|
||||
output.a = ~input.a;
|
||||
output.b = ~input.b;
|
||||
output.hi = ~input.hi;
|
||||
output.lo = ~input.lo;
|
||||
return output;
|
||||
}
|
||||
|
||||
CInt64 CInt64_Add(CInt64 lhs, CInt64 rhs) {
|
||||
if (lhs.b & 0x80000000) {
|
||||
if (rhs.b & 0x80000000) {
|
||||
lhs.b += rhs.b;
|
||||
lhs.a += 1;
|
||||
if (lhs.lo & 0x80000000) {
|
||||
if (rhs.lo & 0x80000000) {
|
||||
lhs.lo += rhs.lo;
|
||||
lhs.hi += 1;
|
||||
} else {
|
||||
lhs.b += rhs.b;
|
||||
if (!(lhs.b & 0x80000000))
|
||||
lhs.a += 1;
|
||||
lhs.lo += rhs.lo;
|
||||
if (!(lhs.lo & 0x80000000))
|
||||
lhs.hi += 1;
|
||||
}
|
||||
} else {
|
||||
if (rhs.b & 0x80000000) {
|
||||
lhs.b += rhs.b;
|
||||
if (!(lhs.b & 0x80000000))
|
||||
lhs.a += 1;
|
||||
if (rhs.lo & 0x80000000) {
|
||||
lhs.lo += rhs.lo;
|
||||
if (!(lhs.lo & 0x80000000))
|
||||
lhs.hi += 1;
|
||||
} else {
|
||||
lhs.b += rhs.b;
|
||||
lhs.lo += rhs.lo;
|
||||
}
|
||||
}
|
||||
lhs.a += rhs.a;
|
||||
lhs.hi += rhs.hi;
|
||||
return lhs;
|
||||
}
|
||||
|
||||
|
@ -66,22 +65,22 @@ CInt64 CInt64_Sub(CInt64 lhs, CInt64 rhs) {
|
|||
CInt64 CInt64_MulU(CInt64 lhs, CInt64 rhs) {
|
||||
CInt64 result;
|
||||
CInt64 work1;
|
||||
unsigned long aaaa;
|
||||
unsigned long bbbb;
|
||||
unsigned long cccc;
|
||||
unsigned long dddd;
|
||||
unsigned long eeee;
|
||||
UInt32 aaaa;
|
||||
UInt32 bbbb;
|
||||
UInt32 cccc;
|
||||
UInt32 dddd;
|
||||
UInt32 eeee;
|
||||
|
||||
aaaa = rhs.b;
|
||||
result.a = result.b = 0;
|
||||
bbbb = lhs.b;
|
||||
cccc = rhs.a;
|
||||
dddd = rhs.b;
|
||||
aaaa = rhs.lo;
|
||||
result.hi = result.lo = 0;
|
||||
bbbb = lhs.lo;
|
||||
cccc = rhs.hi;
|
||||
dddd = rhs.lo;
|
||||
|
||||
while (bbbb != 0) {
|
||||
if (bbbb & 1) {
|
||||
work1.a = cccc;
|
||||
work1.b = dddd;
|
||||
work1.hi = cccc;
|
||||
work1.lo = dddd;
|
||||
result = CInt64_Add(result, work1);
|
||||
}
|
||||
cccc <<= 1;
|
||||
|
@ -91,10 +90,10 @@ CInt64 CInt64_MulU(CInt64 lhs, CInt64 rhs) {
|
|||
bbbb >>= 1;
|
||||
}
|
||||
|
||||
eeee = lhs.a;
|
||||
eeee = lhs.hi;
|
||||
while (eeee != 0 && aaaa != 0) {
|
||||
if (eeee & 1)
|
||||
result.a += aaaa;
|
||||
result.hi += aaaa;
|
||||
aaaa <<= 1;
|
||||
eeee >>= 1;
|
||||
}
|
||||
|
@ -116,26 +115,26 @@ CInt64 CInt64_Mul(CInt64 lhs, CInt64 rhs) {
|
|||
}
|
||||
|
||||
void CInt64_DivMod(const CInt64 *lhs, const CInt64 *rhs, CInt64 *pDiv, CInt64 *pMod) {
|
||||
unsigned char bad;
|
||||
unsigned long workA;
|
||||
unsigned long workB;
|
||||
unsigned long leftA;
|
||||
unsigned long leftB;
|
||||
unsigned long rightA;
|
||||
unsigned long rightB;
|
||||
unsigned long outA;
|
||||
unsigned long outB;
|
||||
Boolean bad;
|
||||
UInt32 workA;
|
||||
UInt32 workB;
|
||||
UInt32 leftA;
|
||||
UInt32 leftB;
|
||||
UInt32 rightA;
|
||||
UInt32 rightB;
|
||||
UInt32 outA;
|
||||
UInt32 outB;
|
||||
CInt64 work;
|
||||
int counter;
|
||||
|
||||
bad = (rhs->a == 0) && (rhs->b == 0);
|
||||
bad = (rhs->hi == 0) && (rhs->lo == 0);
|
||||
if (!bad) {
|
||||
workA = 0;
|
||||
workB = 0;
|
||||
leftA = lhs->a;
|
||||
leftB = lhs->b;
|
||||
rightA = rhs->a;
|
||||
rightB = rhs->b;
|
||||
leftA = lhs->hi;
|
||||
leftB = lhs->lo;
|
||||
rightA = rhs->hi;
|
||||
rightB = rhs->lo;
|
||||
outA = 0;
|
||||
outB = 0;
|
||||
counter = 0;
|
||||
|
@ -166,20 +165,20 @@ void CInt64_DivMod(const CInt64 *lhs, const CInt64 *rhs, CInt64 *pDiv, CInt64 *p
|
|||
|
||||
outB |= 1;
|
||||
|
||||
work.a = workA;
|
||||
work.b = workB;
|
||||
work.hi = workA;
|
||||
work.lo = workB;
|
||||
work = CInt64_Sub(work, *rhs);
|
||||
workA = work.a;
|
||||
workB = work.b;
|
||||
workA = work.hi;
|
||||
workB = work.lo;
|
||||
} while (++counter < 64);
|
||||
|
||||
if (pDiv) {
|
||||
pDiv->a = outA;
|
||||
pDiv->b = outB;
|
||||
pDiv->hi = outA;
|
||||
pDiv->lo = outB;
|
||||
}
|
||||
if (pMod) {
|
||||
pMod->a = workA;
|
||||
pMod->b = workB;
|
||||
pMod->hi = workA;
|
||||
pMod->lo = workB;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -238,50 +237,50 @@ CInt64 CInt64_ModU(CInt64 lhs, CInt64 rhs) {
|
|||
|
||||
CInt64 CInt64_Shl(CInt64 lhs, CInt64 rhs) {
|
||||
int counter;
|
||||
unsigned long a;
|
||||
unsigned long b;
|
||||
UInt32 a;
|
||||
UInt32 b;
|
||||
|
||||
if (rhs.a == 0 && rhs.b < 64) {
|
||||
a = lhs.a;
|
||||
b = lhs.b;
|
||||
for (counter = rhs.b; counter != 0; --counter) {
|
||||
if (rhs.hi == 0 && rhs.lo < 64) {
|
||||
a = lhs.hi;
|
||||
b = lhs.lo;
|
||||
for (counter = rhs.lo; counter != 0; --counter) {
|
||||
a <<= 1;
|
||||
if (b & 0x80000000)
|
||||
a |= 1;
|
||||
b <<= 1;
|
||||
}
|
||||
lhs.a = a;
|
||||
lhs.b = b;
|
||||
lhs.hi = a;
|
||||
lhs.lo = b;
|
||||
} else {
|
||||
lhs.a = 0;
|
||||
lhs.b = 0;
|
||||
lhs.hi = 0;
|
||||
lhs.lo = 0;
|
||||
}
|
||||
return lhs;
|
||||
}
|
||||
|
||||
CInt64 CInt64_Shr(CInt64 lhs, CInt64 rhs) {
|
||||
int counter;
|
||||
long a;
|
||||
unsigned long b;
|
||||
SInt32 a;
|
||||
UInt32 b;
|
||||
|
||||
if (rhs.a == 0 && rhs.b < 64) {
|
||||
a = lhs.a;
|
||||
b = lhs.b;
|
||||
for (counter = rhs.b; counter != 0; --counter) {
|
||||
if (rhs.hi == 0 && rhs.lo < 64) {
|
||||
a = lhs.hi;
|
||||
b = lhs.lo;
|
||||
for (counter = rhs.lo; counter != 0; --counter) {
|
||||
b >>= 1;
|
||||
if (a & 1)
|
||||
b |= 0x80000000;
|
||||
a >>= 1;
|
||||
}
|
||||
lhs.a = a;
|
||||
lhs.b = b;
|
||||
lhs.hi = a;
|
||||
lhs.lo = b;
|
||||
} else {
|
||||
if (lhs.a & 0x80000000) {
|
||||
lhs.a = 0xFFFFFFFF;
|
||||
lhs.b = 0xFFFFFFFF;
|
||||
if (lhs.hi & 0x80000000) {
|
||||
lhs.hi = 0xFFFFFFFF;
|
||||
lhs.lo = 0xFFFFFFFF;
|
||||
} else {
|
||||
lhs.a = 0;
|
||||
lhs.b = 0;
|
||||
lhs.hi = 0;
|
||||
lhs.lo = 0;
|
||||
}
|
||||
}
|
||||
return lhs;
|
||||
|
@ -289,35 +288,35 @@ CInt64 CInt64_Shr(CInt64 lhs, CInt64 rhs) {
|
|||
|
||||
CInt64 CInt64_ShrU(CInt64 lhs, CInt64 rhs) {
|
||||
int counter;
|
||||
unsigned long a;
|
||||
unsigned long b;
|
||||
UInt32 a;
|
||||
UInt32 b;
|
||||
|
||||
if (rhs.a == 0 && rhs.b < 64) {
|
||||
a = lhs.a;
|
||||
b = lhs.b;
|
||||
for (counter = rhs.b; counter != 0; --counter) {
|
||||
if (rhs.hi == 0 && rhs.lo < 64) {
|
||||
a = lhs.hi;
|
||||
b = lhs.lo;
|
||||
for (counter = rhs.lo; counter != 0; --counter) {
|
||||
b >>= 1;
|
||||
if (a & 1)
|
||||
b |= 0x80000000;
|
||||
a >>= 1;
|
||||
}
|
||||
lhs.a = a;
|
||||
lhs.b = b;
|
||||
lhs.hi = a;
|
||||
lhs.lo = b;
|
||||
} else {
|
||||
lhs.a = 0;
|
||||
lhs.b = 0;
|
||||
lhs.hi = 0;
|
||||
lhs.lo = 0;
|
||||
}
|
||||
return lhs;
|
||||
}
|
||||
|
||||
int CInt64_UnsignedCompare(const CInt64 *lhs, const CInt64 *rhs) {
|
||||
if (lhs->a == rhs->a) {
|
||||
if (lhs->b < rhs->b)
|
||||
if (lhs->hi == rhs->hi) {
|
||||
if (lhs->lo < rhs->lo)
|
||||
return -1;
|
||||
else
|
||||
return lhs->b > rhs->b;
|
||||
return lhs->lo > rhs->lo;
|
||||
} else {
|
||||
return ((unsigned long) lhs->a < rhs->a) ? -1 : 1;
|
||||
return ((UInt32) lhs->hi < rhs->hi) ? -1 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -330,62 +329,62 @@ int CInt64_SignedCompare(const CInt64 *lhs, const CInt64 *rhs) {
|
|||
return CInt64_UnsignedCompare(&lhs_, &rhs_);
|
||||
}
|
||||
|
||||
unsigned char CInt64_Less(CInt64 lhs, CInt64 rhs) {
|
||||
Boolean CInt64_Less(CInt64 lhs, CInt64 rhs) {
|
||||
return CInt64_SignedCompare(&lhs, &rhs) < 0;
|
||||
}
|
||||
|
||||
unsigned char CInt64_LessU(CInt64 lhs, CInt64 rhs) {
|
||||
Boolean CInt64_LessU(CInt64 lhs, CInt64 rhs) {
|
||||
return CInt64_UnsignedCompare(&lhs, &rhs) < 0;
|
||||
}
|
||||
|
||||
unsigned char CInt64_Greater(CInt64 lhs, CInt64 rhs) {
|
||||
Boolean CInt64_Greater(CInt64 lhs, CInt64 rhs) {
|
||||
return CInt64_SignedCompare(&lhs, &rhs) > 0;
|
||||
}
|
||||
|
||||
unsigned char CInt64_GreaterU(CInt64 lhs, CInt64 rhs) {
|
||||
Boolean CInt64_GreaterU(CInt64 lhs, CInt64 rhs) {
|
||||
return CInt64_UnsignedCompare(&lhs, &rhs) > 0;
|
||||
}
|
||||
|
||||
unsigned char CInt64_LessEqual(CInt64 lhs, CInt64 rhs) {
|
||||
Boolean CInt64_LessEqual(CInt64 lhs, CInt64 rhs) {
|
||||
return CInt64_SignedCompare(&lhs, &rhs) <= 0;
|
||||
}
|
||||
|
||||
unsigned char CInt64_LessEqualU(CInt64 lhs, CInt64 rhs) {
|
||||
Boolean CInt64_LessEqualU(CInt64 lhs, CInt64 rhs) {
|
||||
return CInt64_UnsignedCompare(&lhs, &rhs) <= 0;
|
||||
}
|
||||
|
||||
unsigned char CInt64_GreaterEqual(CInt64 lhs, CInt64 rhs) {
|
||||
Boolean CInt64_GreaterEqual(CInt64 lhs, CInt64 rhs) {
|
||||
return CInt64_SignedCompare(&lhs, &rhs) >= 0;
|
||||
}
|
||||
|
||||
unsigned char CInt64_GreaterEqualU(CInt64 lhs, CInt64 rhs) {
|
||||
Boolean CInt64_GreaterEqualU(CInt64 lhs, CInt64 rhs) {
|
||||
return CInt64_UnsignedCompare(&lhs, &rhs) >= 0;
|
||||
}
|
||||
|
||||
unsigned char CInt64_Equal(CInt64 lhs, CInt64 rhs) {
|
||||
return lhs.a == rhs.a && lhs.b == rhs.b;
|
||||
Boolean CInt64_Equal(CInt64 lhs, CInt64 rhs) {
|
||||
return lhs.hi == rhs.hi && lhs.lo == rhs.lo;
|
||||
}
|
||||
|
||||
unsigned char CInt64_NotEqual(CInt64 lhs, CInt64 rhs) {
|
||||
return lhs.a != rhs.a || lhs.b != rhs.b;
|
||||
Boolean CInt64_NotEqual(CInt64 lhs, CInt64 rhs) {
|
||||
return lhs.hi != rhs.hi || lhs.lo != rhs.lo;
|
||||
}
|
||||
|
||||
unsigned char CInt64_IsInRange(CInt64 value, short len) {
|
||||
Boolean CInt64_IsInRange(CInt64 value, short len) {
|
||||
CInt64 bound;
|
||||
|
||||
if (value.a & 0x80000000) {
|
||||
if (value.hi & 0x80000000) {
|
||||
switch (len) {
|
||||
case 1:
|
||||
bound.b = 0xFFFFFF80;
|
||||
bound.a = 0xFFFFFFFF;
|
||||
bound.lo = 0xFFFFFF80;
|
||||
bound.hi = 0xFFFFFFFF;
|
||||
break;
|
||||
case 2:
|
||||
bound.b = 0xFFFF8000;
|
||||
bound.a = 0xFFFFFFFF;
|
||||
bound.lo = 0xFFFF8000;
|
||||
bound.hi = 0xFFFFFFFF;
|
||||
break;
|
||||
case 4:
|
||||
bound.b = 0x80000000;
|
||||
bound.a = 0xFFFFFFFF;
|
||||
bound.lo = 0x80000000;
|
||||
bound.hi = 0xFFFFFFFF;
|
||||
break;
|
||||
case 8:
|
||||
return 1;
|
||||
|
@ -396,16 +395,16 @@ unsigned char CInt64_IsInRange(CInt64 value, short len) {
|
|||
} else {
|
||||
switch (len) {
|
||||
case 1:
|
||||
bound.b = 0x7F;
|
||||
bound.a = 0;
|
||||
bound.lo = 0x7F;
|
||||
bound.hi = 0;
|
||||
break;
|
||||
case 2:
|
||||
bound.b = 0x7FFF;
|
||||
bound.a = 0;
|
||||
bound.lo = 0x7FFF;
|
||||
bound.hi = 0;
|
||||
break;
|
||||
case 4:
|
||||
bound.b = 0x7FFFFFFF;
|
||||
bound.a = 0;
|
||||
bound.lo = 0x7FFFFFFF;
|
||||
bound.hi = 0;
|
||||
break;
|
||||
case 8:
|
||||
return 1;
|
||||
|
@ -416,14 +415,14 @@ unsigned char CInt64_IsInRange(CInt64 value, short len) {
|
|||
}
|
||||
}
|
||||
|
||||
unsigned char CInt64_IsInURange(CInt64 value, short len) {
|
||||
Boolean CInt64_IsInURange(CInt64 value, short len) {
|
||||
switch (len) {
|
||||
case 1:
|
||||
return value.a == 0 && (value.b & 0xFFFFFF00) == 0;
|
||||
return value.hi == 0 && (value.lo & 0xFFFFFF00) == 0;
|
||||
case 2:
|
||||
return value.a == 0 && (value.b & 0xFFFF0000) == 0;
|
||||
return value.hi == 0 && (value.lo & 0xFFFF0000) == 0;
|
||||
case 4:
|
||||
return value.a == 0;
|
||||
return value.hi == 0;
|
||||
case 8:
|
||||
return 1;
|
||||
default:
|
||||
|
@ -432,20 +431,20 @@ unsigned char CInt64_IsInURange(CInt64 value, short len) {
|
|||
}
|
||||
|
||||
CInt64 CInt64_And(CInt64 lhs, CInt64 rhs) {
|
||||
lhs.a &= rhs.a;
|
||||
lhs.b &= rhs.b;
|
||||
lhs.hi &= rhs.hi;
|
||||
lhs.lo &= rhs.lo;
|
||||
return lhs;
|
||||
}
|
||||
|
||||
CInt64 CInt64_Xor(CInt64 lhs, CInt64 rhs) {
|
||||
lhs.a ^= rhs.a;
|
||||
lhs.b ^= rhs.b;
|
||||
lhs.hi ^= rhs.hi;
|
||||
lhs.lo ^= rhs.lo;
|
||||
return lhs;
|
||||
}
|
||||
|
||||
CInt64 CInt64_Or(CInt64 lhs, CInt64 rhs) {
|
||||
lhs.a |= rhs.a;
|
||||
lhs.b |= rhs.b;
|
||||
lhs.hi |= rhs.hi;
|
||||
lhs.lo |= rhs.lo;
|
||||
return lhs;
|
||||
}
|
||||
|
||||
|
@ -454,43 +453,43 @@ void CInt64_ConvertInt32(CInt64 *i) {
|
|||
}
|
||||
|
||||
void CInt64_ConvertUInt32(CInt64 *i) {
|
||||
CInt64_SetULong(i, (unsigned long) i->b);
|
||||
CInt64_SetULong(i, (UInt32) i->lo);
|
||||
}
|
||||
|
||||
void CInt64_ConvertInt16(CInt64 *i) {
|
||||
i->b = (short) i->b;
|
||||
i->lo = (SInt32) i->lo;
|
||||
CInt64_Extend32(i);
|
||||
}
|
||||
|
||||
void CInt64_ConvertUInt16(CInt64 *i) {
|
||||
CInt64_SetULong(i, (unsigned short) i->b);
|
||||
CInt64_SetULong(i, (UInt16) i->lo);
|
||||
}
|
||||
|
||||
void CInt64_ConvertInt8(CInt64 *i) {
|
||||
i->b = (char) i->b;
|
||||
i->lo = (SInt8) i->lo;
|
||||
CInt64_Extend32(i);
|
||||
}
|
||||
|
||||
void CInt64_ConvertUInt8(CInt64 *i) {
|
||||
CInt64_SetULong(i, (unsigned char) i->b);
|
||||
CInt64_SetULong(i, (UInt8) i->lo);
|
||||
}
|
||||
|
||||
void CInt64_ConvertUFromLongDouble(CInt64 *pResult, double value) {
|
||||
union { float f; unsigned long l; } cvt;
|
||||
unsigned long a, b;
|
||||
union { float f; UInt32 l; } cvt;
|
||||
UInt32 a, b;
|
||||
float threshold;
|
||||
int bits;
|
||||
|
||||
if (value <= 0.0) {
|
||||
pResult->a = 0;
|
||||
pResult->b = 0;
|
||||
pResult->hi = 0;
|
||||
pResult->lo = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
cvt.l = 0x5F800000;
|
||||
if (value >= cvt.f) {
|
||||
pResult->a = 0xFFFFFFFF;
|
||||
pResult->b = 0xFFFFFFFF;
|
||||
pResult->hi = 0xFFFFFFFF;
|
||||
pResult->lo = 0xFFFFFFFF;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -514,8 +513,8 @@ void CInt64_ConvertUFromLongDouble(CInt64 *pResult, double value) {
|
|||
}
|
||||
}
|
||||
|
||||
pResult->a = a;
|
||||
pResult->b = b;
|
||||
pResult->hi = a;
|
||||
pResult->lo = b;
|
||||
}
|
||||
|
||||
void CInt64_ConvertFromLongDouble(CInt64 *pResult, double value) {
|
||||
|
@ -528,18 +527,18 @@ void CInt64_ConvertFromLongDouble(CInt64 *pResult, double value) {
|
|||
}
|
||||
|
||||
double CInt64_ConvertUToLongDouble(const CInt64 *value) {
|
||||
unsigned char bad;
|
||||
unsigned long work;
|
||||
Boolean bad;
|
||||
UInt32 work;
|
||||
int counter;
|
||||
double result;
|
||||
|
||||
bad = (value->a == 0) && (value->b == 0);
|
||||
bad = (value->hi == 0) && (value->lo == 0);
|
||||
if (bad) {
|
||||
return 0.0;
|
||||
} else {
|
||||
result = 0.0;
|
||||
|
||||
work = value->a;
|
||||
work = value->hi;
|
||||
if (work != 0) {
|
||||
for (counter = 0; counter < 32; counter++) {
|
||||
result += result;
|
||||
|
@ -550,7 +549,7 @@ double CInt64_ConvertUToLongDouble(const CInt64 *value) {
|
|||
}
|
||||
|
||||
counter = 0;
|
||||
work = value->b;
|
||||
work = value->lo;
|
||||
for (; counter < 32; counter++) {
|
||||
result += result;
|
||||
if (work & 0x80000000)
|
||||
|
@ -564,7 +563,7 @@ double CInt64_ConvertUToLongDouble(const CInt64 *value) {
|
|||
|
||||
double CInt64_ConvertToLongDouble(const CInt64 *value) {
|
||||
CInt64 tmp;
|
||||
if (value->a & 0x80000000) {
|
||||
if (value->hi & 0x80000000) {
|
||||
tmp = CInt64_Neg(*value);
|
||||
return -CInt64_ConvertUToLongDouble(&tmp);
|
||||
} else {
|
||||
|
@ -572,18 +571,18 @@ double CInt64_ConvertToLongDouble(const CInt64 *value) {
|
|||
}
|
||||
}
|
||||
|
||||
char *CInt64_ScanOctString(CInt64 *pResult, char *str, unsigned char *pFail) {
|
||||
char *CInt64_ScanOctString(CInt64 *pResult, char *str, Boolean *pFail) {
|
||||
int ch;
|
||||
CInt64 tmp;
|
||||
unsigned long a;
|
||||
unsigned long b;
|
||||
UInt32 a;
|
||||
UInt32 b;
|
||||
|
||||
*pFail = 0;
|
||||
pResult->a = pResult->b = 0;
|
||||
pResult->hi = pResult->lo = 0;
|
||||
|
||||
while ((ch = *str) >= '0' && *str <= '7') {
|
||||
a = pResult->a;
|
||||
b = pResult->b;
|
||||
a = pResult->hi;
|
||||
b = pResult->lo;
|
||||
if (a & 0xE0000000)
|
||||
*pFail = 1;
|
||||
|
||||
|
@ -591,8 +590,8 @@ char *CInt64_ScanOctString(CInt64 *pResult, char *str, unsigned char *pFail) {
|
|||
SHIFT_LEFT_ONE(a, b);
|
||||
SHIFT_LEFT_ONE(a, b);
|
||||
|
||||
pResult->a = a;
|
||||
pResult->b = b;
|
||||
pResult->hi = a;
|
||||
pResult->lo = b;
|
||||
|
||||
CInt64_SetLong(&tmp, ch - '0');
|
||||
*pResult = CInt64_Add(*pResult, tmp);
|
||||
|
@ -602,28 +601,28 @@ char *CInt64_ScanOctString(CInt64 *pResult, char *str, unsigned char *pFail) {
|
|||
return str;
|
||||
}
|
||||
|
||||
char *CInt64_ScanDecString(CInt64 *pResult, char *str, unsigned char *pFail) {
|
||||
char *CInt64_ScanDecString(CInt64 *pResult, char *str, Boolean *pFail) {
|
||||
int ch;
|
||||
CInt64 tmp;
|
||||
unsigned long a;
|
||||
unsigned long b;
|
||||
UInt32 a;
|
||||
UInt32 b;
|
||||
|
||||
*pFail = 0;
|
||||
pResult->a = pResult->b = 0;
|
||||
pResult->hi = pResult->lo = 0;
|
||||
|
||||
while ((ch = *str) >= '0' && *str <= '9') {
|
||||
a = pResult->a;
|
||||
b = pResult->b;
|
||||
a = pResult->hi;
|
||||
b = pResult->lo;
|
||||
if (a & 0xE0000000)
|
||||
*pFail = 1;
|
||||
|
||||
SHIFT_LEFT_ONE(a, b);
|
||||
tmp.a = a;
|
||||
tmp.b = b;
|
||||
tmp.hi = a;
|
||||
tmp.lo = b;
|
||||
SHIFT_LEFT_ONE(a, b);
|
||||
SHIFT_LEFT_ONE(a, b);
|
||||
pResult->a = a;
|
||||
pResult->b = b;
|
||||
pResult->hi = a;
|
||||
pResult->lo = b;
|
||||
|
||||
if (CInt64_IsNegative(pResult)) {
|
||||
*pResult = CInt64_Add(*pResult, tmp);
|
||||
|
@ -648,15 +647,15 @@ char *CInt64_ScanDecString(CInt64 *pResult, char *str, unsigned char *pFail) {
|
|||
return str;
|
||||
}
|
||||
|
||||
char *CInt64_ScanHexString(CInt64 *pResult, char *str, unsigned char *pFail) {
|
||||
char *CInt64_ScanHexString(CInt64 *pResult, char *str, Boolean *pFail) {
|
||||
/* NOT MATCHING */
|
||||
int digit;
|
||||
CInt64 tmp;
|
||||
unsigned long a;
|
||||
unsigned long b;
|
||||
UInt32 a;
|
||||
UInt32 b;
|
||||
|
||||
*pFail = 0;
|
||||
pResult->a = pResult->b = 0;
|
||||
pResult->hi = pResult->lo = 0;
|
||||
|
||||
for (;;) {
|
||||
if ((digit = str[0]) >= '0' && digit <= '9')
|
||||
|
@ -668,8 +667,8 @@ char *CInt64_ScanHexString(CInt64 *pResult, char *str, unsigned char *pFail) {
|
|||
else
|
||||
break;
|
||||
|
||||
a = pResult->a;
|
||||
b = pResult->b;
|
||||
a = pResult->hi;
|
||||
b = pResult->lo;
|
||||
++str;
|
||||
|
||||
if (a & 0xF0000000)
|
||||
|
@ -680,8 +679,8 @@ char *CInt64_ScanHexString(CInt64 *pResult, char *str, unsigned char *pFail) {
|
|||
SHIFT_LEFT_ONE(a, b);
|
||||
SHIFT_LEFT_ONE(a, b);
|
||||
|
||||
pResult->a = a;
|
||||
pResult->b = b;
|
||||
pResult->hi = a;
|
||||
pResult->lo = b;
|
||||
|
||||
CInt64_SetLong(&tmp, (char) digit);
|
||||
*pResult = CInt64_Add(*pResult, tmp);
|
||||
|
@ -690,13 +689,13 @@ char *CInt64_ScanHexString(CInt64 *pResult, char *str, unsigned char *pFail) {
|
|||
return str;
|
||||
}
|
||||
|
||||
char *CInt64_ScanBinString(CInt64 *pResult, char *str, unsigned char *pFail) {
|
||||
char *CInt64_ScanBinString(CInt64 *pResult, char *str, Boolean *pFail) {
|
||||
char digit;
|
||||
unsigned long a;
|
||||
unsigned long b;
|
||||
UInt32 a;
|
||||
UInt32 b;
|
||||
|
||||
*pFail = 0;
|
||||
pResult->a = pResult->b = 0;
|
||||
pResult->hi = pResult->lo = 0;
|
||||
|
||||
for (;;) {
|
||||
if (*str == '0')
|
||||
|
@ -706,8 +705,8 @@ char *CInt64_ScanBinString(CInt64 *pResult, char *str, unsigned char *pFail) {
|
|||
else
|
||||
break;
|
||||
|
||||
a = pResult->a;
|
||||
b = pResult->b;
|
||||
a = pResult->hi;
|
||||
b = pResult->lo;
|
||||
++str;
|
||||
|
||||
if (a & 0x80000000)
|
||||
|
@ -715,8 +714,8 @@ char *CInt64_ScanBinString(CInt64 *pResult, char *str, unsigned char *pFail) {
|
|||
|
||||
SHIFT_LEFT_ONE(a, b);
|
||||
|
||||
pResult->a = a;
|
||||
pResult->b = b;
|
||||
pResult->hi = a;
|
||||
pResult->lo = b;
|
||||
|
||||
if (digit == 1)
|
||||
*pResult = CInt64_Add(*pResult, cint64_one);
|
||||
|
@ -725,11 +724,11 @@ char *CInt64_ScanBinString(CInt64 *pResult, char *str, unsigned char *pFail) {
|
|||
return str;
|
||||
}
|
||||
|
||||
char *CInt64_ScanAsmNumber(CInt64 *pResult, char *str, unsigned char *pFail) {
|
||||
unsigned char isMaybeBin;
|
||||
unsigned char isOct;
|
||||
unsigned char isMaybeDec;
|
||||
unsigned char isBin;
|
||||
char *CInt64_ScanAsmNumber(CInt64 *pResult, char *str, Boolean *pFail) {
|
||||
Boolean isMaybeBin;
|
||||
Boolean isOct;
|
||||
Boolean isMaybeDec;
|
||||
Boolean isBin;
|
||||
char *p;
|
||||
|
||||
isMaybeBin = 1;
|
||||
|
@ -794,13 +793,13 @@ int CInt64_PrintDec(char *output, CInt64 value) {
|
|||
}
|
||||
|
||||
if (!CInt64_IsZero(&value)) {
|
||||
divisor.b = 10;
|
||||
divisor.a = 0;
|
||||
divisor.lo = 10;
|
||||
divisor.hi = 0;
|
||||
|
||||
bufp = buf;
|
||||
for (;;) {
|
||||
rem = CInt64_ModU(value, divisor);
|
||||
*(bufp++) = rem.b + '0';
|
||||
*(bufp++) = rem.lo + '0';
|
||||
value = CInt64_DivU(value, divisor);
|
||||
if (CInt64_IsZero(&value) != 0)
|
||||
break;
|
||||
|
@ -829,18 +828,18 @@ int CInt64_PrintHex(char *output, CInt64 value) {
|
|||
|
||||
length = 0;
|
||||
if (!CInt64_IsZero(&value)) {
|
||||
shift.b = 4;
|
||||
shift.a = 0;
|
||||
mask.b = 0xF;
|
||||
mask.a = 0;
|
||||
shift.lo = 4;
|
||||
shift.hi = 0;
|
||||
mask.lo = 0xF;
|
||||
mask.hi = 0;
|
||||
|
||||
bufp = buf;
|
||||
for (;;) {
|
||||
rem = CInt64_And(value, mask);
|
||||
if ((long) rem.b >= 10)
|
||||
*(bufp++) = rem.b + 'A';
|
||||
if ((SInt32) rem.lo >= 10)
|
||||
*(bufp++) = rem.lo + 'A';
|
||||
else
|
||||
*(bufp++) = rem.b + '0';
|
||||
*(bufp++) = rem.lo + '0';
|
||||
value = CInt64_ShrU(value, shift);
|
||||
if (CInt64_IsZero(&value) != 0)
|
||||
break;
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,5 @@
|
|||
#pragma once
|
||||
#ifndef CMDLINE_H
|
||||
#define CMDLINE_H
|
||||
|
||||
#include "cw_common.h"
|
||||
#include "pref_structs.h"
|
||||
|
@ -747,3 +748,5 @@ extern OSErr GetMacFileType(const FSSpec *spec, OSType *mactype);
|
|||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#pragma once
|
||||
#ifndef ROOT_COMMON_H
|
||||
#define ROOT_COMMON_H
|
||||
|
||||
/*
|
||||
* Common imports and Mac OS types
|
||||
|
@ -113,7 +114,7 @@ typedef const unsigned char *ConstStr255Param;
|
|||
// XXX: MacTypes.h defines StrLength() which is an inline for C++ and a macro for C
|
||||
// This might be useful?
|
||||
|
||||
#ifdef __MWERKS__
|
||||
#ifdef __MWERKS__
|
||||
#pragma options align=mac68k
|
||||
#endif
|
||||
typedef struct Point {
|
||||
|
@ -302,3 +303,5 @@ typedef CInfoPBRec *CInfoPBPtr;
|
|||
#ifdef __MWERKS__
|
||||
#pragma options align=reset
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,880 @@
|
|||
#include "compiler/common.h"
|
||||
|
||||
// THESE TYPES ARE NOT YET SORTED
|
||||
#include "compiler/tokens.h"
|
||||
#include "compiler/CompilerTools.h"
|
||||
|
||||
#ifdef __MWERKS__
|
||||
#pragma options align=mac68k
|
||||
#endif
|
||||
|
||||
enum {
|
||||
AlignMode0_Mac68k,
|
||||
AlignMode1_Mac68k4byte,
|
||||
AlignMode2_PPC,
|
||||
AlignMode3_1Byte,
|
||||
AlignMode4_2Byte,
|
||||
AlignMode5_4Byte,
|
||||
AlignMode6_8Byte,
|
||||
AlignMode7_16Byte,
|
||||
AlignMode8
|
||||
};
|
||||
|
||||
// not sure how many of these are char and how many are unsigned char or Boolean
|
||||
typedef struct COpts {
|
||||
char little_endian;
|
||||
char codegen_dynamic;
|
||||
char codegen_pic;
|
||||
char no_common;
|
||||
char no_implicit_templates;
|
||||
char absolutepath; // determines the path written to debug info
|
||||
char x06; // linker/objgen related
|
||||
short cpu;
|
||||
char schedule_cpu;
|
||||
unsigned char schedule_mode; // may be an enum??
|
||||
SInt32 debuglisting;
|
||||
char profile;
|
||||
char traceback;
|
||||
char disable_registers;
|
||||
char fp_contract;
|
||||
char no_register_save_helpers;
|
||||
char ppc_unroll_speculative;
|
||||
short ppc_unroll_instructions_limit;
|
||||
short ppc_unroll_factor_limit;
|
||||
char altivec_model;
|
||||
UInt8 x1B; // altivec/vrsave related
|
||||
UInt8 code_alignment;
|
||||
char x1D;
|
||||
UInt8 x1E; // some register used in TOC_use_isel
|
||||
UInt8 gen_fsel;
|
||||
char ppc_opt_bclr_bcctr;
|
||||
char use_lmw_stmw;
|
||||
char report_heap_info;
|
||||
char misaligned_mem_access;
|
||||
char switch_tables;
|
||||
char prepare_compress;
|
||||
char some_alignment; // used in CMach_AllocationAlignment
|
||||
char asmsemicolcomment;
|
||||
char asmpoundcomment;
|
||||
StringPtr oldprefixname;
|
||||
short inlinelevel;
|
||||
int inline_max_size;
|
||||
int inline_max_total_size;
|
||||
char inline_bottom_up;
|
||||
Boolean cplusplus;
|
||||
Boolean ecplusplus;
|
||||
char objective_c;
|
||||
char objc_strict;
|
||||
char ARM_conform;
|
||||
char ARM_scoping;
|
||||
char require_prototypes;
|
||||
char trigraphs;
|
||||
char only_std_keywords;
|
||||
char enumsalwaysint;
|
||||
char ANSI_strict;
|
||||
char mpwc_relax;
|
||||
char mpwc_newline;
|
||||
char ignore_oldstyle;
|
||||
char cpp_extensions;
|
||||
char pointercast_lvalue;
|
||||
char useRTTI;
|
||||
char delete_exception;
|
||||
char _4B;
|
||||
Boolean oldalignment;
|
||||
char unsignedchars;
|
||||
char multibyteaware;
|
||||
char autoinline;
|
||||
char defer_codegen;
|
||||
Boolean direct_to_som;
|
||||
char som_env_check;
|
||||
char som_call_opt;
|
||||
char booltruefalse;
|
||||
char old_enum_mangler;
|
||||
char longlong;
|
||||
char longlong_enums;
|
||||
char no_tfuncinline;
|
||||
char _59;
|
||||
char flat_include;
|
||||
char syspath_once;
|
||||
char always_import;
|
||||
char simple_class_byval;
|
||||
char wchar_type;
|
||||
char vbase_ctor_offset;
|
||||
char vbase_abi_v2;
|
||||
char def_inherited;
|
||||
char template_patch;
|
||||
char template_friends;
|
||||
char faster_pch_gen;
|
||||
char array_new_delete;
|
||||
Boolean dollar_identifiers;
|
||||
char def_inline_tfuncs;
|
||||
char arg_dep_lookup;
|
||||
Boolean simple_prepdump;
|
||||
char line_prepdump;
|
||||
char fullpath_prepdump;
|
||||
char old_mtemplparser;
|
||||
char suppress_init_code;
|
||||
char reverse_bitfields;
|
||||
Boolean c9x;
|
||||
char float_constants;
|
||||
char no_static_dtors;
|
||||
char longlong_prepeval;
|
||||
char const_strings;
|
||||
char dumpir;
|
||||
char experimental;
|
||||
char gcc_extensions;
|
||||
char stdc_fp_contract;
|
||||
char stdc_fenv_access;
|
||||
char stdc_cx_limitedr;
|
||||
char old_argmatch;
|
||||
char optEH;
|
||||
char optEH2;
|
||||
char new_mangler;
|
||||
char microsoft;
|
||||
Boolean warningerrors;
|
||||
char pedantic;
|
||||
char check_header_flags;
|
||||
Boolean supress_warnings;
|
||||
Boolean warn_illpragma;
|
||||
char warn_emptydecl;
|
||||
char warn_possunwant;
|
||||
char warn_unusedvar;
|
||||
char warn_unusedarg;
|
||||
char warn_extracomma;
|
||||
char warn_hidevirtual;
|
||||
char warn_largeargs;
|
||||
char warn_implicitconv;
|
||||
char warn_notinlined;
|
||||
char warn_structclass;
|
||||
char warn_padding;
|
||||
char warn_no_side_effect;
|
||||
char warn_resultnotused;
|
||||
char warn_ptr_int_conv;
|
||||
char align_mode;
|
||||
Boolean align_array_members;
|
||||
char dont_reuse_strings;
|
||||
char pool_strings;
|
||||
char explicit_zero_data;
|
||||
char readonly_strings;
|
||||
char exceptions;
|
||||
char _99;
|
||||
char dont_inline;
|
||||
char always_inline;
|
||||
char peephole;
|
||||
char global_optimizer;
|
||||
char side_effects;
|
||||
char internal;
|
||||
char import;
|
||||
char export;
|
||||
char lib_export;
|
||||
char nosyminline;
|
||||
char force_active;
|
||||
char optimizationlevel;
|
||||
char optimize_for_size;
|
||||
char optimizewithasm;
|
||||
char crippled;
|
||||
char opt_common_subs;
|
||||
char opt_loop_invariants;
|
||||
char opt_propagation;
|
||||
char opt_dead_assignments;
|
||||
char opt_strength_reduction;
|
||||
char opt_strength_reduction_strict;
|
||||
char opt_dead_code;
|
||||
char opt_lifetimes;
|
||||
char _B1; // unused?
|
||||
char opt_unroll_loops;
|
||||
char opt_vectorize_loops;
|
||||
char _B4; // amount of IRO passes?
|
||||
char opt_pointer_analysis;
|
||||
char opt_pointer_analysis_mode;
|
||||
char loop_unroll_count;
|
||||
char loop_unroll_size_threshold;
|
||||
char isGeneratingDebugInfo;
|
||||
CWDataType pchCreator;
|
||||
CWDataType pchType;
|
||||
CWDataType text;
|
||||
HashNameNode *forcedSegment; // when set by #pragma segment
|
||||
} COpts;
|
||||
|
||||
typedef struct CParams {
|
||||
CWPluginContext context;
|
||||
CWObjectData objectdata;
|
||||
Handle objectDataHandle;
|
||||
Handle browseDataHandle;
|
||||
SInt32 pluginRequest;
|
||||
SInt32 apiVersion;
|
||||
FSSpec projectFile;
|
||||
SInt32 projectFileCount;
|
||||
SInt32 mainFileNumber;
|
||||
FSSpec mainFileSpec;
|
||||
const char *mainFileText;
|
||||
SInt32 mainFileTextLength;
|
||||
Boolean isPrecompiling;
|
||||
Boolean isAutoPrecompiling;
|
||||
Boolean isPreprocessing;
|
||||
Boolean isGeneratingDebugInfo;
|
||||
Boolean isCachingPrecompiledHeaders;
|
||||
CWBrowseOptions browseOptions;
|
||||
Boolean field276;
|
||||
SInt16 mainFileID;
|
||||
CWDataType targetOS;
|
||||
CWDataType targetCPU;
|
||||
char *targetName;
|
||||
} CParams;
|
||||
|
||||
|
||||
typedef struct VarInfo { // OK!
|
||||
Object *func;
|
||||
SInt32 usage;
|
||||
TStreamElement deftoken;
|
||||
SInt16 varnumber;
|
||||
Boolean noregister;
|
||||
Boolean used;
|
||||
UInt8 flags;
|
||||
UInt8 rclass;
|
||||
SInt16 reg;
|
||||
SInt16 regHi;
|
||||
} VarInfo;
|
||||
|
||||
|
||||
|
||||
typedef struct DefArgCtorInfo {
|
||||
Object *default_func;
|
||||
ENode *default_arg;
|
||||
} DefArgCtorInfo;
|
||||
|
||||
typedef struct XRefOffset {
|
||||
UInt32 xrefoffset;
|
||||
SInt32 offset;
|
||||
} XRefOffset;
|
||||
|
||||
typedef struct InlineXRef {
|
||||
struct InlineXRef *next;
|
||||
Object *object;
|
||||
UInt16 xrefmode;
|
||||
UInt16 numxrefs;
|
||||
XRefOffset xref[1];
|
||||
} InlineXRef;
|
||||
|
||||
|
||||
typedef enum StatementType {
|
||||
ST_NOP = 1,
|
||||
ST_LABEL,
|
||||
ST_GOTO,
|
||||
ST_EXPRESSION,
|
||||
ST_SWITCH,
|
||||
ST_IFGOTO,
|
||||
ST_IFNGOTO,
|
||||
ST_RETURN,
|
||||
ST_OVF,
|
||||
ST_EXIT,
|
||||
ST_ENTRY,
|
||||
ST_BEGINCATCH,
|
||||
ST_ENDCATCH,
|
||||
ST_ENDCATCHDTOR,
|
||||
ST_GOTOEXPR,
|
||||
ST_ASM,
|
||||
ST_BEGINLOOP,
|
||||
ST_ENDLOOP,
|
||||
ST_ILLEGAL
|
||||
} StatementType;
|
||||
|
||||
typedef enum ExceptionActionType {
|
||||
EAT_NOP,
|
||||
EAT_DESTROYLOCAL,
|
||||
EAT_DESTROYLOCALCOND,
|
||||
EAT_DESTROYLOCALOFFSET,
|
||||
EAT_DESTROYLOCALPOINTER,
|
||||
EAT_DESTROYLOCALARRAY,
|
||||
EAT_DESTROYPARTIALARRAY,
|
||||
EAT_DESTROYMEMBER,
|
||||
EAT_DESTROYMEMBERCOND,
|
||||
EAT_DESTROYMEMBERARRAY,
|
||||
EAT_DELETEPOINTER,
|
||||
EAT_DELETELOCALPOINTER,
|
||||
EAT_DELETEPOINTERCOND,
|
||||
EAT_CATCHBLOCK,
|
||||
EAT_ACTIVECATCHBLOCK,
|
||||
EAT_SPECIFICATION,
|
||||
EAT_TERMINATE,
|
||||
EAT_DESTROYBASE,
|
||||
EAT_NACTIONS
|
||||
} ExceptionActionType;
|
||||
|
||||
typedef struct ExceptionAction {
|
||||
struct ExceptionAction *prev;
|
||||
union {
|
||||
struct {
|
||||
Object *local;
|
||||
Object *dtor;
|
||||
} destroy_local;
|
||||
struct {
|
||||
Object *local;
|
||||
Object *cond;
|
||||
Object *dtor;
|
||||
} destroy_local_cond;
|
||||
struct {
|
||||
Object *local;
|
||||
Object *dtor;
|
||||
SInt32 offset;
|
||||
} destroy_local_offset;
|
||||
struct {
|
||||
Object *pointer;
|
||||
Object *dtor;
|
||||
} destroy_local_pointer;
|
||||
struct {
|
||||
Object *localarray;
|
||||
Object *dtor;
|
||||
SInt32 elements;
|
||||
SInt32 element_size;
|
||||
} destroy_local_array;
|
||||
struct {
|
||||
Object *arraypointer;
|
||||
Object *arraycounter;
|
||||
Object *dtor;
|
||||
Object *element_size;
|
||||
} destroy_partial_array;
|
||||
struct {
|
||||
Object *objectptr;
|
||||
Object *dtor;
|
||||
SInt32 offset;
|
||||
} destroy_member;
|
||||
struct {
|
||||
Object *objectptr;
|
||||
Object *cond;
|
||||
Object *dtor;
|
||||
SInt32 offset;
|
||||
} destroy_member_cond;
|
||||
struct {
|
||||
Object *objectptr;
|
||||
Object *dtor;
|
||||
SInt32 offset;
|
||||
SInt32 elements;
|
||||
SInt32 element_size;
|
||||
} destroy_member_array;
|
||||
struct {
|
||||
Object *pointerobject;
|
||||
Object *deletefunc;
|
||||
} delete_pointer;
|
||||
struct {
|
||||
Object *pointerobject;
|
||||
Object *deletefunc;
|
||||
Object *cond;
|
||||
} delete_pointer_cond;
|
||||
struct {
|
||||
Object *catch_object;
|
||||
Object *catch_info_object;
|
||||
CLabel *catch_label;
|
||||
Object *catch_typeid;
|
||||
Type *catch_type;
|
||||
UInt32 catch_qual;
|
||||
} catch_block;
|
||||
struct {
|
||||
Object *catch_info_object;
|
||||
Boolean call_dtor;
|
||||
} active_catch_block;
|
||||
struct {
|
||||
SInt32 unexp_ids;
|
||||
Object **unexp_id;
|
||||
CLabel *unexp_label;
|
||||
Object *unexp_info_object;
|
||||
} specification;
|
||||
struct {
|
||||
Object *object;
|
||||
Boolean is_dep;
|
||||
} local;
|
||||
} data;
|
||||
ExceptionActionType type;
|
||||
} ExceptionAction;
|
||||
|
||||
typedef struct Statement {
|
||||
struct Statement *next;
|
||||
StatementType type;
|
||||
char marked;
|
||||
UInt8 flags;
|
||||
UInt16 value;
|
||||
ENode *expr;
|
||||
CLabel *label;
|
||||
ExceptionAction *dobjstack;
|
||||
SInt32 sourceoffset;
|
||||
HashNameNode *sourcefilepath;
|
||||
} Statement;
|
||||
|
||||
typedef struct CLabel {
|
||||
struct CLabel *next;
|
||||
Statement *stmt;
|
||||
HashNameNode *uniquename;
|
||||
HashNameNode *name;
|
||||
PCodeLabel *pclabel;
|
||||
void *sicg_label;
|
||||
} CLabel;
|
||||
|
||||
typedef struct MemInitializer {
|
||||
struct MemInitializer *next;
|
||||
union {
|
||||
ENodeList *nodes;
|
||||
ENode *expr;
|
||||
} e;
|
||||
union {
|
||||
ObjMemberVar *ivar;
|
||||
Type *type;
|
||||
} u;
|
||||
Boolean is_ivar;
|
||||
Boolean is_expr;
|
||||
} MemInitializer;
|
||||
|
||||
|
||||
typedef enum DepNameType {
|
||||
DNT_NAME,
|
||||
DNT_CONVERSION,
|
||||
DNT_DTOR,
|
||||
DNT_NAMESPACE,
|
||||
DNT_QUALNAME,
|
||||
DNT_TEMPLATE,
|
||||
DNT_TYPENAME
|
||||
} DepNameType;
|
||||
|
||||
typedef struct DepName {
|
||||
struct DepName *next;
|
||||
union {
|
||||
HashNameNode *name;
|
||||
NameSpace *nspace;
|
||||
struct {
|
||||
Type *type;
|
||||
UInt32 qual;
|
||||
} conv;
|
||||
struct {
|
||||
HashNameNode *name;
|
||||
TemplArg *args;
|
||||
} templ;
|
||||
struct {
|
||||
HashNameNode *name;
|
||||
Type *type;
|
||||
} tname;
|
||||
} u;
|
||||
DepNameType type;
|
||||
} DepName;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef enum SubKind {
|
||||
SUBKIND_NAMESPACE,
|
||||
SUBKIND_TYPE,
|
||||
SUBKIND_OBJECT
|
||||
} SubKind;
|
||||
|
||||
typedef struct Substitution {
|
||||
struct Substitution *next;
|
||||
union {
|
||||
NameSpace *nspace;
|
||||
struct {
|
||||
Type *type;
|
||||
UInt32 qual;
|
||||
} type;
|
||||
Object *obj;
|
||||
} u;
|
||||
int id;
|
||||
SubKind kind;
|
||||
} Substitution;
|
||||
|
||||
|
||||
// CScope.c
|
||||
extern Boolean cscope_is_member_func;
|
||||
extern Object *cscope_currentfunc;
|
||||
extern TypeClass *cscope_currentclass;
|
||||
extern NameSpace *cscope_current;
|
||||
extern NameSpace *cscope_root;
|
||||
|
||||
typedef struct CScopeSave {
|
||||
NameSpace *current;
|
||||
TypeClass *currentclass;
|
||||
Object *currentfunc;
|
||||
Boolean is_member_func;
|
||||
} CScopeSave; // assumed name
|
||||
|
||||
typedef struct CScopeParseResult {
|
||||
NameSpace *nspace_0;
|
||||
HashNameNode *name_4;
|
||||
Type *x8;
|
||||
void *xC;
|
||||
ObjBase *obj_10;
|
||||
NameSpaceObjectList *nsol_14;
|
||||
BClassList *bcl_18;
|
||||
Boolean x1C;
|
||||
Boolean x1D;
|
||||
Boolean isambig;
|
||||
Boolean x1F;
|
||||
Boolean x20;
|
||||
Boolean x21;
|
||||
} CScopeParseResult;
|
||||
|
||||
typedef struct CScopeNSIterator {
|
||||
NameSpace *nspace;
|
||||
NameSpaceLookupList *lookup;
|
||||
CScopeParseResult *result;
|
||||
} CScopeNSIterator;
|
||||
|
||||
typedef struct CScopeObjectIterator {
|
||||
NameSpace *nspace;
|
||||
NameSpaceName *nextname;
|
||||
NameSpaceObjectList *currlist;
|
||||
int hashindex;
|
||||
} CScopeObjectIterator;
|
||||
|
||||
extern void CScope_Setup();
|
||||
extern void CScope_Cleanup();
|
||||
extern void CScope_GetScope(CScopeSave *save);
|
||||
extern void CScope_SetNameSpaceScope(NameSpace *nspace, CScopeSave *save);
|
||||
extern void CScope_SetClassScope(TypeClass *cls, CScopeSave *save);
|
||||
extern void CScope_SetClassDefScope(TypeClass *cls, CScopeSave *save);
|
||||
extern void CScope_SetFunctionScope(Object *function, CScopeSave *save);
|
||||
extern void CScope_SetMethodScope(Object *function, TypeClass *cls, Boolean unknownFlag, CScopeSave *save);
|
||||
extern void CScope_RestoreScope(CScopeSave *saved);
|
||||
extern Boolean CScope_IsEmptySymTable();
|
||||
extern Boolean CScope_IsInLocalNameSpace(NameSpace *nspace);
|
||||
extern NameSpaceObjectList *CScope_FindName(NameSpace *nspace, HashNameNode *name);
|
||||
extern NameSpaceName *CScope_FindNameSpaceName(NameSpace *nspace, HashNameNode *name);
|
||||
extern NameSpaceObjectList *CScope_InsertName(NameSpace *nspace, HashNameNode *name);
|
||||
extern NameSpaceObjectList *CScope_ArgumentDependentNameLookup(NameSpaceObjectList *list, HashNameNode *name, ENodeList *argNodes, Boolean flag);
|
||||
extern NameSpace *CScope_NewHashNameSpace(HashNameNode *name);
|
||||
extern NameSpace *CScope_NewListNameSpace(HashNameNode *name, Boolean is_global);
|
||||
extern NameSpace *CScope_FindNonClassNonFunctionNS(NameSpace *nspace);
|
||||
extern NameSpace *CScope_FindGlobalNS(NameSpace *nspoce);
|
||||
extern Boolean CScope_IsStdNameSpace(NameSpace *nspace);
|
||||
extern Boolean CScope_IsEmptyNameSpace(NameSpace *nspace);
|
||||
extern void CScope_MergeNameSpace(NameSpace *dst, NameSpace *src);
|
||||
extern void CScope_AddObject(NameSpace *nspace, HashNameNode *name, ObjBase *obj);
|
||||
extern void CScope_AddGlobalObject(Object *obj);
|
||||
extern NameSpaceLookupList *CScope_BuildNameSpaceLookupList(NameSpace *nspace);
|
||||
extern Boolean CScope_FindQualifiedClassMember(CScopeParseResult *result, TypeClass *tclass, HashNameNode *name);
|
||||
extern Type *CScope_GetType(NameSpace *nspace, HashNameNode *name, void **unk6);
|
||||
extern Type *CScope_GetTagType(NameSpace *nspace, HashNameNode *name);
|
||||
extern Boolean CScope_ParseExprName(CScopeParseResult *result);
|
||||
extern Boolean CScope_ParseDeclName(CScopeParseResult *result);
|
||||
extern Boolean CScope_ParseQualifiedNameSpace(CScopeParseResult *result, Boolean flag1, Boolean flag2);
|
||||
extern Boolean CScope_ParseElaborateName(CScopeParseResult *result);
|
||||
extern Boolean CScope_FindObject(NameSpace *nspace, CScopeParseResult *result, HashNameNode *name);
|
||||
extern Boolean CScope_FindNonClassObject(NameSpace *nspace, CScopeParseResult *result, HashNameNode *name);
|
||||
extern NameSpaceObjectList *CScope_FindObjectList(CScopeParseResult *result, HashNameNode *name);
|
||||
extern Boolean CScope_PossibleTypeName(HashNameNode *name);
|
||||
extern Boolean CScope_FindClassMemberObject(TypeClass *tclass, CScopeParseResult *result, HashNameNode *name);
|
||||
extern void CScope_InitObjectIterator(CScopeObjectIterator *iterator, NameSpace *nspace);
|
||||
extern ObjBase *CScope_NextObjectIteratorObject(CScopeObjectIterator *iterator);
|
||||
extern NameSpaceObjectList *CScope_NextObjectIteratorObjectList(CScopeObjectIterator *iterator);
|
||||
extern void CScope_DefineTypeTag(NameSpace *nspace, HashNameNode *name, Type *type);
|
||||
extern Type *CScope_GetLocalTagType(NameSpace *nspace, HashNameNode *name);
|
||||
extern Boolean CScope_FindTypeName(NameSpace *nspace, HashNameNode *name, CScopeParseResult *result);
|
||||
extern NameSpaceObjectList *CScope_GetLocalObject(NameSpace *nspace, HashNameNode *name);
|
||||
extern BClassList *CScope_GetClassAccessPath(BClassList *list, TypeClass *tclass);
|
||||
extern Boolean CScope_ParseMemberName(TypeClass *tclass, CScopeParseResult *result, Boolean flag);
|
||||
extern void CScope_AddClassUsingDeclaration(TypeClass *tclass, TypeClass *tclass2, HashNameNode *name, AccessType access);
|
||||
extern void CScope_ParseUsingDeclaration(NameSpace *nspace, AccessType access);
|
||||
extern void CScope_ParseNameSpaceAlias(HashNameNode *name);
|
||||
extern void CScope_ParseUsingDirective(NameSpace *nspace);
|
||||
|
||||
// CMachine.c
|
||||
extern TypeIntegral stbool;
|
||||
extern TypeIntegral stchar;
|
||||
extern TypeIntegral stsignedchar;
|
||||
extern TypeIntegral stunsignedchar;
|
||||
extern TypeIntegral stwchar;
|
||||
extern TypeIntegral stsignedshort;
|
||||
extern TypeIntegral stunsignedshort;
|
||||
extern TypeIntegral stsignedint;
|
||||
extern TypeIntegral stunsignedint;
|
||||
extern TypeIntegral stsignedlong;
|
||||
extern TypeIntegral stunsignedlong;
|
||||
extern TypeIntegral stsignedlonglong;
|
||||
extern TypeIntegral stunsignedlonglong;
|
||||
extern TypeIntegral stfloat;
|
||||
extern TypeIntegral stshortdouble;
|
||||
extern TypeIntegral stdouble;
|
||||
extern TypeIntegral stlongdouble;
|
||||
|
||||
extern TypeStruct stvectorunsignedchar;
|
||||
extern TypeStruct stvectorsignedchar;
|
||||
extern TypeStruct stvectorboolchar;
|
||||
extern TypeStruct stvectorunsignedshort;
|
||||
extern TypeStruct stvectorsignedshort;
|
||||
extern TypeStruct stvectorboolshort;
|
||||
extern TypeStruct stvectorunsignedlong;
|
||||
extern TypeStruct stvectorsignedlong;
|
||||
extern TypeStruct stvectorboollong;
|
||||
extern TypeStruct stvectorfloat;
|
||||
extern TypeStruct stvectorpixel;
|
||||
extern TypeStruct stvector;
|
||||
|
||||
extern void CMach_Configure();
|
||||
extern SInt32 CMach_GetQUALalign(UInt32 qual);
|
||||
extern SInt32 CMach_ArgumentAlignment(Type *type);
|
||||
extern SInt32 CMach_AllocationAlignment(Type *type, UInt32 qual);
|
||||
extern CInt64 CMach_CalcIntDiadic(Type *type, CInt64 left, short op, CInt64 right);
|
||||
extern CInt64 CMach_CalcIntMonadic(Type *type, short op, CInt64 val);
|
||||
extern CInt64 CMach_CalcIntConvertFromFloat(Type *type, Float fval);
|
||||
extern void CMach_InitIntMem(Type *type, CInt64 val, void *mem);
|
||||
extern void CMach_InitVectorMem(Type *type, MWVector128 val, void *mem);
|
||||
extern Float CMach_CalcFloatDiadic(Type *type, Float left, short op, Float right);
|
||||
extern Float CMach_CalcFloatMonadic(Type *type, short op, Float fval);
|
||||
extern Boolean CMach_CalcFloatDiadicBool(Type *type, Float left, short op, Float right);
|
||||
extern Boolean CMach_CalcVectorDiadicBool(Type *type, MWVector128 *left, short op, MWVector128 *right);
|
||||
extern char *CMach_FloatScan(char *input, Float *result, Boolean *fail);
|
||||
extern Float CMach_CalcFloatConvertFromInt(Type *type, CInt64 val);
|
||||
extern Float CMach_CalcFloatConvert(Type *type, Float fval);
|
||||
extern Boolean CMach_FloatIsZero(Float fval);
|
||||
extern Boolean CMach_FloatIsOne(Float fval);
|
||||
extern Boolean CMach_FloatIsNegOne(Float fval);
|
||||
extern void CMach_InitFloatMem(Type *type, Float val, void *mem);
|
||||
extern void CMach_PrintFloat(char *buf, Float val);
|
||||
extern void CMach_PragmaParams();
|
||||
extern void CMach_AdjustFuntionArgs();
|
||||
extern SInt16 CMach_GetStructAlign(TypeStruct *tstruct);
|
||||
extern SInt16 CMach_GetClassAlign(TypeClass *tclass);
|
||||
extern SInt16 CMach_GetTypeAlign(Type *type);
|
||||
extern SInt16 CMach_MemberAlignValue(Type *type, SInt32 var);
|
||||
extern void CMach_StructLayoutInitOffset(SInt32 offset);
|
||||
extern SInt32 CMach_StructLayoutGetCurSize();
|
||||
extern SInt32 CMach_StructLayoutGetOffset(Type *type, UInt32 qual);
|
||||
extern SInt32 CMach_StructLayoutBitfield(TypeBitfield *tbitfield, UInt32 qual);
|
||||
extern UInt8 CMach_GetFunctionResultClass(TypeFunc *tfunc);
|
||||
extern Boolean CMach_PassResultInHiddenArg(Type *type);
|
||||
extern const char *CMach_GetCPU();
|
||||
extern Boolean CMach_FloatIsPowerOf2(Float flt);
|
||||
extern Float CMach_FloatReciprocal(Float flt);
|
||||
extern SInt32 CMach_RoundedSizeOf(Object *object);
|
||||
extern void CMach_ReInitRuntimeObjects();
|
||||
|
||||
// CPrep.c
|
||||
typedef struct Macro {
|
||||
struct Macro *next;
|
||||
HashNameNode *name;
|
||||
void *c;
|
||||
Boolean xC;
|
||||
Boolean xD;
|
||||
Boolean is_special;
|
||||
Boolean xF;
|
||||
void *e;
|
||||
} Macro;
|
||||
typedef struct TokenStack {
|
||||
char *pos;
|
||||
char *macrostart;
|
||||
Macro *macro;
|
||||
Boolean macrocheck;
|
||||
} TokenStack;
|
||||
|
||||
extern CParams *cparamblkptr;
|
||||
extern short tk;
|
||||
extern CInt64 tkintconst;
|
||||
extern Float tkfloatconst;
|
||||
extern char *tkstring;
|
||||
extern HashNameNode *tkidentifier;
|
||||
extern SInt32 tksize;
|
||||
extern short ispascalstring;
|
||||
extern short nlflag;
|
||||
extern SInt32 lines;
|
||||
extern Boolean spaceskip;
|
||||
extern struct Macro **macrohashtable;
|
||||
extern Boolean cprep_nomem_exit;
|
||||
extern Boolean cprep_nostring;
|
||||
extern Boolean cprep_eoltokens;
|
||||
extern TokenStack tokenstack[128];
|
||||
extern short tokenstacklevel;
|
||||
extern SInt32 cprep_cursymfile; // might be a ptr?
|
||||
extern char *pos;
|
||||
extern char *macropos;
|
||||
extern char *nextcharpos;
|
||||
extern char CPrep_SkipNewCommentChar;
|
||||
extern Boolean preprocessing_only;
|
||||
extern Handle stringmem;
|
||||
extern SInt32 maxstringsize;
|
||||
extern char cprep_idarray[256];
|
||||
extern Boolean was_escchar;
|
||||
extern Boolean macrocheck;
|
||||
extern Boolean widestring;
|
||||
extern Boolean at_linestart;
|
||||
extern char *prep_file_start;
|
||||
extern char *prep_file_end;
|
||||
extern char *macrostart;
|
||||
extern Boolean cprep_strconcat;
|
||||
extern CPrepFileInfo *prep_file;
|
||||
extern short filesp;
|
||||
extern SInt32 linenumber;
|
||||
extern GList pplist;
|
||||
extern TStreamElement *ts_current;
|
||||
extern SInt32 ts_preread_elements;
|
||||
|
||||
extern void CPrep_InsertSpecialMacro(Macro *macro, char *name);
|
||||
extern void CPrep_InsertSpecialMacros();
|
||||
extern void CPrep_RemoveSpecialMacros();
|
||||
extern Boolean setupprep();
|
||||
extern void cleanupprep();
|
||||
extern void CPrep_TSBufferGrow(int amount);
|
||||
extern void CPrep_TokenStreamGetState(SInt32 *state);
|
||||
extern void CPrep_TokenStreamSetState(SInt32 *state);
|
||||
extern void CPrep_UnLex();
|
||||
extern void CPrep_TokenStreamSetCurState(SInt32 *state);
|
||||
extern void CPrep_StreamGetBlock();
|
||||
extern void CPrep_StreamGetSemicolon();
|
||||
extern void CPrep_StreamGetTemplate();
|
||||
extern void CPrep_StreamInsert();
|
||||
extern void CPrep_StreamRemove();
|
||||
extern void CPrep_RemoveTokens();
|
||||
extern void CPrep_TokenStreamFlush();
|
||||
extern void CPrep_CurStreamElement();
|
||||
extern void CPrep_GetTokenContext(TStreamElement *token, CPrepFileInfo **tokenfile, SInt32 *selectionoffset, short *tokensize, SInt32 *linenumber, char *buf1, short *tokenoffset, short *tokenlength, char *buf2, short *lastarg);
|
||||
extern void CPrep_Error(short code);
|
||||
extern void CPrep_ErrorName(short code, const char *name);
|
||||
extern void CPrep_Warning(short code);
|
||||
extern void CPrep_WarningName(short code, const char *name);
|
||||
extern void CPrep_ErrorMessage(int errTable, char *str, Boolean flag1, Boolean flag2);
|
||||
extern void CPrep_ErrorMessageVA(int code, const char *format, va_list list, Boolean flag1, Boolean flag2);
|
||||
extern void popfile();
|
||||
extern void CPrep_SetSourceFile();
|
||||
extern void CPrep_GetSourceFilePath();
|
||||
extern void CPrep_NewFileOffsetInfo();
|
||||
extern void CPrep_GetFileOffsetInfo();
|
||||
extern void CPrep_GetFileOffsetInfo2();
|
||||
extern void CPrep_ResetFileInfo();
|
||||
extern void CPrep_GetPrepPos();
|
||||
extern Boolean C_Compiler(CParams *param);
|
||||
extern void poptokenseq();
|
||||
extern void foundnl();
|
||||
extern void newline();
|
||||
extern short notendofline();
|
||||
extern char *CPrep_GetFileName(char *buffer, Boolean flag1, Boolean flag2);
|
||||
extern void macrotest();
|
||||
extern void CPrep_PragmaLex();
|
||||
extern void CPrep_PushOption();
|
||||
extern void CPrep_PopOption();
|
||||
extern void preprocessor();
|
||||
extern void CPrep_BrowserTokenOffset();
|
||||
extern void CPrep_BrowserFileOffset();
|
||||
extern void CPrep_BrowserFilePosition(CPrepFileInfo **fileinfo, SInt32 *offset);
|
||||
extern CPrepFileInfo *CPrep_BrowserCurrentFile();
|
||||
|
||||
// CPrepTokenizer.c
|
||||
extern short prepskipnextchar();
|
||||
extern short prepnextchar();
|
||||
extern short prepnextstringchar(char *str, Boolean flag);
|
||||
extern void CPrep_MatchChar(char ch, Boolean flag);
|
||||
extern char *CPrep_MatchChar2(char *str, char ch, Boolean flag);
|
||||
extern short prepcurchar();
|
||||
extern char *ReadIdentifier(char *str);
|
||||
extern char *CPrep_SkipNewComment(char *str);
|
||||
extern Boolean skipendoflinematch(char *str, Boolean flag);
|
||||
extern void skipendofline();
|
||||
extern void CPrep_SkipAsmComment();
|
||||
extern short lookahead();
|
||||
extern short lookahead_noeol();
|
||||
extern short lex();
|
||||
extern short plex();
|
||||
extern short lexidentifier();
|
||||
|
||||
// LOOSE DECLS
|
||||
extern Boolean C_Compiler(CParams *param);
|
||||
extern void PrecompilerRead(short refnum, void *buffer);
|
||||
extern void CodeGen_InitCompiler();
|
||||
extern void CodeGen_TermCompiler();
|
||||
extern void CodeGen_InitBackEndOptions();
|
||||
extern void CodeGen_UpdateOptimizerOptions();
|
||||
extern void CodeGen_UpdateBackEndOptions();
|
||||
extern void MWUnmangle(const char *name, char *buf, int size);
|
||||
extern COpts copts;
|
||||
extern CParams *cparamblkptr;
|
||||
extern FuncArg elipsis;
|
||||
extern FuncArg oldstyle;
|
||||
extern HashNameNode *constructor_name_node;
|
||||
extern HashNameNode *destructor_name_node;
|
||||
extern char *CMangler_GetOperator(HashNameNode *str);
|
||||
extern jmp_buf errorreturn;
|
||||
extern Boolean cprep_nomem_exit;
|
||||
extern Boolean anyerrors;
|
||||
extern Boolean fatalerrors;
|
||||
extern SInt32 lines;
|
||||
extern char string[256];
|
||||
extern TemplStack *ctempl_curinstance;
|
||||
typedef struct ParserTryBlock {
|
||||
struct ParserTryBlock *next;
|
||||
jmp_buf jmpbuf;
|
||||
NameSpace *cscope_current;
|
||||
TypeClass *cscope_currentclass;
|
||||
Object *cscope_currentfunc;
|
||||
TemplStack *ctempl_curinstance;
|
||||
TStreamElement *cerror_locktoken;
|
||||
Boolean cscope_is_member_func;
|
||||
} ParserTryBlock;
|
||||
extern ParserTryBlock *trychain;
|
||||
extern Boolean in_assembler;
|
||||
extern Boolean preprocessing_only;
|
||||
extern void AssemblerError();
|
||||
#include "compiler/types.h"
|
||||
extern short tk;
|
||||
extern HashNameNode *tkidentifier;
|
||||
extern short lex();
|
||||
extern short notendofline();
|
||||
extern short lookahead();
|
||||
extern Object *CClass_Constructor(TypeClass *tclass);
|
||||
extern Object *CClass_Destructor(TypeClass *tclass);
|
||||
extern int CClass_CheckPures(TypeClass *tclass);
|
||||
extern Boolean CParser_IsPublicRuntimeObject(Object *obj);
|
||||
extern Boolean CParser_ParseOperatorName(short *token, Boolean flag1, Boolean flag2);
|
||||
extern Boolean CTemplTool_EqualArgs(TemplArg *a, TemplArg *b);
|
||||
extern TypeTemplDep *CDecl_NewTemplDepType(TypeTemplDepType tdtype);
|
||||
extern GList name_mangle_list;
|
||||
extern void CPrep_UnLex();
|
||||
extern Type *CTempl_ClassGetType(TypeClass *tclass);
|
||||
extern short is_typesame(Type *t1, Type *t2);
|
||||
extern Boolean is_unsigned(Type *type);
|
||||
extern void CDecl_CompleteType(Type *type);
|
||||
extern TemplArg *CTempl_ParseUncheckTemplArgs(void *fixmelater, Boolean flag);
|
||||
extern SInt32 CClass_VirtualBaseOffset(TypeClass *tclass, TypeClass *base);
|
||||
extern Boolean CClass_IsMoreAccessiblePath(BClassList *a, BClassList *b);
|
||||
extern Boolean CClass_ClassDominates(TypeClass *a, TypeClass *b);
|
||||
extern Boolean CParser_CheckTemplateClassUsage(TemplClass *tmclass, Boolean flag);
|
||||
extern Type *CTempl_ParseTemplTemplParam(Type *t);
|
||||
extern void CClass_CheckPathAccess(BClassList *bcl, void *unk, AccessType access);
|
||||
extern BClassList *CClass_GetPathCopy(BClassList *path, Boolean flag);
|
||||
extern AccessType global_access;
|
||||
extern UInt32 CParser_GetTypeQualifiers(Type *type, UInt32 qual);
|
||||
extern void CTemplClass_RegisterUsingDecl(TemplClass *tclass, Type *target, AccessType access);
|
||||
extern void CodeGen_InsertSpecialMacros();
|
||||
extern char *CodeGen_ExpandSpecialMacro(Macro *macro);
|
||||
extern void CPrep_PreprocessDumpFileInfo(Boolean flag);
|
||||
extern Boolean gForceSourceLoc;
|
||||
extern void ObjGen_SegmentName(); // might take an arg, not sure since it's empty
|
||||
|
||||
enum {
|
||||
CPU_PPC401,
|
||||
CPU_PPC403,
|
||||
CPU_PPC505,
|
||||
CPU_PPC509,
|
||||
CPU_PPC555,
|
||||
CPU_PPC601,
|
||||
CPU_PPC602,
|
||||
CPU_PPC603,
|
||||
CPU_PPC603e,
|
||||
CPU_PPC604,
|
||||
CPU_PPC604e,
|
||||
CPU_PPC740,
|
||||
CPU_PPC750,
|
||||
CPU_PPC801,
|
||||
CPU_PPC821,
|
||||
CPU_PPC823,
|
||||
CPU_PPC850,
|
||||
CPU_PPC860,
|
||||
CPU_PPC8240,
|
||||
CPU_PPC8260,
|
||||
CPU_PPC7400 = 0x15,
|
||||
CPU_PPCGEKKO,
|
||||
CPU_PPCELF,
|
||||
CPU_PPC7450,
|
||||
CPU_PPC556,
|
||||
CPU_PPC565
|
||||
};
|
||||
|
||||
extern char *ScanFloat(char *input, double *output, Boolean *fail);
|
||||
|
||||
#ifdef __MWERKS__
|
||||
#pragma options align=reset
|
||||
#endif
|
|
@ -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
|
|
@ -1,9 +1,7 @@
|
|||
#pragma once
|
||||
#ifndef COMPILER_CINT64_H
|
||||
#define COMPILER_CINT64_H
|
||||
|
||||
typedef struct _CInt64 {
|
||||
long a;
|
||||
unsigned long b;
|
||||
} CInt64;
|
||||
#include "compiler/common.h"
|
||||
|
||||
// make sure this is in the right place
|
||||
extern const CInt64 cint64_negone;
|
||||
|
@ -13,23 +11,26 @@ extern const CInt64 cint64_max;
|
|||
extern const CInt64 cint64_min;
|
||||
|
||||
inline int CInt64_IsNegative(const CInt64 *n) {
|
||||
return (n->a & 0x80000000) != 0;
|
||||
return (n->hi & 0x80000000) != 0;
|
||||
}
|
||||
inline void CInt64_SetLong(CInt64 *pN, long n) {
|
||||
pN->b = n;
|
||||
pN->a = (n < 0) ? 0xFFFFFFFF : 0;
|
||||
inline void CInt64_SetLong(CInt64 *pN, SInt32 n) {
|
||||
pN->lo = n;
|
||||
pN->hi = (n < 0) ? 0xFFFFFFFF : 0;
|
||||
}
|
||||
inline void CInt64_SetULong(CInt64 *pN, unsigned long n) {
|
||||
pN->b = n;
|
||||
pN->a = 0;
|
||||
inline void CInt64_SetULong(CInt64 *pN, UInt32 n) {
|
||||
pN->lo = n;
|
||||
pN->hi = 0;
|
||||
}
|
||||
|
||||
// i don't think this one is real lol
|
||||
inline int CInt64_IsZero(CInt64 *n) {
|
||||
return n->a == 0 && n->b == 0;
|
||||
//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->a = (n->b >> 31) ? 0xFFFFFFFF : 0;
|
||||
n->hi = (n->lo >> 31) ? 0xFFFFFFFF : 0;
|
||||
}
|
||||
|
||||
extern void CInt64_Init();
|
||||
|
@ -50,18 +51,18 @@ 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 unsigned char CInt64_Less(CInt64 lhs, CInt64 rhs);
|
||||
extern unsigned char CInt64_LessU(CInt64 lhs, CInt64 rhs);
|
||||
extern unsigned char CInt64_Greater(CInt64 lhs, CInt64 rhs);
|
||||
extern unsigned char CInt64_GreaterU(CInt64 lhs, CInt64 rhs);
|
||||
extern unsigned char CInt64_LessEqual(CInt64 lhs, CInt64 rhs);
|
||||
extern unsigned char CInt64_LessEqualU(CInt64 lhs, CInt64 rhs);
|
||||
extern unsigned char CInt64_GreaterEqual(CInt64 lhs, CInt64 rhs);
|
||||
extern unsigned char CInt64_GreaterEqualU(CInt64 lhs, CInt64 rhs);
|
||||
extern unsigned char CInt64_Equal(CInt64 lhs, CInt64 rhs);
|
||||
extern unsigned char CInt64_NotEqual(CInt64 lhs, CInt64 rhs);
|
||||
extern unsigned char CInt64_IsInRange(CInt64 value, short len);
|
||||
extern unsigned char CInt64_IsInURange(CInt64 value, short len);
|
||||
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);
|
||||
|
@ -75,11 +76,13 @@ 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, unsigned char *pFail);
|
||||
extern char *CInt64_ScanDecString(CInt64 *pResult, char *str, unsigned char *pFail);
|
||||
extern char *CInt64_ScanHexString(CInt64 *pResult, char *str, unsigned char *pFail);
|
||||
extern char *CInt64_ScanBinString(CInt64 *pResult, char *str, unsigned char *pFail);
|
||||
extern char *CInt64_ScanAsmNumber(CInt64 *pResult, char *str, unsigned char *pFail);
|
||||
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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -1,4 +1,5 @@
|
|||
#pragma once
|
||||
#ifndef ROOT_CW_COMMON_H
|
||||
#define ROOT_CW_COMMON_H
|
||||
|
||||
/*
|
||||
* Things that seem to be shared across different CodeWarrior modules
|
||||
|
@ -41,3 +42,5 @@ typedef struct ParserPluginCallbacks {
|
|||
CWPLUGIN_ENTRY (*SupportsPlugin)(const CLPluginInfo *pluginfo, OSType cpu, OSType os, Boolean *isSupported);
|
||||
CWPLUGIN_ENTRY (*SupportsPanels)(int numPanels, const char **panelNames, Boolean *isSupported);
|
||||
} ParserPluginCallbacks;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#pragma once
|
||||
#ifndef CMDLINE_OSLIB_H
|
||||
#define CMDLINE_OSLIB_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define OS_PATHSEP '/'
|
||||
|
@ -236,3 +238,5 @@ extern int HPrintF(Handle text, const char *format, ...);
|
|||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -211,9 +211,9 @@ typedef struct PFrontEndC {
|
|||
Boolean ecplusplus;
|
||||
Boolean objective_c;
|
||||
Boolean defer_codegen;
|
||||
Boolean templateparser;
|
||||
Boolean c99;
|
||||
Boolean bottomupinline;
|
||||
// Boolean templateparser;
|
||||
// Boolean c99;
|
||||
// Boolean bottomupinline;
|
||||
} PFrontEndC;
|
||||
|
||||
typedef struct PWarningC {
|
||||
|
|
2
notes
2
notes
|
@ -59,7 +59,7 @@ DONE compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/libimp-ma
|
|||
|
||||
---- CCompiler.c
|
||||
---- CParser.c
|
||||
---- compiler_and_linker/FrontEnd/Common/CompilerTools.c
|
||||
DONE compiler_and_linker/FrontEnd/Common/CompilerTools.c (except for endian work)
|
||||
---- CodeGenOptPPC.c
|
||||
---- IrOptimizer.c
|
||||
---- CodeGen.c
|
||||
|
|
|
@ -64,7 +64,10 @@ MWC_FLAGS="-c -g -opt l=4,noschedule,speed -enum min -Iincludes -Isdk_hdrs -w al
|
|||
#
|
||||
#~/bin/mwccppc $MWC_FLAGS -o objs/cc-mach-ppc-mw.o compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Static/cc-mach-ppc-mw.c
|
||||
#
|
||||
~/bin/mwccppc $MWC_FLAGS -o objs/CCompiler.o compiler_and_linker/unsorted/CCompiler.c
|
||||
#
|
||||
#~/bin/mwccppc $MWC_FLAGS -o objs/Arguments.o unsorted/Arguments.c
|
||||
~/bin/mwccppc $MWC_FLAGS -o objs/CmdLineBuildDate.o unsorted/CmdLineBuildDate.c
|
||||
#~/bin/mwccppc $MWC_FLAGS -o objs/Help.o unsorted/Help.c
|
||||
#~/bin/mwccppc $MWC_FLAGS -o objs/IO.o unsorted/IO.c
|
||||
#~/bin/mwccppc $MWC_FLAGS -o objs/OptimizerHelpers.o unsorted/OptimizerHelpers.c
|
||||
|
@ -87,3 +90,5 @@ MWC_FLAGS="-c -g -opt l=4,noschedule,speed -enum min -Iincludes -Isdk_hdrs -w al
|
|||
#~/bin/mwccppc $MWC_FLAGS -o objs/uCOS.o unsorted/uCOS.c
|
||||
#~/bin/mwccppc $MWC_FLAGS -o objs/uLibImporter.o unsorted/uLibImporter.c
|
||||
#~/bin/mwccppc $MWC_FLAGS -o objs/Utils.o unsorted/Utils.c
|
||||
|
||||
ld /usr/lib/crt1.o objs/*.o -framework System /Applications/Metrowerks\ CodeWarrior\ 7.0/Metrowerks\ CodeWarrior/MacOS\ X\ Support/Libraries/Runtime/Libs/MSL_Runtime_Mach-O.a
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
const char *CMDLINE_BUILD_TIME = "19:36:14";
|
||||
const char *CMDLINE_BUILD_DATE = "Aug 25 2001";
|
Loading…
Reference in New Issue