fix various inaccuracies exposed by the mach ppc plugin

This commit is contained in:
Ash Wolf 2023-01-20 00:39:43 +00:00
parent 4d670146b4
commit 7d986adf37
24 changed files with 429 additions and 422 deletions

View File

@ -8,7 +8,7 @@ include_directories(includes)
include_directories(sdk_hdrs)
# add_compile_definitions(CW_ENABLE_IRO_DEBUG)
add_compile_definitions(CW_ENABLE_PCODE_DEBUG CW_TARGET_MACH CW_CLT)
add_compile_definitions(CW_ENABLE_PCODE_DEBUG CW_TARGET_MACH CW_CLT CW_REPLICATE_PPC_CODEGEN_BUG)
add_executable(mwcc
command_line/CmdLine/Src/Clients/CLStaticMain.c

View File

@ -51,8 +51,10 @@ static void prepmacro(Macro *macro);
static void prepifskip(void);
static void gotonexttoken(void);
#ifdef CW_CLT
extern SInt16 *CLT_filesp;
extern CPrepFileInfo **CLT_filestack;
#endif
struct CompilerOption {
char *name;
@ -390,8 +392,10 @@ Boolean setupprep(void) {
tokenstacklevel = 0;
cprep_cursymfile = 0;
cprep_files = 0;
#ifdef CW_CLT
CLT_filesp = &filesp;
CLT_filestack = filestack;
#endif
anyerrors = 0;
fatalerrors = 0;
was_prep_error = 0;
@ -403,11 +407,9 @@ Boolean setupprep(void) {
if (InitGList(&mlist, 10000))
CError_NoMem();
stringmem = COS_NewHandle(256);
if (!stringmem)
if (!(stringmem = COS_NewHandle(256)))
CError_NoMem();
ts_buffer = COS_NewHandle(1024 * sizeof(TStreamElement));
if (!ts_buffer)
if (!(ts_buffer = COS_NewHandle(1024 * sizeof(TStreamElement))))
CError_NoMem();
COS_LockHandleHi(ts_buffer);
ts_first = (TStreamElement *) *ts_buffer;
@ -495,7 +497,7 @@ static Boolean setupfile(StringPtr filename, Boolean flag1, Boolean flag2) {
SInt16 refnum;
SInt16 file_vrefnum;
char *extpos;
unsigned char *src;
char *src;
char *append;
char *dst;
int len;
@ -519,7 +521,7 @@ static Boolean setupfile(StringPtr filename, Boolean flag1, Boolean flag2) {
if (CWFindAndLoadFile(cparamblkptr->context, myfilename, &fileinfo) != cwNoErr) {
if (filename[0] + strlen(".framework/Headers") < 255) {
if ((extpos = strchr(myfilename, '/'))) {
src = filename + 1;
src = (char *) filename + 1;
append = ".framework/Headers";
dst = myfilename;
len = filename[0];
@ -804,8 +806,8 @@ loop:
void CPrep_StreamGetBlock(TokenStream *stream, CPrepStreamFuncPtr func, int arg) {
Boolean save_eoltokens;
SInt32 start_offset;
Boolean tryflag;
SInt32 start_offset;
SInt32 count;
start_offset = ts_current - ts_first - 1;
@ -997,8 +999,8 @@ void CPrep_TokenStreamFlush(void) {
ts_current = ts_first;
}
static int CPrep_TokenSize(char *str) {
int len;
static short CPrep_TokenSize(char *str) {
short len;
int c;
if ((str[0] >= 'a' && str[0] <= 'z') || (str[0] >= 'A' && str[0] <= 'Z') || (str[0] == '_')) {
@ -1028,16 +1030,31 @@ static int CPrep_TokenSize(char *str) {
if (str[1] == '=' || str[1] == '+') return 2;
break;
case '-':
if (str[1] == '>') return (str[2] == '*') ? 3 : 2;
if (str[1] == '>') {
if (str[2] == '*')
return 3;
else
return 2;
}
if (str[1] == '=' || str[1] == '-') return 2;
break;
case '<':
if (str[1] == '=') return 2;
if (str[1] == '<') return (str[2] == '=') ? 3 : 2;
if (str[1] == '<') {
if (str[2] == '=')
return 3;
else
return 2;
}
break;
case '>':
if (str[1] == '=') return 2;
if (str[1] == '>') return (str[2] == '=') ? 3 : 2;
if (str[1] == '>') {
if (str[2] == '=')
return 3;
else
return 2;
}
break;
case '&':
if (str[1] == '=' || str[1] == '&') return 2;
@ -1087,7 +1104,7 @@ void CPrep_GetTokenContext(TStreamElement *token, CPrepFileInfo **tokenfile, SIn
int r5;
int r6;
char *r7;
char *r5x;
const char *r5x;
SInt16 c;
if (token && !token->tokenfile)
@ -1129,7 +1146,7 @@ void CPrep_GetTokenContext(TStreamElement *token, CPrepFileInfo **tokenfile, SIn
if (!cprep_hasprepline) {
line = 1;
for (i = 0; i < p; i++) {
if (filedata[i] == '\r')
if (filedata[i] == 13)
line++;
}
*plinenumber = line;
@ -1148,17 +1165,19 @@ void CPrep_GetTokenContext(TStreamElement *token, CPrepFileInfo **tokenfile, SIn
}
*tokenoffset = 0;
r5 = 1;
while (r5 < 80 && (r7 - r5) >= r4 && r7[-r5] != '\r')
while (r5 < 80 && (r7 - r5) >= r4 && r7[-r5] != 13)
r5++;
r5--;
while ((c = r7[-r5]) && (c == ' ' || c == '\t' || c == TK_4))
r5--;
r6 = 0;
while ((c = r7[-r5]) != '\r' && c && r6 < 126) {
while ((c = r7[-r5]) != 13 && c && r6 < 126) {
if (!r5)
*tokenoffset = r6;
if (c != TK_4) {
buf1[r6++] = (c != '\t') ? c : ' ';
if (c == '\t')
c = ' ';
buf1[r6++] = c;
}
r5--;
}
@ -1179,8 +1198,8 @@ void CPrep_GetTokenContext(TStreamElement *token, CPrepFileInfo **tokenfile, SIn
r5x = filedata;
*lastarg = p;
}
for (i = 0; i < 31 && *r5x; i++) {
buf2[i] = *(r5x++);
for (i = 0; i < 31 && r5x[i]; i++) {
buf2[i] = r5x[i];
}
buf2[i] = 0;
@ -1577,7 +1596,7 @@ static Boolean is_nextchar(short t) {
return 0;
p = tokenstack[--level].pos;
continue;
case '\r':
case 13:
p++;
continue;
}
@ -1765,7 +1784,7 @@ loop:
}
pos = nextcharpos;
goto loop;
case '\r':
case 13:
newline();
pos = nextcharpos;
goto loop;
@ -1794,7 +1813,7 @@ loop:
poptokenseq();
goto loop;
}
case '\r':
case 13:
return 0;
}
@ -2159,7 +2178,7 @@ static Boolean CPrep_CheckTarget(void) {
}
static Boolean CPrep_CheckOption(void) {
UInt16 offset;
UInt32 offset;
UInt8 *ptr;
struct CompilerOption *option;
Boolean result;
@ -2381,7 +2400,7 @@ char *CPrep_GetFileName(char *buffer, Boolean flag1, Boolean flag2) {
FSSpec spec;
Str255 filename;
int size;
char *src;
StringPtr src;
char *dst;
COS_FileGetFSSpecInfo(&filestack[flag1 ? 0 : filesp]->textfile, NULL, NULL, filename);
@ -2395,7 +2414,7 @@ char *CPrep_GetFileName(char *buffer, Boolean flag1, Boolean flag2) {
if (flag2)
*(dst++) = '"';
src = (char *) filename;
src = filename;
while (size-- > 0)
*(dst++) = *(++src);
@ -2759,32 +2778,29 @@ void CPrep_PopOption(SInt32 id) {
}
static void CPrep_PragmaImExport(int flags) {
// does not match - weirdness with the branching inside the loop
NameSpaceObjectList *list;
do {
if (!notendofline())
break;
if (plex() != TK_IDENTIFIER)
if (
!notendofline() ||
plex() != TK_IDENTIFIER ||
!(list = CScope_GetLocalObject(cscope_root, tkidentifier))
)
break;
if (!(list = CScope_GetLocalObject(cscope_root, tkidentifier))) {
break;
} else {
while (list) {
if (list->object->otype == OT_OBJECT) {
switch (OBJECT(list->object)->datatype) {
case DDATA:
case DFUNC:
OBJECT(list->object)->flags |= flags;
break;
default:
CPrep_Warning(CErrorStr186);
return;
}
while (list) {
if (list->object->otype == OT_OBJECT) {
switch (OBJECT(list->object)->datatype) {
case DDATA:
case DFUNC:
OBJECT(list->object)->flags |= flags;
break;
default:
CPrep_Warning(CErrorStr186);
return;
}
list = list->next;
}
list = list->next;
}
if (!notendofline())
@ -2839,24 +2855,25 @@ static void pragma_on_off_reset(UInt32 bits) {
}
static HashNameNode *CPrep_PragmaOnceName(StringPtr name, Boolean flag) {
// does not match, can't be bothered to fix it atm
short len;
char myname[256];
unsigned char *src;
char buf[256];
char *myname;
char *src;
char *dst;
short len;
len = name[0];
if (len > 250)
len = 250;
dst = &myname[1];
src = &name[1];
myname = &buf[1];
dst = myname;
src = (char *) &name[1];
while (len-- > 0) {
*(dst++) = tolower(*(src++));
}
*dst = 0;
myname[0] = (copts.syspath_once && flag) ? '$' : -'\\';
*(--myname) = (copts.syspath_once && flag) ? '$' : -'\\';
return GetHashNameNodeExport(myname);
}
@ -2935,7 +2952,7 @@ static void CPrep_PragmaUnused(void) {
list = CScope_GetLocalObject(nspace, tkidentifier);
if (list && list->object->otype == OT_OBJECT && OBJECT(list->object)->datatype == DLOCAL) {
OBJECT(list->object)->flags |= OBJECT_FLAGS_1;
OBJECT(list->object)->flags = OBJECT(list->object)->flags | OBJECT_FLAGS_1;
if (notendofline()) {
t = plex();
if (t == ')')
@ -2966,10 +2983,13 @@ static void CPrep_PragmaInlineDepth(void) {
break;
case TK_INTCONST:
lv = CInt64_GetULong(&tkintconst);
if (lv >= 0 && lv <= 1024)
copts.inlinelevel = lv ? lv : -1;
else
if (lv >= 0 && lv <= 1024) {
if (!lv)
lv = -1;
copts.inlinelevel = lv;
} else {
CPrep_Warning(CErrorStr186);
}
break;
default:
CPrep_Warning(CErrorStr186);
@ -4168,7 +4188,7 @@ static void prepifskip(void) {
CPrep_Error(CErrorStr105);
}
goto restart;
case '\r':
case 13:
newline();
goto restart;
case '"':
@ -4181,7 +4201,7 @@ static void prepifskip(void) {
t = prepskipnextchar();
pos = nextcharpos;
switch (t) {
case '\r':
case 13:
goto restart;
case 0:
CPrep_Error(CErrorStr102);
@ -4227,7 +4247,7 @@ void preprocessor(void) {
switch (t) {
case 0:
CPrep_Error(CErrorStr102);
case '\r':
case 13:
return;
}

View File

@ -37,11 +37,11 @@ loop:
goto loop;
case ' ':
case '\t':
case '\n':
case LF:
case '\v':
case '\f':
spaceskip = 1;
p++;
spaceskip = 1;
goto loop;
case ';':
pos = (char *) p++;
@ -64,17 +64,17 @@ loop:
case '/':
pos = (char *) p++;
if (copts.multibyteaware) {
while (p[0] == '\\' && !COS_IsMultiByte(start, p) && p[1] == '\r') {
while (p[0] == '\\' && !COS_IsMultiByte(start, p) && p[1] == CR) {
foundnl();
if (p[2] == '\n')
if (p[2] == LF)
p += 3;
else
p += 2;
}
} else {
while (p[0] == '\\' && p[1] == '\r') {
while (p[0] == '\\' && p[1] == CR) {
foundnl();
if (p[2] == '\n')
if (p[2] == LF)
p += 3;
else
p += 2;
@ -99,17 +99,17 @@ loop:
}
if (c == '*') {
if (copts.multibyteaware) {
while (p[0] == '\\' && !COS_IsMultiByte(start, p) && p[1] == '\r') {
while (p[0] == '\\' && !COS_IsMultiByte(start, p) && p[1] == CR) {
foundnl();
if (p[2] == '\n')
if (p[2] == LF)
p += 3;
else
p += 2;
}
} else {
while (p[0] == '\\' && p[1] == '\r') {
while (p[0] == '\\' && p[1] == CR) {
foundnl();
if (p[2] == '\n')
if (p[2] == LF)
p += 3;
else
p += 2;
@ -120,7 +120,7 @@ loop:
goto loop;
}
}
if (c == '\r')
if (c == CR)
foundnl();
}
}
@ -138,10 +138,10 @@ loop:
case '\\':
pos = (char *) p++;
mid_backslash:
if (*p == '\r') {
if (*p == CR) {
if (!copts.multibyteaware || !COS_IsMultiByte(start, p - 1)) {
foundnl();
if (p[1] == '\n')
if (p[1] == LF)
p += 2;
else
p += 1;
@ -208,17 +208,17 @@ loop:
return c;
case '/':
if (copts.multibyteaware) {
while (p[0] == '\\' && !COS_IsMultiByte(start, p) && p[1] == '\r') {
while (p[0] == '\\' && !COS_IsMultiByte(start, p) && p[1] == CR) {
foundnl();
if (p[2] == '\n')
if (p[2] == LF)
p += 3;
else
p += 2;
}
} else {
while (p[0] == '\\' && p[1] == '\r') {
while (p[0] == '\\' && p[1] == CR) {
foundnl();
if (p[2] == '\n')
if (p[2] == LF)
p += 3;
else
p += 2;
@ -242,17 +242,17 @@ loop:
}
if (c == '*') {
if (copts.multibyteaware) {
while (p[0] == '\\' && !COS_IsMultiByte(start, p) && p[1] == '\r') {
while (p[0] == '\\' && !COS_IsMultiByte(start, p) && p[1] == CR) {
foundnl();
if (p[2] == '\n')
if (p[2] == LF)
p += 3;
else
p += 2;
}
} else {
while (p[0] == '\\' && p[1] == '\r') {
while (p[0] == '\\' && p[1] == CR) {
foundnl();
if (p[2] == '\n')
if (p[2] == LF)
p += 3;
else
p += 2;
@ -261,7 +261,7 @@ loop:
if (*p == '/')
break;
}
if (c == '\r')
if (c == CR)
foundnl();
}
pos = (char *) p + 1;
@ -272,10 +272,10 @@ loop:
}
case '\\':
backslash:
if (*p == '\r') {
if (*p == CR) {
if (!copts.multibyteaware || !COS_IsMultiByte(start, p - 1)) {
foundnl();
if (p[1] == '\n')
if (p[1] == LF)
p += 2;
else
p += 1;
@ -345,12 +345,12 @@ loop:
return c;
case '\\':
backslash:
if (p[0] == '\r' && (!copts.multibyteaware || !COS_IsMultiByte(str, p - 1))) {
if (p[0] == CR && (!copts.multibyteaware || !COS_IsMultiByte(str, p - 1))) {
if (flag)
foundnl();
else
prepnextstringchar_foundnl = 1;
if (p[1] == '\n')
if (p[1] == LF)
p += 2;
else
p += 1;
@ -421,11 +421,11 @@ loop:
return;
}
if (c == '\r') {
if (c == CR) {
if (!copts.multibyteaware || !COS_IsMultiByte(start, p - 1)) {
if (flag)
foundnl();
if (*p == '\n')
if (*p == LF)
p++;
CPrep_Error(CErrorStr112);
pos = p;
@ -445,8 +445,8 @@ loop:
case '<':
case '=':
case '>':
haveBackslash = 0;
p += 2;
haveBackslash = 0;
goto loop;
case '/':
p += 2;
@ -456,10 +456,10 @@ loop:
if (c == '\\' && !haveBackslash && (!copts.multibyteaware || !COS_IsMultiByte(start, p - 1))) {
backslash:
if (*p == '\r') {
if (*p == CR) {
if (flag)
foundnl();
if (*(++p) == '\n')
if (*(++p) == LF)
p++;
haveBackslash = 0;
} else {
@ -496,11 +496,11 @@ loop:
return p - 1;
}
if (c == '\r') {
if (c == CR) {
if (!copts.multibyteaware || !COS_IsMultiByte(start, p - 1)) {
if (flag)
foundnl();
if (*p == '\n')
if (*p == LF)
p++;
CPrep_Error(CErrorStr112);
return p;
@ -519,8 +519,8 @@ loop:
case '<':
case '=':
case '>':
haveBackslash = 0;
p += 2;
haveBackslash = 0;
goto loop;
case '/':
p += 2;
@ -530,10 +530,10 @@ loop:
if (c == '\\' && !haveBackslash && (!copts.multibyteaware || !COS_IsMultiByte(start, p - 1))) {
backslash:
if (*p == '\r') {
if (*p == CR) {
if (flag)
foundnl();
if (*(++p) == '\n')
if (*(++p) == LF)
p++;
haveBackslash = 0;
} else {
@ -582,7 +582,7 @@ static void prepcurstringchar_skip(void) {
}
char *ReadIdentifier(const char *p) {
char buf[256];
unsigned char buf[256];
const char *start;
unsigned int ch;
int len;
@ -590,15 +590,15 @@ char *ReadIdentifier(const char *p) {
start = p;
len = 0;
for (;;) {
ch = (unsigned char) *p;
if (cprep_idarray[ch]) {
ch = *p;
if (cprep_idarray[(unsigned char) *p]) {
if (len < 255)
buf[len++] = *p;
p++;
} else {
if (copts.multibyteaware) {
if ((unsigned char) *p == '\\' && !COS_IsMultiByte(start, p) && p[1] == '\r') {
if (p[2] == '\n')
if ((unsigned char) *p == '\\' && !COS_IsMultiByte(start, p) && p[1] == CR) {
if (p[2] == LF)
p += 3;
else
p += 2;
@ -607,8 +607,8 @@ char *ReadIdentifier(const char *p) {
break;
}
} else {
if ((unsigned char) *p == '\\' && p[1] == '\r') {
if (p[2] == '\n')
if ((unsigned char) *p == '\\' && p[1] == CR) {
if (p[2] == LF)
p += 3;
else
p += 2;
@ -621,7 +621,7 @@ char *ReadIdentifier(const char *p) {
}
buf[len] = 0;
tkidentifier = GetHashNameNodeExport(buf);
tkidentifier = GetHashNameNodeExport((char *) buf);
return (char *) p;
}
@ -807,14 +807,14 @@ static SInt32 nextchar(StringPtr str) {
case 'f': return 12;
case 'n':
if (copts.mpwc_newline)
return 13;
return CR;
else
return 10;
return LF;
case 'r':
if (copts.mpwc_newline)
return 10;
return LF;
else
return 13;
return CR;
case 'e': return 27;
case 'x':
chr = tohex(prepnextstringchar(str, 1));
@ -874,26 +874,26 @@ StringPtr CPrep_SkipNewComment(StringPtr str) {
p[-1] = ' ';
continue;
case '\r':
CPrep_SkipNewCommentChar = '\r';
case CR:
CPrep_SkipNewCommentChar = CR;
return p;
case '\\':
if (copts.multibyteaware && COS_IsMultiByte(str, p - 1))
continue;
if (*p == '\r') {
if (*p == CR) {
++p;
foundnl();
}
if (*p == '\n')
if (*p == LF)
p++;
continue;
case '"':
if (InlineAsm_gccmode) {
CPrep_SkipNewCommentChar = '\r';
CPrep_SkipNewCommentChar = CR;
return p - 1;
}
continue;
@ -910,7 +910,7 @@ Boolean skipendoflinematch(StringPtr str, short token) {
while (1) {
switch (*(str++)) {
case 0:
case '\r':
case CR:
pos = (char *) str - 1;
return 0;
@ -937,16 +937,16 @@ Boolean skipendoflinematch(StringPtr str, short token) {
pos = (char *) str - 1;
return 0;
case '\r':
case CR:
foundnl();
if (*str == '\n')
if (*str == LF)
str++;
break;
}
break;
case '?':
if (copts.trigraphs && str[0] == '?' && str[1] == '/' && str[2] == '\r') {
if (copts.trigraphs && str[0] == '?' && str[1] == '/' && str[2] == CR) {
foundnl();
str += 3;
}
@ -966,7 +966,7 @@ void skipendofline(void) {
while (1) {
switch (*(p++)) {
case 0:
case '\r':
case CR:
pos = (char *) p - 1;
return;
@ -984,17 +984,17 @@ void skipendofline(void) {
case '/':
if (copts.multibyteaware) {
while (*p == '\\' && !COS_IsMultiByte(start, p) && p[1] == '\r') {
while (*p == '\\' && !COS_IsMultiByte(start, p) && p[1] == CR) {
foundnl();
if (p[2] == '\n')
if (p[2] == LF)
p += 3;
else
p += 2;
}
} else {
while (*p == '\\' && p[1] == '\r') {
while (*p == '\\' && p[1] == CR) {
foundnl();
if (p[2] == '\n')
if (p[2] == LF)
p += 3;
else
p += 2;
@ -1004,7 +1004,7 @@ void skipendofline(void) {
if (*p == '/' && (!copts.ANSIstrict || copts.cplusplus)) {
// EOL comment
pos = (char *) CPrep_SkipNewComment(p + 1);
if (CPrep_SkipNewCommentChar == '\r')
if (CPrep_SkipNewCommentChar == CR)
pos--;
return;
}
@ -1026,17 +1026,17 @@ void skipendofline(void) {
if (ch == '*') {
if (copts.multibyteaware) {
while (*p == '\\' && !COS_IsMultiByte(start, p) && p[1] == '\r') {
while (*p == '\\' && !COS_IsMultiByte(start, p) && p[1] == CR) {
foundnl();
if (p[2] == '\n')
if (p[2] == LF)
p += 3;
else
p += 2;
}
} else {
while (*p == '\\' && p[1] == '\r') {
while (*p == '\\' && p[1] == CR) {
foundnl();
if (p[2] == '\n')
if (p[2] == LF)
p += 3;
else
p += 2;
@ -1049,7 +1049,7 @@ void skipendofline(void) {
}
}
if (ch == '\r')
if (ch == CR)
foundnl();
}
}
@ -1059,9 +1059,9 @@ void skipendofline(void) {
if (copts.multibyteaware && COS_IsMultiByte(start, p - 1))
continue;
if (*p == '\r') {
if (*p == CR) {
foundnl();
if (p[1] == '\n')
if (p[1] == LF)
p += 2;
else
p += 1;
@ -1069,7 +1069,7 @@ void skipendofline(void) {
break;
case '?':
if (copts.trigraphs && p[0] == '?' && p[1] == '/' && p[2] == '\r') {
if (copts.trigraphs && p[0] == '?' && p[1] == '/' && p[2] == CR) {
foundnl();
p += 3;
}
@ -1106,7 +1106,7 @@ static short tapos(short _t) {
start = (StringPtr) pos;
t = nextchar((StringPtr) pos);
if ((t == '\'' || t == 0 || t == '\r') && !was_escchar) {
if ((t == '\'' || t == 0 || t == CR) && !was_escchar) {
CPrep_Error(CErrorStr100);
tkintconst = cint64_zero;
tksize = IT_INT;
@ -1169,7 +1169,7 @@ static short tapos(short _t) {
i = bytecount;
while (1) {
if ((t2 == 0 || t2 == '\r') && !was_escchar) {
if ((t2 == 0 || t2 == CR) && !was_escchar) {
CPrep_Error(CErrorStr100);
break;
}
@ -1201,7 +1201,7 @@ static short tapos(short _t) {
static short tquot(short t) {
Type *type;
StringPtr string_ptr;
char *string_ptr;
SInt32 size;
short c;
StringPtr save_pos;
@ -1213,7 +1213,7 @@ static short tquot(short t) {
if (cprep_nostring)
return '"';
string_ptr = (StringPtr) *stringmem;
string_ptr = *stringmem;
ispascalstring = 0;
size = 0;
if (widestring)
@ -1235,7 +1235,7 @@ static short tquot(short t) {
while (1) {
c = nextchar(start_pos);
if ((c == '"' || c == '\r' || c == 0) && !was_escchar) {
if ((c == '"' || c == CR || c == 0) && !was_escchar) {
if (c == 0 && (tokenstacklevel > 0 || pos >= prep_file_end))
CPrep_Error(CErrorStr102);
else if (c != '"')
@ -1243,10 +1243,10 @@ static short tquot(short t) {
break;
}
if ((size + type->size) >= maxstringsize) {
SInt32 offset = string_ptr - (StringPtr) *stringmem;
SInt32 offset = string_ptr - *stringmem;
if (!COS_ResizeHandle(stringmem, maxstringsize += 256))
CError_NoMem();
string_ptr = (StringPtr) *stringmem + offset;
string_ptr = *stringmem + offset;
}
if (type->size != 1) {
CInt64_SetLong(&ch64, c);
@ -2242,7 +2242,7 @@ typedef struct StringChunk {
} StringChunk;
static void CPrep_StringConCat(Boolean flag) {
StringPtr buffer;
char *buffer;
StringChunk *chunks;
StringChunk *chunk;
char *saveString;
@ -2287,7 +2287,7 @@ static void CPrep_StringConCat(Boolean flag) {
}
elem = ts_current - 1;
elem->data.tkstring.data = (char *) buffer;
elem->data.tkstring.data = buffer;
elem->data.tkstring.size = offset;
elem->subtype = ispascalstring;
cprep_strconcat = 0;

View File

@ -1442,7 +1442,7 @@ Type *CScope_GetTagType(NameSpace *nspace, HashNameNode *name) {
static Boolean CScope_DependentTemplateMember(CScopeParseResult *result, TypeTemplDep *ttempldep, Boolean flag1, Boolean flag2) {
SInt32 streamstate;
short token;
int token;
TypeTemplDep *newtype;
TypeTemplDep *newtype2;
@ -2537,30 +2537,30 @@ void CScope_AddClassUsingDeclaration(TypeClass *tclass, TypeClass *tclass2, Hash
void CScope_ParseUsingDeclaration(NameSpace *nspace, AccessType access, Boolean flag) {
NameSpace *saveNSpace;
Boolean flag_r27;
Boolean flag_r26;
Boolean isTemplate;
Boolean isTypename;
NameSpaceObjectList *scan;
CScopeParseResult result;
if (nspace->theclass) {
flag_r27 = (TYPE_CLASS(nspace->theclass)->flags & CLASS_FLAGS_100) ? 1 : 0;
flag_r26 = 0;
isTemplate = (TYPE_CLASS(nspace->theclass)->flags & CLASS_FLAGS_100) != 0;
isTypename = 0;
if (tk == TK_TYPENAME) {
if (!flag_r27)
if (!isTemplate)
CError_Error(CErrorStr200);
flag_r26 = 1;
isTypename = 1;
tk = lex();
}
if (!CScope_ParseMemberName(nspace->theclass, &result, flag_r27)) {
if (!CScope_ParseMemberName(nspace->theclass, &result, isTemplate)) {
CError_Error(CErrorStr200);
return;
}
if (result.x8 && IS_TYPE_TEMPLATE(result.x8) && TYPE_TEMPLATE(result.x8)->dtype == TEMPLDEP_QUALNAME) {
CError_ASSERT(3578, flag_r27);
CError_ASSERT(3578, isTemplate);
if (flag_r26) {
if (isTypename) {
ObjType *objtype = galloc(sizeof(ObjType));
memclrw(objtype, sizeof(ObjType));
objtype->otype = OT_TYPE;

View File

@ -190,8 +190,8 @@ void AppendGListWord(GList *gl, SInt16 theword) {
ptr = *gl->data + gl->size;
gl->size += 2;
*(ptr++) = ((unsigned char *) &theword)[0];
*(ptr++) = ((unsigned char *) &theword)[1];
*(ptr++) = ((char *) &theword)[0];
*(ptr++) = ((char *) &theword)[1];
}
void AppendGListTargetEndianWord(GList *gl, SInt16 theword) {
@ -205,8 +205,8 @@ void AppendGListTargetEndianWord(GList *gl, SInt16 theword) {
ptr = *gl->data + gl->size;
gl->size += 2;
theword = CTool_EndianConvertWord16(theword);
*(ptr++) = ((unsigned char *) &theword)[0];
*(ptr++) = ((unsigned char *) &theword)[1];
*(ptr++) = ((char *) &theword)[0];
*(ptr++) = ((char *) &theword)[1];
}
void AppendGListLong(GList *gl, SInt32 theword) {
@ -219,10 +219,10 @@ void AppendGListLong(GList *gl, SInt32 theword) {
ptr = *gl->data + gl->size;
gl->size += 4;
*(ptr++) = ((unsigned char *) &theword)[0];
*(ptr++) = ((unsigned char *) &theword)[1];
*(ptr++) = ((unsigned char *) &theword)[2];
*(ptr++) = ((unsigned char *) &theword)[3];
*(ptr++) = ((char *) &theword)[0];
*(ptr++) = ((char *) &theword)[1];
*(ptr++) = ((char *) &theword)[2];
*(ptr++) = ((char *) &theword)[3];
}
void AppendGListTargetEndianLong(GList *gl, SInt32 theword) {
@ -236,10 +236,10 @@ void AppendGListTargetEndianLong(GList *gl, SInt32 theword) {
ptr = *gl->data + gl->size;
gl->size += 4;
theword = CTool_EndianConvertWord32(theword);
*(ptr++) = ((unsigned char *) &theword)[0];
*(ptr++) = ((unsigned char *) &theword)[1];
*(ptr++) = ((unsigned char *) &theword)[2];
*(ptr++) = ((unsigned char *) &theword)[3];
*(ptr++) = ((char *) &theword)[0];
*(ptr++) = ((char *) &theword)[1];
*(ptr++) = ((char *) &theword)[2];
*(ptr++) = ((char *) &theword)[3];
}
void AppendGListID(GList *gl, const char *name) {
@ -365,7 +365,7 @@ SInt16 CHash(const char *string) {
SInt16 hashval;
UInt8 u;
if ((hashval = (UInt8) strlen(string))) {
if ((hashval = (strlen(string) & 0xFF))) {
i = hashval;
u = 0;
while (i > 0) {

View File

@ -33,11 +33,11 @@ short CABI_GetStructResultArgumentIndex(TypeFunc *tfunc) {
}
Type *CABI_GetSizeTType(void) {
return (Type *) &stunsignedlong;
return TYPE(&stunsignedlong);
}
Type *CABI_GetPtrDiffTType(void) {
return (Type *) &stsignedlong;
return TYPE(&stsignedlong);
}
SInt16 CABI_StructSizeAlignValue(Type *type, SInt32 size) {
@ -331,11 +331,11 @@ static SInt32 CABI_GetBaseVTableSize(TypeClass *tclass) {
static void CABI_ApplyClassFlags(Object *obj, UInt8 flags, Boolean unused) {
if (flags & CLASS_EFLAGS_INTERNAL)
obj->flags |= OBJECT_FLAGS_10;
obj->flags = obj->flags | OBJECT_FLAGS_10;
if (flags & CLASS_EFLAGS_IMPORT)
obj->flags |= OBJECT_FLAGS_20;
obj->flags = obj->flags | OBJECT_FLAGS_20;
if (flags & CLASS_EFLAGS_EXPORT)
obj->flags |= OBJECT_FLAGS_40;
obj->flags = obj->flags | OBJECT_FLAGS_40;
}
static void CABI_AllocateVTable(DeclE *decle, TypeClass *tclass) {
@ -472,12 +472,12 @@ void CABI_LayoutClass(DeclE *decle, TypeClass *tclass) {
tclass->align = CMach_GetClassAlign(tclass);
if (tclass->size == 0) {
tclass->size = 1;
tclass->flags |= CLASS_FLAGS_1000;
tclass->flags = tclass->flags | CLASS_FLAGS_1000;
} else {
tclass->size += CABI_StructSizeAlignValue(TYPE(tclass), tclass->size);
}
tclass->flags |= CLASS_FLAGS_2;
tclass->flags = tclass->flags | CLASS_FLAGS_2;
copts.structalignment = saveAlignMode;
}
@ -486,8 +486,8 @@ void CABI_MakeDefaultArgConstructor(TypeClass *tclass, Object *func) {
DefArgCtorInfo *info;
Boolean saveDebugInfo;
ENodeList *copied;
FuncArg *args;
ENodeList *argexprs;
FuncArg *args;
CScopeSave savedScope;
Statement firstStmt;
Statement returnStmt;
@ -1449,7 +1449,7 @@ static Statement *CABI_CopyConAssignCB(Statement *stmt, TypeClass *tclass, TypeC
expr,
CABI_ClassInitLoopCallBack);
} else {
for (i = 0, offset = regions->start; i < count; offset += type->size, i++) {
for (i = 0, offset = regions->start; i < count; i++, offset += type->size) {
expr = CABI_MakeCopyConArgExpr(tclass, flag);
expr->rtype = type;
@ -1647,7 +1647,7 @@ static Statement *CABI_DestroyMembers(Statement *stmt, ObjMemberVar *ivars, Type
dtor = CABI_GetDestructorObject(dtor, 1);
stmt = CABI_DestroyMembers(stmt, ivars->next, tclass);
expr = create_objectrefnode(dtor);
expr->flags |= ENODE_FLAG_80;
expr->flags = expr->flags | ENODE_FLAG_80;
stmt = CFunc_InsertStatement(ST_EXPRESSION, stmt);
stmt->expr = funccallexpr(
@ -1685,12 +1685,17 @@ static Statement *CABI_DestroyBases(Statement *stmt, ClassList *bases) {
SInt32 count;
SInt32 i;
for (base = bases, count = 0; base; base = base->next)
base = bases;
count = 0;
while (base) {
base = base->next;
count++;
}
while (count > 0) {
base = bases;
for (i = 1; i < count; i++)
i = count;
while (i-- > 1)
base = base->next;
if (!base->is_virtual && (dtor = CClass_Destructor(base->base))) {
@ -2011,9 +2016,9 @@ ENode *CABI_DestroyObject(Object *dtor, ENode *objexpr, CABIDestroyMode mode, Bo
expr->rtype = &stvoid;
expr->data.funccall.funcref = create_objectrefnode(dtor);
if (flag1)
expr->data.funccall.funcref->flags |= ENODE_FLAG_80;
expr->data.funccall.funcref->flags = expr->data.funccall.funcref->flags | ENODE_FLAG_80;
expr->data.funccall.functype = TYPE_FUNC(dtor->type);
dtor->flags |= OBJECT_FLAGS_1;
dtor->flags = dtor->flags | OBJECT_FLAGS_1;
list = lalloc(sizeof(ENodeList));
list->node = objexpr;

View File

@ -606,20 +606,12 @@ static Boolean CDecl_IsEnumClassTypeOrRef(Type *type) {
return IS_TYPE_CLASS(type) || IS_TYPE_ENUM(type);
}
typedef enum OpMysteryValue {
OpMysteryValue0 = 0,
OpMysteryValue1 = 1,
OpMysteryValue2 = 2,
OpMysteryValue3 = 3,
OpMysteryValue4 = 4
} OpMysteryValue;
static Boolean CDecl_CheckOperatorType(DeclInfo *declinfo, Boolean flag) {
FuncArg *args;
FuncArg *secondarg;
Type *functype;
short r27;
Boolean r6;
short argCount;
Boolean isMethod;
if (!IS_TYPE_FUNC(declinfo->thetype)) {
CError_Error(CErrorStr193);
@ -630,7 +622,7 @@ static Boolean CDecl_CheckOperatorType(DeclInfo *declinfo, Boolean flag) {
args = TYPE_FUNC(declinfo->thetype)->args;
if (args) {
if (args != &elipsis && args != &oldstyle) {
r27 = OpMysteryValue1;
argCount = 1;
if (args->dexpr) {
switch (declinfo->x3E) {
case TK_NEW:
@ -645,11 +637,7 @@ static Boolean CDecl_CheckOperatorType(DeclInfo *declinfo, Boolean flag) {
secondarg = args->next;
if (secondarg) {
//r27 = ((secondarg != &elipsis && !secondarg->next) != 0) ? OpMysteryValue2 : OpMysteryValue3;
if ((secondarg != &elipsis && !secondarg->next) != 0)
r27 = OpMysteryValue2;
else
r27 = OpMysteryValue3;
argCount = ((secondarg != &elipsis && !secondarg->next) != 0) ? 2 : 3;
if (secondarg->dexpr) {
switch (declinfo->x3E) {
case '(':
@ -664,63 +652,66 @@ static Boolean CDecl_CheckOperatorType(DeclInfo *declinfo, Boolean flag) {
}
}
} else {
r27 = OpMysteryValue3;
argCount = 3;
}
} else {
CError_Error(CErrorStr193);
return 0;
}
r6 = flag && IS_TYPEFUNC_METHOD(TYPE_FUNC(declinfo->thetype)) && !TYPE_METHOD(declinfo->thetype)->x26;
isMethod = flag &&
IS_TYPEFUNC_METHOD(TYPE_FUNC(declinfo->thetype)) &&
!TYPE_METHOD(declinfo->thetype)->x26;
switch (declinfo->x3E) {
case TK_NEW:
case TK_NEW_ARRAY:
if (r6 || !is_typesame(functype, (Type *) &void_ptr) || r27 < OpMysteryValue1 || args->type != CABI_GetSizeTType()) {
if (isMethod || !is_typesame(functype, TYPE(&void_ptr)) || argCount < 1 || args->type != CABI_GetSizeTType()) {
CError_Error(CErrorStr193);
return 0;
}
return 1;
case TK_DELETE:
case TK_DELETE_ARRAY:
if (r6 || !IS_TYPE_VOID(functype) || r27 < OpMysteryValue1 || !is_typesame(args->type, (Type *) &void_ptr)) {
if (isMethod || !IS_TYPE_VOID(functype) || argCount < 1 || !is_typesame(args->type, TYPE(&void_ptr))) {
CError_Error(CErrorStr193);
return 0;
}
return 1;
case '=':
if (!r6) {
if (!isMethod) {
CError_Error(CErrorStr193);
return 0;
}
break;
case '(':
if (!r6) {
if (!isMethod) {
CError_Error(CErrorStr193);
return 0;
}
return 1;
case '[':
if (!r6) {
if (!isMethod) {
CError_Error(CErrorStr193);
return 0;
}
break;
case TK_ARROW:
if (r27 != OpMysteryValue1 || r6 == 0) {
if (argCount != 1 || isMethod == 0) {
CError_Error(CErrorStr193);
return 0;
}
return 1;
case TK_INCREMENT:
case TK_DECREMENT:
if (r27 == OpMysteryValue2 && secondarg->type != (Type *) &stsignedint) {
if (argCount == 2 && secondarg->type != TYPE(&stsignedint)) {
CError_Error(CErrorStr193);
return 0;
}
break;
}
if (flag && !r6) {
if (flag && !isMethod) {
CError_Error(CErrorStr193);
return 0;
}
@ -732,11 +723,11 @@ static Boolean CDecl_CheckOperatorType(DeclInfo *declinfo, Boolean flag) {
case '-':
case TK_INCREMENT:
case TK_DECREMENT:
if (r27 != OpMysteryValue1)
if (argCount != 1)
goto whatever;
case '!':
case '~':
if (r27 == OpMysteryValue1) {
if (argCount == 1) {
if (flag || CDecl_IsEnumClassTypeOrRef(args->type))
return 1;
}
@ -772,7 +763,7 @@ static Boolean CDecl_CheckOperatorType(DeclInfo *declinfo, Boolean flag) {
case TK_DOT_STAR:
case TK_ARROW_STAR:
whatever:
if (r27 == OpMysteryValue2) {
if (argCount == 2) {
if (flag || CDecl_IsEnumClassTypeOrRef(args->type) || CDecl_IsEnumClassTypeOrRef(secondarg->type))
return 1;
}
@ -1408,12 +1399,12 @@ static void CDecl_FuncRedeclCheck(Object *obj, DeclInfo *declinfo, Boolean flag)
}
Object *CDecl_GetFunctionObject(DeclInfo *declinfo, NameSpace *nspace, Boolean *pflag, Boolean someotherflag) {
Boolean r27;
Object *obj;
Type *type;
NameSpace *nspace2;
Type *type;
Object *obj;
NameSpaceObjectList *list;
TypeMemberFunc tmp;
Boolean r27;
Boolean outflag;
r27 = 0;
@ -1429,14 +1420,14 @@ Object *CDecl_GetFunctionObject(DeclInfo *declinfo, NameSpace *nspace, Boolean *
case TYPEFUNC:
case TYPEARRAY:
CError_Error(CErrorStr128);
TYPE_FUNC(declinfo->thetype)->functype = (Type *) &stsignedint;
TYPE_FUNC(declinfo->thetype)->functype = TYPE(&stsignedint);
break;
}
if (nspace2->theclass) {
CError_ASSERT(1969, declinfo->name);
if (!nspace2->theclass->size)
CDecl_CompleteType((Type *) nspace2->theclass);
CDecl_CompleteType(TYPE(nspace2->theclass));
if (!(list = CScope_GetLocalObject(nspace2, declinfo->name))) {
CError_Error(CErrorStr140, declinfo->name->name);
return NULL;
@ -1630,7 +1621,7 @@ void CDecl_TypedefDeclarator(DeclInfo *declinfo) {
CBrowse_NewTypedef(nspace, declinfo->name, declinfo->file, declinfo->file2, declinfo->x60, CPrep_BrowserFileOffset());
}
static void CDecl_DataDeclarator(DeclInfo *declinfo, short access, Boolean flag) {
static void CDecl_DataDeclarator(DeclInfo *declinfo, AccessType access, Boolean flag) {
NameSpaceObjectList *list;
Object *obj;
NameSpace *nspace;
@ -1732,7 +1723,7 @@ static void CDecl_DataDeclarator(DeclInfo *declinfo, short access, Boolean flag)
if (IS_TYPE_CLASS(declinfo->thetype) && TYPE_CLASS(declinfo->thetype)->sominfo)
CError_Error(CErrorStr288);
if (!CanCreateObject(declinfo->thetype))
declinfo->thetype = (Type *) &stsignedint;
declinfo->thetype = TYPE(&stsignedint);
obj = CParser_NewGlobalDataObject(declinfo);
obj->access = access;
@ -3131,11 +3122,11 @@ static void InlineFunctionObject(Object *obj, TypeClass *tclass) {
void CDecl_ExtractClassExportFlags(DeclInfo *declinfo, UInt8 flags) {
if (flags & CLASS_EFLAGS_INTERNAL)
declinfo->exportflags |= EXPORT_FLAGS_INTERNAL;
declinfo->exportflags = declinfo->exportflags | EXPORT_FLAGS_INTERNAL;
if (flags & CLASS_EFLAGS_IMPORT)
declinfo->exportflags |= EXPORT_FLAGS_IMPORT;
declinfo->exportflags = declinfo->exportflags | EXPORT_FLAGS_IMPORT;
if (flags & CLASS_EFLAGS_EXPORT)
declinfo->exportflags |= EXPORT_FLAGS_EXPORT;
declinfo->exportflags = declinfo->exportflags | EXPORT_FLAGS_EXPORT;
}
TypeMemberFunc *CDecl_MakeTypeMemberFunc(TypeFunc *tfunc, TypeClass *tclass, Boolean flag) {
@ -3164,7 +3155,7 @@ static void CDecl_MakeFunctionVirtual(TypeClass *tclass, Object *func) {
func->datatype = DVFUNC;
}
static void CDecl_AddFunctionMember(DeclE *decle, TypeClass *tclass, DeclInfo *declinfo, short access, Boolean flag1, Boolean flag2, Boolean flag3, Boolean flag4) {
static void CDecl_AddFunctionMember(DeclE *decle, TypeClass *tclass, DeclInfo *declinfo, AccessType access, Boolean flag1, Boolean flag2, Boolean flag3, Boolean flag4) {
NameSpaceObjectList *list; // r20
Object *obj; // also r20
TypeMemberFunc *tfunc; // r19
@ -3228,7 +3219,7 @@ static void CDecl_AddFunctionMember(DeclE *decle, TypeClass *tclass, DeclInfo *d
if (flag2) {
tfunc->flags |= FUNC_FLAGS_40;
tclass->flags |= CLASS_FLAGS_40;
tclass->flags = tclass->flags | CLASS_FLAGS_40;
}
if (r31) {
@ -3241,7 +3232,7 @@ static void CDecl_AddFunctionMember(DeclE *decle, TypeClass *tclass, DeclInfo *d
if (!CInt64_IsZero(&tkintconst))
CError_Error(CErrorStr121);
tfunc->flags |= FUNC_FLAGS_8;
tclass->flags |= CLASS_FLAGS_ABSTRACT;
tclass->flags = tclass->flags | CLASS_FLAGS_ABSTRACT;
tk = lex();
} else {
CError_Error(CErrorStr121);
@ -3258,7 +3249,7 @@ static void CDecl_AddFunctionMember(DeclE *decle, TypeClass *tclass, DeclInfo *d
CBrowse_AddClassMemberFunction(obj, CPrep_BrowserTokenOffset(&member_fileoffset) + 1, CPrep_BrowserFileOffset());
}
static Boolean CDecl_IsAccessDeclaration(TypeClass *tclass, short access) {
static Boolean CDecl_IsAccessDeclaration(TypeClass *tclass, AccessType access) {
SInt32 state;
Boolean flag;
@ -3383,7 +3374,7 @@ static void CDecl_ParseFriendDecl(TypeClass *tclass) {
Object *obj;
NameSpace *nspace;
is_templ = (tclass->flags & CLASS_FLAGS_100) ? 1 : 0;
is_templ = (tclass->flags & CLASS_FLAGS_100) != 0;
r27 = (tk == TK_CLASS || tk == TK_STRUCT || tk == TK_UNION);
memclrw(&declinfo, sizeof(DeclInfo));
@ -3469,7 +3460,7 @@ static void CDecl_ParseFriendDecl(TypeClass *tclass) {
CError_Error(CErrorStr123);
}
static ObjMemberVar *CDecl_InstanceDataDeclarator(DeclE *decle, TypeClass *tclass, Type *type, UInt32 qual, HashNameNode *name, short access) {
static ObjMemberVar *CDecl_InstanceDataDeclarator(DeclE *decle, TypeClass *tclass, Type *type, UInt32 qual, HashNameNode *name, AccessType access) {
NameSpaceObjectList *list;
ObjMemberVar *ivar;
ObjMemberVar *scan;
@ -3533,12 +3524,7 @@ void CDecl_CheckCtorIntegrity(FuncArg *args, TypeClass *tclass) {
}
static void CDecl_ParseClassMembers(DeclE *decle, TypeClass *tclass, short mode) {
short access;
UInt32 r22;
UInt32 r21;
UInt8 r20;
Boolean r19;
UInt8 r18;
AccessType access;
Boolean r17;
BigDeclInfo bde;
DeclInfo declinfo;
@ -3546,18 +3532,18 @@ static void CDecl_ParseClassMembers(DeclE *decle, TypeClass *tclass, short mode)
ObjMemberVar *ivar;
ObjMemberVar *scanivar;
Type *tmptype;
UInt32 r22;
UInt32 r21;
UInt8 r20;
UInt8 r18;
Boolean r19;
short t;
r17 = (tclass->flags & CLASS_FLAGS_100) && TEMPL_CLASS(tclass)->pspec_owner;
memclrw(&bde, sizeof(BigDeclInfo));
if (mode == CLASS_MODE_2)
access = ACCESSPRIVATE;
else
access = ACCESSPUBLIC;
access = (mode == CLASS_MODE_2) ? ACCESSPRIVATE : ACCESSPUBLIC;
global_access = access;
//global_access = (mode == CLASS_MODE_2) ? ACCESSPRIVATE : ACCESSPUBLIC;
//access = (mode == CLASS_MODE_2) ? ACCESSPRIVATE : ACCESSPUBLIC;
restart:
while (tk != '}') {
@ -3967,7 +3953,7 @@ void CDecl_MakeVBaseList(TypeClass *tclass) {
SInt32 offset;
if (copts.vbase_ctor_offset)
tclass->flags |= CLASS_FLAGS_8000;
tclass->flags = tclass->flags | CLASS_FLAGS_8000;
for (base = tclass->bases, offset = tclass->size; base; base = base->next) {
for (vbase = base->base->vbases; vbase; vbase = vbase->next) {
@ -4002,7 +3988,7 @@ Boolean CDecl_CheckNewBase(TypeClass *tclass, TypeClass *baseclass, Boolean is_v
CError_Error(CErrorStr191);
return 0;
}
tclass->flags |= CLASS_FLAGS_10;
tclass->flags = tclass->flags | CLASS_FLAGS_10;
}
if (baseclass->flags & CLASS_FLAGS_1) {
@ -4010,7 +3996,7 @@ Boolean CDecl_CheckNewBase(TypeClass *tclass, TypeClass *baseclass, Boolean is_v
CError_Error(CErrorStr191);
return 0;
}
tclass->flags |= CLASS_FLAGS_1;
tclass->flags = tclass->flags | CLASS_FLAGS_1;
}
if (baseclass->sominfo) {
@ -4039,21 +4025,21 @@ Boolean CDecl_CheckNewBase(TypeClass *tclass, TypeClass *baseclass, Boolean is_v
}
if (baseclass->flags & CLASS_FLAGS_2000)
tclass->flags |= CLASS_FLAGS_2000;
tclass->flags = tclass->flags | CLASS_FLAGS_2000;
if (baseclass->flags & CLASS_FLAGS_40)
tclass->flags |= CLASS_FLAGS_40;
tclass->flags = tclass->flags | CLASS_FLAGS_40;
if (baseclass->flags & CLASS_FLAGS_20)
tclass->flags |= CLASS_FLAGS_20;
tclass->flags = tclass->flags | CLASS_FLAGS_20;
if (is_virtual)
tclass->flags |= CLASS_FLAGS_20;
tclass->flags = tclass->flags | CLASS_FLAGS_20;
return 1;
}
static void CDecl_ParseBaseClassList(TypeClass *tclass, short mode, Boolean is_templ) {
Boolean is_virtual;
short access;
AccessType access;
CScopeParseResult pr;
ObjType *inherited_type;
ClassList *base;
@ -4113,7 +4099,7 @@ static void CDecl_ParseBaseClassList(TypeClass *tclass, short mode, Boolean is_t
CParser_CheckTemplateClassUsage(TEMPL_CLASS(pr.x8), 1)) {
CTemplClass_RegisterBaseClass(TEMPL_CLASS(tclass), pr.x8, access, is_virtual);
if (is_virtual)
tclass->flags |= CLASS_FLAGS_20;
tclass->flags = tclass->flags | CLASS_FLAGS_20;
}
continue;
}
@ -4135,12 +4121,12 @@ static void CDecl_ParseBaseClassList(TypeClass *tclass, short mode, Boolean is_t
if (!strcmp(tkidentifier->name, "SingleObject") || !strcmp(tkidentifier->name, "SingleInheritance")) {
if (tclass->bases)
CError_Error(CErrorStr191);
tclass->flags |= CLASS_FLAGS_10;
tclass->flags = tclass->flags | CLASS_FLAGS_10;
tk = lex();
break;
}
if (!strcmp(tkidentifier->name, "__comobject")) {
tclass->flags |= CLASS_FLAGS_2000;
tclass->flags = tclass->flags | CLASS_FLAGS_2000;
tk = lex();
break;
}
@ -4190,7 +4176,7 @@ static void CDecl_ParseBaseClassList(TypeClass *tclass, short mode, Boolean is_t
}
}
static short getaccesstype(AccessType a, AccessType b, AccessType c) {
static AccessType getaccesstype(AccessType a, AccessType b, AccessType c) {
if (a == ACCESSNONE || b == ACCESSNONE || b == ACCESSPRIVATE)
return ACCESSNONE;
@ -4220,14 +4206,14 @@ static void CDecl_AddDefArgConstructor(TypeClass *tclass) {
// empty
}
static void CDecl_AddMemberFunctionObject(TypeClass *tclass, HashNameNode *name, TypeMemberFunc *tmeth, short access) {
static void CDecl_AddMemberFunctionObject(TypeClass *tclass, HashNameNode *name, TypeMemberFunc *tmeth, AccessType access) {
Object *obj = CParser_NewCompilerDefFunctionObject();
obj->name = name;
obj->type = TYPE(tmeth);
obj->qual = Q_80000;
obj->access = access;
obj->nspace = tclass->nspace;
obj->qual |= Q_INLINE;
obj->qual = obj->qual | Q_INLINE;
CScope_AddObject(tclass->nspace, obj->name, OBJ_BASE(obj));
}
@ -4299,7 +4285,7 @@ static void CDecl_AddDefaultCopyConstructor(DeclE *decle, TypeClass *tclass) {
ClassList *base;
ObjMemberVar *ivar;
Object *obj;
short access;
AccessType access;
Boolean has_copyctor;
Boolean is_const;
FuncArg *arg;
@ -4377,7 +4363,7 @@ static void CDecl_AddDefaultAssignmentOperator(DeclE *decle, TypeClass *tclass)
ClassList *base;
ObjMemberVar *ivar;
Object *obj;
short access;
AccessType access;
Boolean is_const;
Boolean has_ass;
DeclInfo declinfo;
@ -4442,7 +4428,7 @@ static void CDecl_AddDefaultDestructor(DeclE *decle, TypeClass *tclass) {
ClassList *base;
ObjMemberVar *ivar;
Object *obj;
short access;
AccessType access;
Boolean has_dtor;
Boolean is_virtual;
DeclInfo declinfo;
@ -4662,11 +4648,11 @@ void CDecl_ParseClassDeclSpec(UInt8 *declspec) {
memclrw(&declinfo, sizeof(DeclInfo));
CParser_ParseDeclSpec(&declinfo, 1);
if (declinfo.exportflags & EXPORT_FLAGS_INTERNAL)
*declspec |= CLASS_EFLAGS_INTERNAL;
*declspec = *declspec | CLASS_EFLAGS_INTERNAL;
if (declinfo.exportflags & EXPORT_FLAGS_IMPORT)
*declspec |= CLASS_EFLAGS_IMPORT;
*declspec = *declspec | CLASS_EFLAGS_IMPORT;
if (declinfo.exportflags & EXPORT_FLAGS_EXPORT)
*declspec |= CLASS_EFLAGS_EXPORT;
*declspec = *declspec | CLASS_EFLAGS_EXPORT;
if ((tk = lex()) != ')')
CError_Error(CErrorStr115);
else
@ -4802,7 +4788,7 @@ void CDecl_ParseClass(DeclInfo *declinfo, short mode, Boolean flag1, UInt8 class
}
}
is_templ = (tclass->flags & CLASS_FLAGS_100) ? 1 : 0;
is_templ = (tclass->flags & CLASS_FLAGS_100) != 0;
if (tclass->flags & CLASS_FLAGS_800) {
TEMPL_CLASS_INST(tclass)->is_instantiated = 1;
if (!declinfo->x28)
@ -4811,7 +4797,7 @@ void CDecl_ParseClass(DeclInfo *declinfo, short mode, Boolean flag1, UInt8 class
CError_ASSERT(6853, copts.structalignment >= 0 && copts.structalignment <= 14);
tclass->eflags |= (UInt8) ((copts.structalignment + 1) << 4);
tclass->eflags = tclass->eflags | (((copts.structalignment + 1) << 4) & 0xF0);
if (tk == ':')
CDecl_ParseBaseClassList(tclass, mode, is_templ);

View File

@ -26,6 +26,10 @@ char cerror_synchdata[32];
short cerror_synchoffset;
int CError_BreakPointcount;
// forward decls
static void CError_BufferAppendType(CErrorBuffer *eb, Type *ty, UInt32 qual);
static void CError_AppendObjectName(CErrorBuffer *eb, Object *obj);
void CError_Init(void) {
cerror_errorcount = 0;
cerror_lasterrorline = -1;
@ -56,17 +60,17 @@ void CError_ResetErrorSkip(void) {
cerror_lasterrorline = -1;
}
void CError_GetErrorString(char *buf, short code) {
static void CError_GetErrorString(char *buf, short code) {
CError_ASSERT(142, code >= CErrorStr100 && code < CErrorStrMAX);
COS_GetString(buf, 10000, code - 99);
}
void CError_BufferInit(CErrorBuffer *eb, char *buf, SInt32 bufSize) {
static void CError_BufferInit(CErrorBuffer *eb, char *buf, SInt32 bufSize) {
eb->start = eb->end = buf;
eb->size = eb->remaining = bufSize - 1;
}
void CError_BufferGrow(CErrorBuffer *eb, SInt32 amount) {
static void CError_BufferGrow(CErrorBuffer *eb, SInt32 amount) {
char *newBuf;
newBuf = lalloc(eb->size + amount);
@ -77,7 +81,7 @@ void CError_BufferGrow(CErrorBuffer *eb, SInt32 amount) {
eb->remaining += amount;
}
void CError_BufferAppendChar(CErrorBuffer *eb, char ch) {
static void CError_BufferAppendChar(CErrorBuffer *eb, char ch) {
if (eb) {
if (!eb->remaining)
CError_BufferGrow(eb, 256);
@ -86,7 +90,7 @@ void CError_BufferAppendChar(CErrorBuffer *eb, char ch) {
}
}
void CError_BufferAppendString(CErrorBuffer *eb, const char *str) {
static void CError_BufferAppendString(CErrorBuffer *eb, const char *str) {
size_t len;
if (eb) {
@ -99,14 +103,14 @@ void CError_BufferAppendString(CErrorBuffer *eb, const char *str) {
}
}
void CError_BufferTerminate(CErrorBuffer *eb) {
static void CError_BufferTerminate(CErrorBuffer *eb) {
if (eb->remaining == 0)
CError_BufferGrow(eb, 1);
*eb->end = 0;
eb->remaining = 0;
}
void CError_BufferAppendQualifier(CErrorBuffer *eb, UInt32 qual) {
static void CError_BufferAppendQualifier(CErrorBuffer *eb, UInt32 qual) {
if (qual & Q_PASCAL)
CError_BufferAppendString(eb, "pascal ");
if (qual & Q_CONST)
@ -119,7 +123,7 @@ void CError_BufferAppendQualifier(CErrorBuffer *eb, UInt32 qual) {
CError_BufferAppendString(eb, "restrict ");
}
void CError_BufferAppendTemplArgExpr(CErrorBuffer *eb, ENode *node) {
static void CError_BufferAppendTemplArgExpr(CErrorBuffer *eb, ENode *node) {
char buf[32];
if (node) {
@ -138,7 +142,7 @@ void CError_BufferAppendTemplArgExpr(CErrorBuffer *eb, ENode *node) {
CError_BufferAppendString(eb, "{targ_expr}");
}
void CError_BufferAppendTemplArg(CErrorBuffer *eb, TemplArg *targ) {
static void CError_BufferAppendTemplArg(CErrorBuffer *eb, TemplArg *targ) {
switch (targ->pid.type) {
case TPT_TYPE:
CError_BufferAppendType(eb, targ->data.typeparam.type, targ->data.typeparam.qual);
@ -154,7 +158,7 @@ void CError_BufferAppendTemplArg(CErrorBuffer *eb, TemplArg *targ) {
}
}
void CError_BufferAppendTemplArgs(CErrorBuffer *eb, TemplArg *targs) {
static void CError_BufferAppendTemplArgs(CErrorBuffer *eb, TemplArg *targs) {
if (targs) {
CError_BufferAppendChar(eb, '<');
while (targs) {
@ -167,7 +171,7 @@ void CError_BufferAppendTemplArgs(CErrorBuffer *eb, TemplArg *targs) {
}
}
void CError_BufferAppendNameSpace(CErrorBuffer *eb, NameSpace *nspace) {
static void CError_BufferAppendNameSpace(CErrorBuffer *eb, NameSpace *nspace) {
while (nspace) {
if (nspace->name) {
CError_BufferAppendNameSpace(eb, nspace->parent);
@ -188,7 +192,7 @@ void CError_BufferAppendNameSpace(CErrorBuffer *eb, NameSpace *nspace) {
}
}
void CError_BufferAppendPType(CErrorBuffer *eb, Type *ty) {
static void CError_BufferAppendPType(CErrorBuffer *eb, Type *ty) {
switch (ty->type) {
case TYPEPOINTER:
CError_BufferAppendPType(eb, TYPE_POINTER(ty)->target);
@ -207,12 +211,12 @@ void CError_BufferAppendPType(CErrorBuffer *eb, Type *ty) {
}
}
void CError_BufferAppendTemplDepType(CErrorBuffer *eb, TypeTemplDep *type) {
static void CError_BufferAppendTemplDepType(CErrorBuffer *eb, TypeTemplDep *type) {
char buf[64];
switch (type->dtype) {
case TEMPLDEP_ARGUMENT:
if (type->u.pid.nindex)
sprintf(buf, "T%" PRId32 "%" PRId32, type->u.pid.nindex, type->u.pid.index);
sprintf(buf, "T%" PRId32 "_%" PRId32, type->u.pid.nindex, type->u.pid.index);
else
sprintf(buf, "T%" PRId32, type->u.pid.index);
CError_BufferAppendString(eb, buf);
@ -248,7 +252,7 @@ void CError_BufferAppendTemplDepType(CErrorBuffer *eb, TypeTemplDep *type) {
}
}
void CError_BufferAppendFuncArgs(CErrorBuffer *eb, TypeFunc *tfunc, Boolean isMethod) {
static void CError_BufferAppendFuncArgs(CErrorBuffer *eb, TypeFunc *tfunc, Boolean isMethod) {
FuncArg *arg;
UInt32 qual;
@ -288,7 +292,7 @@ void CError_BufferAppendFuncArgs(CErrorBuffer *eb, TypeFunc *tfunc, Boolean isMe
CError_BufferAppendQualifier(eb, qual);
}
void CError_BufferAppendType(CErrorBuffer *eb, Type *ty, UInt32 qual) {
static void CError_BufferAppendType(CErrorBuffer *eb, Type *ty, UInt32 qual) {
// not matching - register issues
Type *scan;
Type *scan2;
@ -505,7 +509,7 @@ char *CError_GetTypeName(Type *ty, UInt32 qual, Boolean useGlobalHeap) {
return strcpy(ptr, eb.start);
}
void CError_AppendUnqualFunctionName(CErrorBuffer *eb, NameSpace *nspace, HashNameNode *name, TypeFunc *tfunc) {
static void CError_AppendUnqualFunctionName(CErrorBuffer *eb, NameSpace *nspace, HashNameNode *name, TypeFunc *tfunc) {
Boolean flag = 0;
char *opname;
@ -535,7 +539,7 @@ void CError_AppendUnqualFunctionName(CErrorBuffer *eb, NameSpace *nspace, HashNa
}
}
void CError_AppendFunctionName(CErrorBuffer *eb, NameSpace *nspace, HashNameNode *name, TemplArg *templargs, TypeFunc *tfunc) {
static void CError_AppendFunctionName(CErrorBuffer *eb, NameSpace *nspace, HashNameNode *name, TemplArg *templargs, TypeFunc *tfunc) {
while (nspace->is_templ && nspace->parent)
nspace = nspace->parent;
@ -551,7 +555,7 @@ void CError_AppendFunctionName(CErrorBuffer *eb, NameSpace *nspace, HashNameNode
}
}
void CError_AppendObjectName(CErrorBuffer *eb, Object *obj) {
static void CError_AppendObjectName(CErrorBuffer *eb, Object *obj) {
if (obj->type->type == TYPEFUNC) {
CError_AppendFunctionName(eb, obj->nspace, obj->name, obj->u.func.inst ? obj->u.func.inst->args : NULL, TYPE_FUNC(obj->type));
} else {
@ -560,7 +564,7 @@ void CError_AppendObjectName(CErrorBuffer *eb, Object *obj) {
}
}
void CError_AppendMethodName(CErrorBuffer *eb, ObjCMethod *meth) {
static void CError_AppendMethodName(CErrorBuffer *eb, ObjCMethod *meth) {
ObjCMethodArg *arg;
CError_BufferAppendChar(eb, meth->is_class_method ? '+' : '-');
@ -648,8 +652,8 @@ void CError_ErrorMessage(int errTable, char *str, Boolean flag1, Boolean flag2)
TStreamElement *token;
short tokensize;
CPrepFileInfo *tokenfile;
char buf[128];
CWMessageRef myref;
char buf[128];
CWMessageRef *ref;
unsigned char messagetype;
@ -703,7 +707,7 @@ void CError_ErrorMessage(int errTable, char *str, Boolean flag1, Boolean flag2)
cerror_token = NULL;
}
void CError_BufferAppendTemplateStack(CErrorBuffer *eb) {
static void CError_BufferAppendTemplateStack(CErrorBuffer *eb) {
TemplStack *stack[64];
TemplStack *scan;
int index;
@ -717,7 +721,7 @@ void CError_BufferAppendTemplateStack(CErrorBuffer *eb) {
}
for (index = count - 1; index >= 0; index--) {
CError_BufferAppendChar(eb, '\n');
CError_BufferAppendChar(eb, LF);
for (indent = index; indent < count; indent++)
CError_BufferAppendChar(eb, ' ');
CError_BufferAppendString(eb, "(instantiating: '");
@ -800,7 +804,7 @@ void CError_ErrorMessageVA(int code, const char *format, va_list list, Boolean f
CError_ErrorMessage(code, eb.start, flag1, flag2);
}
void CError_VAErrorMessage(int code, va_list list, Boolean flag1, Boolean flag2) {
static void CError_VAErrorMessage(int code, va_list list, Boolean flag1, Boolean flag2) {
char buf[256];
CError_GetErrorString(buf, code);
@ -898,7 +902,7 @@ void CError_ErrorFuncCall(short code, NameSpaceObjectList *args, ENodeList *argN
exit_main_loop:
while (args) {
if (args->object->otype == OT_OBJECT) {
CError_BufferAppendChar(&eb, '\n');
CError_BufferAppendChar(&eb, LF);
CError_BufferAppendChar(&eb, '\'');
CError_AppendObjectName(&eb, (Object *) args->object);
CError_BufferAppendChar(&eb, '\'');
@ -941,13 +945,13 @@ void CError_OverloadedFunctionError(Object *obj, ObjectList *olst) {
CError_BufferAppendString(&eb, string);
if (obj) {
CError_BufferAppendChar(&eb, '\n');
CError_BufferAppendChar(&eb, LF);
CError_BufferAppendChar(&eb, '\'');
CError_AppendObjectName(&eb, obj);
CError_BufferAppendChar(&eb, '\'');
}
while (olst) {
CError_BufferAppendChar(&eb, '\n');
CError_BufferAppendChar(&eb, LF);
CError_BufferAppendChar(&eb, '\'');
CError_AppendObjectName(&eb, olst->object);
CError_BufferAppendChar(&eb, '\'');

View File

@ -1649,7 +1649,7 @@ static ENode *primary_expression(Boolean flag) {
else
tk = lex();
if (ENODE_IS(expr, EASS))
expr->flags |= ENODE_FLAG_80;
expr->flags = expr->flags | ENODE_FLAG_80;
return expr;
case '[':
if (copts.objective_c)
@ -2227,7 +2227,7 @@ restart:
}
if (obj->datatype == DINLINEFUNC)
CError_Error(CErrorStr175);
obj->flags |= OBJECT_FLAGS_2;
obj->flags = obj->flags | OBJECT_FLAGS_2;
if (flag && !copts.cplusplus && obj->sclass == TK_REGISTER)
CError_Error(CErrorStr163);
break;
@ -2806,7 +2806,7 @@ static ENode *CExpr_MemberPointerCast(ENode *expr, TypeMemberPointer *type, UInt
ENode *do_typecast(ENode *expr, Type *type, UInt32 qual) {
TypePointer *tptr;
ENode *tmp;
UInt32 flags;
short flags;
if (!copts.old_argmatch)
return CExpr_Convert(expr, type, qual, 1, 0);
@ -2830,7 +2830,7 @@ ENode *do_typecast(ENode *expr, Type *type, UInt32 qual) {
flags = qual & ENODE_FLAG_QUALS;
if (ENODE_IS(expr, EOBJLIST))
return CExpr_AssignmentPromotion(expr, type, flags, 1);
return CExpr_AssignmentPromotion(expr, type, qual & ENODE_FLAG_QUALS, 1);
if (ENODE_IS(expr, EOBJREF) && IS_TYPE_NONSTATIC_METHOD(expr->data.objref->type)) {
CError_Error(CErrorStr221);
@ -2898,7 +2898,7 @@ ENode *do_typecast(ENode *expr, Type *type, UInt32 qual) {
if (ENODE_IS(expr, ETYPCON) && expr->rtype->type == type->type && expr->rtype->size == type->size) {
if (is_unsigned(expr->rtype) == is_unsigned(type) && ENODE_QUALS(expr) == qual) {
expr->rtype = type;
expr->flags |= ENODE_FLAG_80;
expr->flags = expr->flags | ENODE_FLAG_80;
return expr;
}
}
@ -4153,14 +4153,14 @@ ENode *CExpr_New_ECOND_Node(ENode *cond, ENode *expr1, ENode *expr2) {
result->rtype = expr1->rtype;
result->flags = expr1->flags | expr2->flags;
result->data.cond.cond = cond;
if (ENODE_IS(expr1, EFUNCCALL) && expr1->rtype == &stvoid && (expr1->flags & ENODE_FLAG_VOLATILE)) {
if (ENODE_IS(expr1, EFUNCCALL) && expr1->rtype == &stvoid && (expr1->flags & ENODE_FLAG_VOLATILE) != 0) {
result->rtype = expr2->rtype;
result->flags = expr2->flags;
result->data.cond.expr1 = expr1;
result->data.cond.expr2 = expr2;
return result;
}
if (ENODE_IS(expr2, EFUNCCALL) && expr2->rtype == &stvoid && (expr2->flags & ENODE_FLAG_VOLATILE)) {
if (ENODE_IS(expr2, EFUNCCALL) && expr2->rtype == &stvoid && (expr2->flags & ENODE_FLAG_VOLATILE) != 0) {
result->rtype = expr1->rtype;
result->flags = expr1->flags;
result->data.cond.expr1 = expr1;

View File

@ -1339,7 +1339,7 @@ static void makeifstatement(ENode *expr, CLabel *label1, CLabel *label2, Boolean
if (!flag1)
stmt->type = ST_IFNGOTO;
if (flag2)
stmt->flags |= StmtFlag_4;
stmt->flags = stmt->flags | StmtFlag_4;
}
static void CFunc_HasDtorTempCallBack(ENode *expr) {
@ -1359,7 +1359,7 @@ static void ifstatement(Boolean flag1, ENode *expr, CLabel *label, Boolean flag2
stmt->label = label;
stmt->expr = expr;
if (flag2)
stmt->flags |= StmtFlag_4;
stmt->flags = stmt->flags | StmtFlag_4;
return;
}
}
@ -3030,7 +3030,7 @@ void CFunc_ParseFuncDef(Object *func, DeclInfo *di, TypeClass *tclass, Boolean i
stmt16->expr->rtype == &stvoid &&
(stmt16->expr->flags & ENODE_FLAG_VOLATILE)
)
curstmt->flags |= StmtFlag_8;
curstmt->flags = curstmt->flags | StmtFlag_8;
}
CheckCLabels();

View File

@ -643,7 +643,7 @@ static void CInit_SetBitfield(TypeBitfield *tbitfield, UInt8 *buffer, CInt64 val
pos = tbitfield->unkB + tbitfield->unkA - 1;
step = -1;
}
for (i = 0; i < tbitfield->unkB; i++) {
for (i = 0; i < tbitfield->unkB; i++, pos += step) {
if (CInt64_GetULong(&val) & 1) {
if (copts.littleendian) {
buffer[pos >> 3] |= 1 << (pos & 7);
@ -652,7 +652,6 @@ static void CInit_SetBitfield(TypeBitfield *tbitfield, UInt8 *buffer, CInt64 val
}
}
val = CInt64_ShrU(val, cint64_one);
pos += step;
}
}
@ -1916,7 +1915,7 @@ static void CInit_AutoInit(Type *type, ENode *valueexpr, Boolean flag) {
copy = galloc(sizeof(TypePointer));
*TYPE_POINTER(copy) = *TYPE_POINTER(type);
type = copy;
type->size++;
copy->size++;
}
expr = create_objectrefnode(cinit_initinfo->obj1C);
if (!IS_TYPE_POINTER_ONLY(expr->rtype)) {
@ -2022,13 +2021,11 @@ static ENode *CInit_GenericData(Object *obj, Type *type, UInt32 qual, ExprCB exp
case TYPEPOINTER:
case TYPEMEMBERPOINTER:
generic_type:
if (obj) {
cv = obj->qual;
cv &= Q_CONST | Q_VOLATILE;
} else {
cv = cinit_initinfo->obj1C->qual;
cv &= Q_CONST | Q_VOLATILE;
}
if (obj)
cv = obj->qual & Q_CV;
else
cv = cinit_initinfo->obj1C->qual & Q_CV;
if (tk == '{') {
tk = lex();
expr = assignment_expression();
@ -2771,7 +2768,7 @@ void CInit_InitializeData(Object *obj) {
} else {
if (obj->flags & OBJECT_FLAGS_4)
CError_Error(CErrorStr329, obj);
obj->flags |= OBJECT_FLAGS_4;
obj->flags = obj->flags | OBJECT_FLAGS_4;
needs_construction = 0;
if (IS_TYPE_ARRAY(obj->type)) {
@ -3050,7 +3047,7 @@ static void declaredata(Object *obj, void *data, OLinkList *list, SInt32 size, B
if (cparamblkptr->precompile == 1) {
PreComp_StaticData(obj, data, list, size);
} else {
obj->flags |= OBJECT_FLAGS_4;
obj->flags = obj->flags | OBJECT_FLAGS_4;
if (!fatalerrors) {
for (scan = list; scan; scan = scan->next)
CInline_ObjectAddrRef(scan->obj);

View File

@ -75,9 +75,8 @@ CInt64 CInt64_MulU(CInt64 lhs, CInt64 rhs) {
result.hi = result.lo = 0;
bbbb = lhs.lo;
cccc = rhs.hi;
dddd = rhs.lo;
while (bbbb != 0) {
for (dddd = aaaa; bbbb != 0; dddd <<= 1, bbbb >>= 1) {
if (bbbb & 1) {
work1.hi = cccc;
work1.lo = dddd;
@ -86,8 +85,6 @@ CInt64 CInt64_MulU(CInt64 lhs, CInt64 rhs) {
cccc <<= 1;
if (dddd & 0x80000000)
cccc |= 1;
dddd <<= 1;
bbbb >>= 1;
}
eeee = lhs.hi;
@ -449,29 +446,31 @@ CInt64 CInt64_Or(CInt64 lhs, CInt64 rhs) {
}
void CInt64_ConvertInt32(CInt64 *i) {
CInt64_Extend32(i);
i->hi = (i->lo & 0x80000000) ? 0xFFFFFFFF : 0;
}
void CInt64_ConvertUInt32(CInt64 *i) {
CInt64_SetULong(i, (UInt32) i->lo);
i->hi = 0;
}
void CInt64_ConvertInt16(CInt64 *i) {
i->lo = (SInt16) i->lo;
CInt64_Extend32(i);
i->hi = (i->lo & 0x80000000) ? 0xFFFFFFFF : 0;
}
void CInt64_ConvertUInt16(CInt64 *i) {
CInt64_SetULong(i, (UInt16) i->lo);
i->lo = (UInt16) i->lo;
i->hi = 0;
}
void CInt64_ConvertInt8(CInt64 *i) {
i->lo = (SInt8) i->lo;
CInt64_Extend32(i);
i->hi = (i->lo & 0x80000000) ? 0xFFFFFFFF : 0;
}
void CInt64_ConvertUInt8(CInt64 *i) {
CInt64_SetULong(i, (UInt8) i->lo);
i->lo = (UInt8) i->lo;
i->hi = 0;
}
void CInt64_ConvertUFromLongDouble(CInt64 *pResult, double value) {
@ -648,7 +647,6 @@ char *CInt64_ScanDecString(CInt64 *pResult, char *str, Boolean *pFail) {
}
char *CInt64_ScanHexString(CInt64 *pResult, char *str, Boolean *pFail) {
/* NOT MATCHING */
int digit;
CInt64 tmp;
UInt32 a;
@ -658,7 +656,8 @@ char *CInt64_ScanHexString(CInt64 *pResult, char *str, Boolean *pFail) {
pResult->hi = pResult->lo = 0;
for (;;) {
if ((digit = str[0]) >= '0' && digit <= '9')
digit = str[0];
if (digit >= '0' && digit <= '9')
digit = digit - '0';
else if (digit >= 'A' && digit <= 'F')
digit = digit - 'A' + 10;
@ -667,9 +666,9 @@ char *CInt64_ScanHexString(CInt64 *pResult, char *str, Boolean *pFail) {
else
break;
++str;
a = pResult->hi;
b = pResult->lo;
++str;
if (a & 0xF0000000)
*pFail = 1;
@ -705,9 +704,9 @@ char *CInt64_ScanBinString(CInt64 *pResult, char *str, Boolean *pFail) {
else
break;
++str;
a = pResult->hi;
b = pResult->lo;
++str;
if (a & 0x80000000)
*pFail = 1;
@ -788,8 +787,8 @@ int CInt64_PrintDec(char *output, CInt64 value) {
if (CInt64_IsNegative(&value)) {
value = CInt64_Neg(value);
*output = '-';
length++;
output++;
length++;
}
if (!CInt64_IsZero(&value)) {
@ -801,7 +800,7 @@ int CInt64_PrintDec(char *output, CInt64 value) {
rem = CInt64_ModU(value, divisor);
*(bufp++) = rem.lo + '0';
value = CInt64_DivU(value, divisor);
if (CInt64_IsZero(&value) != 0)
if (CInt64_IsZero(&value))
break;
}
@ -841,7 +840,7 @@ int CInt64_PrintHex(char *output, CInt64 value) {
else
*(bufp++) = rem.lo + '0';
value = CInt64_ShrU(value, shift);
if (CInt64_IsZero(&value) != 0)
if (CInt64_IsZero(&value))
break;
}
@ -874,7 +873,7 @@ int CInt64_PrintBin(char *output, CInt64 value) {
else
*(bufp++) = '0';
value = CInt64_ShrU(value, cint64_one);
if (CInt64_IsZero(&value) != 0)
if (CInt64_IsZero(&value))
break;
}

View File

@ -1518,10 +1518,10 @@ static void removeunusedlabels(Statement *stmt) {
for (action = scan->dobjstack; action; action = action->prev) {
if (action->type == EAT_CATCHBLOCK) {
action->data.catch_block.catch_label->stmt->marked = 1;
action->data.catch_block.catch_label->stmt->flags |= StmtFlag_1;
action->data.catch_block.catch_label->stmt->flags = action->data.catch_block.catch_label->stmt->flags | StmtFlag_1;
} else if (action->type == EAT_SPECIFICATION) {
action->data.specification.unexp_label->stmt->marked = 1;
action->data.specification.unexp_label->stmt->flags |= StmtFlag_1;
action->data.specification.unexp_label->stmt->flags = action->data.specification.unexp_label->stmt->flags | StmtFlag_1;
}
}
}
@ -1798,7 +1798,7 @@ static void COpt_Optimize(Object *obj, Statement *stmt) {
static void COpt_ELABELCallBack(ENode *expr) {
CError_ASSERT(2195, expr->data.label->stmt && expr->data.label->stmt->type == ST_LABEL);
expr->data.label->stmt->flags |= StmtFlag_1;
expr->data.label->stmt->flags = expr->data.label->stmt->flags | StmtFlag_1;
}
void COpt_SimpleOptimizer(Object *obj, Statement *stmt) {

View File

@ -219,7 +219,7 @@ typedef struct TypeSig {
UInt8 x2;
} TypeSig;
static UInt8 CSOM_GetTypeSig(TypeSig *sig, Type *type, Boolean flag) {
static int CSOM_GetTypeSig(TypeSig *sig, Type *type, Boolean flag) {
if (type->size > 4)
sig->x1 |= fgAnyNon4Bytes;
@ -370,7 +370,7 @@ void CSOM_MakeSOMClass(TypeClass *tclass) {
tclass->sominfo = info;
info->classdataobject = CSOM_MakeObject(tclass->classname->name, "ClassData", 28);
info->classdataobject->flags |= OBJECT_FLAGS_40;
info->classdataobject->flags = info->classdataobject->flags | OBJECT_FLAGS_40;
}
}
@ -604,7 +604,7 @@ typedef struct SOMGenerator {
static SOMAncestor *CSOM_FindAddAncestor(SOMGenerator *gen, TypeClass *tclass, TypeClass *ancestorClass, UInt16 *resultIndex) {
SOMAncestor *ancestor;
SOMAncestor *scan;
int index;
UInt16 index;
ancestor = gen->ancestors;
for (scan = ancestor, index = 0; scan; scan = scan->next, index++) {
@ -618,8 +618,8 @@ static SOMAncestor *CSOM_FindAddAncestor(SOMGenerator *gen, TypeClass *tclass, T
if (ancestor) {
index = 1;
while (ancestor->next) {
ancestor = ancestor->next;
index++;
ancestor = ancestor->next;
}
ancestor->next = lalloc(sizeof(SOMAncestor));
@ -709,7 +709,7 @@ static void CSOM_GenerateOverrideIntroLists(SOMGenerator *gen, TypeClass *tclass
SOMReleaseOrder *order;
SOMReleaseOrder *order2;
SInt32 index;
SInt32 index2;
UInt16 index2;
for (order = tclass->sominfo->order, index = 0; order; order = order->next, index++) {
method = lalloc(sizeof(SOMMethod));
@ -795,15 +795,13 @@ static void CSOM_GenerateClassAncestors(SOMGenerator *gen, TypeClass *tclass) {
relocs = NULL;
size = 0;
ancestor = gen->ancestors;
while (ancestor) {
for (ancestor = gen->ancestors; ancestor; ancestor = ancestor->next) {
OLinkList *reloc = lalloc(sizeof(OLinkList));
reloc->next = relocs;
relocs = reloc;
reloc->obj = ancestor->tclass->sominfo->classdataobject;
reloc->offset = size;
reloc->somevalue = 0;
ancestor = ancestor->next;
size += 4;
}
@ -831,22 +829,18 @@ static void CSOM_GenerateOverrideProcs(SOMGenerator *gen, TypeClass *tclass) {
relocs = NULL;
offset = 0;
ancestor = gen->ancestors;
while (ancestor) {
for (ancestor = gen->ancestors; ancestor; ancestor = ancestor->next) {
if (ancestor->overrides) {
override = ancestor->overrides;
while (override) {
for (override = ancestor->overrides; override; override = override->next) {
OLinkList *reloc = lalloc(sizeof(OLinkList));
reloc->next = relocs;
relocs = reloc;
reloc->obj = override->a;
reloc->offset = offset;
reloc->somevalue = 0;
override = override->next;
offset += 4;
}
}
ancestor = ancestor->next;
}
buf = lalloc(size);
@ -872,8 +866,8 @@ static Object *CSOM_GenerateOverrideData(SOMGenerator *gen) {
override = ancestor->overrides;
overrideCount = 0;
while (override) {
override = override->next;
overrideCount++;
override = override->next;
}
AppendGListWord(&name_mangle_list, CTool_EndianConvertWord16(overrideCount));
@ -993,8 +987,8 @@ static void CSOM_GenerateSpecialProcs(SOMGenerator *gen, TypeClass *tclass) {
static Object *CSOM_GenerateParentVersion(SOMGenerator *gen) {
SInt32 size;
UInt32 *buf;
SInt32 offset;
SOMAncestor *ancestor;
SInt32 offset;
size = 8 * (gen->counts.numDirectParents + gen->counts.numMetaClasses);
buf = lalloc(size);
@ -1009,7 +1003,7 @@ static Object *CSOM_GenerateParentVersion(SOMGenerator *gen) {
return CInit_DeclareString((char *) buf, size, 0, 0);
}
static void CSOM_SetNibble(UInt8 *buf, int offset, UInt8 value) {
static void CSOM_SetNibble(char *buf, int offset, UInt8 value) {
int i = offset >> 1;
if (offset & 1) {
int left = buf[i] & 0xF0;
@ -1025,7 +1019,7 @@ static void CSOM_SetNibble(UInt8 *buf, int offset, UInt8 value) {
static Object *CSOM_GenerateSlotUsage(SOMGenerator *gen) {
SInt32 size;
SOMMethod *method;
UInt8 *buf;
char *buf;
int offset;
size = (gen->counts.classTokenCount + 1) / 2;
@ -1046,7 +1040,7 @@ static Object *CSOM_GenerateSlotUsage(SOMGenerator *gen) {
}
}
return CInit_DeclareString((char *) buf, size, 0, 0);
return CInit_DeclareString(buf, size, 0, 0);
}
static Object *CSOM_GenerateSignature(SOMGenerator *gen) {
@ -1264,7 +1258,7 @@ static void CSOM_GenerateClassDataObject(SOMGenerator *gen, TypeClass *tclass) {
SOMMethod *method;
relocs = NULL;
for (size = 24, method = gen->methods; method; method = method->next, size += 4) {
for (size = 24, method = gen->methods; method; method = method->next) {
if (method->state == SOMMS_Method) {
reloc = lalloc(sizeof(OLinkList));
reloc->next = relocs;
@ -1273,6 +1267,7 @@ static void CSOM_GenerateClassDataObject(SOMGenerator *gen, TypeClass *tclass) {
reloc->offset = size;
reloc->somevalue = 0;
}
size += 4;
}
buf = lalloc(size);
@ -2056,7 +2051,7 @@ ENode *CSOM_MethodAccess(BClassList *path, Object *func, Boolean flag) {
NULL);
expr->rtype = indirectExpr->rtype;
if (copts.som_env_check && tclass3->sominfo->oidl_callstyle == 0)
expr->flags |= ENODE_FLAG_10;
expr->flags = expr->flags | ENODE_FLAG_10;
} else {
CSOM_FindIntroClassOffset(tclass2, func, &tclass3, &offset);
if (copts.som_call_optimize && CSOM_CanUseGlueCall(TYPE_FUNC(func->type)))
@ -2067,7 +2062,7 @@ ENode *CSOM_MethodAccess(BClassList *path, Object *func, Boolean flag) {
expr = makemonadicnode(expr, EINDIRECT);
expr->rtype = CDecl_NewPointerType(func->type);
if (copts.som_env_check && tclass3->sominfo->oidl_callstyle == 0)
expr->flags |= ENODE_FLAG_10;
expr->flags = expr->flags | ENODE_FLAG_10;
}
return expr;

View File

@ -318,11 +318,10 @@ static UInt8 CTempl_GetTemplateNestIndex(NameSpace *nspace) {
return count;
}
static TemplParam *CTempl_ParseParam(NameSpace *nspace, TemplParam *paramList, int index, UInt8 nindex) {
TemplParam *param;
static TemplParam *CTempl_ParseParam(NameSpace *nspace, TemplParam *param, UInt16 index, UInt8 nindex) {
DeclInfo di;
short startToken;
SInt32 savedState;
short startToken;
param = galloc(sizeof(TemplParam));
memclrw(param, sizeof(TemplParam));
@ -447,7 +446,7 @@ static TemplParam *CTempl_ParseParamList(NameSpace *nspace, UInt8 nindex) {
TemplParam **ptr;
TemplParam *param;
TemplParam *scan;
int index;
UInt16 index;
params = NULL;
index = 0;
@ -484,7 +483,7 @@ static TemplParam *CTempl_ParseParamList(NameSpace *nspace, UInt8 nindex) {
TemplArg *CTempl_ParseUncheckTemplArgs(TemplParam *params, Boolean is_global) {
TemplArg *args;
TemplArg *last;
int index;
UInt16 index;
if (tk != '<') {
CError_Error(CErrorStr230);
@ -988,7 +987,7 @@ static void CTempl_ParseConversionFunctionTemplate(DeclInfo *di, DeclFucker *wha
return;
}
tclass->flags |= CLASS_FLAGS_40;
tclass->flags = tclass->flags | CLASS_FLAGS_40;
CError_QualifierCheck(di->qual & ~Q_INLINE);
conversion_type_name(di);

View File

@ -231,9 +231,9 @@ static void retain_argument_register(Object *obj, short reg) {
}
static void allocate_local_vregs(void) {
VarInfo *vi;
ObjectList *list;
Object *obj;
VarInfo *vi;
if (copts.codegen_pic && uses_globals && assignable_registers[RegClass_GPR]) {
if (assignable_registers[RegClass_GPR]) {
@ -863,7 +863,6 @@ void CodeGen_Generator(Statement *statements, Object *func, UInt8 mysteryFlag, B
Statement *stmt;
Boolean has_varargs;
PCodeBlock *tmp;
Object *obj;
SInt32 size;
CodeGen_InitialSanityCheck();
@ -877,8 +876,11 @@ void CodeGen_Generator(Statement *statements, Object *func, UInt8 mysteryFlag, B
if (!func) {
func = createstaticinitobject();
} else if (func && func->name) {
PrintProgressFunction(func->name->name);
} else {
#ifdef CW_CLT
if (func && func->name)
PrintProgressFunction(func->name->name);
#endif
}
gFunction = func;
@ -981,8 +983,7 @@ void CodeGen_Generator(Statement *statements, Object *func, UInt8 mysteryFlag, B
break;
case ST_ENDCATCHDTOR:
CError_ASSERT(2056, stmt->expr->data.objref->datatype == DLOCAL);
obj = stmt->expr->data.objref;
add_immediate(3, local_base_register(obj), obj, 0);
add_immediate(3, local_base_register(stmt->expr->data.objref), stmt->expr->data.objref, 0);
{
UInt32 masks[RegClassMax] = {0, 0, 0, 0, 0};
masks[RegClass_GPR] |= 1 << 3;
@ -1467,7 +1468,7 @@ void CodeGen_ParsePragma(HashNameNode *name) {
return;
}
if (!strcmp(name->name, "unroll_speculative")) {
if (!strcmp(name->name, "ppc_unroll_speculative")) {
if (plex() == TK_IDENTIFIER) {
if (!strcmp(tkidentifier->name, "off")) {
copts.unroll_speculative = 0;
@ -1484,7 +1485,7 @@ void CodeGen_ParsePragma(HashNameNode *name) {
return;
}
if (!strcmp(name->name, "unroll_instr_limit")) {
if (!strcmp(name->name, "ppc_unroll_instructions_limit")) {
t = plex();
if (t == TK_INTCONST) {
copts.unroll_instr_limit = CInt64_GetULong(&tkintconst);
@ -1539,7 +1540,7 @@ void CodeGen_ParsePragma(HashNameNode *name) {
return;
}
if (!strcmp(name->name, "unroll_factor_limit")) {
if (!strcmp(name->name, "ppc_unroll_factor_limit")) {
t = plex();
if (t == TK_INTCONST) {
copts.unroll_factor_limit = CInt64_GetULong(&tkintconst);

View File

@ -115,7 +115,6 @@ static void CountUsage(void) {
Statement *IRO_Optimizer(Object *func, Statement *statements) {
Boolean changed;
Boolean changed2;
int pass;
int passCount;
@ -292,30 +291,30 @@ Statement *IRO_Optimizer(Object *func, Statement *statements) {
IRO_RemoveUnreachable();
IRO_DumpAfterPhase("IRO_RemoveUnreachable", 0);
changed2 = IRO_RemoveRedundantJumps();
changed = IRO_RemoveRedundantJumps();
IRO_DumpAfterPhase("IRO_RemoveRedundantJumps", 0);
changed2 |= IRO_RemoveLabels();
changed |= IRO_RemoveLabels();
IRO_DumpAfterPhase("IRO_RemoveLabels", 0);
changed2 |= IRO_DoJumpChaining();
changed |= IRO_DoJumpChaining();
IRO_DumpAfterPhase("IRO_DoJumpChaining", 0);
if (copts.propagation) {
IRO_RenumberInts();
IRO_DumpAfterPhase("Before IRO_CopyAndConstantPropagation", 0);
changed2 |= IRO_CopyAndConstantPropagation();
changed |= IRO_CopyAndConstantPropagation();
IRO_DumpAfterPhase("After IRO_CopyAndConstantPropagation", 0);
IRO_ConstantFolding();
}
if (copts.deadstore || copts.propagation)
changed2 |= IRO_UseDef(copts.deadstore, copts.propagation);
changed |= IRO_UseDef(copts.deadstore, copts.propagation);
IRO_DumpAfterPhase("IRO_UseDef", 0);
changed2 |= IRO_EvaluateConditionals();
changed |= IRO_EvaluateConditionals();
IRO_DumpAfterPhase("IRO_EvaluateConditionals", 0);
} while (changed2);
} while (changed);
}
if (copts.lifetimes) {

View File

@ -29,7 +29,7 @@ typedef struct Reloc {
SInt32 relocID;
SInt32 picOffset;
struct Reloc *next;
RelocType relocType;
char relocType;
MWReloc mwRelType;
} Reloc;
@ -113,7 +113,8 @@ SInt32 pic_base_offset;
#define RELOC_DATA(_id) (((RelocDataT *) (*RelocData.data))[(_id)])
static Section SegmentForceCreate = SECT_TEXT;
enum { ForceCreateCount = 1 };
static Section SegmentForceCreate[ForceCreateCount] = { SECT_TEXT };
// forward decls
static void CreateTheSegment(void);
@ -884,13 +885,13 @@ void ObjGen_Finish(void) {
argMask = 0xFFFF;
if (value & 0x8000)
value += 0x10000;
value = (value >> 16) & 0xFFFF;
value = (value & 0xFFFF0000) >> 16;
nextRelType = PPC_RELOC_HA16_SECTDIFF;
break;
case MW_RELOC_6_HI16:
opMask = 0xFFFF0000;
argMask = 0xFFFF;
value = (value >> 16) & 0xFFFF;
value = (value & 0xFFFF0000) >> 16;
nextRelType = PPC_RELOC_HI16_SECTDIFF;
break;
case MW_RELOC_8:
@ -945,13 +946,13 @@ void ObjGen_Finish(void) {
argMask = 0xFFFF;
if (value & 0x8000)
value += 0x10000;
value = (value >> 16) & 0xFFFF;
value = (value & 0xFFFF0000) >> 16;
nextRelType = PPC_RELOC_HA16;
break;
case MW_RELOC_6_HI16:
opMask = 0xFFFF0000;
argMask = 0xFFFF;
value = (value >> 16) & 0xFFFF;
value = (value & 0xFFFF0000) >> 16;
nextRelType = PPC_RELOC_HI16;
break;
case MW_RELOC_8:
@ -1011,8 +1012,11 @@ void ObjGen_SetupSym(void) {
}
static void CreateTheSegment(void) {
int i;
TheSegment = MachO_CreateSegment("", 7, 7, 0);
Sections[SegmentForceCreate] = ObjGen_GetSection(SegmentForceCreate);
for (i = 0; i < ForceCreateCount; i++)
Sections[SegmentForceCreate[i]] = ObjGen_GetSection(SegmentForceCreate[i]);
}
static void patchuplazyptr(Object *object) {
@ -1143,9 +1147,9 @@ static void declaredata(Object *object, char *data, OLinkList *olinklist, UInt32
if (!align)
align = 1;
if (offset % align) {
if ((offset % align) != 0) {
// issue here
SInt32 adjust = align - (offset % align);
int adjust = align - (offset % align);
offset = offset + adjust;
}
@ -1223,7 +1227,7 @@ void ObjGen_SrcBreakName(HashNameNode *name, SInt32 fileModDate, Boolean flag) {
if (name && copts.absolutepath)
ptr = buf1 + strlen(buf1);
else
ptr = strrchr(buf1, '/');
ptr = strrchr(buf1, OS_PATHSEP);
if ((flag || name) && ptr && copts.absolutepath) {
if (!strncmp(buf1, "Mac OS X:", strlen("Mac OS X:"))) {
@ -1236,8 +1240,20 @@ void ObjGen_SrcBreakName(HashNameNode *name, SInt32 fileModDate, Boolean flag) {
ptr3 = buf1;
}
while (ptr3 <= ptr)
*(ptr2++) = *(ptr3++);
while (ptr3 <= ptr) {
#ifdef CW_HOST_MAC_CLASSIC
if (*ptr3 == '/')
*ptr2 = ':';
else if (*ptr3 == ':')
*ptr2 = '/';
else
*ptr2 = *ptr3;
#else
*ptr2 = *ptr3;
#endif
ptr2++;
ptr3++;
}
*ptr2 = 0;
if (flag && !name) {
@ -1305,8 +1321,7 @@ MachOSection *ObjGen_DeclareCode(Object *object, SInt32 size) {
return section;
}
MachOSection *ObjGen_DeclareMachSection() {
// unknown args
MachOSection *ObjGen_DeclareMachSection(char *segname, char *sectname, UInt32 align, UInt32 flags) {
CError_FATAL(2020);
return NULL;
}
@ -1589,7 +1604,7 @@ void ObjGen_DeclareExceptionTables(Object *object, SInt32 codesize, char *data,
flag22 = 0;
if (len == 8) {
if (CTool_EndianConvertWord16(*((UInt16 *) data) & 8) >> 3) {
if ((CTool_EndianConvertWord16(*((UInt16 *) data)) >> 3) & 1) {
*((UInt16 *) data) = CTool_EndianConvertWord16(CTool_EndianConvertWord16(*((UInt16 *) data)) & ~8);
len = 4;
}

View File

@ -23,10 +23,10 @@ void load_immediate(short reg, SInt32 value) {
short tmpreg2;
if (!FITS_IN_SHORT(value)) {
if (copts.optimizationlevel > 1 && value)
if (copts.optimizationlevel > 1 && LOW_PART_BUGGY(value))
tmpreg = used_virtual_registers[RegClass_GPR]++;
emitpcode(PC_LIS, tmpreg2 = tmpreg, 0, (short) HIGH_PART(value));
if (LOW_PART(value))
if (LOW_PART_BUGGY(value))
emitpcode(PC_ADDI, reg, tmpreg2, 0, LOW_PART(value));
} else {
emitpcode(PC_LI, reg, value);
@ -263,7 +263,7 @@ void combine(Operand *opA, Operand *opB, short output_reg, Operand *opOut) {
emitpcode(PC_ADDI, opOut->regOffset, opB->regOffset, 0, LOW_PART(opA->immediate));
} else {
emitpcode(PC_ADDIS, opOut->regOffset, opB->regOffset, 0, (short) HIGH_PART(opA->immediate));
if (LOW_PART(opA->immediate))
if (LOW_PART_BUGGY(opA->immediate))
emitpcode(PC_ADDI, opOut->regOffset, opOut->regOffset, 0, LOW_PART(opA->immediate));
}
break;
@ -381,10 +381,10 @@ void Coerce_to_register(Operand *op, Type *type, short output_reg) {
emitpcode(PC_LI, reg, offset);
} else {
tmp = reg;
if (copts.optimizationlevel > 1 && offset)
if (copts.optimizationlevel > 1 && LOW_PART_BUGGY(offset))
tmp = used_virtual_registers[RegClass_GPR]++;
emitpcode(PC_LIS, tmp, 0, (short) HIGH_PART(offset));
if (LOW_PART(offset))
if (LOW_PART_BUGGY(offset))
emitpcode(PC_ADDI, reg, tmp, 0, LOW_PART(offset));
}
break;
@ -530,10 +530,10 @@ void coerce_to_register_pair(Operand *op, Type *type, short output_reg, short ou
emitpcode(PC_LI, reg, offset);
} else {
tmp1 = reg;
if (copts.optimizationlevel > 1 && offset)
if (copts.optimizationlevel > 1 && LOW_PART_BUGGY(offset))
tmp1 = used_virtual_registers[RegClass_GPR]++;
emitpcode(PC_LIS, tmp1, 0, (short) HIGH_PART(offset));
if (LOW_PART(offset))
if (LOW_PART_BUGGY(offset))
emitpcode(PC_ADDI, reg, tmp1, 0, LOW_PART(offset));
}
regHi = output_regHi ? output_regHi : used_virtual_registers[RegClass_GPR]++;

View File

@ -615,34 +615,13 @@ extern void CError_SetNullErrorToken(void);
extern void CError_LockErrorPos(TStreamElement *token, TStreamElement **saved);
extern void CError_UnlockErrorPos(TStreamElement **saved);
extern void CError_ResetErrorSkip(void);
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, ...);

View File

@ -27,18 +27,11 @@ CW_INLINE void CInt64_SetULong(CInt64 *pN, UInt32 n) {
}
CW_INLINE Boolean CInt64_IsZero(CInt64 *n) {
//if (n->hi == 0 && n->lo == 0)
// return 1;
//else
// return 0;
return n->hi == 0 && n->lo == 0;
}
CW_INLINE Boolean CInt64_IsOne(CInt64 *n) { // assumed name
return n->hi == 0 && n->lo == 1;
}
CW_INLINE void CInt64_Extend32(CInt64 *n) { // assumed name
n->hi = (n->lo >> 31) ? 0xFFFFFFFF : 0;
}
extern void CInt64_Init(void);
extern CInt64 CInt64_Not(CInt64 input);

View File

@ -62,7 +62,7 @@ extern void ObjGen_DeclareVectorConst(Object *object);
extern void ObjGenMach_SymFuncEnd(Object *function, UInt32 offset);
extern void ObjGen_CodeSetup(void);
extern MachOSection *ObjGen_DeclareFunction(Object *object);
extern MachOSection *ObjGen_DeclareMachSection(/* unknown args */);
extern MachOSection *ObjGen_DeclareMachSection(char *segname, char *sectname, UInt32 align, UInt32 flags);
extern void ObjGen_Relocate(MachOSection *section, SInt32 offset, SInt32 relocID, RelocType relocType, MWReloc mwRelType);
extern SInt32 ObjGen_DeclareLiteralString(UInt32 len, char *data, SInt32 align);
extern UInt32 ObjGen_GetSectSize(MachOSection *section);

View File

@ -3,6 +3,8 @@
#include "cw_common.h"
enum { CR = 13, LF = 10 };
typedef struct HashNameNode {
struct HashNameNode *next;
SInt32 id;
@ -326,9 +328,18 @@ struct CompilerLinkerParamBlk {
#define FITS_IN_USHORT(value) ( (value) == ((unsigned short) (value)) )
#define FITS_IN_HI_SHORT(value) ( (value) == (value & 0xFFFF0000) )
#define FITS_IN_SHORT2(value) ( ((short) (value)) == (value) )
#define HIGH_PART(value) ( (short) (((value) >> 16) + (((value) & 0x8000) >> 15)) )
#define HIGH_PART(value) ( (short) (((value) >> 16) + (((value) >> 15) & 1)) )
#define LOW_PART(value) ( (short) (value) )
// The PowerPC code generator has a bug which breaks the PowerPC code generator,
// causing 32-bit value loads to emit "addi x, y, 0" even if the lower 16 bits are
// zero. This define simulates that behaviour on other platforms
#ifdef CW_REPLICATE_PPC_CODEGEN_BUG
#define LOW_PART_BUGGY(value) (value)
#else
#define LOW_PART_BUGGY(value) ( (short) (value) )
#endif
#ifdef __MWERKS__
#pragma options align=reset
#endif

View File

@ -3,7 +3,11 @@
#include "common.h"
#ifdef CW_HOST_MAC_CLASSIC
#define OS_PATHSEP ':'
#else
#define OS_PATHSEP '/'
#endif
/**
* OS abstraction layer