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) include_directories(sdk_hdrs)
# add_compile_definitions(CW_ENABLE_IRO_DEBUG) # 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 add_executable(mwcc
command_line/CmdLine/Src/Clients/CLStaticMain.c command_line/CmdLine/Src/Clients/CLStaticMain.c

View File

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

View File

@ -37,11 +37,11 @@ loop:
goto loop; goto loop;
case ' ': case ' ':
case '\t': case '\t':
case '\n': case LF:
case '\v': case '\v':
case '\f': case '\f':
spaceskip = 1;
p++; p++;
spaceskip = 1;
goto loop; goto loop;
case ';': case ';':
pos = (char *) p++; pos = (char *) p++;
@ -64,17 +64,17 @@ loop:
case '/': case '/':
pos = (char *) p++; pos = (char *) p++;
if (copts.multibyteaware) { if (copts.multibyteaware) {
while (p[0] == '\\' && !COS_IsMultiByte(start, p) && p[1] == '\r') { while (p[0] == '\\' && !COS_IsMultiByte(start, p) && p[1] == CR) {
foundnl(); foundnl();
if (p[2] == '\n') if (p[2] == LF)
p += 3; p += 3;
else else
p += 2; p += 2;
} }
} else { } else {
while (p[0] == '\\' && p[1] == '\r') { while (p[0] == '\\' && p[1] == CR) {
foundnl(); foundnl();
if (p[2] == '\n') if (p[2] == LF)
p += 3; p += 3;
else else
p += 2; p += 2;
@ -99,17 +99,17 @@ loop:
} }
if (c == '*') { if (c == '*') {
if (copts.multibyteaware) { if (copts.multibyteaware) {
while (p[0] == '\\' && !COS_IsMultiByte(start, p) && p[1] == '\r') { while (p[0] == '\\' && !COS_IsMultiByte(start, p) && p[1] == CR) {
foundnl(); foundnl();
if (p[2] == '\n') if (p[2] == LF)
p += 3; p += 3;
else else
p += 2; p += 2;
} }
} else { } else {
while (p[0] == '\\' && p[1] == '\r') { while (p[0] == '\\' && p[1] == CR) {
foundnl(); foundnl();
if (p[2] == '\n') if (p[2] == LF)
p += 3; p += 3;
else else
p += 2; p += 2;
@ -120,7 +120,7 @@ loop:
goto loop; goto loop;
} }
} }
if (c == '\r') if (c == CR)
foundnl(); foundnl();
} }
} }
@ -138,10 +138,10 @@ loop:
case '\\': case '\\':
pos = (char *) p++; pos = (char *) p++;
mid_backslash: mid_backslash:
if (*p == '\r') { if (*p == CR) {
if (!copts.multibyteaware || !COS_IsMultiByte(start, p - 1)) { if (!copts.multibyteaware || !COS_IsMultiByte(start, p - 1)) {
foundnl(); foundnl();
if (p[1] == '\n') if (p[1] == LF)
p += 2; p += 2;
else else
p += 1; p += 1;
@ -208,17 +208,17 @@ loop:
return c; return c;
case '/': case '/':
if (copts.multibyteaware) { if (copts.multibyteaware) {
while (p[0] == '\\' && !COS_IsMultiByte(start, p) && p[1] == '\r') { while (p[0] == '\\' && !COS_IsMultiByte(start, p) && p[1] == CR) {
foundnl(); foundnl();
if (p[2] == '\n') if (p[2] == LF)
p += 3; p += 3;
else else
p += 2; p += 2;
} }
} else { } else {
while (p[0] == '\\' && p[1] == '\r') { while (p[0] == '\\' && p[1] == CR) {
foundnl(); foundnl();
if (p[2] == '\n') if (p[2] == LF)
p += 3; p += 3;
else else
p += 2; p += 2;
@ -242,17 +242,17 @@ loop:
} }
if (c == '*') { if (c == '*') {
if (copts.multibyteaware) { if (copts.multibyteaware) {
while (p[0] == '\\' && !COS_IsMultiByte(start, p) && p[1] == '\r') { while (p[0] == '\\' && !COS_IsMultiByte(start, p) && p[1] == CR) {
foundnl(); foundnl();
if (p[2] == '\n') if (p[2] == LF)
p += 3; p += 3;
else else
p += 2; p += 2;
} }
} else { } else {
while (p[0] == '\\' && p[1] == '\r') { while (p[0] == '\\' && p[1] == CR) {
foundnl(); foundnl();
if (p[2] == '\n') if (p[2] == LF)
p += 3; p += 3;
else else
p += 2; p += 2;
@ -261,7 +261,7 @@ loop:
if (*p == '/') if (*p == '/')
break; break;
} }
if (c == '\r') if (c == CR)
foundnl(); foundnl();
} }
pos = (char *) p + 1; pos = (char *) p + 1;
@ -272,10 +272,10 @@ loop:
} }
case '\\': case '\\':
backslash: backslash:
if (*p == '\r') { if (*p == CR) {
if (!copts.multibyteaware || !COS_IsMultiByte(start, p - 1)) { if (!copts.multibyteaware || !COS_IsMultiByte(start, p - 1)) {
foundnl(); foundnl();
if (p[1] == '\n') if (p[1] == LF)
p += 2; p += 2;
else else
p += 1; p += 1;
@ -345,12 +345,12 @@ loop:
return c; return c;
case '\\': case '\\':
backslash: 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) if (flag)
foundnl(); foundnl();
else else
prepnextstringchar_foundnl = 1; prepnextstringchar_foundnl = 1;
if (p[1] == '\n') if (p[1] == LF)
p += 2; p += 2;
else else
p += 1; p += 1;
@ -421,11 +421,11 @@ loop:
return; return;
} }
if (c == '\r') { if (c == CR) {
if (!copts.multibyteaware || !COS_IsMultiByte(start, p - 1)) { if (!copts.multibyteaware || !COS_IsMultiByte(start, p - 1)) {
if (flag) if (flag)
foundnl(); foundnl();
if (*p == '\n') if (*p == LF)
p++; p++;
CPrep_Error(CErrorStr112); CPrep_Error(CErrorStr112);
pos = p; pos = p;
@ -445,8 +445,8 @@ loop:
case '<': case '<':
case '=': case '=':
case '>': case '>':
haveBackslash = 0;
p += 2; p += 2;
haveBackslash = 0;
goto loop; goto loop;
case '/': case '/':
p += 2; p += 2;
@ -456,10 +456,10 @@ loop:
if (c == '\\' && !haveBackslash && (!copts.multibyteaware || !COS_IsMultiByte(start, p - 1))) { if (c == '\\' && !haveBackslash && (!copts.multibyteaware || !COS_IsMultiByte(start, p - 1))) {
backslash: backslash:
if (*p == '\r') { if (*p == CR) {
if (flag) if (flag)
foundnl(); foundnl();
if (*(++p) == '\n') if (*(++p) == LF)
p++; p++;
haveBackslash = 0; haveBackslash = 0;
} else { } else {
@ -496,11 +496,11 @@ loop:
return p - 1; return p - 1;
} }
if (c == '\r') { if (c == CR) {
if (!copts.multibyteaware || !COS_IsMultiByte(start, p - 1)) { if (!copts.multibyteaware || !COS_IsMultiByte(start, p - 1)) {
if (flag) if (flag)
foundnl(); foundnl();
if (*p == '\n') if (*p == LF)
p++; p++;
CPrep_Error(CErrorStr112); CPrep_Error(CErrorStr112);
return p; return p;
@ -519,8 +519,8 @@ loop:
case '<': case '<':
case '=': case '=':
case '>': case '>':
haveBackslash = 0;
p += 2; p += 2;
haveBackslash = 0;
goto loop; goto loop;
case '/': case '/':
p += 2; p += 2;
@ -530,10 +530,10 @@ loop:
if (c == '\\' && !haveBackslash && (!copts.multibyteaware || !COS_IsMultiByte(start, p - 1))) { if (c == '\\' && !haveBackslash && (!copts.multibyteaware || !COS_IsMultiByte(start, p - 1))) {
backslash: backslash:
if (*p == '\r') { if (*p == CR) {
if (flag) if (flag)
foundnl(); foundnl();
if (*(++p) == '\n') if (*(++p) == LF)
p++; p++;
haveBackslash = 0; haveBackslash = 0;
} else { } else {
@ -582,7 +582,7 @@ static void prepcurstringchar_skip(void) {
} }
char *ReadIdentifier(const char *p) { char *ReadIdentifier(const char *p) {
char buf[256]; unsigned char buf[256];
const char *start; const char *start;
unsigned int ch; unsigned int ch;
int len; int len;
@ -590,15 +590,15 @@ char *ReadIdentifier(const char *p) {
start = p; start = p;
len = 0; len = 0;
for (;;) { for (;;) {
ch = (unsigned char) *p; ch = *p;
if (cprep_idarray[ch]) { if (cprep_idarray[(unsigned char) *p]) {
if (len < 255) if (len < 255)
buf[len++] = *p; buf[len++] = *p;
p++; p++;
} else { } else {
if (copts.multibyteaware) { if (copts.multibyteaware) {
if ((unsigned char) *p == '\\' && !COS_IsMultiByte(start, p) && p[1] == '\r') { if ((unsigned char) *p == '\\' && !COS_IsMultiByte(start, p) && p[1] == CR) {
if (p[2] == '\n') if (p[2] == LF)
p += 3; p += 3;
else else
p += 2; p += 2;
@ -607,8 +607,8 @@ char *ReadIdentifier(const char *p) {
break; break;
} }
} else { } else {
if ((unsigned char) *p == '\\' && p[1] == '\r') { if ((unsigned char) *p == '\\' && p[1] == CR) {
if (p[2] == '\n') if (p[2] == LF)
p += 3; p += 3;
else else
p += 2; p += 2;
@ -621,7 +621,7 @@ char *ReadIdentifier(const char *p) {
} }
buf[len] = 0; buf[len] = 0;
tkidentifier = GetHashNameNodeExport(buf); tkidentifier = GetHashNameNodeExport((char *) buf);
return (char *) p; return (char *) p;
} }
@ -807,14 +807,14 @@ static SInt32 nextchar(StringPtr str) {
case 'f': return 12; case 'f': return 12;
case 'n': case 'n':
if (copts.mpwc_newline) if (copts.mpwc_newline)
return 13; return CR;
else else
return 10; return LF;
case 'r': case 'r':
if (copts.mpwc_newline) if (copts.mpwc_newline)
return 10; return LF;
else else
return 13; return CR;
case 'e': return 27; case 'e': return 27;
case 'x': case 'x':
chr = tohex(prepnextstringchar(str, 1)); chr = tohex(prepnextstringchar(str, 1));
@ -874,26 +874,26 @@ StringPtr CPrep_SkipNewComment(StringPtr str) {
p[-1] = ' '; p[-1] = ' ';
continue; continue;
case '\r': case CR:
CPrep_SkipNewCommentChar = '\r'; CPrep_SkipNewCommentChar = CR;
return p; return p;
case '\\': case '\\':
if (copts.multibyteaware && COS_IsMultiByte(str, p - 1)) if (copts.multibyteaware && COS_IsMultiByte(str, p - 1))
continue; continue;
if (*p == '\r') { if (*p == CR) {
++p; ++p;
foundnl(); foundnl();
} }
if (*p == '\n') if (*p == LF)
p++; p++;
continue; continue;
case '"': case '"':
if (InlineAsm_gccmode) { if (InlineAsm_gccmode) {
CPrep_SkipNewCommentChar = '\r'; CPrep_SkipNewCommentChar = CR;
return p - 1; return p - 1;
} }
continue; continue;
@ -910,7 +910,7 @@ Boolean skipendoflinematch(StringPtr str, short token) {
while (1) { while (1) {
switch (*(str++)) { switch (*(str++)) {
case 0: case 0:
case '\r': case CR:
pos = (char *) str - 1; pos = (char *) str - 1;
return 0; return 0;
@ -937,16 +937,16 @@ Boolean skipendoflinematch(StringPtr str, short token) {
pos = (char *) str - 1; pos = (char *) str - 1;
return 0; return 0;
case '\r': case CR:
foundnl(); foundnl();
if (*str == '\n') if (*str == LF)
str++; str++;
break; break;
} }
break; break;
case '?': case '?':
if (copts.trigraphs && str[0] == '?' && str[1] == '/' && str[2] == '\r') { if (copts.trigraphs && str[0] == '?' && str[1] == '/' && str[2] == CR) {
foundnl(); foundnl();
str += 3; str += 3;
} }
@ -966,7 +966,7 @@ void skipendofline(void) {
while (1) { while (1) {
switch (*(p++)) { switch (*(p++)) {
case 0: case 0:
case '\r': case CR:
pos = (char *) p - 1; pos = (char *) p - 1;
return; return;
@ -984,17 +984,17 @@ void skipendofline(void) {
case '/': case '/':
if (copts.multibyteaware) { if (copts.multibyteaware) {
while (*p == '\\' && !COS_IsMultiByte(start, p) && p[1] == '\r') { while (*p == '\\' && !COS_IsMultiByte(start, p) && p[1] == CR) {
foundnl(); foundnl();
if (p[2] == '\n') if (p[2] == LF)
p += 3; p += 3;
else else
p += 2; p += 2;
} }
} else { } else {
while (*p == '\\' && p[1] == '\r') { while (*p == '\\' && p[1] == CR) {
foundnl(); foundnl();
if (p[2] == '\n') if (p[2] == LF)
p += 3; p += 3;
else else
p += 2; p += 2;
@ -1004,7 +1004,7 @@ void skipendofline(void) {
if (*p == '/' && (!copts.ANSIstrict || copts.cplusplus)) { if (*p == '/' && (!copts.ANSIstrict || copts.cplusplus)) {
// EOL comment // EOL comment
pos = (char *) CPrep_SkipNewComment(p + 1); pos = (char *) CPrep_SkipNewComment(p + 1);
if (CPrep_SkipNewCommentChar == '\r') if (CPrep_SkipNewCommentChar == CR)
pos--; pos--;
return; return;
} }
@ -1026,17 +1026,17 @@ void skipendofline(void) {
if (ch == '*') { if (ch == '*') {
if (copts.multibyteaware) { if (copts.multibyteaware) {
while (*p == '\\' && !COS_IsMultiByte(start, p) && p[1] == '\r') { while (*p == '\\' && !COS_IsMultiByte(start, p) && p[1] == CR) {
foundnl(); foundnl();
if (p[2] == '\n') if (p[2] == LF)
p += 3; p += 3;
else else
p += 2; p += 2;
} }
} else { } else {
while (*p == '\\' && p[1] == '\r') { while (*p == '\\' && p[1] == CR) {
foundnl(); foundnl();
if (p[2] == '\n') if (p[2] == LF)
p += 3; p += 3;
else else
p += 2; p += 2;
@ -1049,7 +1049,7 @@ void skipendofline(void) {
} }
} }
if (ch == '\r') if (ch == CR)
foundnl(); foundnl();
} }
} }
@ -1059,9 +1059,9 @@ void skipendofline(void) {
if (copts.multibyteaware && COS_IsMultiByte(start, p - 1)) if (copts.multibyteaware && COS_IsMultiByte(start, p - 1))
continue; continue;
if (*p == '\r') { if (*p == CR) {
foundnl(); foundnl();
if (p[1] == '\n') if (p[1] == LF)
p += 2; p += 2;
else else
p += 1; p += 1;
@ -1069,7 +1069,7 @@ void skipendofline(void) {
break; break;
case '?': case '?':
if (copts.trigraphs && p[0] == '?' && p[1] == '/' && p[2] == '\r') { if (copts.trigraphs && p[0] == '?' && p[1] == '/' && p[2] == CR) {
foundnl(); foundnl();
p += 3; p += 3;
} }
@ -1106,7 +1106,7 @@ static short tapos(short _t) {
start = (StringPtr) pos; start = (StringPtr) pos;
t = nextchar((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); CPrep_Error(CErrorStr100);
tkintconst = cint64_zero; tkintconst = cint64_zero;
tksize = IT_INT; tksize = IT_INT;
@ -1169,7 +1169,7 @@ static short tapos(short _t) {
i = bytecount; i = bytecount;
while (1) { while (1) {
if ((t2 == 0 || t2 == '\r') && !was_escchar) { if ((t2 == 0 || t2 == CR) && !was_escchar) {
CPrep_Error(CErrorStr100); CPrep_Error(CErrorStr100);
break; break;
} }
@ -1201,7 +1201,7 @@ static short tapos(short _t) {
static short tquot(short t) { static short tquot(short t) {
Type *type; Type *type;
StringPtr string_ptr; char *string_ptr;
SInt32 size; SInt32 size;
short c; short c;
StringPtr save_pos; StringPtr save_pos;
@ -1213,7 +1213,7 @@ static short tquot(short t) {
if (cprep_nostring) if (cprep_nostring)
return '"'; return '"';
string_ptr = (StringPtr) *stringmem; string_ptr = *stringmem;
ispascalstring = 0; ispascalstring = 0;
size = 0; size = 0;
if (widestring) if (widestring)
@ -1235,7 +1235,7 @@ static short tquot(short t) {
while (1) { while (1) {
c = nextchar(start_pos); 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)) if (c == 0 && (tokenstacklevel > 0 || pos >= prep_file_end))
CPrep_Error(CErrorStr102); CPrep_Error(CErrorStr102);
else if (c != '"') else if (c != '"')
@ -1243,10 +1243,10 @@ static short tquot(short t) {
break; break;
} }
if ((size + type->size) >= maxstringsize) { if ((size + type->size) >= maxstringsize) {
SInt32 offset = string_ptr - (StringPtr) *stringmem; SInt32 offset = string_ptr - *stringmem;
if (!COS_ResizeHandle(stringmem, maxstringsize += 256)) if (!COS_ResizeHandle(stringmem, maxstringsize += 256))
CError_NoMem(); CError_NoMem();
string_ptr = (StringPtr) *stringmem + offset; string_ptr = *stringmem + offset;
} }
if (type->size != 1) { if (type->size != 1) {
CInt64_SetLong(&ch64, c); CInt64_SetLong(&ch64, c);
@ -2242,7 +2242,7 @@ typedef struct StringChunk {
} StringChunk; } StringChunk;
static void CPrep_StringConCat(Boolean flag) { static void CPrep_StringConCat(Boolean flag) {
StringPtr buffer; char *buffer;
StringChunk *chunks; StringChunk *chunks;
StringChunk *chunk; StringChunk *chunk;
char *saveString; char *saveString;
@ -2287,7 +2287,7 @@ static void CPrep_StringConCat(Boolean flag) {
} }
elem = ts_current - 1; elem = ts_current - 1;
elem->data.tkstring.data = (char *) buffer; elem->data.tkstring.data = buffer;
elem->data.tkstring.size = offset; elem->data.tkstring.size = offset;
elem->subtype = ispascalstring; elem->subtype = ispascalstring;
cprep_strconcat = 0; 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) { static Boolean CScope_DependentTemplateMember(CScopeParseResult *result, TypeTemplDep *ttempldep, Boolean flag1, Boolean flag2) {
SInt32 streamstate; SInt32 streamstate;
short token; int token;
TypeTemplDep *newtype; TypeTemplDep *newtype;
TypeTemplDep *newtype2; TypeTemplDep *newtype2;
@ -2537,30 +2537,30 @@ void CScope_AddClassUsingDeclaration(TypeClass *tclass, TypeClass *tclass2, Hash
void CScope_ParseUsingDeclaration(NameSpace *nspace, AccessType access, Boolean flag) { void CScope_ParseUsingDeclaration(NameSpace *nspace, AccessType access, Boolean flag) {
NameSpace *saveNSpace; NameSpace *saveNSpace;
Boolean flag_r27; Boolean isTemplate;
Boolean flag_r26; Boolean isTypename;
NameSpaceObjectList *scan; NameSpaceObjectList *scan;
CScopeParseResult result; CScopeParseResult result;
if (nspace->theclass) { if (nspace->theclass) {
flag_r27 = (TYPE_CLASS(nspace->theclass)->flags & CLASS_FLAGS_100) ? 1 : 0; isTemplate = (TYPE_CLASS(nspace->theclass)->flags & CLASS_FLAGS_100) != 0;
flag_r26 = 0; isTypename = 0;
if (tk == TK_TYPENAME) { if (tk == TK_TYPENAME) {
if (!flag_r27) if (!isTemplate)
CError_Error(CErrorStr200); CError_Error(CErrorStr200);
flag_r26 = 1; isTypename = 1;
tk = lex(); tk = lex();
} }
if (!CScope_ParseMemberName(nspace->theclass, &result, flag_r27)) { if (!CScope_ParseMemberName(nspace->theclass, &result, isTemplate)) {
CError_Error(CErrorStr200); CError_Error(CErrorStr200);
return; return;
} }
if (result.x8 && IS_TYPE_TEMPLATE(result.x8) && TYPE_TEMPLATE(result.x8)->dtype == TEMPLDEP_QUALNAME) { 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)); ObjType *objtype = galloc(sizeof(ObjType));
memclrw(objtype, sizeof(ObjType)); memclrw(objtype, sizeof(ObjType));
objtype->otype = OT_TYPE; objtype->otype = OT_TYPE;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -643,7 +643,7 @@ static void CInit_SetBitfield(TypeBitfield *tbitfield, UInt8 *buffer, CInt64 val
pos = tbitfield->unkB + tbitfield->unkA - 1; pos = tbitfield->unkB + tbitfield->unkA - 1;
step = -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 (CInt64_GetULong(&val) & 1) {
if (copts.littleendian) { if (copts.littleendian) {
buffer[pos >> 3] |= 1 << (pos & 7); 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); 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)); copy = galloc(sizeof(TypePointer));
*TYPE_POINTER(copy) = *TYPE_POINTER(type); *TYPE_POINTER(copy) = *TYPE_POINTER(type);
type = copy; type = copy;
type->size++; copy->size++;
} }
expr = create_objectrefnode(cinit_initinfo->obj1C); expr = create_objectrefnode(cinit_initinfo->obj1C);
if (!IS_TYPE_POINTER_ONLY(expr->rtype)) { 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 TYPEPOINTER:
case TYPEMEMBERPOINTER: case TYPEMEMBERPOINTER:
generic_type: generic_type:
if (obj) { if (obj)
cv = obj->qual; cv = obj->qual & Q_CV;
cv &= Q_CONST | Q_VOLATILE; else
} else { cv = cinit_initinfo->obj1C->qual & Q_CV;
cv = cinit_initinfo->obj1C->qual;
cv &= Q_CONST | Q_VOLATILE;
}
if (tk == '{') { if (tk == '{') {
tk = lex(); tk = lex();
expr = assignment_expression(); expr = assignment_expression();
@ -2771,7 +2768,7 @@ void CInit_InitializeData(Object *obj) {
} else { } else {
if (obj->flags & OBJECT_FLAGS_4) if (obj->flags & OBJECT_FLAGS_4)
CError_Error(CErrorStr329, obj); CError_Error(CErrorStr329, obj);
obj->flags |= OBJECT_FLAGS_4; obj->flags = obj->flags | OBJECT_FLAGS_4;
needs_construction = 0; needs_construction = 0;
if (IS_TYPE_ARRAY(obj->type)) { 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) { if (cparamblkptr->precompile == 1) {
PreComp_StaticData(obj, data, list, size); PreComp_StaticData(obj, data, list, size);
} else { } else {
obj->flags |= OBJECT_FLAGS_4; obj->flags = obj->flags | OBJECT_FLAGS_4;
if (!fatalerrors) { if (!fatalerrors) {
for (scan = list; scan; scan = scan->next) for (scan = list; scan; scan = scan->next)
CInline_ObjectAddrRef(scan->obj); CInline_ObjectAddrRef(scan->obj);

View File

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

View File

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

View File

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

View File

@ -318,11 +318,10 @@ static UInt8 CTempl_GetTemplateNestIndex(NameSpace *nspace) {
return count; return count;
} }
static TemplParam *CTempl_ParseParam(NameSpace *nspace, TemplParam *paramList, int index, UInt8 nindex) { static TemplParam *CTempl_ParseParam(NameSpace *nspace, TemplParam *param, UInt16 index, UInt8 nindex) {
TemplParam *param;
DeclInfo di; DeclInfo di;
short startToken;
SInt32 savedState; SInt32 savedState;
short startToken;
param = galloc(sizeof(TemplParam)); param = galloc(sizeof(TemplParam));
memclrw(param, sizeof(TemplParam)); memclrw(param, sizeof(TemplParam));
@ -447,7 +446,7 @@ static TemplParam *CTempl_ParseParamList(NameSpace *nspace, UInt8 nindex) {
TemplParam **ptr; TemplParam **ptr;
TemplParam *param; TemplParam *param;
TemplParam *scan; TemplParam *scan;
int index; UInt16 index;
params = NULL; params = NULL;
index = 0; index = 0;
@ -484,7 +483,7 @@ static TemplParam *CTempl_ParseParamList(NameSpace *nspace, UInt8 nindex) {
TemplArg *CTempl_ParseUncheckTemplArgs(TemplParam *params, Boolean is_global) { TemplArg *CTempl_ParseUncheckTemplArgs(TemplParam *params, Boolean is_global) {
TemplArg *args; TemplArg *args;
TemplArg *last; TemplArg *last;
int index; UInt16 index;
if (tk != '<') { if (tk != '<') {
CError_Error(CErrorStr230); CError_Error(CErrorStr230);
@ -988,7 +987,7 @@ static void CTempl_ParseConversionFunctionTemplate(DeclInfo *di, DeclFucker *wha
return; return;
} }
tclass->flags |= CLASS_FLAGS_40; tclass->flags = tclass->flags | CLASS_FLAGS_40;
CError_QualifierCheck(di->qual & ~Q_INLINE); CError_QualifierCheck(di->qual & ~Q_INLINE);
conversion_type_name(di); 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) { static void allocate_local_vregs(void) {
VarInfo *vi;
ObjectList *list; ObjectList *list;
Object *obj; Object *obj;
VarInfo *vi;
if (copts.codegen_pic && uses_globals && assignable_registers[RegClass_GPR]) { if (copts.codegen_pic && uses_globals && assignable_registers[RegClass_GPR]) {
if (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; Statement *stmt;
Boolean has_varargs; Boolean has_varargs;
PCodeBlock *tmp; PCodeBlock *tmp;
Object *obj;
SInt32 size; SInt32 size;
CodeGen_InitialSanityCheck(); CodeGen_InitialSanityCheck();
@ -877,8 +876,11 @@ void CodeGen_Generator(Statement *statements, Object *func, UInt8 mysteryFlag, B
if (!func) { if (!func) {
func = createstaticinitobject(); func = createstaticinitobject();
} else if (func && func->name) { } else {
PrintProgressFunction(func->name->name); #ifdef CW_CLT
if (func && func->name)
PrintProgressFunction(func->name->name);
#endif
} }
gFunction = func; gFunction = func;
@ -981,8 +983,7 @@ void CodeGen_Generator(Statement *statements, Object *func, UInt8 mysteryFlag, B
break; break;
case ST_ENDCATCHDTOR: case ST_ENDCATCHDTOR:
CError_ASSERT(2056, stmt->expr->data.objref->datatype == DLOCAL); CError_ASSERT(2056, stmt->expr->data.objref->datatype == DLOCAL);
obj = stmt->expr->data.objref; add_immediate(3, local_base_register(stmt->expr->data.objref), stmt->expr->data.objref, 0);
add_immediate(3, local_base_register(obj), obj, 0);
{ {
UInt32 masks[RegClassMax] = {0, 0, 0, 0, 0}; UInt32 masks[RegClassMax] = {0, 0, 0, 0, 0};
masks[RegClass_GPR] |= 1 << 3; masks[RegClass_GPR] |= 1 << 3;
@ -1467,7 +1468,7 @@ void CodeGen_ParsePragma(HashNameNode *name) {
return; return;
} }
if (!strcmp(name->name, "unroll_speculative")) { if (!strcmp(name->name, "ppc_unroll_speculative")) {
if (plex() == TK_IDENTIFIER) { if (plex() == TK_IDENTIFIER) {
if (!strcmp(tkidentifier->name, "off")) { if (!strcmp(tkidentifier->name, "off")) {
copts.unroll_speculative = 0; copts.unroll_speculative = 0;
@ -1484,7 +1485,7 @@ void CodeGen_ParsePragma(HashNameNode *name) {
return; return;
} }
if (!strcmp(name->name, "unroll_instr_limit")) { if (!strcmp(name->name, "ppc_unroll_instructions_limit")) {
t = plex(); t = plex();
if (t == TK_INTCONST) { if (t == TK_INTCONST) {
copts.unroll_instr_limit = CInt64_GetULong(&tkintconst); copts.unroll_instr_limit = CInt64_GetULong(&tkintconst);
@ -1539,7 +1540,7 @@ void CodeGen_ParsePragma(HashNameNode *name) {
return; return;
} }
if (!strcmp(name->name, "unroll_factor_limit")) { if (!strcmp(name->name, "ppc_unroll_factor_limit")) {
t = plex(); t = plex();
if (t == TK_INTCONST) { if (t == TK_INTCONST) {
copts.unroll_factor_limit = CInt64_GetULong(&tkintconst); copts.unroll_factor_limit = CInt64_GetULong(&tkintconst);

View File

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

View File

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

View File

@ -23,10 +23,10 @@ void load_immediate(short reg, SInt32 value) {
short tmpreg2; short tmpreg2;
if (!FITS_IN_SHORT(value)) { if (!FITS_IN_SHORT(value)) {
if (copts.optimizationlevel > 1 && value) if (copts.optimizationlevel > 1 && LOW_PART_BUGGY(value))
tmpreg = used_virtual_registers[RegClass_GPR]++; tmpreg = used_virtual_registers[RegClass_GPR]++;
emitpcode(PC_LIS, tmpreg2 = tmpreg, 0, (short) HIGH_PART(value)); 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)); emitpcode(PC_ADDI, reg, tmpreg2, 0, LOW_PART(value));
} else { } else {
emitpcode(PC_LI, reg, value); 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)); emitpcode(PC_ADDI, opOut->regOffset, opB->regOffset, 0, LOW_PART(opA->immediate));
} else { } else {
emitpcode(PC_ADDIS, opOut->regOffset, opB->regOffset, 0, (short) HIGH_PART(opA->immediate)); 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)); emitpcode(PC_ADDI, opOut->regOffset, opOut->regOffset, 0, LOW_PART(opA->immediate));
} }
break; break;
@ -381,10 +381,10 @@ void Coerce_to_register(Operand *op, Type *type, short output_reg) {
emitpcode(PC_LI, reg, offset); emitpcode(PC_LI, reg, offset);
} else { } else {
tmp = reg; tmp = reg;
if (copts.optimizationlevel > 1 && offset) if (copts.optimizationlevel > 1 && LOW_PART_BUGGY(offset))
tmp = used_virtual_registers[RegClass_GPR]++; tmp = used_virtual_registers[RegClass_GPR]++;
emitpcode(PC_LIS, tmp, 0, (short) HIGH_PART(offset)); 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)); emitpcode(PC_ADDI, reg, tmp, 0, LOW_PART(offset));
} }
break; break;
@ -530,10 +530,10 @@ void coerce_to_register_pair(Operand *op, Type *type, short output_reg, short ou
emitpcode(PC_LI, reg, offset); emitpcode(PC_LI, reg, offset);
} else { } else {
tmp1 = reg; tmp1 = reg;
if (copts.optimizationlevel > 1 && offset) if (copts.optimizationlevel > 1 && LOW_PART_BUGGY(offset))
tmp1 = used_virtual_registers[RegClass_GPR]++; tmp1 = used_virtual_registers[RegClass_GPR]++;
emitpcode(PC_LIS, tmp1, 0, (short) HIGH_PART(offset)); 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)); emitpcode(PC_ADDI, reg, tmp1, 0, LOW_PART(offset));
} }
regHi = output_regHi ? output_regHi : used_virtual_registers[RegClass_GPR]++; 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_LockErrorPos(TStreamElement *token, TStreamElement **saved);
extern void CError_UnlockErrorPos(TStreamElement **saved); extern void CError_UnlockErrorPos(TStreamElement **saved);
extern void CError_ResetErrorSkip(void); 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 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_GetQualifiedName(NameSpace *nspace, HashNameNode *name);
extern char *CError_GetFunctionName(NameSpace *nspace, HashNameNode *name, TypeFunc *tfunc); extern char *CError_GetFunctionName(NameSpace *nspace, HashNameNode *name, TypeFunc *tfunc);
extern char *CError_GetObjectName(Object *obj); extern char *CError_GetObjectName(Object *obj);
extern char *CError_GetNameString(NameSpace *nspace, HashNameNode *operatorName); extern char *CError_GetNameString(NameSpace *nspace, HashNameNode *operatorName);
extern void CError_ErrorMessage(int errTable, char *buf, Boolean flag1, Boolean flag2); 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_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_Error(int code, ...);
extern void CError_ErrorTerm(short code); extern void CError_ErrorTerm(short code);
extern void CError_ErrorSkip(int 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) { 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; return n->hi == 0 && n->lo == 0;
} }
CW_INLINE Boolean CInt64_IsOne(CInt64 *n) { // assumed name CW_INLINE Boolean CInt64_IsOne(CInt64 *n) { // assumed name
return n->hi == 0 && n->lo == 1; 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 void CInt64_Init(void);
extern CInt64 CInt64_Not(CInt64 input); 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 ObjGenMach_SymFuncEnd(Object *function, UInt32 offset);
extern void ObjGen_CodeSetup(void); extern void ObjGen_CodeSetup(void);
extern MachOSection *ObjGen_DeclareFunction(Object *object); 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 void ObjGen_Relocate(MachOSection *section, SInt32 offset, SInt32 relocID, RelocType relocType, MWReloc mwRelType);
extern SInt32 ObjGen_DeclareLiteralString(UInt32 len, char *data, SInt32 align); extern SInt32 ObjGen_DeclareLiteralString(UInt32 len, char *data, SInt32 align);
extern UInt32 ObjGen_GetSectSize(MachOSection *section); extern UInt32 ObjGen_GetSectSize(MachOSection *section);

View File

@ -3,6 +3,8 @@
#include "cw_common.h" #include "cw_common.h"
enum { CR = 13, LF = 10 };
typedef struct HashNameNode { typedef struct HashNameNode {
struct HashNameNode *next; struct HashNameNode *next;
SInt32 id; SInt32 id;
@ -326,9 +328,18 @@ struct CompilerLinkerParamBlk {
#define FITS_IN_USHORT(value) ( (value) == ((unsigned short) (value)) ) #define FITS_IN_USHORT(value) ( (value) == ((unsigned short) (value)) )
#define FITS_IN_HI_SHORT(value) ( (value) == (value & 0xFFFF0000) ) #define FITS_IN_HI_SHORT(value) ( (value) == (value & 0xFFFF0000) )
#define FITS_IN_SHORT2(value) ( ((short) (value)) == (value) ) #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) ) #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__ #ifdef __MWERKS__
#pragma options align=reset #pragma options align=reset
#endif #endif

View File

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