summaryrefslogtreecommitdiff
path: root/compiler_and_linker/FrontEnd/C
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--compiler_and_linker/FrontEnd/C/CPrep.c1362
-rw-r--r--compiler_and_linker/FrontEnd/C/CPrepTokenizer.c106
-rw-r--r--compiler_and_linker/FrontEnd/C/CScope.c413
-rw-r--r--compiler_and_linker/FrontEnd/Common/CompilerTools.c29
4 files changed, 1290 insertions, 620 deletions
diff --git a/compiler_and_linker/FrontEnd/C/CPrep.c b/compiler_and_linker/FrontEnd/C/CPrep.c
index f38c504..80472b1 100644
--- a/compiler_and_linker/FrontEnd/C/CPrep.c
+++ b/compiler_and_linker/FrontEnd/C/CPrep.c
@@ -1,16 +1,25 @@
-#include "compiler.h"
+#include "compiler/CPrep.h"
+#include "compiler/CBrowse.h"
+#include "compiler/CCompiler.h"
#include "compiler/CError.h"
+#include "compiler/CException.h"
#include "compiler/CInt64.h"
-#include "compiler/objects.h"
-#include "compiler/scopes.h"
-#include "compiler/tokens.h"
-#include "cos.h"
#include "compiler/CMachine.h"
#include "compiler/CParser.h"
-#include "compiler/CPrep.h"
+#include "compiler/CPrec.h"
+#include "compiler/CPreprocess.h"
#include "compiler/CPrepTokenizer.h"
#include "compiler/CScope.h"
+#include "compiler/CSOM.h"
#include "compiler/CodeGen.h"
+#include "compiler/CompilerTools.h"
+#include "compiler/FuncLevelAsmPPC.h"
+#include "compiler/IroPointerAnalysis.h"
+#include "compiler/ObjGenMachO.h"
+#include "compiler/objects.h"
+#include "compiler/scopes.h"
+#include "compiler/tokens.h"
+#include "cos.h"
#ifdef __MWERKS__
#pragma options align=mac68k
@@ -31,17 +40,16 @@ enum {
IfState_1 = 1,
IfState_2 = 2,
IfState_3 = 3,
- IfState_4 = 4,
- IfState_5 = 5
+ IfState_4 = 4
};
// forward declarations
-static PrepValue CPrep_ParseCond();
-static PrepValue CPrep_ParseBinary(PrepValue *rhs, short op);
+static PrepValue CPrep_ParseCond(void);
+static PrepValue CPrep_ParseBinary(PrepValue *rhs, short precLimit);
static char *XpandMacro(Macro *macro);
static void prepmacro(Macro *macro);
-static void prepifskip();
-static void gotonexttoken();
+static void prepifskip(void);
+static void gotonexttoken(void);
extern SInt16 *CLT_filesp;
extern CPrepFileInfo **CLT_filestack;
@@ -305,7 +313,7 @@ static void cannotopenerror(StringPtr filename, Boolean err) {
if (prep_file) {
was_prep_error = 1;
- CError_Error(151, fname);
+ CError_Error(CErrorStr151, fname);
if (err)
longjmp(errorreturn, 1);
} else {
@@ -325,7 +333,7 @@ void CPrep_InsertSpecialMacro(Macro *macro, char *name) {
insertmacro(macro);
}
-void CPrep_InsertSpecialMacros() {
+void CPrep_InsertSpecialMacros(void) {
CPrep_InsertSpecialMacro(&lineM, "__LINE__");
CPrep_InsertSpecialMacro(&fileM, "__FILE__");
CPrep_InsertSpecialMacro(&dateM, "__DATE__");
@@ -343,7 +351,7 @@ void CPrep_InsertSpecialMacros() {
CodeGen_InsertSpecialMacros();
}
-void CPrep_RemoveSpecialMacros() {
+void CPrep_RemoveSpecialMacros(void) {
Macro **scan;
int x;
@@ -359,11 +367,11 @@ void CPrep_RemoveSpecialMacros() {
}
}
-static void CPrep_Reconfig() {
+static void CPrep_Reconfig(void) {
cprep_idarray['$'] = copts.dollar_identifiers != 0;
}
-Boolean setupprep() {
+Boolean setupprep(void) {
int x;
now_time = time(NULL);
@@ -436,7 +444,7 @@ Boolean setupprep() {
return 0;
}
-void cleanupprep() {
+void cleanupprep(void) {
while (filesp >= 0)
popfile();
@@ -494,7 +502,7 @@ static Boolean setupfile(StringPtr filename, Boolean flag1, Boolean flag2) {
if (filesp >= 31) {
was_prep_error = 1;
- CError_ErrorTerm(243);
+ CError_ErrorTerm(CErrorStr243);
return 0;
}
@@ -657,11 +665,10 @@ void CPrep_TokenStreamSetState(SInt32 *state) {
ts_current = ts_first + *state;
}
-void CPrep_UnLex() {
+void CPrep_UnLex(void) {
++ts_preread_elements;
--ts_current;
-#line 900
- CError_ASSERT(ts_current >= ts_first);
+ CError_ASSERT(900, ts_current >= ts_first);
}
void CPrep_TokenStreamSetCurState(SInt32 *state) {
@@ -726,7 +733,7 @@ loop:
}
if (!t)
return 0;
- if (t == TK_NEG7) {
+ if (t == TK_EOL) {
t = lex();
v++;
}
@@ -795,7 +802,7 @@ loop:
return v;
}
-void CPrep_StreamGetBlock(TStream *stream, CPrepStreamFuncPtr func, int arg) {
+void CPrep_StreamGetBlock(TokenStream *stream, CPrepStreamFuncPtr func, int arg) {
Boolean save_eoltokens;
SInt32 start_offset;
Boolean tryflag;
@@ -814,20 +821,20 @@ void CPrep_StreamGetBlock(TStream *stream, CPrepStreamFuncPtr func, int arg) {
tryflag = 1;
case ':':
if (!(count = CPrep_StreamSkipToBrace(func, 0))) {
- CError_Error(121);
+ CError_Error(CErrorStr121);
cprep_eoltokens = save_eoltokens;
return;
}
case '{':
break;
default:
- CError_Error(121);
+ CError_Error(CErrorStr121);
cprep_eoltokens = save_eoltokens;
return;
}
if (!(count = CPrep_StreamSkipBlock(func, count))) {
- CError_Error(121);
+ CError_Error(CErrorStr121);
cprep_eoltokens = save_eoltokens;
return;
}
@@ -835,12 +842,12 @@ void CPrep_StreamGetBlock(TStream *stream, CPrepStreamFuncPtr func, int arg) {
if (tryflag) {
tryloop:
switch (lex()) {
- case TK_NEG7:
+ case TK_EOL:
count++;
goto tryloop;
case TK_CATCH:
if (!(count = CPrep_StreamSkipToBrace(func, count)) || !(count = CPrep_StreamSkipBlock(func, count))) {
- CError_Error(242);
+ CError_Error(CErrorStr242);
cprep_eoltokens = save_eoltokens;
return;
}
@@ -848,7 +855,7 @@ void CPrep_StreamGetBlock(TStream *stream, CPrepStreamFuncPtr func, int arg) {
goto tryloop;
break;
default:
- CError_Error(242);
+ CError_Error(CErrorStr242);
cprep_eoltokens = save_eoltokens;
return;
}
@@ -860,7 +867,7 @@ void CPrep_StreamGetBlock(TStream *stream, CPrepStreamFuncPtr func, int arg) {
memcpy(stream->firsttoken, ts_first + start_offset, count * sizeof(TStreamElement));
}
-void CPrep_StreamGetSemicolon(TStream *stream, CPrepStreamFuncPtr func) {
+void CPrep_StreamGetSemicolon(TokenStream *stream, CPrepStreamFuncPtr func) {
SInt32 count;
SInt32 start_offset;
Boolean save_eoltokens;
@@ -887,7 +894,7 @@ void CPrep_StreamGetSemicolon(TStream *stream, CPrepStreamFuncPtr func) {
cprep_eoltokens = save_eoltokens;
}
-void CPrep_StreamGetTemplate(TStream *stream, CPrepStreamFuncPtr func) {
+void CPrep_StreamGetTemplate(TokenStream *stream, CPrepStreamFuncPtr func) {
SInt32 count;
SInt32 start_offset;
Boolean save_eoltokens;
@@ -903,9 +910,9 @@ void CPrep_StreamGetTemplate(TStream *stream, CPrepStreamFuncPtr func) {
loop:
switch (tk) {
case 0:
- CError_ErrorTerm(102);
+ CError_ErrorTerm(CErrorStr102);
case '}':
- CError_Error(229);
+ CError_Error(CErrorStr229);
return;
case ';':
count++;
@@ -940,7 +947,7 @@ loop:
if (level <= 0)
break;
if (!(tk = lex()))
- CError_ErrorTerm(102);
+ CError_ErrorTerm(CErrorStr102);
} while (1);
if (lookahead() == ';') {
tk = lex();
@@ -954,7 +961,7 @@ loop:
cprep_eoltokens = save_eoltokens;
}
-void CPrep_StreamInsert(TStream *stream, SInt32 *state) {
+void CPrep_StreamInsert(TokenStream *stream, SInt32 *state) {
if (ts_preread_elements + (ts_current - ts_first) + stream->tokens >= ts_elements)
CPrep_TSBufferGrow(stream->tokens);
if (ts_preread_elements)
@@ -964,7 +971,7 @@ void CPrep_StreamInsert(TStream *stream, SInt32 *state) {
CPrep_TokenStreamGetState(state);
}
-void CPrep_StreamRemove(TStream *stream, SInt32 *state) {
+void CPrep_StreamRemove(TokenStream *stream, SInt32 *state) {
TStreamElement *end;
SInt32 amount;
@@ -979,14 +986,13 @@ void CPrep_StreamRemove(TStream *stream, SInt32 *state) {
}
void CPrep_RemoveTokens(SInt32 amount) {
-#line 1296
- CError_ASSERT(ts_preread_elements >= amount);
+ CError_ASSERT(1296, ts_preread_elements >= amount);
ts_preread_elements -= amount;
memmove(ts_current, ts_current + amount, sizeof(TStreamElement) * ts_preread_elements);
}
-void CPrep_TokenStreamFlush() {
+void CPrep_TokenStreamFlush(void) {
if (!ts_preread_elements)
ts_current = ts_first;
}
@@ -1060,7 +1066,7 @@ static int CPrep_TokenSize(char *str) {
return 1;
}
-TStreamElement *CPrep_CurStreamElement() {
+TStreamElement *CPrep_CurStreamElement(void) {
static TStreamElement dummyelement;
if (ts_first < ts_current)
return ts_current - 1;
@@ -1091,10 +1097,8 @@ void CPrep_GetTokenContext(TStreamElement *token, CPrepFileInfo **tokenfile, SIn
if (!token && ts_first < ts_current)
prevtoken = ts_current - 1;
- if (prevtoken && !prevtoken->tokenfile) {
-#line 1454
- CError_FATAL();
- }
+ if (prevtoken && !prevtoken->tokenfile)
+ CError_FATAL(1454);
if (was_prep_error || !prevtoken) {
if (!prep_file)
@@ -1147,13 +1151,13 @@ void CPrep_GetTokenContext(TStreamElement *token, CPrepFileInfo **tokenfile, SIn
while (r5 < 80 && (r7 - r5) >= r4 && r7[-r5] != '\r')
r5++;
r5--;
- while ((c = r7[-r5]) && (c == ' ' || c == '\t' || c == 4))
+ while ((c = r7[-r5]) && (c == ' ' || c == '\t' || c == TK_4))
r5--;
r6 = 0;
while ((c = r7[-r5]) != '\r' && c && r6 < 126) {
if (!r5)
*tokenoffset = r6;
- if (c != 4) {
+ if (c != TK_4) {
buf1[r6++] = (c != '\t') ? c : ' ';
}
r5--;
@@ -1200,7 +1204,7 @@ void CPrep_ErrorName(short code, const char *name) {
in_assembler = 0;
was_prep_error = 1;
if (code == 102 && (tokenstacklevel > 0 || pos < prep_file_end))
- CError_Error(105, name);
+ CError_Error(CErrorStr105, name);
else
CError_Error(code, name);
in_assembler = save;
@@ -1238,18 +1242,20 @@ void CPrep_ErrorMessageVA(int code, const char *format, va_list list, Boolean fl
in_assembler = save;
}
-void popfile() {
- // r5 and r6 are swapped, not sure why
+void popfile(void) {
+ CPrepFileInfo *file;
+
if (filesp >= 0) {
CWReleaseFileText(cparamblkptr->context, prep_file->textbuffer);
prep_file->textbuffer = NULL;
if (--filesp >= 0) {
- prep_file = filestack[filesp];
- prep_file_start = prep_file->textbuffer;
- prep_file_end = prep_file->textbuffer + prep_file->textlength;
- pos = prep_file_start + prep_file->pos;
- linenumber = prep_file->linenumber;
- cprep_hasprepline = prep_file->hasprepline;
+ file = filestack[filesp];
+ prep_file = file;
+ prep_file_start = file->textbuffer;
+ prep_file_end = file->textbuffer + file->textlength;
+ pos = prep_file_start + file->pos;
+ linenumber = file->linenumber;
+ cprep_hasprepline = file->hasprepline;
at_linestart = 1;
}
if (preprocessing_only && !copts.simple_prepdump)
@@ -1257,7 +1263,7 @@ void popfile() {
}
}
-static SInt32 prepoffset() {
+static SInt32 prepoffset(void) {
if (filesp > 0)
return filestack[0]->pos;
else if (tokenstacklevel)
@@ -1266,7 +1272,7 @@ static SInt32 prepoffset() {
return pos - filestack[0]->textbuffer;
}
-static SInt32 prepoffset2() {
+static SInt32 prepoffset2(void) {
return lineoffset;
}
@@ -1396,8 +1402,7 @@ void CPrep_GetFileOffsetInfo2(FileOffsetInfo *foi, SInt32 *pLine, HashNameNode *
}
*pLine = foi->tokenline;
-#line 2010
- CError_ASSERT(*pLine >= 0);
+ CError_ASSERT(2010, *pLine >= 0);
*pName = foi->file ? foi->file->nameNode : NULL;
}
@@ -1484,14 +1489,14 @@ UInt8 C_Compiler(CParams *param) {
if (tokenstacklevel) {
was_prep_error = 1;
- CError_ErrorTerm(119);
+ CError_ErrorTerm(CErrorStr119);
} else if (iflevel) {
was_prep_error = 0;
ts.tokenfile = ifstack[iflevel - 1].file;
ts.tokenoffset = ifstack[iflevel - 1].pos;
if (iflevel)
CError_SetErrorToken(&ts);
- CError_ErrorTerm(119);
+ CError_ErrorTerm(CErrorStr119);
}
if (!anyerrors) {
@@ -1536,7 +1541,7 @@ UInt8 C_Compiler(CParams *param) {
static void pushtokenseq(Macro *macro) {
if (tokenstacklevel >= 128) {
was_prep_error = 1;
- CError_ErrorTerm(111);
+ CError_ErrorTerm(CErrorStr111);
} else {
tokenstack[tokenstacklevel].pos = pos;
tokenstack[tokenstacklevel].macrostart = macrostart;
@@ -1548,7 +1553,7 @@ static void pushtokenseq(Macro *macro) {
}
}
-void poptokenseq() {
+void poptokenseq(void) {
if (!--tokenstacklevel && dofreeaheap)
freeaheap();
@@ -1586,7 +1591,7 @@ static Boolean is_nextchar(short t) {
return 0;
}
-static Macro *ismacroname() {
+static Macro *ismacroname(void) {
Macro *scan;
Boolean save_macrocheck;
HashNameNode *name = tkidentifier;
@@ -1675,7 +1680,7 @@ static Macro *ismacroname5(char *str) {
return NULL;
}
-static Macro *ismacroname3() {
+static Macro *ismacroname3(void) {
Macro *scan;
HashNameNode *name = tkidentifier;
@@ -1716,7 +1721,7 @@ static Macro *ismacroname4(HashNameNode *name) {
return scan;
}
-void foundnl() {
+void foundnl(void) {
if (!tokenstacklevel) {
if (preprocessing_only)
CPrep_PreprocessDumpNewLine();
@@ -1727,7 +1732,7 @@ void foundnl() {
}
}
-void newline() {
+void newline(void) {
foundnl();
nlflag = 1;
at_linestart = 1;
@@ -1739,7 +1744,7 @@ void newline() {
}
}
-static void gotonexttoken() {
+static void gotonexttoken(void) {
char *save_pos;
Macro *macro;
char c;
@@ -1777,7 +1782,7 @@ loop:
}
}
-short notendofline() {
+short notendofline(void) {
char *save_pos;
Macro *macro;
char c;
@@ -1809,80 +1814,286 @@ loop:
static void CPrep_MacroRedefError(char *name, Boolean *flag) {
if (!*flag) {
if (copts.gcc_extensions) {
- CPrep_WarningName(108, name);
+ CPrep_WarningName(CErrorStr108, name);
} else if (copts.cpp_extensions) {
if (copts.pedantic)
- CPrep_WarningName(108, name);
+ CPrep_WarningName(CErrorStr108, name);
} else {
- CPrep_ErrorName(108, name);
+ CPrep_ErrorName(CErrorStr108, name);
}
*flag = 1;
}
}
-static void goendofline() {
+static void goendofline(void) {
if (notendofline()) {
- CPrep_Error(113);
+ CPrep_Error(CErrorStr113);
skipendofline();
}
}
-static void CPrep_Define() {
+static void CPrep_Define(void) {
Macro *existing_macro; // r31
- HashNameNode *name; // r29
- short r28; // r28
- Boolean r27; // r27
Macro *macro; // r20
+ HashNameNode *name; // r29
+ HashNameNode **names; // r20
short t; // r17
+ short i;
+ short argCount; // r28
+ char *ptr19;
+ char *ptr17;
+ Boolean hasVarArgs; // r27
+ Boolean isPrecedingTokenAnArg;
+ Boolean tokenPasteFlag;
Boolean error_flag;
+ HashNameNode *myNameList[128];
macrocheck = 0;
nlflag = 0;
t = lexidentifier();
if (nlflag) {
- CPrep_Error(112);
+ CPrep_Error(CErrorStr112);
skipendofline();
}
if (t != TK_IDENTIFIER) {
- CPrep_Error(107);
+ CPrep_Error(CErrorStr107);
skipendofline();
return;
}
- macro = ismacroname3();
+ existing_macro = ismacroname3();
name = tkidentifier;
error_flag = 0;
- r27 = 0;
+ hasVarArgs = 0;
if (prepcurchar() == '(') {
- r28 = 1;
+ argCount = 1;
pos = nextcharpos;
- // fix me
+ if (existing_macro)
+ names = existing_macro->names;
+ else
+ names = NULL;
+
+ do {
+ t = lexidentifier();
+ if (t != TK_IDENTIFIER)
+ break;
+
+ if (nlflag) {
+ CPrep_Error(CErrorStr112);
+ return;
+ }
+
+ if (!strcmp(tkidentifier->name, "__VA_ARGS__")) {
+ CPrep_ErrorName(CErrorStr365, tkidentifier->name);
+ return;
+ }
+
+ for (i = 1; i < argCount; i++) {
+ if (!strcmp(tkidentifier->name, myNameList[i - 1]->name)) {
+ CPrep_ErrorName(CErrorStr365, tkidentifier->name);
+ return;
+ }
+ }
+
+ myNameList[argCount - 1] = tkidentifier;
+
+ if (existing_macro) {
+ if ((existing_macro->xC & 0x7FFF) < argCount)
+ CPrep_MacroRedefError(name->name, &error_flag);
+ if (names[argCount - 1] != tkidentifier && !copts.cpp_extensions)
+ CPrep_MacroRedefError(name->name, &error_flag);
+ }
+
+ if (argCount >= 128)
+ CError_Error(CErrorStr110);
+ else
+ argCount++;
+
+ t = plex();
+ if (nlflag) {
+ CPrep_Error(CErrorStr112);
+ return;
+ }
+ } while (t == ',');
+
+ if (nlflag) {
+ CPrep_Error(CErrorStr112);
+ return;
+ }
+
+ if (t == TK_ELLIPSIS) {
+ hasVarArgs = 1;
+ myNameList[argCount - 1] = GetHashNameNode("__VA_ARGS__");
+ if (argCount >= 128)
+ CError_Error(CErrorStr110);
+ else
+ argCount++;
+
+ t = plex();
+ if (nlflag) {
+ CPrep_Error(CErrorStr112);
+ return;
+ }
+ }
+
+ if (t != ')') {
+ CPrep_Error(CErrorStr109);
+ skipendofline();
+ return;
+ }
+
+ macro = galloc(sizeof(Macro) + sizeof(HashNameNode *) + sizeof(HashNameNode *) * (argCount - 2));
} else {
macro = galloc(sizeof(Macro));
- r28 = 0;
+ argCount = 0;
}
- if (existing_macro && (existing_macro->xC & 0x7FFF) != r28)
+ if (existing_macro && (existing_macro->xC & 0x7FFF) != argCount)
CPrep_MacroRedefError(name->name, &error_flag);
macro->name = name;
- macro->xC = r27 ? (r28 | 0x8000) : r28;
+ macro->xC = hasVarArgs ? (argCount | 0x8000) : argCount;
macro->is_special = 0;
macro->xF = 0;
- if (r28 > 1) {
- // fix me
- }
+ for (i = 1; i < argCount; i++)
+ macro->names[i - 1] = myNameList[i - 1];
mlist.size = 0;
if (notendofline()) {
- // fix me
+ while (1) {
+ tokenPasteFlag = 0;
+ innerLoop:
+ isPrecedingTokenAnArg = 0;
+ ptr19 = pos;
+ spaceskip = 0;
+ t = prepnextchar();
+
+ switch (t) {
+ case 0:
+ CPrep_Error(CErrorStr102);
+ break;
+
+ case '"':
+ case '\'':
+ CPrep_MatchChar(t, 1);
+ AppendGListData(&mlist, ptr19, pos - ptr19);
+ break;
+
+ case '#':
+ ptr17 = pos;
+ if (prepnextchar() == '#')
+ CPrep_Error(CErrorStr117);
+ pos = ptr17;
+
+ if (notendofline()) {
+ t = prepnextchar();
+ if ((t >= 'a' && t <= 'z') || (t >= 'A' && t <= 'Z') || t == '_') {
+ pos = ReadIdentifier(pos - 1);
+ for (i = 1; i < argCount; i++) {
+ if (tkidentifier == macro->names[i - 1])
+ break;
+ }
+
+ if (i < argCount) {
+ AppendGListByte(&mlist, TK_MACRO_ARG_HASH);
+ AppendGListByte(&mlist, i);
+ break;
+ }
+ }
+ }
+
+ if (copts.ANSI_strict)
+ CPrep_Error(CErrorStr117);
+ AppendGListByte(&mlist, '#');
+ pos = ptr17;
+ break;
+
+ default:
+ if ((t >= 'a' && t <= 'z') || (t >= 'A' && t <= 'Z') || t == '_') {
+ pos = ReadIdentifier(pos - 1);
+ for (i = 1; i < argCount; i++) {
+ if (tkidentifier == macro->names[i - 1])
+ break;
+ }
+
+ if (i < argCount) {
+ AppendGListByte(&mlist, tokenPasteFlag ? TK_MACRO_ARG_2 : TK_MACRO_ARG_1);
+ AppendGListByte(&mlist, i);
+ isPrecedingTokenAnArg = 1;
+ } else {
+ AppendGListName(&mlist, tkidentifier->name);
+ }
+ } else {
+ AppendGListByte(&mlist, t);
+ }
+ }
+
+ if (!notendofline())
+ break;
+
+ ptr17 = pos;
+ if (prepnextchar() == '#' && prepnextchar() == '#') {
+ if (!notendofline())
+ CPrep_Error(CErrorStr117);
+ if (isPrecedingTokenAnArg)
+ (*mlist.data)[mlist.size - 2] = TK_MACRO_ARG_2;
+ tokenPasteFlag = 1;
+ goto innerLoop;
+ }
+ pos = ptr17;
+
+ if (spaceskip)
+ AppendGListByte(&mlist, ' ');
+ }
+ }
+
+ macrocheck = 1;
+
+ if (mlist.size > 0) {
+ AppendGListByte(&mlist, 0);
+ if (mlist.size > 0x20000) {
+ CPrep_Error(CErrorStr111);
+ return;
+ }
+
+ if (existing_macro) {
+ if (!existing_macro->c || memcmp(*mlist.data, existing_macro->c, mlist.size))
+ CPrep_MacroRedefError(name->name, &error_flag);
+ }
+
+ macro->c = galloc(mlist.size);
+ memcpy(macro->c, *mlist.data, mlist.size);
} else {
- // fix me
+ macro->c = NULL;
+ if (existing_macro && existing_macro->c)
+ CPrep_MacroRedefError(name->name, &error_flag);
+ }
+
+ if (existing_macro && error_flag)
+ return;
+
+ macro->next = macrohashtable[macro->name->hashval];
+ macrohashtable[macro->name->hashval] = macro;
+
+ if (cparamblkptr->browseOptions.recordMacros && prep_file->recordbrowseinfo) {
+ CBrowse_NewMacro(macro, prep_file, gDirectiveStart, pos - prep_file_start + 1);
+ }
+
+ if (error_flag) {
+ macro = macrohashtable[macro->name->hashval];
+ while (1) {
+ if (macro->next == existing_macro) {
+ macro->next = macro->next->next;
+ break;
+ }
+ macro = macro->next;
+ CError_ASSERT(2847, macro);
+ }
}
}
-static void prepundefine() {
+static void prepundefine(void) {
short t;
Macro *macro;
Macro **scan;
@@ -1891,10 +2102,10 @@ static void prepundefine() {
nlflag = 0;
t = lexidentifier();
if (nlflag) {
- CPrep_Error(112);
+ CPrep_Error(CErrorStr112);
skipendofline();
} else if (t != TK_IDENTIFIER) {
- CPrep_Error(107);
+ CPrep_Error(CErrorStr107);
skipendofline();
} else {
name = tkidentifier;
@@ -1909,12 +2120,121 @@ static void prepundefine() {
}
}
-static Boolean CPrep_CheckTarget() {}
-static Boolean CPrep_CheckOption() {}
-static char *CPrep_XpandDefinedCheck(char *) {}
+static Boolean CPrep_CheckTarget(void) {
+ Boolean result;
+
+ if (!notendofline()) {
+ CError_Error(CErrorStr112);
+ return 0;
+ }
+
+ if (plex() != '(') {
+ CError_Error(CErrorStr114);
+ return 0;
+ }
+
+ if (!notendofline()) {
+ CError_Error(CErrorStr112);
+ return 0;
+ }
+
+ if (plex() != TK_STRING) {
+ CError_Error(CErrorStr120);
+ return 0;
+ }
+
+ result = !strcmp(cparams.targetName, tkstring);
+
+ if (!notendofline()) {
+ CError_Error(CErrorStr112);
+ return 0;
+ }
+
+ if (plex() != ')') {
+ CError_Error(CErrorStr115);
+ return 0;
+ }
+
+ return result;
+}
+
+static Boolean CPrep_CheckOption(void) {
+ UInt16 offset;
+ UInt8 *ptr;
+ struct CompilerOption *option;
+ Boolean result;
+
+ if (!notendofline()) {
+ CError_Error(CErrorStr112);
+ return 0;
+ }
+
+ if (plex() != '(') {
+ CError_Error(CErrorStr114);
+ return 0;
+ }
+
+ if (!notendofline()) {
+ CError_Error(CErrorStr112);
+ return 0;
+ }
+
+ if (lexidentifier() != TK_IDENTIFIER) {
+ CError_Error(CErrorStr107);
+ return 0;
+ }
+
+ if (!strcmp(tkidentifier->name, "scheduling")) {
+ result = copts.schedule_mode != 0;
+ } else if (!strcmp(tkidentifier->name, "precompile")) {
+ result = cparamblkptr->isPrecompiling == 1;
+ } else if (!strcmp(tkidentifier->name, "preprocess")) {
+ result = cparamblkptr->isPreprocessing;
+ } else {
+ for (option = compileroptions; option->name; option++) {
+ if (!strcmp(tkidentifier->name, option->name)) {
+ offset = option->bits & OPT_OFFSET_MASK;
+ ptr = (UInt8 *) (offset + (intptr_t) &copts);
+ result = *ptr;
+ if (offset == OPT_OFFSET(booltruefalse) && !copts.cplusplus)
+ result = 0;
+ goto gotResult;
+ }
+ }
+ result = 0;
+ }
+
+gotResult:
+ if (!notendofline()) {
+ CError_Error(CErrorStr112);
+ return 0;
+ }
+
+ if (plex() != ')') {
+ CError_Error(CErrorStr115);
+ return 0;
+ }
+
+ return result;
+}
+
+static char *CPrep_XpandDefinedCheck(char *str) {
+ while (*str == ' ' || (*str >= 9 && *str <= 12))
+ str++;
+
+ if (*str == '(') {
+ str++;
+ while (*str == ' ' || (*str >= 9 && *str <= 12))
+ str++;
+ }
+
+ if ((*str >= 'a' && *str <= 'z') || (*str >= 'A' && *str <= 'Z') || *str == '_')
+ return ReadIdentifier(str);
+
+ return NULL;
+}
static char *XpandString(Macro *macro, char *somepos) {
- // almost matches, r22 and r23 are swapped at the end
short start_level;
char *curpos;
char *tmp;
@@ -1923,7 +2243,6 @@ static char *XpandString(Macro *macro, char *somepos) {
char *macro_output;
Macro *macro2;
int c;
- char *resultptr;
pushtokenseq(macro);
macropos = somepos;
@@ -1971,7 +2290,7 @@ static char *XpandString(Macro *macro, char *somepos) {
tmplen = mlist.size;
if (tmplen > 0x20000) {
macropos = pos;
- CPrep_Error(111);
+ CPrep_Error(CErrorStr111);
return "";
}
curpos = aalloc(tmplen);
@@ -2049,16 +2368,43 @@ static char *XpandString(Macro *macro, char *somepos) {
AppendGListByte(&mlist, 0);
skip_null_term:
if ((tmplen = mlist.size) > 0x20000) {
- CPrep_Error(111);
+ CPrep_Error(CErrorStr111);
return "";
- } else {
- resultptr = aalloc(tmplen);
- memcpy(resultptr, *mlist.data, tmplen);
- return resultptr;
}
+
+ tmp = aalloc(tmplen);
+ memcpy(tmp, *mlist.data, tmplen);
+ return tmp;
}
char *CPrep_GetFileName(char *buffer, Boolean flag1, Boolean flag2) {
+ FSSpec spec;
+ Str255 filename;
+ int size;
+ char *src;
+ char *dst;
+
+ COS_FileGetFSSpecInfo(&filestack[flag1 ? 0 : filesp]->textfile, NULL, NULL, filename);
+
+ size = filename[0];
+ if (!buffer)
+ buffer = galloc(size + 3);
+
+ dst = buffer;
+
+ if (flag2)
+ *(dst++) = '"';
+
+ src = (char *) filename;
+ while (size-- > 0)
+ *(dst++) = *(++src);
+
+ if (flag2)
+ *(dst++) = '"';
+
+ *(dst++) = 0;
+
+ return buffer;
}
static char *XpandSpecialMacro(Macro *macro) {
@@ -2113,6 +2459,230 @@ static char *XpandSpecialMacro(Macro *macro) {
}
static char *XpandMacro(Macro *macro) {
+ void **buf1;
+ void **buf2;
+ Boolean hasVarArgs;
+ int argCount;
+ int maxArgs;
+ char *p;
+ char *p2;
+ char *input;
+ short ch;
+ short t;
+ short i;
+ short depth;
+ short spaceFlag;
+ Boolean inVarArgs;
+ SInt32 tmplen;
+
+ if (macro->is_special)
+ return XpandSpecialMacro(macro);
+
+ argCount = macro->xC & 0x7FFF;
+ hasVarArgs = (macro->xC & 0x8000) != 0;
+
+ if (argCount) {
+ gotonexttoken();
+ CError_ASSERT(3293, prepnextchar() == '(');
+ if (argCount > 1) {
+ inVarArgs = hasVarArgs && argCount == 2;
+ maxArgs = argCount - 1;
+ buf1 = aalloc(sizeof(void *) * maxArgs);
+ buf2 = aalloc(sizeof(void *) * maxArgs);
+ i = 1;
+ while (i < argCount) {
+ spaceFlag = 1;
+ depth = 0;
+ mlist.size = 0;
+ restart1:
+ spaceskip = 0;
+ restart2:
+ t = prepnextchar();
+ switch (t) {
+ case '\r':
+ foundnl();
+ spaceskip = 1;
+ goto restart2;
+ case '\t':
+ case '\n':
+ case '\v':
+ case '\f':
+ case ' ':
+ spaceskip = 1;
+ goto restart2;
+ case 0:
+ if (tokenstacklevel != 0) {
+ poptokenseq();
+ goto restart2;
+ }
+ CPrep_Error(CErrorStr102);
+ break;
+ case '"':
+ case '\'':
+ p = pos - 1;
+ CPrep_MatchChar(t, 0);
+ AppendGListData(&mlist, p, pos - p);
+ goto restart1;
+ case ')':
+ if (--depth < 0) {
+ if (++i >= argCount)
+ break;
+ macropos = pos;
+ CPrep_Error(CErrorStr116);
+ return "";
+ }
+ goto do_default;
+ case ',':
+ if (depth <= 0 && !inVarArgs) {
+ i++;
+ if (hasVarArgs && i == maxArgs) {
+ inVarArgs = 1;
+ } else if (i >= argCount) {
+ macropos = pos;
+ CPrep_Error(CErrorStr115);
+ return "";
+ }
+ break;
+ }
+ goto do_default;
+ case '(':
+ depth++;
+ default:
+ do_default:
+ if (spaceskip && !spaceFlag)
+ AppendGListByte(&mlist, ' ');
+ AppendGListByte(&mlist, t);
+ spaceFlag = 0;
+ goto restart1;
+ }
+
+ buf2[i - 2] = buf1[i - 2] = NULL;
+ if (mlist.size > 0) {
+ AppendGListByte(&mlist, 0);
+ tmplen = mlist.size;
+ if (tmplen <= 0x20000) {
+ buf1[i - 2] = aalloc(tmplen);
+ memcpy(buf1[i - 2], *mlist.data, tmplen);
+ } else {
+ CPrep_Error(CErrorStr111);
+ }
+ }
+ }
+ } else {
+ gotonexttoken();
+ if (prepnextchar() != ')') {
+ macropos = pos;
+ CPrep_Error(CErrorStr115);
+ }
+ }
+ }
+
+ if (!macro->c)
+ return "";
+
+ if (argCount <= 1 && hasVarArgs == 0)
+ return XpandString(macro, macro->c);
+
+ input = macro->c;
+ mlist.size = 0;
+ while ((ch = *(input++))) {
+ switch (ch) {
+ case '"':
+ case '\'':
+ p = input - 1;
+ input = CPrep_MatchChar2(input, ch, 0);
+ AppendGListData(&mlist, p, input - p);
+ break;
+
+ case TK_MACRO_ARG_2:
+ p = buf1[*(input++) - 1];
+ if (p) {
+ while (1) {
+ switch (*p) {
+ case 0:
+ break;
+ case TK_4:
+ case TK_5:
+ p++;
+ continue;
+ default:
+ AppendGListByte(&mlist, *(p++));
+ continue;
+ }
+ break;
+ }
+ }
+ break;
+
+ case TK_MACRO_ARG_HASH:
+ AppendGListByte(&mlist, '"');
+ p = buf1[*(input++) - 1];
+ if (p) {
+ while ((ch = *(p++))) {
+ switch (ch) {
+ case TK_4:
+ case TK_5:
+ break;
+ case '"':
+ AppendGListByte(&mlist, '\\');
+ case '\'':
+ AppendGListByte(&mlist, ch);
+ while (*p && *p != ch) {
+ if (*p == '"' || *p == '\\')
+ AppendGListByte(&mlist, '\\');
+ AppendGListByte(&mlist, *(p++));
+ }
+ if (*p == '"')
+ AppendGListByte(&mlist, '\\');
+ if (*p)
+ AppendGListByte(&mlist, *(p++));
+ break;
+ default:
+ AppendGListByte(&mlist, ch);
+ break;
+ }
+ }
+ }
+ AppendGListByte(&mlist, '"');
+ break;
+
+ case TK_MACRO_ARG_1:
+ i = *(input++) - 1;
+ p = buf2[i];
+ if (!p) {
+ if (!buf1[i])
+ break;
+
+ tmplen = mlist.size;
+ p2 = aalloc(tmplen);
+ memcpy(p2, *mlist.data, tmplen);
+ p = buf2[i] = XpandString(NULL, buf1[i]);
+ mlist.size = 0;
+ AppendGListData(&mlist, p2, tmplen);
+ }
+
+ while (*p)
+ AppendGListByte(&mlist, *(p++));
+
+ if (p[-1] == '>' && *input == '>')
+ AppendGListByte(&mlist, ' ');
+ break;
+
+ default:
+ AppendGListByte(&mlist, ch);
+ }
+ }
+
+ AppendGListByte(&mlist, 0);
+
+ if (mlist.size > 0x20000) {
+ CPrep_Error(CErrorStr111);
+ return "";
+ } else {
+ p = aalloc(mlist.size);
+ memcpy(p, *mlist.data, mlist.size);
+ return XpandString(macro, p);
+ }
}
static void prepmacro(Macro *macro) {
@@ -2133,7 +2703,7 @@ static void prepmacro(Macro *macro) {
spaceskip = save_spaceskip;
}
-Boolean macrotest() {
+Boolean macrotest(void) {
Macro *macro;
if ((macro = ismacroname())) {
prepmacro(macro);
@@ -2147,7 +2717,7 @@ short CPrep_PragmaLex(Boolean no_err) {
if (notendofline())
return plex();
if (!no_err)
- CPrep_Error(113);
+ CPrep_Error(CErrorStr113);
return 0;
}
@@ -2209,7 +2779,7 @@ static void CPrep_PragmaImExport(int flags) {
OBJECT(list->object)->flags |= flags;
break;
default:
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
return;
}
}
@@ -2222,7 +2792,7 @@ static void CPrep_PragmaImExport(int flags) {
} while (plex() == ',' && notendofline());
if (copts.warn_illpragma)
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
}
static void pragma_on_off_reset(UInt32 bits) {
@@ -2258,15 +2828,14 @@ static void pragma_on_off_reset(UInt32 bits) {
else if ((bits & OPT_OFFSET_MASK) == OPT_OFFSET(lib_export))
imex_flags = OBJECT_FLAGS_60;
else
-#line 3610
- CError_FATAL();
+ CError_FATAL(3610);
CPrep_PragmaImExport(imex_flags);
return;
}
}
if (copts.warn_illpragma)
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
}
static HashNameNode *CPrep_PragmaOnceName(StringPtr name, Boolean flag) {
@@ -2291,20 +2860,20 @@ static HashNameNode *CPrep_PragmaOnceName(StringPtr name, Boolean flag) {
return GetHashNameNodeExport(myname);
}
-static void pragma_precompile_target() {
+static void pragma_precompile_target(void) {
if (!notendofline()) {
- CPrep_Error(112);
+ CPrep_Error(CErrorStr112);
return;
}
if (plex() != TK_STRING) {
- CPrep_Error(117);
+ CPrep_Error(CErrorStr117);
skipendofline();
return;
}
if (ispascalstring) {
- CPrep_Error(101);
+ CPrep_Error(CErrorStr101);
skipendofline();
return;
}
@@ -2319,15 +2888,15 @@ static void CPrep_DefinePragmaOnceMacro(StringPtr name, Boolean flag) {
namenode = CPrep_PragmaOnceName(name, flag);
if (!ismacroname4(namenode)) {
- macro = galloc(sizeof(Macro));
- memclrw(macro, sizeof(Macro));
+ macro = galloc(sizeof(Macro) + sizeof(HashNameNode *));
+ memclrw(macro, sizeof(Macro) + sizeof(HashNameNode *));
macro->name = namenode;
macro->next = macrohashtable[namenode->hashval];
macrohashtable[namenode->hashval] = macro;
}
}
-static void CPrep_PragmaOnce() {
+static void CPrep_PragmaOnce(void) {
if (notendofline()) {
if (plex() == TK_IDENTIFIER) {
if (!strcmp(tkidentifier->name, "on")) {
@@ -2339,7 +2908,7 @@ static void CPrep_PragmaOnce() {
}
}
if (copts.warn_illpragma)
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
} else {
Str255 filename;
COS_FileGetFSSpecInfo(&prep_file->textfile, NULL, NULL, filename);
@@ -2347,7 +2916,7 @@ static void CPrep_PragmaOnce() {
}
}
-static void CPrep_PragmaUnused() {
+static void CPrep_PragmaUnused(void) {
NameSpace *nspace;
NameSpaceObjectList *list;
short t;
@@ -2366,7 +2935,7 @@ static void CPrep_PragmaUnused() {
list = CScope_GetLocalObject(nspace, tkidentifier);
if (list && list->object->otype == OT_OBJECT && OBJECT(list->object)->datatype == DLOCAL) {
- OBJECT(list->object)->flags |= OBJECT_FLAGS_UNUSED;
+ OBJECT(list->object)->flags |= OBJECT_FLAGS_1;
if (notendofline()) {
t = plex();
if (t == ')')
@@ -2381,17 +2950,17 @@ static void CPrep_PragmaUnused() {
}
if (copts.warn_illpragma)
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
}
-static void CPrep_PragmaInlineDepth() {
+static void CPrep_PragmaInlineDepth(void) {
int lv;
if (notendofline() && plex() == '(' && notendofline()) {
switch (plex()) {
case TK_IDENTIFIER:
if (strcmp(tkidentifier->name, "smart"))
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
else
copts.inlinelevel = 0;
break;
@@ -2400,78 +2969,78 @@ static void CPrep_PragmaInlineDepth() {
if (lv >= 0 && lv <= 1024)
copts.inlinelevel = lv ? lv : -1;
else
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
break;
default:
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
skipendofline();
return;
}
if (!notendofline() || plex() != ')') {
- CPrep_Warning(115);
+ CPrep_Warning(CErrorStr115);
}
if (notendofline()) {
- CPrep_Warning(113);
+ CPrep_Warning(CErrorStr113);
skipendofline();
}
} else {
if (copts.warn_illpragma)
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
}
}
-static void CPrep_PragmaInlineMaxSize() {
+static void CPrep_PragmaInlineMaxSize(void) {
if (notendofline() && plex() == '(' && notendofline()) {
switch (plex()) {
case TK_INTCONST:
copts.inline_max_size = CInt64_GetULong(&tkintconst);
break;
default:
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
skipendofline();
return;
}
if (!notendofline() || plex() != ')') {
- CPrep_Warning(115);
+ CPrep_Warning(CErrorStr115);
}
if (notendofline()) {
- CPrep_Warning(113);
+ CPrep_Warning(CErrorStr113);
skipendofline();
}
} else {
if (copts.warn_illpragma)
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
}
}
-static void CPrep_PragmaInlineMaxTotalSize() {
+static void CPrep_PragmaInlineMaxTotalSize(void) {
if (notendofline() && plex() == '(' && notendofline()) {
switch (plex()) {
case TK_INTCONST:
copts.inline_max_total_size = CInt64_GetULong(&tkintconst);
break;
default:
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
skipendofline();
return;
}
if (!notendofline() || plex() != ')') {
- CPrep_Warning(115);
+ CPrep_Warning(CErrorStr115);
}
if (notendofline()) {
- CPrep_Warning(113);
+ CPrep_Warning(CErrorStr113);
skipendofline();
}
} else {
if (copts.warn_illpragma)
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
}
}
-static void pragma_segment() {
+static void pragma_segment(void) {
short i;
short t;
char name[256];
@@ -2490,17 +3059,17 @@ static void pragma_segment() {
name[i] = 0;
if (!i || i >= 255)
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
copts.forcedSegment = GetHashNameNodeExport(name);
ObjGen_SegmentName();
} else {
if (copts.warn_illpragma)
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
}
}
-static void pragma_options() {
+static void pragma_options(void) {
if (notendofline() && plex() == TK_IDENTIFIER && !strcmp(tkidentifier->name, "align") && notendofline() && plex() == '=' && notendofline() && plex() == TK_IDENTIFIER) {
if (!strcmp(tkidentifier->name, "reset")) {
CPrep_PopOption(OPT_OFFSET(align_mode));
@@ -2524,18 +3093,18 @@ static void pragma_options() {
}
if (copts.warn_illpragma)
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
skipendofline();
return;
done:
if (notendofline()) {
- CPrep_Error(113);
+ CPrep_Error(CErrorStr113);
skipendofline();
}
}
-static void pragma_push() {
+static void pragma_push(void) {
struct COptsPush *push;
push = galloc(sizeof(struct COptsPush));
@@ -2545,17 +3114,17 @@ static void pragma_push() {
push->opts = copts;
}
-static void pragma_pop() {
+static void pragma_pop(void) {
if (coptpushs) {
copts = coptpushs->opts;
coptpushs = coptpushs->next;
CMach_Configure();
} else {
- CPrep_Error(237);
+ CPrep_Error(CErrorStr237);
}
}
-static void pragma_overload() {
+static void pragma_overload(void) {
Object *obj;
if (cparamblkptr->isPreprocessing) {
@@ -2567,19 +3136,19 @@ static void pragma_overload() {
tk = lex();
if ((obj = CParser_ParseObject())) {
if (obj->sclass && obj->sclass != 0x103)
- CPrep_Error(177);
+ CPrep_Error(CErrorStr177);
obj->qual |= Q_OVERLOAD;
} else {
- CPrep_Error(186);
+ CPrep_Error(CErrorStr186);
}
if (nlflag)
- CPrep_Error(112);
+ CPrep_Error(CErrorStr112);
if (tk != ';')
- CPrep_Error(123);
+ CPrep_Error(CErrorStr123);
}
-static void pragma_optimization_level() {
+static void pragma_optimization_level(void) {
short t;
int lv;
@@ -2589,14 +3158,14 @@ static void pragma_optimization_level() {
lv = CInt64_GetULong(&tkintconst);
if (lv >= 0 && lv <= 4) {
if (copts.crippled && lv > 1) {
- CPrep_Warning(385);
+ CPrep_Warning(CErrorStr385);
lv = 1;
}
CPrep_PushOption(OPT_OFFSET(optimizationlevel), lv);
CodeGen_UpdateOptimizerOptions();
CodeGen_UpdateBackEndOptions();
} else {
- CPrep_Error(154);
+ CPrep_Error(CErrorStr154);
skipendofline();
}
} else if (t == TK_IDENTIFIER && !strcmp(tkidentifier->name, "reset")) {
@@ -2604,17 +3173,17 @@ static void pragma_optimization_level() {
CodeGen_UpdateOptimizerOptions();
CodeGen_UpdateBackEndOptions();
} else {
- CPrep_Error(105);
+ CPrep_Error(CErrorStr105);
skipendofline();
}
} else {
if (copts.warn_illpragma)
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
skipendofline();
}
}
-static void pragma_opt_unroll_count() {
+static void pragma_opt_unroll_count(void) {
short t;
int lv;
@@ -2627,7 +3196,7 @@ static void pragma_opt_unroll_count() {
CodeGen_UpdateOptimizerOptions();
CodeGen_UpdateBackEndOptions();
} else {
- CPrep_Error(154);
+ CPrep_Error(CErrorStr154);
skipendofline();
}
} else if (t == TK_IDENTIFIER && !strcmp(tkidentifier->name, "reset")) {
@@ -2635,17 +3204,17 @@ static void pragma_opt_unroll_count() {
CodeGen_UpdateOptimizerOptions();
CodeGen_UpdateBackEndOptions();
} else {
- CPrep_Error(105);
+ CPrep_Error(CErrorStr105);
skipendofline();
}
} else {
if (copts.warn_illpragma)
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
skipendofline();
}
}
-static void pragma_opt_unroll_instr_count() {
+static void pragma_opt_unroll_instr_count(void) {
short t;
int lv;
@@ -2658,7 +3227,7 @@ static void pragma_opt_unroll_instr_count() {
CodeGen_UpdateOptimizerOptions();
CodeGen_UpdateBackEndOptions();
} else {
- CPrep_Error(154);
+ CPrep_Error(CErrorStr154);
skipendofline();
}
} else if (t == TK_IDENTIFIER && !strcmp(tkidentifier->name, "reset")) {
@@ -2666,17 +3235,17 @@ static void pragma_opt_unroll_instr_count() {
CodeGen_UpdateOptimizerOptions();
CodeGen_UpdateBackEndOptions();
} else {
- CPrep_Error(105);
+ CPrep_Error(CErrorStr105);
skipendofline();
}
} else {
if (copts.warn_illpragma)
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
skipendofline();
}
}
-static void pragma_pack() {
+static void pragma_pack(void) {
int t;
int i;
Boolean did_push;
@@ -2697,7 +3266,7 @@ static void pragma_pack() {
cprep_packstack[cprep_packstackp].align_mode = copts.align_mode;
did_push = 1;
} else {
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
}
} else if (!strcmp(tkidentifier->name, "pop")) {
if (cprep_packstackp < 128) {
@@ -2705,7 +3274,7 @@ static void pragma_pack() {
cprep_packstackp++;
did_pop = 1;
} else {
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
}
} else {
if (did_push) {
@@ -2719,10 +3288,10 @@ static void pragma_pack() {
copts.align_mode = cprep_packstack[i].align_mode;
cprep_packstackp = i + 1;
} else {
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
}
} else {
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
}
did_pop = 0;
did_push = 0;
@@ -2750,7 +3319,7 @@ static void pragma_pack() {
break;
default:
if (copts.warn_illpragma)
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
}
}
did_pop = 0;
@@ -2765,15 +3334,15 @@ static void pragma_pack() {
} while (1);
}
if (t != ')' && copts.warn_illpragma)
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
macrocheck = 0;
} else {
if (copts.warn_illpragma)
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
}
}
-static void pragma_comment() {
+static void pragma_comment(void) {
int t;
short start_tokenstacklevel = tokenstacklevel;
@@ -2799,13 +3368,13 @@ static void pragma_comment() {
}
} else {
if (copts.warn_illpragma)
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
skipendofline();
return;
}
} else {
if (copts.warn_illpragma)
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
skipendofline();
return;
}
@@ -2825,25 +3394,25 @@ static void pragma_comment() {
}
} else {
if (copts.warn_illpragma)
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
skipendofline();
return;
}
} else {
if (copts.warn_illpragma)
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
skipendofline();
return;
}
} else {
if (copts.warn_illpragma)
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
skipendofline();
return;
}
} else {
if (copts.warn_illpragma)
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
skipendofline();
return;
}
@@ -2851,17 +3420,17 @@ static void pragma_comment() {
if (t != ')') {
if (copts.warn_illpragma)
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
skipendofline();
}
} else {
if (copts.warn_illpragma)
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
skipendofline();
}
}
-static void pragma_message() {
+static void pragma_message(void) {
int t;
short start_tokenstacklevel;
char str[128];
@@ -2893,22 +3462,22 @@ static void pragma_message() {
skipendofline();
} else {
if (copts.warn_illpragma)
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
skipendofline();
}
} else if (plex() != ')') {
if (copts.warn_illpragma)
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
skipendofline();
}
} else {
if (copts.warn_illpragma)
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
skipendofline();
}
}
-static void preppragma() {
+static void preppragma(void) {
struct CompilerOption *opt;
Boolean save_eoltokens;
@@ -2998,14 +3567,14 @@ static void preppragma() {
}
} else {
if (copts.warn_illpragma)
- CPrep_Warning(186);
+ CPrep_Warning(CErrorStr186);
skipendofline();
macrocheck = 1;
return;
}
foundOption:
if (notendofline()) {
- CPrep_Error(113);
+ CPrep_Error(CErrorStr113);
skipendofline();
}
CPrep_Reconfig();
@@ -3025,13 +3594,13 @@ static void prepinclude(Boolean flag) {
StringPtr ptr;
if (!notendofline()) {
- CPrep_Error(112);
+ CPrep_Error(CErrorStr112);
return;
}
t = prepcurchar();
if (t != '"' && t != '<') {
- CPrep_Error(117);
+ CPrep_Error(CErrorStr117);
skipendofline();
return;
}
@@ -3043,10 +3612,10 @@ static void prepinclude(Boolean flag) {
if (!copts.flat_include)
r29 = 0;
len = 0;
- while ((t = prepnextstringchar(save_pos, 1)) != '>') {
- if (t != 5) {
+ while ((t = prepnextstringchar((StringPtr) save_pos, 1)) != '>') {
+ if (t != TK_5) {
if (len > 254) {
- CPrep_Error(106);
+ CPrep_Error(CErrorStr106);
skipendofline();
return;
}
@@ -3062,7 +3631,7 @@ static void prepinclude(Boolean flag) {
macrocheck = 0;
buf[1] = 0;
if (t != TK_STRING) {
- CPrep_Error(117);
+ CPrep_Error(CErrorStr117);
skipendofline();
return;
}
@@ -3104,19 +3673,19 @@ all_done:
setupfile(ptr, r29, flag);
}
-static void prepline() {
+static void prepline(void) {
short t;
short len;
char buf[256];
cprep_hasprepline = 1;
if (!notendofline()) {
- CPrep_Error(112);
+ CPrep_Error(CErrorStr112);
return;
}
if (plex() != TK_INTCONST) {
- CPrep_Error(117);
+ CPrep_Error(CErrorStr117);
skipendofline();
return;
}
@@ -3124,7 +3693,7 @@ static void prepline() {
linenumber = CInt64_GetULong(&tkintconst) - 1;
if (notendofline()) {
if (prepnextchar() != '"') {
- CPrep_Error(117);
+ CPrep_Error(CErrorStr117);
skipendofline();
return;
}
@@ -3134,7 +3703,7 @@ static void prepline() {
if (!t)
break;
if (len > 252) {
- CPrep_Error(106);
+ CPrep_Error(CErrorStr106);
skipendofline();
return;
}
@@ -3152,79 +3721,174 @@ static void prepline() {
}
}
-static TypeIntegral *CPrep_GetPrepType(PrepValue *pv) {
+static Type *CPrep_GetPrepType(PrepValue *pv) {
if (copts.longlong_prepeval || copts.c9x) {
if (pv->is_unsigned)
- return &stunsignedlonglong;
+ return TYPE(&stunsignedlonglong);
else
- return &stsignedlonglong;
+ return TYPE(&stsignedlonglong);
} else {
if (pv->is_unsigned)
- return &stunsignedlong;
+ return TYPE(&stunsignedlong);
else
- return &stsignedlong;
+ return TYPE(&stsignedlong);
}
}
-static PrepValue CPrep_ParseUnary() {
+static PrepValue CPrep_ParseUnary(void) {
+ PrepValue val;
+
+ if (!notendofline()) {
+ CPrep_Error(CErrorStr112);
+ val.val = cint64_zero;
+ val.is_unsigned = 0;
+ } else {
+ switch (plex()) {
+ case '-':
+ val = CPrep_ParseUnary();
+ val.val = CMach_CalcIntMonadic(CPrep_GetPrepType(&val), '-', val.val);
+ return val;
+
+ case '+':
+ val = CPrep_ParseUnary();
+ return val;
+
+ case '!':
+ val = CPrep_ParseUnary();
+ CInt64_SetLong(&val.val, CInt64_IsZero(&val.val));
+ return val;
+
+ case '~':
+ val = CPrep_ParseUnary();
+ val.val = CMach_CalcIntMonadic(CPrep_GetPrepType(&val), '~', val.val);
+ return val;
+
+ case '(':
+ val = CPrep_ParseCond();
+ if (exprtk != ')') {
+ CPrep_Error(CErrorStr115);
+ return val;
+ }
+ break;
+
+ case TK_TRUE:
+ val.val = cint64_one;
+ val.is_unsigned = 1;
+ break;
+
+ default:
+ CPrep_Error(CErrorStr141);
+ case TK_FALSE:
+ val.val = cint64_zero;
+ val.is_unsigned = 1;
+ break;
+
+ case TK_INTCONST:
+ val.val = tkintconst;
+ val.is_unsigned = (tksize == IT_ULONGLONG || tksize == IT_ULONG || tksize == IT_UINT || tksize == IT_UCHAR);
+ break;
+ case TK_IDENTIFIER:
+ val.val = cint64_zero;
+ val.is_unsigned = 0;
+ if (!strcmp("defined", tkidentifier->name)) {
+ macrocheck = 0;
+ if (!notendofline()) {
+ CPrep_Error(CErrorStr112);
+ break;
+ }
+
+ if ((exprtk = plex()) == '(') {
+ if (!notendofline()) {
+ CPrep_Error(CErrorStr112);
+ macrocheck = 1;
+ break;
+ }
+
+ if (lexidentifier() != TK_IDENTIFIER) {
+ CPrep_Error(CErrorStr107);
+ macrocheck = 1;
+ break;
+ }
+
+ if (ismacroname3())
+ val.val = cint64_one;
+
+ if (!notendofline()) {
+ CPrep_Error(CErrorStr112);
+ macrocheck = 1;
+ break;
+ }
+
+ if (plex() != ')')
+ CPrep_Error(CErrorStr115);
+ } else if (exprtk == TK_IDENTIFIER) {
+ if (ismacroname3())
+ val.val = cint64_one;
+ } else {
+ CPrep_Error(CErrorStr107);
+ }
+
+ macrocheck = 1;
+ }
+ break;
+ }
+ }
+
+ exprtk = notendofline() ? plex() : (short) 0;
+ return val;
}
-static PrepValue CPrep_ParseBinary(PrepValue *rhs, short op) {
- // i need a lot of fixing :(
+static PrepValue CPrep_ParseBinary(PrepValue *rhs, short precLimit) {
PrepValue a;
PrepValue b;
- short t;
- short op2;
- short op3;
- short prec2;
- short prec3;
+ short op;
+ short prec;
+ short newprec;
- if (!rhs) {
+ if (!rhs)
a = CPrep_ParseUnary();
- } else {
+ else
a = *rhs;
- }
- op2 = op;
-restart:
- op3 = exprtk;
- prec3 = GetPrec(op3);
- if (!prec3) {
- return a;
- }
- if (!notendofline()) {
- CPrep_Error(112);
- return a;
- }
- b = CPrep_ParseUnary();
- prec3 = prec3; // variable change situation?
- do {
- if (exprtk == ')' || !notendofline()) {
- if (b.is_unsigned)
- a.is_unsigned = 1;
- a.val = CMach_CalcIntDiadic((Type *) CPrep_GetPrepType(&a), a.val, t, b.val);
+ while (1) {
+ if (!(prec = GetPrec(op = exprtk)))
return a;
- }
- op = GetPrec(exprtk);
- if (!op) {
- CPrep_Error(141);
+ if (!notendofline()) {
+ CPrep_Error(CErrorStr112);
return a;
}
- if (prec3 >= prec2) {
- if (b.is_unsigned)
- a.is_unsigned = 1;
- a.val = CMach_CalcIntDiadic((Type *) CPrep_GetPrepType(&a), a.val, t, b.val);
- if (GetPrec(op) > op2)
- goto restart;
- return a;
+
+ b = CPrep_ParseUnary();
+ while (1) {
+ if (exprtk == ')' || !notendofline()) {
+ if (b.is_unsigned)
+ a.is_unsigned = 1;
+ a.val = CMach_CalcIntDiadic(CPrep_GetPrepType(&a), a.val, op, b.val);
+ return a;
+ }
+
+ if (!(newprec = GetPrec(exprtk))) {
+ CPrep_Error(CErrorStr141);
+ return a;
+ }
+
+ if (prec >= newprec) {
+ if (b.is_unsigned)
+ a.is_unsigned = 1;
+ a.val = CMach_CalcIntDiadic(CPrep_GetPrepType(&a), a.val, op, b.val);
+ if (GetPrec(newprec) <= precLimit)
+ return a;
+ break;
+ } else {
+ b = CPrep_ParseBinary(&b, prec);
+ }
}
- b = CPrep_ParseBinary(&b, prec3);
- } while (1);
+ }
}
-static PrepValue CPrep_ParseCond() {
+static PrepValue CPrep_ParseCond(void) {
PrepValue a;
PrepValue b;
PrepValue c;
@@ -3233,15 +3897,15 @@ static PrepValue CPrep_ParseCond() {
if (exprtk == '?') {
b = CPrep_ParseCond();
if (!notendofline()) {
- CPrep_Error(112);
+ CPrep_Error(CErrorStr112);
return a;
}
if (exprtk != ':') {
- CPrep_Error(170);
+ CPrep_Error(CErrorStr170);
return a;
}
if (!notendofline()) {
- CPrep_Error(112);
+ CPrep_Error(CErrorStr112);
return a;
}
c = CPrep_ParseCond();
@@ -3251,7 +3915,7 @@ static PrepValue CPrep_ParseCond() {
return a;
}
-static void doevalconstexpr() {
+static void doevalconstexpr(void) {
PrepValue v;
macrocheck = 1;
@@ -3259,10 +3923,10 @@ static void doevalconstexpr() {
cprep_incondexpr = 1;
v = CPrep_ParseCond();
if (exprtk)
- CPrep_Error(141);
+ CPrep_Error(CErrorStr141);
cprep_incondexpr = 0;
if (nlflag)
- CPrep_Error(112);
+ CPrep_Error(CErrorStr112);
else
goendofline();
tkintconst = v.val;
@@ -3270,7 +3934,7 @@ static void doevalconstexpr() {
static void pushifstate(SInt16 state) {
if (iflevel >= 64) {
- CPrep_Error(215);
+ CPrep_Error(CErrorStr215);
} else {
ifstack[iflevel].state = state;
ifstack[iflevel].file = prep_file;
@@ -3279,9 +3943,9 @@ static void pushifstate(SInt16 state) {
}
}
-static void popifstate() {
+static void popifstate(void) {
if (iflevel <= 0) {
- CPrep_Error(117);
+ CPrep_Error(CErrorStr117);
} else {
switch (ifstack[iflevel - 1].state) {
case IfState_1:
@@ -3303,7 +3967,7 @@ static void popifstate() {
}
}
-static void positiveif() {
+static void positiveif(void) {
pushifstate(IfState_0);
}
@@ -3316,7 +3980,7 @@ static void negativeif(Boolean flag) {
}
}
-static void prepif() {
+static void prepif(void) {
if (iflevel > 0) {
switch (ifstack[iflevel - 1].state) {
case IfState_1:
@@ -3335,7 +3999,7 @@ static void prepif() {
positiveif();
}
-static void prepifdef() {
+static void prepifdef(void) {
if (iflevel > 0) {
switch (ifstack[iflevel - 1].state) {
case IfState_1:
@@ -3349,13 +4013,13 @@ static void prepifdef() {
macrocheck = 0;
if (!notendofline()) {
- CPrep_Error(112);
+ CPrep_Error(CErrorStr112);
negativeif(1);
return;
}
if (lexidentifier() != TK_IDENTIFIER) {
- CPrep_Error(107);
+ CPrep_Error(CErrorStr107);
negativeif(1);
return;
}
@@ -3368,7 +4032,7 @@ static void prepifdef() {
negativeif(1);
}
-static void prepifndef() {
+static void prepifndef(void) {
if (iflevel > 0) {
switch (ifstack[iflevel - 1].state) {
case IfState_1:
@@ -3382,13 +4046,13 @@ static void prepifndef() {
macrocheck = 0;
if (!notendofline()) {
- CPrep_Error(112);
+ CPrep_Error(CErrorStr112);
negativeif(1);
return;
}
if (lexidentifier() != TK_IDENTIFIER) {
- CPrep_Error(107);
+ CPrep_Error(CErrorStr107);
negativeif(1);
return;
}
@@ -3401,9 +4065,9 @@ static void prepifndef() {
negativeif(1);
}
-static void prepelif() {
+static void prepelif(void) {
if (iflevel <= 0 || ifstack[iflevel - 1].state == IfState_2 || ifstack[iflevel - 1].state == IfState_4) {
- CPrep_Error(118);
+ CPrep_Error(CErrorStr118);
skipendofline();
return;
}
@@ -3423,14 +4087,13 @@ static void prepelif() {
prepifskip();
break;
default:
-#line 5700
- CError_FATAL();
+ CError_FATAL(5700);
}
}
-static void prepelse() {
+static void prepelse(void) {
if (iflevel <= 0 || ifstack[iflevel - 1].state == IfState_2 || ifstack[iflevel - 1].state == IfState_4) {
- CPrep_Error(118);
+ CPrep_Error(CErrorStr118);
skipendofline();
return;
}
@@ -3452,14 +4115,13 @@ static void prepelse() {
ifstack[iflevel - 1].state = IfState_4;
break;
default:
-#line 5738
- CError_FATAL();
+ CError_FATAL(5738);
}
}
-static void prependif() {
+static void prependif(void) {
if (iflevel <= 0) {
- CPrep_Error(118);
+ CPrep_Error(CErrorStr118);
skipendofline();
return;
}
@@ -3474,7 +4136,7 @@ static void prependif() {
popifstate();
}
-static void prepifskip() {
+static void prepifskip(void) {
// this function does something very weird with its code generation that i can't match
TStreamElement ts;
short t;
@@ -3484,70 +4146,74 @@ static void prepifskip() {
case IfState_1:
case IfState_3:
case IfState_4:
- restart:
- t = prepskipnextchar();
- pos = nextcharpos;
- switch (t) {
- case 0:
- if (tokenstacklevel > 0) {
- poptokenseq();
- } else if (tokenstacklevel > 0 || pos >= prep_file_end) {
- if (filesp > 0) {
- popfile();
- } else {
- was_prep_error = 0;
- ts.tokenfile = ifstack[iflevel - 1].file;
- ts.tokenoffset = ifstack[iflevel - 1].pos;
- CError_SetErrorToken(&ts);
- CError_ErrorTerm(119);
- iflevel = 0;
- return;
- }
- } else {
- CPrep_Error(105);
- }
- goto restart;
- case '\r':
- newline();
- goto restart;
- case '"':
- skipendoflinematch(pos, '"');
- goto restart;
- case '\'':
- skipendoflinematch(pos, '"');
- goto restart;
- case '#':
- t = prepskipnextchar();
- pos = nextcharpos;
- switch (t) {
- case '\r':
- goto restart;
- case 0:
- CPrep_Error(102);
- default:
- pos = ReadIdentifier(pos - 1);
- if (!strcmp("if", tkidentifier->name)) {
- prepif();
- } else if (!strcmp("ifdef", tkidentifier->name)) {
- prepifdef();
- } else if (!strcmp("ifndef", tkidentifier->name)) {
- prepifndef();
- } else if (!strcmp("elif", tkidentifier->name)) {
- prepelif();
- } else if (!strcmp("else", tkidentifier->name)) {
- prepelse();
- } else if (!strcmp("endif", tkidentifier->name)) {
- prependif();
+ while (1) {
+ t = prepskipnextchar();
+ pos = nextcharpos;
+ switch (t) {
+ case 0:
+ if (tokenstacklevel > 0) {
+ poptokenseq();
+ } else if (tokenstacklevel > 0 || pos >= prep_file_end) {
+ if (filesp > 0) {
+ popfile();
} else {
- skipendofline();
- goto restart;
+ was_prep_error = 0;
+ ts.tokenfile = ifstack[iflevel - 1].file;
+ ts.tokenoffset = ifstack[iflevel - 1].pos;
+ CError_SetErrorToken(&ts);
+ CError_ErrorTerm(CErrorStr119);
+ iflevel = 0;
+ return;
}
- }
- break;
- default:
- skipendofline();
- goto restart;
+ } else {
+ CPrep_Error(CErrorStr105);
+ }
+ continue;
+ case '\r':
+ newline();
+ continue;
+ case '"':
+ skipendoflinematch((StringPtr) pos, '"');
+ continue;
+ case '\'':
+ skipendoflinematch((StringPtr) pos, '"');
+ continue;
+ case '#':
+ t = prepskipnextchar();
+ pos = nextcharpos;
+ switch (t) {
+ case '\r':
+ continue;
+ case 0:
+ CPrep_Error(CErrorStr102);
+ default:
+ pos = ReadIdentifier(pos - 1);
+ if (!strcmp("if", tkidentifier->name)) {
+ prepif();
+ } else if (!strcmp("ifdef", tkidentifier->name)) {
+ prepifdef();
+ } else if (!strcmp("ifndef", tkidentifier->name)) {
+ prepifndef();
+ } else if (!strcmp("elif", tkidentifier->name)) {
+ prepelif();
+ } else if (!strcmp("else", tkidentifier->name)) {
+ prepelse();
+ } else if (!strcmp("endif", tkidentifier->name)) {
+ prependif();
+ } else {
+ skipendofline();
+ continue;
+ }
+ }
+ break;
+ default:
+ skipendofline();
+ continue;
+ }
+ break;
}
+ break;
+ case IfState_2:
default:
return;
}
@@ -3555,7 +4221,7 @@ static void prepifskip() {
}
}
-void preprocessor() {
+void preprocessor(void) {
short t;
gDirectiveStart = pos - prep_file_start;
@@ -3564,7 +4230,7 @@ void preprocessor() {
switch (t) {
case 0:
- CPrep_Error(102);
+ CPrep_Error(CErrorStr102);
case '\r':
return;
}
@@ -3591,7 +4257,7 @@ void preprocessor() {
return;
}
if (!strcmp("error", tkidentifier->name)) {
- CPrep_Error(318);
+ CPrep_Error(CErrorStr318);
CError_ResetErrorSkip();
skipendofline();
macrocheck = 1;
@@ -3604,7 +4270,7 @@ void preprocessor() {
}
if (!copts.ANSI_strict) {
if (!strcmp("warning", tkidentifier->name)) {
- CPrep_Warning(337);
+ CPrep_Warning(CErrorStr337);
skipendofline();
macrocheck = 1;
return;
@@ -3652,7 +4318,7 @@ void preprocessor() {
return;
}
}
- CPrep_Error(104);
+ CPrep_Error(CErrorStr104);
skipendofline();
macrocheck = 1;
}
@@ -3661,7 +4327,7 @@ SInt32 CPrep_BrowserTokenOffset(FileOffsetInfo *foi) {
return foi->tokenoffset;
}
-SInt32 CPrep_BrowserFileOffset() {
+SInt32 CPrep_BrowserFileOffset(void) {
if (ts_first < ts_current)
return ts_current[-1].tokenoffset + 1;
else if (tokenstacklevel)
@@ -3693,6 +4359,6 @@ void CPrep_BrowserFilePosition(CPrepFileInfo **fileinfo, SInt32 *offset) {
}
}
-CPrepFileInfo *CPrep_BrowserCurrentFile() {
+CPrepFileInfo *CPrep_BrowserCurrentFile(void) {
return prep_file;
}
diff --git a/compiler_and_linker/FrontEnd/C/CPrepTokenizer.c b/compiler_and_linker/FrontEnd/C/CPrepTokenizer.c
index 4ea0fb0..4c36aab 100644
--- a/compiler_and_linker/FrontEnd/C/CPrepTokenizer.c
+++ b/compiler_and_linker/FrontEnd/C/CPrepTokenizer.c
@@ -91,7 +91,7 @@ loop:
for (;;) {
if (!(c = *(p++))) {
if (tokenstacklevel > 0 || p >= (StringPtr) prep_file_end) {
- CPrep_Error(103);
+ CPrep_Error(CErrorStr103);
nextcharpos = (char *) p - 1;
return c;
}
@@ -235,7 +235,7 @@ loop:
if (!(c = *(p++))) {
if (tokenstacklevel > 0 || p >= (StringPtr) prep_file_end) {
pos = (char *) p - 1;
- CPrep_Error(103);
+ CPrep_Error(CErrorStr103);
return c;
}
p[-1] = ' ';
@@ -411,12 +411,12 @@ void CPrep_MatchChar(char ch, Boolean flag) {
loop:
if (!(c = *(p++))) {
if (tokenstacklevel > 0 || p >= prep_file_end)
- CPrep_Error(102);
+ CPrep_Error(CErrorStr102);
else if (ch == '"')
- CPrep_Error(101);
+ CPrep_Error(CErrorStr101);
else if (ch == '\'')
- CPrep_Error(100);
- CPrep_Error(117);
+ CPrep_Error(CErrorStr100);
+ CPrep_Error(CErrorStr117);
pos = p - 1;
return;
}
@@ -427,7 +427,7 @@ loop:
foundnl();
if (*p == '\n')
p++;
- CPrep_Error(112);
+ CPrep_Error(CErrorStr112);
pos = p;
return;
}
@@ -487,12 +487,12 @@ char *CPrep_MatchChar2(char *start, char ch, Boolean flag) {
loop:
if (!(c = *(p++))) {
if (tokenstacklevel > 0 || p >= prep_file_end)
- CPrep_Error(102);
+ CPrep_Error(CErrorStr102);
else if (ch == '"')
- CPrep_Error(101);
+ CPrep_Error(CErrorStr101);
else if (ch == '\'')
- CPrep_Error(100);
- CPrep_Error(117);
+ CPrep_Error(CErrorStr100);
+ CPrep_Error(CErrorStr117);
return p - 1;
}
@@ -502,7 +502,7 @@ loop:
foundnl();
if (*p == '\n')
p++;
- CPrep_Error(112);
+ CPrep_Error(CErrorStr112);
return p;
}
haveBackslash = 0;
@@ -700,7 +700,7 @@ static short intsuffix(short token, Boolean flag) {
}
if ((t >= 'a' && t <= 'z') || (t >= 'A' && t <= 'Z') || (t == '_') || (t >= '0' && t <= '9'))
- CPrep_Error(105);
+ CPrep_Error(CErrorStr105);
if (!is_longlong && !is_long) {
if (!is_unsigned && CInt64_IsInRange(tkintconst, stsignedint.size))
@@ -720,7 +720,7 @@ static short intsuffix(short token, Boolean flag) {
if (CInt64_IsInURange(tkintconst, stsignedlonglong.size))
return IT_ULONGLONG;
}
- CError_Error(154);
+ CError_Error(CErrorStr154);
tkintconst = cint64_zero;
return IT_INT;
}
@@ -766,7 +766,7 @@ static short floatsuffix(short token) {
}
if ((token >= 'a' && token <= 'z') || (token >= 'A' && token <= 'Z') || (token == '_') || (token >= '0' && token <= '9')) {
- CPrep_Error(105);
+ CPrep_Error(CErrorStr105);
whichtype = IT_DOUBLE;
}
@@ -819,7 +819,7 @@ static SInt32 nextchar(StringPtr str) {
case 'x':
chr = tohex(prepnextstringchar(str, 1));
if (chr == -1) {
- CPrep_Error(100);
+ CPrep_Error(CErrorStr100);
return ' ';
}
out_of_bounds = 0;
@@ -830,7 +830,7 @@ static SInt32 nextchar(StringPtr str) {
out_of_bounds = 1;
}
if (out_of_bounds)
- CError_Error(100);
+ CError_Error(CErrorStr100);
break;
default:
if (t >= '0' && t <= '7') {
@@ -845,7 +845,7 @@ static SInt32 nextchar(StringPtr str) {
i++;
}
if (out_of_bounds)
- CError_Error(100);
+ CError_Error(CErrorStr100);
} else {
chr = t;
}
@@ -1018,7 +1018,7 @@ void skipendofline(void) {
if ((ch = *(p++)) == 0) {
if (tokenstacklevel > 0 || p >= (StringPtr) prep_file_end) {
pos = (char *) p - 1;
- CPrep_Error(103);
+ CPrep_Error(CErrorStr103);
return;
}
p[-1] = ' ';
@@ -1084,12 +1084,12 @@ void CPrep_SkipAsmComment(void) {
macrocheck = save_macrocheck;
}
-static short tille(void) { return TK_NEG6; }
+static short tille(void) { return TK_ILLEGAL; }
static short tcret(void) {
newline();
if (cprep_eoltokens)
- return TK_NEG7;
+ return TK_EOL;
else
return 0;
}
@@ -1107,7 +1107,7 @@ static short tapos(short _t) {
start = (StringPtr) pos;
t = nextchar((StringPtr) pos);
if ((t == '\'' || t == 0 || t == '\r') && !was_escchar) {
- CPrep_Error(100);
+ CPrep_Error(CErrorStr100);
tkintconst = cint64_zero;
tksize = IT_INT;
return TK_INTCONST;
@@ -1170,7 +1170,7 @@ static short tapos(short _t) {
while (1) {
if ((t2 == 0 || t2 == '\r') && !was_escchar) {
- CPrep_Error(100);
+ CPrep_Error(CErrorStr100);
break;
}
@@ -1183,7 +1183,7 @@ static short tapos(short _t) {
break;
if (i >= stunsignedlonglong.size) {
- CPrep_Error(100);
+ CPrep_Error(CErrorStr100);
break;
}
}
@@ -1237,9 +1237,9 @@ static short tquot(short t) {
c = nextchar(start_pos);
if ((c == '"' || c == '\r' || c == 0) && !was_escchar) {
if (c == 0 && (tokenstacklevel > 0 || pos >= prep_file_end))
- CPrep_Error(102);
+ CPrep_Error(CErrorStr102);
else if (c != '"')
- CPrep_Error(101);
+ CPrep_Error(CErrorStr101);
break;
}
if ((size + type->size) >= maxstringsize) {
@@ -1262,7 +1262,7 @@ static short tquot(short t) {
if (ispascalstring) {
if (size > 255 && type->size == 1) {
- CPrep_Error(106);
+ CPrep_Error(CErrorStr106);
size = 255;
}
CInt64_SetLong(&ch64, size / type->size);
@@ -1571,7 +1571,7 @@ static short tzero(short t) {
case 'e':
pos = CMach_FloatScan(p, &tkfloatconst, &floatFailed);
if (floatFailed)
- CPrep_Error(154);
+ CPrep_Error(CErrorStr154);
tksize = floatsuffix(prepcurchar());
return TK_FLOATCONST;
}
@@ -1580,7 +1580,7 @@ static short tzero(short t) {
}
if (failed) {
- CPrep_Error(154);
+ CPrep_Error(CErrorStr154);
tkintconst = cint64_zero;
}
@@ -1601,7 +1601,7 @@ static short tpoin(void) {
if (ch >= '0' && ch <= '9') {
pos = CMach_FloatScan(p, &tkfloatconst, &failed);
if (failed)
- CPrep_Error(154);
+ CPrep_Error(CErrorStr154);
tksize = floatsuffix(prepcurchar());
return TK_FLOATCONST;
}
@@ -1631,13 +1631,13 @@ static short tnumb(short t) {
if (ch == '.' || ch == 'e' || ch == 'E') {
pos = CMach_FloatScan(p, &tkfloatconst, &floatFailed);
if (floatFailed)
- CPrep_Error(154);
+ CPrep_Error(CErrorStr154);
tksize = floatsuffix(prepcurchar());
return TK_FLOATCONST;
}
if (failed) {
- CPrep_Error(154);
+ CPrep_Error(CErrorStr154);
tkintconst = cint64_zero;
}
@@ -1744,12 +1744,12 @@ static short tchrc(void) {
if (copts.cplusplus) {
if (!strcmp("const_cast", tkidentifier->name)) {
if (copts.ecplusplus)
- CPrep_Warning(339);
+ CPrep_Warning(CErrorStr339);
return TK_CONST_CAST;
}
if (!strcmp("catch", tkidentifier->name)) {
if (copts.ecplusplus)
- CPrep_Warning(339);
+ CPrep_Warning(CErrorStr339);
return TK_CATCH;
}
if (!strcmp("class", tkidentifier->name))
@@ -1778,7 +1778,7 @@ static short tchrd(void) {
return TK_DELETE;
if (!strcmp("dynamic_cast", tkidentifier->name)) {
if (copts.ecplusplus)
- CPrep_Warning(339);
+ CPrep_Warning(CErrorStr339);
return TK_DYNAMIC_CAST;
}
}
@@ -1875,7 +1875,7 @@ static short tchrm(void) {
return 0;
if (copts.cplusplus && !strcmp("mutable", tkidentifier->name)) {
if (copts.ecplusplus)
- CPrep_Warning(339);
+ CPrep_Warning(CErrorStr339);
return TK_MUTABLE;
}
return TK_IDENTIFIER;
@@ -1891,7 +1891,7 @@ static short tchrn(short t) {
return TK_NEW;
if (!strcmp("namespace", tkidentifier->name)) {
if (copts.ecplusplus)
- CPrep_Warning(339);
+ CPrep_Warning(CErrorStr339);
return TK_NAMESPACE;
}
if (!in_assembler && !preprocessing_only) {
@@ -1957,7 +1957,7 @@ static short tchrr(void) {
return TK_RETURN;
if (copts.cplusplus && !strcmp("reinterpret_cast", tkidentifier->name)) {
if (copts.ecplusplus)
- CPrep_Warning(339);
+ CPrep_Warning(CErrorStr339);
return TK_REINTERPRET_CAST;
}
if (copts.c9x && !strcmp("restrict", tkidentifier->name))
@@ -1984,7 +1984,7 @@ static short tchrs(void) {
return TK_SWITCH;
if (copts.cplusplus && !strcmp("static_cast", tkidentifier->name)) {
if (copts.ecplusplus)
- CPrep_Warning(339);
+ CPrep_Warning(CErrorStr339);
return TK_STATIC_CAST;
}
return TK_IDENTIFIER;
@@ -2006,27 +2006,27 @@ static short tchrt(void) {
return TK_TRUE;
if (!strcmp("template", tkidentifier->name)) {
if (copts.ecplusplus)
- CPrep_Warning(339);
+ CPrep_Warning(CErrorStr339);
return TK_TEMPLATE;
}
if (!strcmp("try", tkidentifier->name)) {
if (copts.ecplusplus)
- CPrep_Warning(339);
+ CPrep_Warning(CErrorStr339);
return TK_TRY;
}
if (!strcmp("throw", tkidentifier->name)) {
if (copts.ecplusplus)
- CPrep_Warning(339);
+ CPrep_Warning(CErrorStr339);
return TK_THROW;
}
if (!strcmp("typeid", tkidentifier->name)) {
if (copts.ecplusplus)
- CPrep_Warning(339);
+ CPrep_Warning(CErrorStr339);
return TK_TYPEID;
}
if (!strcmp("typename", tkidentifier->name)) {
if (copts.ecplusplus)
- CPrep_Warning(339);
+ CPrep_Warning(CErrorStr339);
return TK_TYPENAME;
}
}
@@ -2044,7 +2044,7 @@ static short tchru(void) {
return TK_UNSIGNED;
if (copts.cplusplus && !strcmp("using", tkidentifier->name)) {
if (copts.ecplusplus)
- CPrep_Warning(339);
+ CPrep_Warning(CErrorStr339);
return TK_USING;
}
return TK_IDENTIFIER;
@@ -2151,7 +2151,7 @@ static short tdoll(short t) {
static short tisid(void) {
if (!tokenstacklevel)
- CError_Error(105);
+ CError_Error(CErrorStr105);
return 0;
}
@@ -2161,7 +2161,7 @@ static short tnull(short t) {
return t;
} else {
pos[-1] = -64;
- return TK_NEG6;
+ return TK_ILLEGAL;
}
}
@@ -2169,7 +2169,7 @@ static short t0x1a(void) {
if (*pos == 0)
return 0;
else
- return TK_NEG6;
+ return TK_ILLEGAL;
}
typedef short (*TokenizePtr)(short);
@@ -2228,7 +2228,7 @@ short lookahead_noeol(void) {
CPrep_TokenStreamGetState(&state);
do {
t = lex();
- } while (t == TK_NEG7);
+ } while (t == TK_EOL);
CPrep_TokenStreamSetState(&state);
return t;
@@ -2303,7 +2303,7 @@ static void CPrep_StringConCat(Boolean flag) {
ch = lex();
elem = --ts_current;
memmove(elem, elem + 1, sizeof(TStreamElement) * ts_preread_elements);
- } while (ch == TK_NEG7);
+ } while (ch == TK_EOL);
chunk = lalloc(sizeof(StringChunk));
chunk->next = chunks;
@@ -2330,7 +2330,7 @@ short lex(void) {
short t;
while (1) {
- if (ts_preread_elements > 0)
+ if (ts_preread_elements <= 0)
break;
t = ts_current->tokentype;
@@ -2353,7 +2353,7 @@ short lex(void) {
tksize = ts_current->data.tkstring.size;
ispascalstring = ts_current->subtype;
break;
- case TK_NEG7:
+ case TK_EOL:
nlflag = 1;
if (!cprep_eoltokens) {
ts_current++;
@@ -2414,7 +2414,7 @@ short lex(void) {
return t;
}
break;
- case TK_NEG6:
+ case TK_ILLEGAL:
ts_current++;
CError_Error(CErrorStr105);
ts_current--;
diff --git a/compiler_and_linker/FrontEnd/C/CScope.c b/compiler_and_linker/FrontEnd/C/CScope.c
index f15787c..a59a8a7 100644
--- a/compiler_and_linker/FrontEnd/C/CScope.c
+++ b/compiler_and_linker/FrontEnd/C/CScope.c
@@ -1,17 +1,29 @@
-#include "compiler.h"
+#include "compiler/CScope.h"
+#include "compiler/CClass.h"
+#include "compiler/CDecl.h"
#include "compiler/CError.h"
#include "compiler/CMangler.h"
#include "compiler/CParser.h"
#include "compiler/CPrep.h"
-#include "compiler/CScope.h"
+#include "compiler/CPrepTokenizer.h"
+#include "compiler/CTemplateClass.h"
+#include "compiler/CTemplateNew.h"
+#include "compiler/CTemplateTools.h"
+#include "compiler/CompilerTools.h"
#include "compiler/enode.h"
#include "compiler/objects.h"
#include "compiler/scopes.h"
#include "compiler/templates.h"
#include "compiler/types.h"
+typedef enum ELookupType {
+ Lookup_0,
+ Lookup_1,
+ Lookup_2
+} ELookupType;
+
static Boolean cscope_isambig;
-static UInt8 cscope_lookuptype;
+static ELookupType cscope_lookuptype;
static SInt32 cscope_foundclassoffset;
static TemplClass *cscope_foundtemplate;
static TypeClass *cscope_foundclass;
@@ -23,14 +35,14 @@ TypeClass *cscope_currentclass;
NameSpace *cscope_current;
NameSpace *cscope_root;
-void CScope_Setup() {
+void CScope_Setup(void) {
cscope_current = cscope_root = CScope_NewHashNameSpace(0);
cscope_currentclass = NULL;
cscope_currentfunc = NULL;
cscope_is_member_func = 0;
}
-void CScope_Cleanup() {
+void CScope_Cleanup(void) {
}
void CScope_GetScope(CScopeSave *save) {
@@ -113,16 +125,15 @@ void CScope_RestoreScope(CScopeSave *saved) {
}
static Boolean CScope_ObjectIsFunction(Object *obj) {
- return obj->otype == OT_OBJECT && obj->type->type == TYPEFUNC;
+ return obj->otype == OT_OBJECT && IS_TYPE_FUNC(obj->type);
}
-Boolean CScope_IsEmptySymTable() {
+Boolean CScope_IsEmptySymTable(void) {
NameSpaceObjectList *scan;
NameSpaceName *nsname;
int i;
-#line 232
- CError_ASSERT(cscope_root->is_hash);
+ CError_ASSERT(232, cscope_root->is_hash);
i = 0;
do {
@@ -157,9 +168,9 @@ static void CScope_AppendNameSpaceName(NameSpaceName *nsn) {
static void CScope_AmbigNameError(NameSpace *nspace1, NameSpace *nspace2, HashNameNode *name) {
if (name && nspace1 != nspace2) {
- CError_Error(319, CError_GetNameString(nspace1, name), CError_GetNameString(nspace2, name));
+ CError_Error(CErrorStr319, CError_GetNameString(nspace1, name), CError_GetNameString(nspace2, name));
} else {
- CError_Error(188, nspace2);
+ CError_Error(CErrorStr188, nspace2);
}
}
@@ -248,8 +259,7 @@ NameSpaceObjectList *CScope_InsertName(NameSpace *nspace, HashNameNode *name) {
static NameSpaceObjectList *CScope_AppendName(NameSpace *nspace, HashNameNode *name) {
NameSpaceName *nsname;
NameSpaceName *scan;
-#line 387
- CError_ASSERT(!nspace->is_hash);
+ CError_ASSERT(387, !nspace->is_hash);
if (nspace->is_global)
nsname = galloc(sizeof(NameSpaceName));
@@ -327,14 +337,13 @@ restart:
case TYPEMEMBERPOINTER:
list = CScope_BuildTypeAssociatedNameSpaceList(list, TYPE_MEMBER_POINTER(type)->ty1);
type = TYPE_MEMBER_POINTER(type)->ty2;
- if (type->type != TYPECLASS)
+ if (!IS_TYPE_CLASS(type))
break;
case TYPECLASS:
list = CScope_AddNameSpaceToList(list, TYPE_CLASS(type)->nspace);
break;
default:
-#line 494
- CError_FATAL();
+ CError_FATAL(494);
}
return list;
@@ -366,7 +375,7 @@ NameSpaceObjectList *CScope_ArgumentDependentNameLookup(NameSpaceObjectList *lis
for (iscan = CScope_FindQualName(scan->nspace, name); iscan; iscan = iscan->next) {
if (iscan->object->otype != OT_OBJECT)
continue;
- if (OBJECT(iscan->object)->type->type != TYPEFUNC)
+ if (!IS_TYPE_FUNC(OBJECT(iscan->object)->type))
continue;
if (flag && (TYPE_FUNC(OBJECT(iscan->object)->type)->flags & FUNC_FLAGS_METHOD))
continue;
@@ -441,16 +450,14 @@ Boolean CScope_IsStdNameSpace(NameSpace *nspace) {
}
Boolean CScope_IsEmptyNameSpace(NameSpace *nspace) {
-#line 664
- CError_ASSERT(!nspace->is_hash);
+ CError_ASSERT(664, !nspace->is_hash);
return !nspace->data.list;
}
void CScope_MergeNameSpace(NameSpace *dst, NameSpace *src) {
NameSpaceName *nsname;
-#line 678
- CError_ASSERT(!dst->is_hash && !src->is_hash);
+ CError_ASSERT(678, !dst->is_hash && !src->is_hash);
if ((nsname = dst->data.list)) {
while (nsname->next)
@@ -473,19 +480,19 @@ void CScope_AddObject(NameSpace *nspace, HashNameNode *name, ObjBase *obj) {
newlist = lalloc(sizeof(NameSpaceObjectList));
if (obj->otype == OT_NAMESPACE || objlist->object->otype == OT_NAMESPACE) {
- CError_Error(322/*, objlist->object*/);
+ CError_Error(CErrorStr322/*, objlist->object*/);
return;
}
if (obj->otype == OT_TYPETAG) {
do {
if (objlist->object->otype == OT_TYPETAG) {
- CError_Error(322/*, objlist->object*/);
+ CError_Error(CErrorStr322/*, objlist->object*/);
return;
}
if (copts.cplusplus && objlist->object->otype == OT_TYPE && !is_typesame(OBJ_TYPE_TAG(obj)->type, OBJ_TYPE(objlist->object)->type)) {
- CError_Error(332);
+ CError_Error(CErrorStr332);
return;
}
@@ -501,12 +508,11 @@ void CScope_AddObject(NameSpace *nspace, HashNameNode *name, ObjBase *obj) {
if (objlist->object->otype == OT_TYPETAG) {
if (copts.cplusplus && obj->otype == OT_TYPE && !is_typesame(OBJ_TYPE(obj)->type, OBJ_TYPE_TAG(objlist->object)->type)) {
- CError_Error(332);
+ CError_Error(CErrorStr332);
return;
}
-#line 739
- CError_ASSERT(!objlist->next);
+ CError_ASSERT(739, !objlist->next);
newlist->object = objlist->object;
newlist->next = NULL;
@@ -516,7 +522,7 @@ void CScope_AddObject(NameSpace *nspace, HashNameNode *name, ObjBase *obj) {
}
if (!copts.cplusplus || !CScope_ObjectIsFunction(OBJECT(obj))) {
- CError_Error(322);
+ CError_Error(CErrorStr322);
return;
}
@@ -530,7 +536,7 @@ void CScope_AddObject(NameSpace *nspace, HashNameNode *name, ObjBase *obj) {
}
if (!CScope_ObjectIsFunction(OBJECT(objlist->object))) {
- CError_Error(322);
+ CError_Error(CErrorStr322);
return;
}
@@ -597,8 +603,7 @@ NameSpaceLookupList *CScope_BuildNameSpaceLookupList(NameSpace *nspace) {
goto foundIt;
}
}
-#line 853
- CError_FATAL();
+ CError_FATAL(853);
foundIt:
for (current2 = currentL->namespaces; current2; current2 = current2->next) {
if (current2->nspace == current->nspace)
@@ -718,8 +723,7 @@ restart:
case OT_NAMESPACE:
return OBJ_NAMESPACE(list->object)->nspace;
default:
-#line 1052
- CError_FATAL();
+ CError_FATAL(1052);
break;
case OT_ENUMCONST:
case OT_MEMBERVAR:
@@ -728,10 +732,10 @@ restart:
goto restart;
}
- if (type->type != TYPECLASS) {
- if (type->type == TYPETEMPLATE)
+ if (!IS_TYPE_CLASS(type)) {
+ if (IS_TYPE_TEMPLATE(type))
return NULL;
- CError_Error(320);
+ CError_Error(CErrorStr320);
if (fail)
*fail = 1;
return NULL;
@@ -741,13 +745,13 @@ restart:
}
static BClassList *CScope_RecFindClassMember(CScopeParseResult *result, TypeClass *tclass, SInt32 offset) {
- // does not match, r24 and r23 are swapped at the end x.x
Boolean fail;
NameSpace *nspace;
NameSpaceObjectList *list;
- ClassList *base;
TypeClass *bestClass;
- BClassList *bestBase, *n;
+ BClassList *bestBase;
+ ClassList *base;
+ BClassList *n;
BClassList *candidate;
SInt32 thisoffset;
BClassList *newlist;
@@ -761,7 +765,7 @@ static BClassList *CScope_RecFindClassMember(CScopeParseResult *result, TypeClas
}
switch (cscope_lookuptype) {
- case 2:
+ case Lookup_2:
fail = 0;
if ((nspace = CScope_ExtractNameSpace(list, &fail))) {
if (cscope_foundclass) {
@@ -780,20 +784,20 @@ static BClassList *CScope_RecFindClassMember(CScopeParseResult *result, TypeClas
newlist = lalloc(sizeof(BClassList));
newlist->next = NULL;
- newlist->type = (Type *) tclass;
+ newlist->type = TYPE(tclass);
return newlist;
}
if (fail)
return NULL;
break;
- case 0:
+ case Lookup_0:
if (cscope_foundclass) {
if (
list->object->otype == OT_TYPETAG
&& result->nsol_14->object->otype == OT_TYPETAG
- && OBJ_TYPE_TAG(list->object)->type->type == TYPECLASS
- && OBJ_TYPE_TAG(result->nsol_14->object)->type->type == TYPECLASS
+ && IS_TYPE_CLASS(OBJ_TYPE_TAG(list->object)->type)
+ && IS_TYPE_CLASS(OBJ_TYPE_TAG(result->nsol_14->object)->type)
&& (TYPE_CLASS(OBJ_TYPE_TAG(list->object)->type)->flags & CLASS_FLAGS_800)
&& (TYPE_CLASS(OBJ_TYPE_TAG(result->nsol_14->object)->type)->flags & CLASS_FLAGS_800)
&& TEMPL_CLASS_INST(OBJ_TYPE_TAG(list->object)->type)->templ == TEMPL_CLASS_INST(OBJ_TYPE_TAG(result->nsol_14->object)->type)->templ
@@ -816,9 +820,9 @@ static BClassList *CScope_RecFindClassMember(CScopeParseResult *result, TypeClas
result->nsol_14 = list;
newlist = lalloc(sizeof(BClassList));
newlist->next = NULL;
- newlist->type = (Type *) tclass;
+ newlist->type = TYPE(tclass);
return newlist;
- case 1:
+ case Lookup_1:
for (; list; list = list->next) {
if (list->object->otype == OT_TYPETAG) {
if (cscope_foundclass) {
@@ -836,14 +840,13 @@ static BClassList *CScope_RecFindClassMember(CScopeParseResult *result, TypeClas
result->x8 = OBJ_TYPE_TAG(list->object)->type;
newlist = lalloc(sizeof(BClassList));
newlist->next = NULL;
- newlist->type = (Type *) tclass;
+ newlist->type = TYPE(tclass);
return newlist;
}
}
break;
default:
-#line 1202
- CError_FATAL();
+ CError_FATAL(1202);
}
}
@@ -852,7 +855,7 @@ static BClassList *CScope_RecFindClassMember(CScopeParseResult *result, TypeClas
if ((candidate = CScope_RecFindClassMember(result, base->base, thisoffset))) {
n = lalloc(sizeof(BClassList));
n->next = candidate;
- n->type = (Type *) tclass;
+ n->type = TYPE(tclass);
if (bestBase && bestClass == cscope_foundclass) {
if (CClass_IsMoreAccessiblePath(n, bestBase))
bestBase = n;
@@ -866,7 +869,7 @@ static BClassList *CScope_RecFindClassMember(CScopeParseResult *result, TypeClas
return bestBase;
}
-static Boolean CScope_FindClassMember(CScopeParseResult *result, NameSpace *nspace, HashNameNode *name, UInt8 lookupType) {
+static Boolean CScope_FindClassMember(CScopeParseResult *result, NameSpace *nspace, HashNameNode *name, ELookupType lookupType) {
BClassList *bcl;
BClassList *scan;
@@ -907,11 +910,11 @@ static BClassList *CScope_GetAccessPathRec(TypeClass *src, TypeClass *dest, SInt
if (src == dest) {
if (cscope_foundclass && cscope_foundclassoffset != offset)
- CError_Error(188);
+ CError_Error(CErrorStr188);
list = lalloc(sizeof(BClassList));
list->next = NULL;
- list->type = (Type *) src;
+ list->type = TYPE(src);
cscope_foundclass = src;
cscope_foundclassoffset = offset;
return list;
@@ -925,7 +928,7 @@ static BClassList *CScope_GetAccessPathRec(TypeClass *src, TypeClass *dest, SInt
if (best) {
list = lalloc(sizeof(BClassList));
list->next = best;
- list->type = (Type *) src;
+ list->type = TYPE(src);
return list;
}
@@ -946,7 +949,7 @@ static NameSpace *CScope_FindLookupNameSpace(CScopeNSIterator *iterator, NameSpa
Boolean fail = 0;
if (lookup->nspace->theclass) {
- if (CScope_FindClassMember(iterator->result, lookup->nspace, name, 2)) {
+ if (CScope_FindClassMember(iterator->result, lookup->nspace, name, Lookup_2)) {
retnspace = iterator->result->nspace_0;
iterator->result->nspace_0 = NULL;
return retnspace;
@@ -1106,7 +1109,7 @@ static NameSpaceObjectList *CScope_NSIteratorFind(CScopeNSIterator *iterator, Ha
if (iterator->lookup->namespaces)
return CScope_FindLookupName(iterator->lookup, name, NULL);
if (iterator->lookup->nspace->theclass) {
- if (CScope_FindClassMember(iterator->result, iterator->lookup->nspace, name, 0)) {
+ if (CScope_FindClassMember(iterator->result, iterator->lookup->nspace, name, Lookup_0)) {
list = iterator->result->nsol_14;
iterator->result->nsol_14 = NULL;
return list;
@@ -1119,7 +1122,7 @@ static NameSpaceObjectList *CScope_NSIteratorFind(CScopeNSIterator *iterator, Ha
return list;
} else {
if (iterator->nspace->theclass) {
- if (CScope_FindClassMember(iterator->result, iterator->nspace, name, 0)) {
+ if (CScope_FindClassMember(iterator->result, iterator->nspace, name, Lookup_0)) {
list = iterator->result->nsol_14;
iterator->result->nsol_14 = NULL;
return list;
@@ -1163,7 +1166,7 @@ static NameSpace *CScope_NSIteratorFindNameSpace(CScopeNSIterator *iterator, Has
if (iterator->lookup->namespaces)
return CScope_FindLookupNameSpace(iterator, iterator->lookup, name);
if (iterator->lookup->nspace->theclass) {
- if (CScope_FindClassMember(iterator->result, iterator->lookup->nspace, name, 2)) {
+ if (CScope_FindClassMember(iterator->result, iterator->lookup->nspace, name, Lookup_2)) {
nspace = iterator->result->nspace_0;
iterator->result->nspace_0 = NULL;
return nspace;
@@ -1176,7 +1179,7 @@ static NameSpace *CScope_NSIteratorFindNameSpace(CScopeNSIterator *iterator, Has
return CScope_ExtractNameSpace(list, NULL);
} else {
if (iterator->nspace->theclass) {
- if (CScope_FindClassMember(iterator->result, iterator->nspace, name, 2)) {
+ if (CScope_FindClassMember(iterator->result, iterator->nspace, name, Lookup_2)) {
nspace = iterator->result->nspace_0;
iterator->result->nspace_0 = NULL;
return nspace;
@@ -1196,7 +1199,7 @@ static Boolean CScope_SetupParseNameResult(CScopeParseResult *result, NameSpaceO
if (!list->next || list->next->object->otype == OT_TYPETAG) {
switch (list->object->otype) {
case OT_NAMESPACE:
- CError_Error(321);
+ CError_Error(CErrorStr321);
return 0;
case OT_TYPE:
result->x8 = OBJ_TYPE(list->object)->type;
@@ -1207,7 +1210,7 @@ static Boolean CScope_SetupParseNameResult(CScopeParseResult *result, NameSpaceO
break;
case OT_TYPETAG:
result->x8 = OBJ_TYPE_TAG(list->object)->type;
- result->xC = NULL;
+ result->xC = 0;
result->obj_10 = list->object;
result->name_4 = name;
result->x20 = 1;
@@ -1226,18 +1229,17 @@ Boolean CScope_FindQualifiedClassMember(CScopeParseResult *result, TypeClass *tc
NameSpaceObjectList *list;
memclrw(result, sizeof(CScopeParseResult));
- CDecl_CompleteType((Type *) tclass);
+ CDecl_CompleteType(TYPE(tclass));
- if (CScope_FindClassMember(result, tclass->nspace, name, 0)) {
+ if (CScope_FindClassMember(result, tclass->nspace, name, Lookup_0)) {
list = result->nsol_14;
-#line 1780
- CError_ASSERT(list);
+ CError_ASSERT(1780, list);
result->nsol_14 = NULL;
if (CScope_SetupParseNameResult(result, list, name) && !result->x8)
return 1;
else
- CError_Error(340, name->name);
+ CError_Error(CErrorStr340, name->name);
}
return 0;
@@ -1252,7 +1254,7 @@ static NameSpace *CScope_FindQualifiedNameSpace(CScopeParseResult *result, NameS
Boolean fail = 0;
if (nspace->theclass) {
- if (CScope_FindClassMember(result, nspace, name, 2)) {
+ if (CScope_FindClassMember(result, nspace, name, Lookup_2)) {
nspace = result->nspace_0;
result->nspace_0 = NULL;
return nspace;
@@ -1291,8 +1293,8 @@ static NameSpaceObjectList *CScope_FindQualifiedName(CScopeParseResult *result,
NameSpaceLookupList *lookup;
if (nspace->theclass) {
- CDecl_CompleteType((Type *) nspace->theclass);
- if (CScope_FindClassMember(result, nspace, name, 0)) {
+ CDecl_CompleteType(TYPE(nspace->theclass));
+ if (CScope_FindClassMember(result, nspace, name, Lookup_0)) {
list = result->nsol_14;
result->nsol_14 = NULL;
return list;
@@ -1324,8 +1326,8 @@ static Boolean CScope_FindQualifiedTag(CScopeParseResult *result, NameSpace *nsp
NameSpaceList *scan;
if (nspace->theclass) {
- CDecl_CompleteType((Type *) nspace->theclass);
- return CScope_FindClassMember(result, nspace, name, 1) != 0;
+ CDecl_CompleteType(TYPE(nspace->theclass));
+ return CScope_FindClassMember(result, nspace, name, Lookup_1) != 0;
}
if ((list = CScope_FindQualName(nspace, name))) {
@@ -1439,46 +1441,46 @@ Type *CScope_GetTagType(NameSpace *nspace, HashNameNode *name) {
}
static Boolean CScope_DependentTemplateMember(CScopeParseResult *result, TypeTemplDep *ttempldep, Boolean flag1, Boolean flag2) {
- // does not match, sign extension/caching mishap
SInt32 streamstate;
short token;
- short token2;
TypeTemplDep *newtype;
TypeTemplDep *newtype2;
CPrep_TokenStreamGetState(&streamstate);
-#line 2026
- CError_ASSERT(lex() == TK_COLON_COLON);
+ token = lex();
+ CError_ASSERT(2026, token == TK_COLON_COLON);
- do {
+ while (1) {
token = lex();
if (token == TK_OPERATOR && flag1) {
if (!CParser_ParseOperatorName(NULL, 1, 1))
return 0;
- newtype = CDecl_NewTemplDepType(TEMPLDEP_QUALNAME);
+ newtype = TYPE_TEMPLATE(CDecl_NewTemplDepType(TEMPLDEP_QUALNAME));
newtype->u.qual.type = ttempldep;
newtype->u.qual.name = tkidentifier;
CPrep_TokenStreamSetState(&streamstate);
lex();
tk = lex();
- result->x8 = (Type *) newtype;
+ result->x8 = TYPE(newtype);
return 1;
- } else if (token == TK_TEMPLATE) {
+ }
+
+ if (token == TK_TEMPLATE) {
if (lex() != TK_IDENTIFIER) {
- CError_Error(107);
+ CError_Error(CErrorStr107);
return 0;
}
CPrep_TokenStreamGetState(&streamstate);
- newtype = CDecl_NewTemplDepType(TEMPLDEP_QUALNAME);
+ newtype = TYPE_TEMPLATE(CDecl_NewTemplDepType(TEMPLDEP_QUALNAME));
newtype->u.qual.type = ttempldep;
newtype->u.qual.name = tkidentifier;
- if ((token2 = lex()) != '<') {
- CError_Error(230);
+ if ((token = lex()) != '<') {
+ CError_Error(CErrorStr230);
return 0;
}
- tk = token2;
- newtype2 = CDecl_NewTemplDepType(TEMPLDEP_QUALTEMPL);
+ tk = token;
+ newtype2 = TYPE_TEMPLATE(CDecl_NewTemplDepType(TEMPLDEP_QUALTEMPL));
newtype2->u.qualtempl.type = newtype;
newtype2->u.qualtempl.args = CTempl_ParseUncheckTemplArgs(NULL, 1);
CPrep_TokenStreamGetState(&streamstate);
@@ -1487,27 +1489,29 @@ static Boolean CScope_DependentTemplateMember(CScopeParseResult *result, TypeTem
continue;
} else {
CPrep_TokenStreamSetState(&streamstate);
- result->x8 = (Type *) newtype2;
+ result->x8 = TYPE(newtype2);
return 1;
}
- } else if (token == TK_IDENTIFIER) {
- newtype = CDecl_NewTemplDepType(TEMPLDEP_QUALNAME);
+ }
+
+ if (token == TK_IDENTIFIER) {
+ newtype = TYPE_TEMPLATE(CDecl_NewTemplDepType(TEMPLDEP_QUALNAME));
newtype->u.qual.type = ttempldep;
newtype->u.qual.name = tkidentifier;
tk = token;
CPrep_TokenStreamGetState(&streamstate);
- token2 = lex();
+ token = lex();
tkidentifier = newtype->u.qual.name;
- if (token2 == TK_COLON_COLON) {
+ if (token == TK_COLON_COLON) {
ttempldep = newtype;
continue;
}
- if ((token2 == '<') && !flag2) {
- tk = token2;
+ if ((token == '<') && !flag2) {
+ tk = token;
newtype2 = newtype;
- newtype = CDecl_NewTemplDepType(TEMPLDEP_QUALTEMPL);
+ newtype = TYPE_TEMPLATE(CDecl_NewTemplDepType(TEMPLDEP_QUALTEMPL));
newtype->u.qualtempl.type = newtype2;
newtype->u.qualtempl.args = CTempl_ParseUncheckTemplArgs(NULL, 1);
@@ -1519,35 +1523,40 @@ static Boolean CScope_DependentTemplateMember(CScopeParseResult *result, TypeTem
}
CPrep_TokenStreamSetState(&streamstate);
- result->x8 = (Type *) newtype;
- return 1;
- } else {
- CPrep_TokenStreamSetState(&streamstate);
- result->x8 = (Type *) ttempldep;
+ result->x8 = TYPE(newtype);
return 1;
}
- } while (1);
+
+ CPrep_TokenStreamSetState(&streamstate);
+ result->x8 = TYPE(ttempldep);
+ return 1;
+ }
}
static Boolean CScope_CheckDtorName(TypeClass *tclass, Boolean *flag) {
if ((tk = lex()) != TK_IDENTIFIER)
- CError_Error(107);
+ CError_Error(CErrorStr107);
if (tclass) {
*flag = 0;
- if ((tclass->classname == tkidentifier) || (CScope_GetType(tclass->nspace, tkidentifier, NULL) == (Type *) tclass) || (CScope_GetType(cscope_current, tkidentifier, NULL) == (Type *) tclass)) {
+ if (
+ (tclass->classname == tkidentifier) ||
+ (CScope_GetType(tclass->nspace, tkidentifier, NULL) == TYPE(tclass)) ||
+ (CScope_GetType(cscope_current, tkidentifier, NULL) == TYPE(tclass))
+ )
+ {
if (!CClass_Destructor(tclass))
*flag = 1;
if ((tclass->flags & CLASS_FLAGS_800) && (lookahead() == '<')) {
tk = lex();
if (!CTemplTool_EqualArgs(TEMPL_CLASS_INST(tclass)->inst_args, CTempl_ParseUncheckTemplArgs(NULL, 0)))
- CError_Error(374);
+ CError_Error(CErrorStr374);
}
return 1;
}
}
- CError_Error(141);
+ CError_Error(CErrorStr141);
return 0;
}
@@ -1561,7 +1570,7 @@ static Boolean CScope_ParseQualifiedName(CScopeParseResult *result, NameSpace *n
switch (tk) {
case TK_TEMPLATE:
if ((tk = lex()) != TK_IDENTIFIER) {
- CError_Error(107);
+ CError_Error(CErrorStr107);
return 0;
}
case TK_IDENTIFIER:
@@ -1589,7 +1598,7 @@ static Boolean CScope_ParseQualifiedName(CScopeParseResult *result, NameSpace *n
flag = 1;
break;
default:
- CError_Error(107);
+ CError_Error(CErrorStr107);
return 0;
}
@@ -1599,13 +1608,13 @@ static Boolean CScope_ParseQualifiedName(CScopeParseResult *result, NameSpace *n
return 1;
}
if (nspace->theclass && !(nspace->theclass->flags & CLASS_FLAGS_2))
- CError_Error(136, nspace->theclass, 0);
+ CError_Error(CErrorStr136, nspace->theclass, 0);
else
- CError_Error(140, saveidentifier->name);
+ CError_Error(CErrorStr140, saveidentifier->name);
return 0;
}
- if (result->x8 && (result->x8->type == TYPECLASS) && (lookahead() == '<')) {
+ if (result->x8 && IS_TYPE_CLASS(result->x8) && (lookahead() == '<')) {
tclass = TYPE_CLASS(result->x8);
if (tclass->flags & CLASS_FLAGS_800)
tclass = TYPE_CLASS(TEMPL_CLASS_INST(tclass)->templ);
@@ -1613,8 +1622,8 @@ static Boolean CScope_ParseQualifiedName(CScopeParseResult *result, NameSpace *n
return 1;
tk = lex();
- result->x8 = CTempl_ClassGetType(tclass);
- if ((result->x8->type == TYPECLASS) && (lookahead() == TK_COLON_COLON)) {
+ result->x8 = CTempl_ClassGetType(TEMPL_CLASS(tclass));
+ if (IS_TYPE_CLASS(result->x8) && (lookahead() == TK_COLON_COLON)) {
lex();
tk = lex();
result->x1D = 1;
@@ -1638,7 +1647,7 @@ Boolean CScope_ParseExprName(CScopeParseResult *result) {
if (!copts.cplusplus) {
memclrw(result, sizeof(CScopeParseResult));
if (tk != TK_IDENTIFIER) {
- CError_Error(107);
+ CError_Error(CErrorStr107);
return 0;
}
@@ -1658,8 +1667,7 @@ Boolean CScope_ParseExprName(CScopeParseResult *result) {
if ((tk == TK_COLON_COLON || tk == TK_IDENTIFIER) && CScope_ParseQualifiedNameSpace(result, 1, 1)) {
if (result->x8)
return 1;
-#line 2313
- CError_ASSERT(result->nspace_0);
+ CError_ASSERT(2313, result->nspace_0);
} else {
memclrw(result, sizeof(CScopeParseResult));
result->nspace_0 = cscope_current;
@@ -1668,10 +1676,10 @@ Boolean CScope_ParseExprName(CScopeParseResult *result) {
switch (tk) {
case TK_TEMPLATE:
if (!result->x1D)
- CError_Error(373);
+ CError_Error(CErrorStr373);
if ((tk = lex()) != TK_IDENTIFIER) {
- CError_Error(107);
+ CError_Error(CErrorStr107);
return 0;
}
case TK_IDENTIFIER:
@@ -1693,13 +1701,13 @@ Boolean CScope_ParseExprName(CScopeParseResult *result) {
name = destructor_name_node;
break;
default:
- CError_Error(107);
+ CError_Error(CErrorStr107);
return 0;
}
if (result->x1D) {
if (!(list = CScope_FindQualifiedName(result, result->nspace_0, name, &result->nspace_0))) {
- CError_Error(140, CError_GetNameString(result->nspace_0, name));
+ CError_Error(CErrorStr140, CError_GetNameString(result->nspace_0, name));
return 0;
} else {
return CScope_SetupParseNameResult(result, list, name);
@@ -1715,7 +1723,7 @@ Boolean CScope_ParseExprName(CScopeParseResult *result) {
} while (CScope_NSIteratorNext(&iterator));
if (result->x1D) {
- CError_Error(140, name->name);
+ CError_Error(CErrorStr140, name->name);
return 0;
} else {
result->nspace_0 = cscope_current;
@@ -1737,7 +1745,7 @@ Boolean CScope_ParseDeclName(CScopeParseResult *result) {
if (!copts.cplusplus) {
non_cpp_mode:
if (tk != TK_IDENTIFIER) {
- CError_Error(107);
+ CError_Error(CErrorStr107);
return 0;
}
memclrw(result, sizeof(CScopeParseResult));
@@ -1756,7 +1764,7 @@ Boolean CScope_ParseDeclName(CScopeParseResult *result) {
return 0;
} else {
if ((tk != TK_COLON_COLON) && (tk != TK_IDENTIFIER)) {
- CError_Error(107);
+ CError_Error(CErrorStr107);
return 0;
}
@@ -1767,8 +1775,7 @@ Boolean CScope_ParseDeclName(CScopeParseResult *result) {
return 1;
nspace = result->nspace_0;
-#line 2435
- CError_ASSERT(nspace);
+ CError_ASSERT(2435, nspace);
switch (tk) {
case TK_OPERATOR:
@@ -1779,7 +1786,7 @@ Boolean CScope_ParseDeclName(CScopeParseResult *result) {
}
CScope_RestoreScope(&save);
if (op)
- CError_Error(121);
+ CError_Error(CErrorStr121);
result->x21 = 1;
return 1;
case TK_IDENTIFIER:
@@ -1789,26 +1796,26 @@ Boolean CScope_ParseDeclName(CScopeParseResult *result) {
break;
case '~':
if (!nspace->theclass) {
- CError_Error(121);
+ CError_Error(CErrorStr121);
return 0;
}
tk = lex();
if (tk != TK_IDENTIFIER) {
- CError_Error(107);
+ CError_Error(CErrorStr107);
return 0;
}
if (nspace->theclass->classname != tkidentifier)
- CError_Error(121);
+ CError_Error(CErrorStr121);
name = destructor_name_node;
break;
default:
- CError_Error(107);
+ CError_Error(CErrorStr107);
return 0;
}
if (result->x1D) {
if (!(list = CScope_FindQualifiedName(result, result->nspace_0, name, &result->nspace_0))) {
- CError_Error(140, name->name);
+ CError_Error(CErrorStr140, name->name);
return 0;
} else {
return CScope_SetupParseNameResult(result, list, name);
@@ -1823,7 +1830,7 @@ Boolean CScope_ParseDeclName(CScopeParseResult *result) {
}
} while (CScope_NSIteratorNext(&iterator));
- CError_Error(140, name->name);
+ CError_Error(CErrorStr140, name->name);
return 0;
}
}
@@ -1851,9 +1858,9 @@ Boolean CScope_ParseQualifiedNameSpace(CScopeParseResult *result, Boolean flag1,
if (tk != TK_TEMPLATE)
return nspace != NULL;
if (!result->x1D)
- CError_Error(373);
+ CError_Error(CErrorStr373);
if ((tk = lex()) != TK_IDENTIFIER) {
- CError_Error(107);
+ CError_Error(CErrorStr107);
return 0;
}
}
@@ -1871,12 +1878,11 @@ Boolean CScope_ParseQualifiedNameSpace(CScopeParseResult *result, Boolean flag1,
// list = r21
for (list = CScope_NSIteratorFind(&iterator, name); list; list = list->next) {
if (list->object->otype == OT_NAMESPACE) {
-#line 2565
- CError_ASSERT(!nspace || !nspace->theclass);
+ CError_ASSERT(2565, !nspace || !nspace->theclass);
result->nspace_0 = nspace = OBJ_NAMESPACE(list->object)->nspace;
if ((tk = lex()) != TK_COLON_COLON) {
- CError_Error(321);
+ CError_Error(CErrorStr321);
return 0;
}
@@ -1891,24 +1897,23 @@ Boolean CScope_ParseQualifiedNameSpace(CScopeParseResult *result, Boolean flag1,
result->x8 = type;
return 1;
} else {
- CError_Error(121);
+ CError_Error(CErrorStr121);
return 0;
}
}
parse_thing:
if (t == '<') {
if (TYPE_CLASS(type)->flags & CLASS_FLAGS_800) {
- type = (Type *) TEMPL_CLASS_INST(type)->templ;
+ type = TYPE(TEMPL_CLASS_INST(type)->templ);
} else if (!(TYPE_CLASS(type)->flags & CLASS_FLAGS_100)) {
result->x8 = type;
return 1;
}
}
if ((tk = lex()) == '<') {
-#line 2609
- CError_ASSERT(TYPE_CLASS(type)->flags & CLASS_FLAGS_100);
- type2 = CTempl_ClassGetType(TYPE_CLASS(type));
- if (type2->type == TYPETEMPLATE) {
+ CError_ASSERT(2609, TYPE_CLASS(type)->flags & CLASS_FLAGS_100);
+ type2 = CTempl_ClassGetType(TEMPL_CLASS(type));
+ if (IS_TYPE_TEMPLATE(type2)) {
if (lookahead() != TK_COLON_COLON) {
result->x8 = type2;
return 1;
@@ -1926,8 +1931,7 @@ Boolean CScope_ParseQualifiedNameSpace(CScopeParseResult *result, Boolean flag1,
tk = lex();
CDecl_CompleteType(type2);
} else {
-#line 2632
- CError_ASSERT(tk == TK_COLON_COLON);
+ CError_ASSERT(2632, tk == TK_COLON_COLON);
if (!(TYPE_CLASS(type)->flags & CLASS_FLAGS_100) || CParser_CheckTemplateClassUsage(TEMPL_CLASS(type), 1))
result->nspace_0 = nspace = TYPE_CLASS(type)->nspace;
CDecl_CompleteType(type);
@@ -1939,10 +1943,10 @@ Boolean CScope_ParseQualifiedNameSpace(CScopeParseResult *result, Boolean flag1,
}
if (list->object->otype == OT_TYPE) {
type2 = OBJ_TYPE(list->object)->type;
- if (type2->type != TYPECLASS) {
- if (type2->type == TYPETEMPLATE) {
+ if (!IS_TYPE_CLASS(type2)) {
+ if (IS_TYPE_TEMPLATE(type2)) {
if (TYPE_TEMPLATE(type2)->dtype == TEMPLDEP_ARGUMENT && TYPE_TEMPLATE(type2)->u.pid.type == TPT_TEMPLATE) {
- type2 = CTempl_ParseTemplTemplParam(type2);
+ type2 = CTempl_ParseTemplTemplParam(TYPE_TEMPLATE(type2));
if ((type2->type != TYPETEMPLATE) || ((t = lookahead()) != TK_COLON_COLON)) {
result->x8 = type2;
return 1;
@@ -1955,7 +1959,7 @@ Boolean CScope_ParseQualifiedNameSpace(CScopeParseResult *result, Boolean flag1,
result->x8 = type2;
return 1;
} else {
- CError_Error(121);
+ CError_Error(CErrorStr121);
return 0;
}
} else {
@@ -1967,8 +1971,7 @@ Boolean CScope_ParseQualifiedNameSpace(CScopeParseResult *result, Boolean flag1,
result->x8 = type2;
return 1;
}
-#line 2686
- CError_ASSERT(tk == TK_COLON_COLON);
+ CError_ASSERT(2686, tk == TK_COLON_COLON);
if (!type2->size)
CDecl_CompleteType(type2);
result->nspace_0 = nspace = TYPE_CLASS(type2)->nspace;
@@ -1982,7 +1985,7 @@ Boolean CScope_ParseQualifiedNameSpace(CScopeParseResult *result, Boolean flag1,
}
} while (CScope_NSIteratorNext(&iterator));
- CError_Error(140, name->name);
+ CError_Error(CErrorStr140, name->name);
return 0;
}
@@ -1995,7 +1998,7 @@ Boolean CScope_ParseElaborateName(CScopeParseResult *result) {
if (!copts.cplusplus) {
memclrw(result, sizeof(CScopeParseResult));
if (tk != TK_IDENTIFIER) {
- CError_Error(107);
+ CError_Error(CErrorStr107);
return 0;
}
@@ -2014,32 +2017,31 @@ Boolean CScope_ParseElaborateName(CScopeParseResult *result) {
return 1;
} else {
if ((tk != TK_COLON_COLON) && (tk != TK_IDENTIFIER)) {
- CError_Error(107);
+ CError_Error(CErrorStr107);
return 0;
}
if (!CScope_ParseQualifiedNameSpace(result, 0, 0)) {
result->nspace_0 = cscope_current;
if (tk != TK_IDENTIFIER) {
- CError_Error(107);
+ CError_Error(CErrorStr107);
return 0;
}
name = tkidentifier;
} else {
if (result->x8)
return 1;
-#line 2760
- CError_ASSERT(result->nspace_0);
+ CError_ASSERT(2760, result->nspace_0);
if (tk != TK_IDENTIFIER) {
- CError_Error(107);
+ CError_Error(CErrorStr107);
return 0;
}
name = tkidentifier;
if (result->x1D) {
if (result->nspace_0->theclass)
- return CScope_FindClassMember(result, result->nspace_0, name, 1) != 0;
+ return CScope_FindClassMember(result, result->nspace_0, name, Lookup_1) != 0;
else
return CScope_FindQualifiedTag(result, result->nspace_0, name);
}
@@ -2145,7 +2147,7 @@ Boolean CScope_FindClassMemberObject(TypeClass *tclass, CScopeParseResult *resul
memclrw(result, sizeof(CScopeParseResult));
- if (CScope_FindClassMember(result, tclass->nspace, name, 0)) {
+ if (CScope_FindClassMember(result, tclass->nspace, name, Lookup_0)) {
list = result->nsol_14;
result->nsol_14 = NULL;
if (list && list->object->otype == OT_OBJECT)
@@ -2285,7 +2287,7 @@ NameSpaceObjectList *CScope_GetLocalObject(NameSpace *nspace, HashNameNode *name
case OT_OBJECT:
return CScope_GetLocalObjects(list);
default:
- CError_Error(122, name->name);
+ CError_Error(CErrorStr122, name->name);
return NULL;
case OT_TYPETAG:
break;
@@ -2323,7 +2325,7 @@ BClassList *CScope_GetClassAccessPath(BClassList *list, TypeClass *tclass) {
list = CScope_GetBaseAccessPathEnd(list);
for (scan = list; scan; scan = scan->next) {
- if (scan->type == (Type *) tclass)
+ if (scan->type == TYPE(tclass))
return scan;
}
@@ -2334,8 +2336,7 @@ BClassList *CScope_GetClassAccessPath(BClassList *list, TypeClass *tclass) {
return list2;
}
}
-#line 3217
- CError_FATAL();
+ CError_FATAL(3217);
}
return NULL;
@@ -2344,9 +2345,9 @@ BClassList *CScope_GetClassAccessPath(BClassList *list, TypeClass *tclass) {
static Boolean CScope_FixMemberResult(TypeClass *tclass, CScopeParseResult *result) {
if (!(result->bcl_18 = CScope_GetClassAccessPath(result->bcl_18, tclass))) {
if (result->name_4)
- CError_Error(150, result->name_4->name);
+ CError_Error(CErrorStr150, result->name_4->name);
else
- CError_Error(328);
+ CError_Error(CErrorStr328);
return 0;
} else {
return 1;
@@ -2364,10 +2365,10 @@ Boolean CScope_ParseMemberName(TypeClass *tclass, CScopeParseResult *result, Boo
if (!CScope_ParseExprName(result))
return 0;
- if (result->x8 && result->x8->type == TYPETEMPLATE && TYPE_TEMPLATE(result->x8)->dtype == TEMPLDEP_QUALNAME) {
+ if (result->x8 && IS_TYPE_TEMPLATE(result->x8) && TYPE_TEMPLATE(result->x8)->dtype == TEMPLDEP_QUALNAME) {
if (flag)
return 1;
- CError_Error(340, TYPE_TEMPLATE(result->x8)->u.qual.name->name);
+ CError_Error(CErrorStr340, TYPE_TEMPLATE(result->x8)->u.qual.name->name);
result->x8 = NULL;
return 0;
}
@@ -2385,7 +2386,7 @@ Boolean CScope_ParseMemberName(TypeClass *tclass, CScopeParseResult *result, Boo
switch (t) {
case TK_COLON_COLON:
memclrw(result, sizeof(CScopeParseResult));
- if (!CScope_FindClassMember(result, tclass->nspace, name, 2))
+ if (!CScope_FindClassMember(result, tclass->nspace, name, Lookup_2))
goto restart;
break;
case '<':
@@ -2402,7 +2403,7 @@ Boolean CScope_ParseMemberName(TypeClass *tclass, CScopeParseResult *result, Boo
}
if (!(list = CScope_FindQualifiedName(result, tclass->nspace, destructor_name_node, &result->nspace_0))) {
- CError_Error(140, CError_GetNameString(result->nspace_0, destructor_name_node));
+ CError_Error(CErrorStr140, CError_GetNameString(result->nspace_0, destructor_name_node));
return 0;
} else {
return CScope_SetupParseNameResult(result, list, destructor_name_node);
@@ -2424,7 +2425,7 @@ static void CScope_AddUsingObject(BClassList *bcl, NameSpace *nspace, ObjBase *o
if (bcl) {
if (!nspace->theclass)
- CError_Error(200);
+ CError_Error(CErrorStr200);
else
CClass_CheckPathAccess(bcl, NULL, obj->access);
}
@@ -2461,15 +2462,15 @@ static void CScope_AddUsingObject(BClassList *bcl, NameSpace *nspace, ObjBase *o
*OBJ_MEMBER_VAR(copy) = *OBJ_MEMBER_VAR(obj);
copy->access = access;
pathcopy = CScope_GetClassAccessPath(CClass_GetPathCopy(bcl, 1), nspace->theclass);
- if (pathcopy && pathcopy->type == (Type *) nspace->theclass) {
+ if (pathcopy && pathcopy->type == TYPE(nspace->theclass)) {
OBJ_MEMBER_VAR_PATH(copy)->has_path = 1;
OBJ_MEMBER_VAR_PATH(copy)->path = pathcopy;
} else {
- CError_Error(221);
+ CError_Error(CErrorStr221);
}
CScope_AddObject(nspace, OBJ_MEMBER_VAR(copy)->name, copy);
} else {
- CError_Error(221);
+ CError_Error(CErrorStr221);
}
} else if (obj->otype == OT_OBJECT) {
if (!nspace->theclass) {
@@ -2492,17 +2493,17 @@ static void CScope_AddUsingObject(BClassList *bcl, NameSpace *nspace, ObjBase *o
OBJECT(copy)->u.alias.member = NULL;
OBJECT(copy)->u.alias.offset = 0;
- if (OBJECT(copy)->type->type == TYPEFUNC && (TYPE_FUNC(OBJECT(copy)->type)->flags & FUNC_FLAGS_METHOD) && !TYPE_METHOD(OBJECT(copy)->type)->x26) {
+ if (IS_TYPE_NONSTATIC_METHOD(OBJECT(copy)->type)) {
if (!(tclass = nspace->theclass) || !(OBJECT(copy)->u.alias.member = CScope_GetClassAccessPath(
- CClass_GetPathCopy(bcl, 1), tclass)) || (OBJECT(copy)->u.alias.member->type != (Type *) nspace->theclass)) {
- CError_Error(221);
+ CClass_GetPathCopy(bcl, 1), tclass)) || (OBJECT(copy)->u.alias.member->type != TYPE(nspace->theclass))) {
+ CError_Error(CErrorStr221);
OBJECT(copy)->u.alias.member = NULL;
}
}
CScope_AddObject(nspace, OBJECT(copy)->name, copy);
} else {
- CError_Error(200);
+ CError_Error(CErrorStr200);
}
}
@@ -2511,8 +2512,8 @@ void CScope_AddClassUsingDeclaration(TypeClass *tclass, TypeClass *tclass2, Hash
NameSpaceObjectList *scan;
memclrw(&result, sizeof(CScopeParseResult));
- if (!CScope_FindClassMember(&result, tclass2->nspace, name, 0) || !CScope_FixMemberResult(tclass, &result)) {
- CError_Error(340, name->name);
+ if (!CScope_FindClassMember(&result, tclass2->nspace, name, Lookup_0) || !CScope_FixMemberResult(tclass, &result)) {
+ CError_Error(CErrorStr340, name->name);
return;
}
@@ -2530,32 +2531,34 @@ void CScope_AddClassUsingDeclaration(TypeClass *tclass, TypeClass *tclass2, Hash
if (result.obj_10)
CScope_AddUsingObject(result.bcl_18, tclass->nspace, result.obj_10, result.name_4, access);
else
- CError_Error(340, name->name);
+ CError_Error(CErrorStr340, name->name);
}
}
-void CScope_ParseUsingDeclaration(NameSpace *nspace, short access, Boolean flag) {
- // almost matches, slight bit of register weirdness
+void CScope_ParseUsingDeclaration(NameSpace *nspace, AccessType access, Boolean flag) {
+ NameSpace *saveNSpace;
+ Boolean flag_r27;
+ Boolean flag_r26;
+ NameSpaceObjectList *scan;
CScopeParseResult result;
if (nspace->theclass) {
- Boolean flag_r27 = (TYPE_CLASS(nspace->theclass)->flags & CLASS_FLAGS_100) ? 1 : 0;
- Boolean flag_r26 = 0;
+ flag_r27 = (TYPE_CLASS(nspace->theclass)->flags & CLASS_FLAGS_100) ? 1 : 0;
+ flag_r26 = 0;
if (tk == TK_TYPENAME) {
if (!flag_r27)
- CError_Error(200);
+ CError_Error(CErrorStr200);
flag_r26 = 1;
tk = lex();
}
if (!CScope_ParseMemberName(nspace->theclass, &result, flag_r27)) {
- CError_Error(200);
+ CError_Error(CErrorStr200);
return;
}
- if (result.x8 && result.x8->type == TYPETEMPLATE && TYPE_TEMPLATE(result.x8)->dtype == TEMPLDEP_QUALNAME) {
-#line 3578
- CError_ASSERT(flag_r27);
+ if (result.x8 && IS_TYPE_TEMPLATE(result.x8) && TYPE_TEMPLATE(result.x8)->dtype == TEMPLDEP_QUALNAME) {
+ CError_ASSERT(3578, flag_r27);
if (flag_r26) {
ObjType *objtype = galloc(sizeof(ObjType));
@@ -2565,32 +2568,34 @@ void CScope_ParseUsingDeclaration(NameSpace *nspace, short access, Boolean flag)
objtype->type = result.x8;
CScope_AddObject(nspace, TYPE_TEMPLATE(result.x8)->u.qual.name, OBJ_BASE(objtype));
} else {
- CTemplClass_RegisterUsingDecl(TEMPL_CLASS(nspace->theclass), result.x8, access);
+ CTemplClass_RegisterUsingDecl(
+ TEMPL_CLASS(nspace->theclass),
+ TYPE_TEMPLATE(result.x8),
+ access);
}
if ((tk = lex()) != ';')
- CError_Error(123);
+ CError_Error(CErrorStr123);
return;
}
if (!result.x1D) {
- CError_Error(200);
+ CError_Error(CErrorStr200);
return;
}
} else {
- NameSpace *savenspace = cscope_current;
+ saveNSpace = cscope_current;
cscope_current = nspace;
if (!CScope_ParseExprName(&result) || !result.x1D) {
- cscope_current = savenspace;
- CError_Error(200);
+ cscope_current = saveNSpace;
+ CError_Error(CErrorStr200);
return;
} else {
- cscope_current = savenspace;
+ cscope_current = saveNSpace;
}
}
if (result.nsol_14) {
- NameSpaceObjectList *scan;
for (scan = result.nsol_14; scan; scan = scan->next) {
if (scan->object->otype == OT_OBJECT)
CScope_AddUsingObject(result.bcl_18, nspace, scan->object, result.name_4, access);
@@ -2599,11 +2604,11 @@ void CScope_ParseUsingDeclaration(NameSpace *nspace, short access, Boolean flag)
if (result.obj_10)
CScope_AddUsingObject(result.bcl_18, nspace, result.obj_10, result.name_4, access);
else
- CError_Error(200);
+ CError_Error(CErrorStr200);
}
if ((tk = lex()) != ';')
- CError_Error(123);
+ CError_Error(CErrorStr123);
}
static NameSpace *CScope_ParseQualifiedNamespaceSpecifier(NameSpace *nspace) {
@@ -2620,7 +2625,7 @@ static NameSpace *CScope_ParseQualifiedNamespaceSpecifier(NameSpace *nspace) {
do {
if (tk != TK_IDENTIFIER) {
- CError_Error(107);
+ CError_Error(CErrorStr107);
break;
}
@@ -2631,7 +2636,7 @@ static NameSpace *CScope_ParseQualifiedNamespaceSpecifier(NameSpace *nspace) {
goto some_goto;
}
} while (CScope_NSIteratorNext(&iterator));
- CError_Error(140, tkidentifier->name);
+ CError_Error(CErrorStr140, tkidentifier->name);
some_goto:
if ((tk = lex()) != TK_COLON_COLON)
break;
@@ -2656,17 +2661,17 @@ void CScope_ParseNameSpaceAlias(HashNameNode *name) {
objns->nspace = CScope_ParseQualifiedNamespaceSpecifier(cscope_current);
CScope_AddObject(cscope_current, name, OBJ_BASE(objns));
} else if (list->object->otype != OT_NAMESPACE) {
- CError_Error(320);
+ CError_Error(CErrorStr320);
tk = lex();
CScope_ParseQualifiedNamespaceSpecifier(cscope_current);
} else {
tk = lex();
if (CScope_ParseQualifiedNamespaceSpecifier(cscope_current) != OBJ_NAMESPACE(list->object)->nspace)
- CError_Error(122, name->name);
+ CError_Error(CErrorStr122, name->name);
}
if (tk != ';')
- CError_Error(123);
+ CError_Error(CErrorStr123);
}
void CScope_ParseUsingDirective(NameSpace *nspace) {
@@ -2686,9 +2691,9 @@ void CScope_ParseUsingDirective(NameSpace *nspace) {
nspace->usings = list;
}
} else {
- CError_Error(321);
+ CError_Error(CErrorStr321);
}
if (tk != ';')
- CError_Error(123);
+ CError_Error(CErrorStr123);
}
diff --git a/compiler_and_linker/FrontEnd/Common/CompilerTools.c b/compiler_and_linker/FrontEnd/Common/CompilerTools.c
index 131aa8e..fff4809 100644
--- a/compiler_and_linker/FrontEnd/Common/CompilerTools.c
+++ b/compiler_and_linker/FrontEnd/Common/CompilerTools.c
@@ -53,7 +53,7 @@ unsigned char *CTool_CtoPstr(char *cstr) {
return (unsigned char *) cstr;
}
-static void GListError() {
+static void GListError(void) {
if (GListErrorProc)
GListErrorProc();
}
@@ -465,7 +465,7 @@ HashNameNode *GetHashNameNodeByID(SInt32 id) {
return NULL;
}
-void NameHashExportReset() {
+void NameHashExportReset(void) {
HashNameNode *node;
short i;
@@ -540,13 +540,13 @@ void NameHashWriteTargetEndianNameTable(GList *glist) {
AppendGListByte(glist, 0);
}
-void InitNameHash() {
+void InitNameHash(void) {
name_hash_nodes = galloc(2048 * sizeof(HashNameNode *));
memclrw(name_hash_nodes, 2048 * sizeof(HashNameNode *));
hash_name_id = 1;
}
-SInt32 CTool_TotalHeapSize() {
+SInt32 CTool_TotalHeapSize(void) {
HeapBlock *blockp;
SInt32 size = 0;
@@ -718,7 +718,7 @@ short initgheap(heaperror_t heaperrorproc) {
return 0;
}
-heaperror_t getheaperror() {
+heaperror_t getheaperror(void) {
return heaperror;
}
@@ -740,7 +740,7 @@ static void relheap(HeapMem *heapp) {
memclrw(heapp, sizeof(HeapMem));
}
-void releaseheaps() {
+void releaseheaps(void) {
relheap(&gheap);
relheap(&lheap);
relheap(&aheap);
@@ -748,11 +748,11 @@ void releaseheaps() {
relheap(&bheap);
}
-void releasegheap() {
+void releasegheap(void) {
relheap(&gheap);
}
-void releaseoheap() {
+void releaseoheap(void) {
relheap(&gheap);
oheap.allocsize = 0x40000;
MoreHeapSpace(&oheap, 0);
@@ -823,17 +823,16 @@ void *balloc(SInt32 s) {
return cp;
}
-void locklheap() {
+void locklheap(void) {
lheaplockcount++;
}
-void unlocklheap() {
+void unlocklheap(void) {
if (lheaplockcount > 0)
--lheaplockcount;
}
-void freelheap() {
- // possible inline or macro?
+void freelheap(void) {
HeapBlock *blockp;
if (lheaplockcount == 0) {
@@ -849,7 +848,7 @@ void freelheap() {
}
}
-void freeaheap() {
+void freeaheap(void) {
HeapBlock *blockp;
blockp = aheap.blocks;
@@ -863,7 +862,7 @@ void freeaheap() {
}
}
-void freeoheap() {
+void freeoheap(void) {
HeapBlock *blockp;
blockp = oheap.blocks;
@@ -877,7 +876,7 @@ void freeoheap() {
}
}
-void freebheap() {
+void freebheap(void) {
HeapBlock *blockp;
blockp = bheap.blocks;