summaryrefslogtreecommitdiff
path: root/compiler_and_linker/FrontEnd/C
diff options
context:
space:
mode:
authorAsh Wolf <ninji@wuffs.org>2023-01-10 11:05:21 +0000
committerAsh Wolf <ninji@wuffs.org>2023-01-10 11:05:21 +0000
commitaec1b8dddc68ecb8288ec6132932e4c7b4bca09f (patch)
tree8138328fe43bcc5fff690dc60caac79aa570ab2b /compiler_and_linker/FrontEnd/C
parentfcfbafff31869ed808bff0639532db1828660e92 (diff)
downloadMWCC-aec1b8dddc68ecb8288ec6132932e4c7b4bca09f.tar.gz
MWCC-aec1b8dddc68ecb8288ec6132932e4c7b4bca09f.zip
getting close to done
Diffstat (limited to '')
-rw-r--r--compiler_and_linker/FrontEnd/C/CPrep.c2
-rw-r--r--compiler_and_linker/FrontEnd/C/CPrepTokenizer.c1073
-rw-r--r--compiler_and_linker/FrontEnd/C/CScope.c4
3 files changed, 814 insertions, 265 deletions
diff --git a/compiler_and_linker/FrontEnd/C/CPrep.c b/compiler_and_linker/FrontEnd/C/CPrep.c
index 4b66e88..f38c504 100644
--- a/compiler_and_linker/FrontEnd/C/CPrep.c
+++ b/compiler_and_linker/FrontEnd/C/CPrep.c
@@ -281,7 +281,7 @@ static Boolean dofreeaheap;
static GList mlist;
static Handle ts_buffer;
static TStreamElement *ts_first;
-static TStreamElement *ts_last;
+TStreamElement *ts_last;
TStreamElement *ts_current;
static SInt32 ts_elements;
SInt32 ts_preread_elements;
diff --git a/compiler_and_linker/FrontEnd/C/CPrepTokenizer.c b/compiler_and_linker/FrontEnd/C/CPrepTokenizer.c
index 62753f8..4ea0fb0 100644
--- a/compiler_and_linker/FrontEnd/C/CPrepTokenizer.c
+++ b/compiler_and_linker/FrontEnd/C/CPrepTokenizer.c
@@ -1,32 +1,34 @@
-#include "compiler.h"
-#include "compiler/tokens.h"
+#include "compiler/CPrepTokenizer.h"
#include "compiler/CError.h"
#include "compiler/CInt64.h"
+#include "compiler/CMachine.h"
+#include "compiler/CParser.h"
+#include "compiler/CPrep.h"
+#include "compiler/CompilerTools.h"
+#include "compiler/InlineAsmPPC.h"
+#include "compiler/tokens.h"
#include "cos.h"
static Boolean prepnextstringchar_foundnl;
-#define UCD (unsigned char *)
-#define CD (char *)
-
-short prepskipnextchar() {
+short prepskipnextchar(void) {
short c;
- unsigned char *start;
- unsigned char *p;
+ StringPtr start;
+ StringPtr p;
- start = UCD pos;
- p = UCD pos;
+ start = (StringPtr) pos;
+ p = (StringPtr) pos;
loop:
switch ((c = *p)) {
case 0:
- if (tokenstacklevel > 0 || CD p >= prep_file_end) {
- pos = CD p;
- nextcharpos = CD p;
+ if (tokenstacklevel > 0 || p >= (StringPtr) prep_file_end) {
+ pos = (char *) p;
+ nextcharpos = (char *) p;
return c;
} else {
- pos = CD p++;
- nextcharpos = CD p;
+ pos = (char *) p++;
+ nextcharpos = (char *) p;
return c;
}
case 4:
@@ -42,27 +44,27 @@ loop:
p++;
goto loop;
case ';':
- pos = CD p++;
+ pos = (char *) p++;
if (tokenstacklevel <= 0 && in_assembler && copts.asmsemicolcomment) {
spaceskip = 1;
- nextcharpos = CPrep_SkipNewComment(CD p);
+ nextcharpos = (char *) CPrep_SkipNewComment(p);
return CPrep_SkipNewCommentChar;
}
- nextcharpos = CD p;
+ nextcharpos = (char *) p;
return c;
case '#':
- pos = CD p++;
+ pos = (char *) p++;
if (tokenstacklevel <= 0 && in_assembler && copts.asmpoundcomment) {
spaceskip = 1;
- nextcharpos = CPrep_SkipNewComment(CD p);
+ nextcharpos = (char *) CPrep_SkipNewComment(p);
return CPrep_SkipNewCommentChar;
}
- nextcharpos = CD p;
+ nextcharpos = (char *) p;
return c;
case '/':
- pos = CD p++;
+ pos = (char *) p++;
if (copts.multibyteaware) {
- while (p[0] == '\\' && !COS_IsMultiByte(CD start, CD p) && p[1] == '\r') {
+ while (p[0] == '\\' && !COS_IsMultiByte(start, p) && p[1] == '\r') {
foundnl();
if (p[2] == '\n')
p += 3;
@@ -81,23 +83,23 @@ loop:
if (tokenstacklevel <= 0) {
if (p[0] == '/' && (!copts.ANSI_strict || copts.cplusplus || copts.c9x)) {
spaceskip = 1;
- nextcharpos = CPrep_SkipNewComment(CD p + 1);
+ nextcharpos = (char *) CPrep_SkipNewComment(p + 1);
return CPrep_SkipNewCommentChar;
} else if (p[0] == '*') {
spaceskip = 1;
p++;
for (;;) {
if (!(c = *(p++))) {
- if (tokenstacklevel > 0 || CD p >= prep_file_end) {
+ if (tokenstacklevel > 0 || p >= (StringPtr) prep_file_end) {
CPrep_Error(103);
- nextcharpos = CD p - 1;
+ nextcharpos = (char *) p - 1;
return c;
}
p[-1] = ' ';
}
if (c == '*') {
if (copts.multibyteaware) {
- while (p[0] == '\\' && !COS_IsMultiByte(CD start, CD p) && p[1] == '\r') {
+ while (p[0] == '\\' && !COS_IsMultiByte(start, p) && p[1] == '\r') {
foundnl();
if (p[2] == '\n')
p += 3;
@@ -123,21 +125,21 @@ loop:
}
}
}
- nextcharpos = CD p;
+ nextcharpos = (char *) p;
return c;
case '%':
- pos = CD p++;
+ pos = (char *) p++;
if (*p == ':' && copts.cplusplus) {
- nextcharpos = CD p + 1;
+ nextcharpos = (char *) p + 1;
return '#';
}
- nextcharpos = CD p;
+ nextcharpos = (char *) p;
return c;
case '\\':
- pos = CD p++;
+ pos = (char *) p++;
mid_backslash:
if (*p == '\r') {
- if (!copts.multibyteaware || !COS_IsMultiByte(CD start, CD p - 1)) {
+ if (!copts.multibyteaware || !COS_IsMultiByte(start, p - 1)) {
foundnl();
if (p[1] == '\n')
p += 2;
@@ -146,67 +148,67 @@ loop:
goto loop;
}
}
- nextcharpos = CD p;
+ nextcharpos = (char *) p;
return c;
case '?':
- pos = CD p++;
+ pos = (char *) p++;
if (copts.trigraphs && p[0] == '?') {
switch (p[1]) {
case '=':
- nextcharpos = CD p + 2;
+ nextcharpos = (char *) p + 2;
return '#';
case '/':
c = '\\';
p += 2;
goto mid_backslash;
case '\'':
- nextcharpos = CD p + 2;
+ nextcharpos = (char *) p + 2;
return '^';
case '(':
- nextcharpos = CD p + 2;
+ nextcharpos = (char *) p + 2;
return '[';
case ')':
- nextcharpos = CD p + 2;
+ nextcharpos = (char *) p + 2;
return ']';
case '!':
- nextcharpos = CD p + 2;
+ nextcharpos = (char *) p + 2;
return '|';
case '<':
- nextcharpos = CD p + 2;
+ nextcharpos = (char *) p + 2;
return '{';
case '>':
- nextcharpos = CD p + 2;
+ nextcharpos = (char *) p + 2;
return '}';
case '-':
- nextcharpos = CD p + 2;
+ nextcharpos = (char *) p + 2;
return '~';
}
}
- nextcharpos = CD p;
+ nextcharpos = (char *) p;
return c;
default:
- pos = CD p++;
- nextcharpos = CD p;
+ pos = (char *) p++;
+ nextcharpos = (char *) p;
return c;
}
}
-short prepnextchar() {
+short prepnextchar(void) {
short c;
- unsigned char *start;
- unsigned char *p;
+ StringPtr start;
+ StringPtr p;
- start = UCD pos;
- p = UCD pos;
+ start = (StringPtr) pos;
+ p = (StringPtr) pos;
loop:
switch ((c = *(p++))) {
case 0:
- pos = CD p - 1;
+ pos = (char *) p - 1;
return c;
case '/':
if (copts.multibyteaware) {
- while (p[0] == '\\' && !COS_IsMultiByte(CD start, CD p) && p[1] == '\r') {
+ while (p[0] == '\\' && !COS_IsMultiByte(start, p) && p[1] == '\r') {
foundnl();
if (p[2] == '\n')
p += 3;
@@ -224,15 +226,15 @@ loop:
}
if (p[0] == '/' && (!copts.ANSI_strict || copts.cplusplus)) {
spaceskip = 1;
- pos = CPrep_SkipNewComment(CD p + 1);
+ pos = (char *) CPrep_SkipNewComment(p + 1);
return CPrep_SkipNewCommentChar;
} else if (p[0] == '*') {
spaceskip = 1;
p++;
for (;;) {
if (!(c = *(p++))) {
- if (tokenstacklevel > 0 || CD p >= prep_file_end) {
- pos = CD p - 1;
+ if (tokenstacklevel > 0 || p >= (StringPtr) prep_file_end) {
+ pos = (char *) p - 1;
CPrep_Error(103);
return c;
}
@@ -240,7 +242,7 @@ loop:
}
if (c == '*') {
if (copts.multibyteaware) {
- while (p[0] == '\\' && !COS_IsMultiByte(CD start, CD p) && p[1] == '\r') {
+ while (p[0] == '\\' && !COS_IsMultiByte(start, p) && p[1] == '\r') {
foundnl();
if (p[2] == '\n')
p += 3;
@@ -262,16 +264,16 @@ loop:
if (c == '\r')
foundnl();
}
- pos = CD p + 1;
+ pos = (char *) p + 1;
return ' ';
} else {
- pos = CD p;
+ pos = (char *) p;
return c;
}
case '\\':
backslash:
if (*p == '\r') {
- if (!copts.multibyteaware || !COS_IsMultiByte(CD start, CD p - 1)) {
+ if (!copts.multibyteaware || !COS_IsMultiByte(start, p - 1)) {
foundnl();
if (p[1] == '\n')
p += 2;
@@ -280,70 +282,70 @@ loop:
goto loop;
}
}
- pos = CD p;
+ pos = (char *) p;
return c;
case '%':
if (*p == ':' && copts.cplusplus) {
- pos = CD p + 1;
+ pos = (char *) p + 1;
return '#';
}
- pos = CD p;
+ pos = (char *) p;
return c;
case '?':
if (copts.trigraphs && p[0] == '?') {
switch (p[1]) {
case '=':
- pos = CD p + 2;
+ pos = (char *) p + 2;
return '#';
case '/':
c = '\\';
p += 2;
goto backslash;
case '\'':
- pos = CD p + 2;
+ pos = (char *) p + 2;
return '^';
case '(':
- pos = CD p + 2;
+ pos = (char *) p + 2;
return '[';
case ')':
- pos = CD p + 2;
+ pos = (char *) p + 2;
return ']';
case '!':
- pos = CD p + 2;
+ pos = (char *) p + 2;
return '|';
case '<':
- pos = CD p + 2;
+ pos = (char *) p + 2;
return '{';
case '>':
- pos = CD p + 2;
+ pos = (char *) p + 2;
return '}';
case '-':
- pos = CD p + 2;
+ pos = (char *) p + 2;
return '~';
}
}
- pos = CD p;
+ pos = (char *) p;
return c;
default:
- pos = CD p;
+ pos = (char *) p;
return c;
}
}
-short prepnextstringchar(char *str, Boolean flag) {
- unsigned char *p;
+short prepnextstringchar(StringPtr str, Boolean flag) {
+ StringPtr p;
short c;
- p = UCD pos;
+ p = (StringPtr) pos;
loop:
switch ((c = *(p++))) {
case 0:
- pos = CD p - 1;
+ pos = (char *) p - 1;
return c;
case '\\':
backslash:
- if (p[0] == '\r' && (!copts.multibyteaware || !COS_IsMultiByte(str, CD p - 1))) {
+ if (p[0] == '\r' && (!copts.multibyteaware || !COS_IsMultiByte(str, p - 1))) {
if (flag)
foundnl();
else
@@ -354,45 +356,45 @@ loop:
p += 1;
goto loop;
}
- pos = CD p;
+ pos = (char *) p;
return c;
case '?':
if (copts.trigraphs && p[0] == '?') {
switch (p[1]) {
case '=':
- pos = CD p + 2;
+ pos = (char *) p + 2;
return '#';
case '/':
c = '\\';
p += 2;
goto backslash;
case '\'':
- pos = CD p + 2;
+ pos = (char *) p + 2;
return '^';
case '(':
- pos = CD p + 2;
+ pos = (char *) p + 2;
return '[';
case ')':
- pos = CD p + 2;
+ pos = (char *) p + 2;
return ']';
case '!':
- pos = CD p + 2;
+ pos = (char *) p + 2;
return '|';
case '<':
- pos = CD p + 2;
+ pos = (char *) p + 2;
return '{';
case '>':
- pos = CD p + 2;
+ pos = (char *) p + 2;
return '}';
case '-':
- pos = CD p + 2;
+ pos = (char *) p + 2;
return '~';
}
}
- pos = CD p;
+ pos = (char *) p;
return c;
default:
- pos = CD p;
+ pos = (char *) p;
return c;
}
}
@@ -401,10 +403,10 @@ void CPrep_MatchChar(char ch, Boolean flag) {
char *p;
char *start;
char c;
- Boolean r26;
+ Boolean haveBackslash;
p = start = pos;
- r26 = 0;
+ haveBackslash = 0;
loop:
if (!(c = *(p++))) {
@@ -429,7 +431,7 @@ loop:
pos = p;
return;
}
- r26 = 0;
+ haveBackslash = 0;
goto loop;
}
@@ -443,7 +445,7 @@ loop:
case '<':
case '=':
case '>':
- r26 = 0;
+ haveBackslash = 0;
p += 2;
goto loop;
case '/':
@@ -452,24 +454,24 @@ loop:
}
}
- if (c == '\\' && !r26 && (!copts.multibyteaware || !COS_IsMultiByte(start, p - 1))) {
+ if (c == '\\' && !haveBackslash && (!copts.multibyteaware || !COS_IsMultiByte(start, p - 1))) {
backslash:
if (*p == '\r') {
if (flag)
foundnl();
if (*(++p) == '\n')
p++;
- r26 = 0;
+ haveBackslash = 0;
} else {
- r26 = 1;
+ haveBackslash = 1;
}
goto loop;
}
- if (c == ch && !r26) {
+ if (c == ch && !haveBackslash) {
pos = p;
} else {
- r26 = 0;
+ haveBackslash = 0;
goto loop;
}
}
@@ -477,10 +479,10 @@ loop:
char *CPrep_MatchChar2(char *start, char ch, Boolean flag) {
char *p;
char c;
- Boolean r28;
+ Boolean haveBackslash;
p = start;
- r28 = 0;
+ haveBackslash = 0;
loop:
if (!(c = *(p++))) {
@@ -503,7 +505,7 @@ loop:
CPrep_Error(112);
return p;
}
- r28 = 0;
+ haveBackslash = 0;
goto loop;
}
@@ -517,7 +519,7 @@ loop:
case '<':
case '=':
case '>':
- r28 = 0;
+ haveBackslash = 0;
p += 2;
goto loop;
case '/':
@@ -526,29 +528,29 @@ loop:
}
}
- if (c == '\\' && !r28 && (!copts.multibyteaware || !COS_IsMultiByte(start, p - 1))) {
+ if (c == '\\' && !haveBackslash && (!copts.multibyteaware || !COS_IsMultiByte(start, p - 1))) {
backslash:
if (*p == '\r') {
if (flag)
foundnl();
if (*(++p) == '\n')
p++;
- r28 = 0;
+ haveBackslash = 0;
} else {
- r28 = 1;
+ haveBackslash = 1;
}
goto loop;
}
- if (c == ch && !r28) {
+ if (c == ch && !haveBackslash) {
return p;
} else {
- r28 = 0;
+ haveBackslash = 0;
goto loop;
}
}
-short prepcurchar() {
+short prepcurchar(void) {
char *save_pos;
short t;
@@ -560,7 +562,7 @@ short prepcurchar() {
return t;
}
-static short prepcurstringchar(char *str) {
+static short prepcurstringchar(StringPtr str) {
char *save_pos;
short t;
@@ -573,51 +575,54 @@ static short prepcurstringchar(char *str) {
return t;
}
-static void prepcurstringchar_skip() {
+static void prepcurstringchar_skip(void) {
pos = nextcharpos;
if (prepnextstringchar_foundnl)
foundnl();
}
-char *ReadIdentifier(char *p) {
+char *ReadIdentifier(const char *p) {
char buf[256];
- char *start;
+ const char *start;
+ unsigned int ch;
int len;
start = p;
len = 0;
-loop:
for (;;) {
- if (!cprep_idarray[(unsigned char) *p])
- break;
- if (len < 255)
- buf[len++] = *p;
- p++;
- }
-
- if (copts.multibyteaware) {
- if ((unsigned char) *p == '\\' && !COS_IsMultiByte(start, p) && p[1] == '\r') {
- if (p[2] == '\n')
- p += 3;
- else
- p += 2;
- foundnl();
- goto loop;
- }
- } else {
- if ((unsigned char) *p == '\\' && p[1] == '\r') {
- if (p[2] == '\n')
- p += 3;
- else
- p += 2;
- foundnl();
- goto loop;
+ ch = (unsigned char) *p;
+ if (cprep_idarray[ch]) {
+ if (len < 255)
+ buf[len++] = *p;
+ p++;
+ } else {
+ if (copts.multibyteaware) {
+ if ((unsigned char) *p == '\\' && !COS_IsMultiByte(start, p) && p[1] == '\r') {
+ if (p[2] == '\n')
+ p += 3;
+ else
+ p += 2;
+ foundnl();
+ } else {
+ break;
+ }
+ } else {
+ if ((unsigned char) *p == '\\' && p[1] == '\r') {
+ if (p[2] == '\n')
+ p += 3;
+ else
+ p += 2;
+ foundnl();
+ } else {
+ break;
+ }
+ }
}
}
buf[len] = 0;
tkidentifier = GetHashNameNodeExport(buf);
- return p;
+ return (char *) p;
}
static short intsuffix(short token, Boolean flag) {
@@ -778,12 +783,11 @@ static short tohex(short token) {
return -1;
}
-static SInt32 nextchar(char *str) {
- // minor register allocation issues
- SInt32 chr_max;
+static SInt32 nextchar(StringPtr str) {
short tmpchr;
- SInt32 chr;
+ SInt32 chr_max;
Boolean out_of_bounds;
+ SInt32 chr;
short i;
short t;
@@ -795,8 +799,7 @@ static SInt32 nextchar(char *str) {
if (t == '\\' && (!copts.multibyteaware || !COS_IsMultiByte(str, pos - 1))) {
was_escchar = 1;
- t = prepnextstringchar(str, 1);
- switch (t) {
+ switch ((t = prepnextstringchar(str, 1))) {
case 'a': return 7;
case 'b': return 8;
case 't': return 9;
@@ -820,7 +823,7 @@ static SInt32 nextchar(char *str) {
return ' ';
}
out_of_bounds = 0;
- while (tohex(tmpchr = prepcurstringchar(str)) != -1) {
+ while (tohex((tmpchr = prepcurstringchar(str))) != -1) {
chr = (chr << 4) + tohex(tmpchr);
prepcurstringchar_skip();
if (chr & ~chr_max)
@@ -834,8 +837,8 @@ static SInt32 nextchar(char *str) {
out_of_bounds = 0;
i = 1;
chr = t - '0';
- while (i < 3 && (tmpchr = prepcurstringchar(str)) >= '0' && tmpchr <= '9') {
- chr = (chr << 3) + (tmpchr - '0');
+ while (i < 3 && (tmpchr = prepcurstringchar(str)) >= '0' && tmpchr <= '7') {
+ chr = (chr << 3) + tmpchr - '0';
prepcurstringchar_skip();
if (chr & ~chr_max)
out_of_bounds = 1;
@@ -857,24 +860,233 @@ static SInt32 nextchar(char *str) {
return (chr & chr_max);
}
-char *CPrep_SkipNewComment(char *str) {
+StringPtr CPrep_SkipNewComment(StringPtr str) {
+ StringPtr p;
+
+ p = str;
+ while (1) {
+ switch (*(p++)) {
+ case 0:
+ if (tokenstacklevel > 0 || p >= (StringPtr) prep_file_end) {
+ CPrep_SkipNewCommentChar = 0;
+ return p - 1;
+ }
+ p[-1] = ' ';
+ continue;
+
+ case '\r':
+ CPrep_SkipNewCommentChar = '\r';
+ return p;
+
+ case '\\':
+ if (copts.multibyteaware && COS_IsMultiByte(str, p - 1))
+ continue;
+
+ if (*p == '\r') {
+ ++p;
+ foundnl();
+ }
+
+ if (*p == '\n')
+ p++;
+ continue;
+
+ case '"':
+ if (InlineAsm_gccmode) {
+ CPrep_SkipNewCommentChar = '\r';
+ return p - 1;
+ }
+ continue;
+ }
+ }
}
-Boolean skipendoflinematch(char *str, short token) {
+Boolean skipendoflinematch(StringPtr str, short token) {
+ StringPtr start;
+
+ start = str - 1;
+ pos = (char *) start;
+
+ while (1) {
+ switch (*(str++)) {
+ case 0:
+ case '\r':
+ pos = (char *) str - 1;
+ return 0;
+
+ case '"':
+ if (token == '"') {
+ pos = (char *) str;
+ return 1;
+ }
+ break;
+
+ case '\'':
+ if (token == '\'') {
+ pos = (char *) str;
+ return 1;
+ }
+ break;
+
+ case '\\':
+ if (copts.multibyteaware && COS_IsMultiByte(start, str - 1))
+ continue;
+
+ switch (*(str++)) {
+ case 0:
+ pos = (char *) str - 1;
+ return 0;
+
+ case '\r':
+ foundnl();
+ if (*str == '\n')
+ str++;
+ break;
+ }
+ break;
+
+ case '?':
+ if (copts.trigraphs && str[0] == '?' && str[1] == '/' && str[2] == '\r') {
+ foundnl();
+ str += 3;
+ }
+ break;
+ }
+ }
}
-void skipendofline() {
+void skipendofline(void) {
+ StringPtr start;
+ StringPtr p;
+ short ch;
+
+ start = (StringPtr) pos;
+ p = (StringPtr) pos;
+
+ while (1) {
+ switch (*(p++)) {
+ case 0:
+ case '\r':
+ pos = (char *) p - 1;
+ return;
+
+ case '"':
+ if (!skipendoflinematch(p, '"'))
+ return;
+ p = (StringPtr) pos;
+ break;
+
+ case '\'':
+ if (!skipendoflinematch(p, '\''))
+ return;
+ p = (StringPtr) pos;
+ break;
+
+ case '/':
+ if (copts.multibyteaware) {
+ while (*p == '\\' && !COS_IsMultiByte(start, p) && p[1] == '\r') {
+ foundnl();
+ if (p[2] == '\n')
+ p += 3;
+ else
+ p += 2;
+ }
+ } else {
+ while (*p == '\\' && p[1] == '\r') {
+ foundnl();
+ if (p[2] == '\n')
+ p += 3;
+ else
+ p += 2;
+ }
+ }
+
+ if (*p == '/' && (!copts.ANSI_strict || copts.cplusplus)) {
+ // EOL comment
+ pos = (char *) CPrep_SkipNewComment(p + 1);
+ if (CPrep_SkipNewCommentChar == '\r')
+ pos--;
+ return;
+ }
+
+ if (*p == '*') {
+ // Block comment
+ pos = (char *) p - 1;
+ spaceskip = 1;
+ p++;
+ while (1) {
+ if ((ch = *(p++)) == 0) {
+ if (tokenstacklevel > 0 || p >= (StringPtr) prep_file_end) {
+ pos = (char *) p - 1;
+ CPrep_Error(103);
+ return;
+ }
+ p[-1] = ' ';
+ }
+
+ if (ch == '*') {
+ if (copts.multibyteaware) {
+ while (*p == '\\' && !COS_IsMultiByte(start, p) && p[1] == '\r') {
+ foundnl();
+ if (p[2] == '\n')
+ p += 3;
+ else
+ p += 2;
+ }
+ } else {
+ while (*p == '\\' && p[1] == '\r') {
+ foundnl();
+ if (p[2] == '\n')
+ p += 3;
+ else
+ p += 2;
+ }
+ }
+
+ if (*p == '/') {
+ p++;
+ break;
+ }
+ }
+
+ if (ch == '\r')
+ foundnl();
+ }
+ }
+ break;
+
+ case '\\':
+ if (copts.multibyteaware && COS_IsMultiByte(start, p - 1))
+ continue;
+
+ if (*p == '\r') {
+ foundnl();
+ if (p[1] == '\n')
+ p += 2;
+ else
+ p += 1;
+ }
+ break;
+
+ case '?':
+ if (copts.trigraphs && p[0] == '?' && p[1] == '/' && p[2] == '\r') {
+ foundnl();
+ p += 3;
+ }
+ break;
+ }
+ }
}
-void CPrep_SkipAsmComment() {
+void CPrep_SkipAsmComment(void) {
Boolean save_macrocheck = macrocheck;
skipendofline();
macrocheck = save_macrocheck;
}
-static short tille() { return TK_NEG6; }
+static short tille(void) { return TK_NEG6; }
-static short tcret() {
+static short tcret(void) {
newline();
if (cprep_eoltokens)
return TK_NEG7;
@@ -882,20 +1094,18 @@ static short tcret() {
return 0;
}
-static short tapos() {
- // has register allocation issues
+static short tapos(short _t) {
+ int t;
+ int t2;
+ int i;
+ StringPtr start;
UInt32 maxvalue;
int bytecount;
- CInt64 ci58;
- CInt64 ci50;
- CInt64 ci48;
- SInt32 t;
- SInt32 t2;
- int i;
- char *start;
+ CInt64 newBits;
+ CInt64 val;
- start = pos;
- t = nextchar(pos);
+ start = (StringPtr) pos;
+ t = nextchar((StringPtr) pos);
if ((t == '\'' || t == 0 || t == '\r') && !was_escchar) {
CPrep_Error(100);
tkintconst = cint64_zero;
@@ -920,8 +1130,7 @@ static short tapos() {
tksize = IT_UINT;
break;
default:
-#line 1386
- CError_FATAL();
+ CError_FATAL(1386);
}
} else {
if (copts.unsignedchars)
@@ -933,48 +1142,53 @@ static short tapos() {
if (widestring) {
switch (stwchar.size) {
case 1:
- CInt64_SetULong(&ci50, 8);
+ CInt64_SetULong(&val, 8);
maxvalue = 0xFF;
bytecount = 1;
break;
case 2:
- CInt64_SetULong(&ci50, 16);
+ CInt64_SetULong(&val, 16);
maxvalue = 0xFFFF;
bytecount = 2;
break;
case 4:
- CInt64_SetULong(&ci50, 32);
+ CInt64_SetULong(&val, 32);
maxvalue = 0xFFFFFFFF;
bytecount = 4;
break;
default:
-#line 1424
- CError_FATAL();
+ CError_FATAL(1424);
}
} else {
- CInt64_SetULong(&ci50, 8);
+ CInt64_SetULong(&val, 8);
maxvalue = 0xFF;
bytecount = 1;
}
CInt64_SetULong(&tkintconst, t & maxvalue);
i = bytecount;
- do {
+
+ while (1) {
if ((t2 == 0 || t2 == '\r') && !was_escchar) {
CPrep_Error(100);
- goto after_char_const;
+ break;
}
- CInt64_SetULong(&ci48, t2 & maxvalue);
- ci58 = CInt64_Shl(tkintconst, ci50);
- tkintconst = CInt64_Or(ci58, ci48);
+
+ CInt64_SetULong(&newBits, t2 & maxvalue);
+ tkintconst = CInt64_Or(CInt64_Shl(tkintconst, val), newBits);
i += bytecount;
+
t2 = nextchar(start);
if (t2 == '\'' && !was_escchar)
- goto after_char_const;
- } while (i < stunsignedlonglong.size);
- CPrep_Error(100);
- after_char_const:
- if (i <= stunsignedint.size && i < stunsignedlong.size)
+ break;
+
+ if (i >= stunsignedlonglong.size) {
+ CPrep_Error(100);
+ break;
+ }
+ }
+
+ if (i <= stunsignedint.size && stunsignedint.size < stunsignedlong.size)
tksize = IT_UINT;
else if (i <= stunsignedlong.size)
tksize = IT_ULONG;
@@ -985,42 +1199,41 @@ static short tapos() {
return TK_INTCONST;
}
-static short tquot() {
- // has register allocation issues
- TypeIntegral *type; // r22
- char *string_ptr; // r21
- SInt32 r20; // r20
- char *save_pos; // r19
- short c; // r19
- char *start_pos; // r18
+static short tquot(short t) {
+ Type *type;
+ StringPtr string_ptr;
+ SInt32 size;
+ short c;
+ StringPtr save_pos;
+ StringPtr start_pos;
CInt64 ch64;
- start_pos = pos;
+ start_pos = (StringPtr) pos;
at_linestart = 0;
if (cprep_nostring)
return '"';
- string_ptr = *stringmem;
+ string_ptr = (StringPtr) *stringmem;
ispascalstring = 0;
- r20 = 0;
+ size = 0;
if (widestring)
- type = &stwchar;
+ type = TYPE(&stwchar);
else
- type = &stchar;
+ type = TYPE(&stchar);
if (prepcurstringchar(start_pos) == '\\') {
- save_pos = pos;
+ save_pos = (StringPtr) pos;
prepcurstringchar_skip();
if (prepcurstringchar(start_pos) == 'p') {
prepcurstringchar_skip();
ispascalstring = 1;
string_ptr += type->size;
} else {
- pos = save_pos;
+ pos = (char *) save_pos;
}
}
- do {
+ while (1) {
c = nextchar(start_pos);
if ((c == '"' || c == '\r' || c == 0) && !was_escchar) {
if (c == 0 && (tokenstacklevel > 0 || pos >= prep_file_end))
@@ -1029,51 +1242,53 @@ static short tquot() {
CPrep_Error(101);
break;
}
- if ((r20 + type->size) >= maxstringsize) {
- string_ptr = (char *) (string_ptr - *stringmem);
+ if ((size + type->size) >= maxstringsize) {
+ SInt32 offset = string_ptr - (StringPtr) *stringmem;
if (!COS_ResizeHandle(stringmem, maxstringsize += 256))
CError_NoMem();
- string_ptr = *stringmem + (SInt32) string_ptr;
+ string_ptr = (StringPtr) *stringmem + offset;
}
if (type->size != 1) {
CInt64_SetLong(&ch64, c);
- CMach_InitIntMem((Type *) type, ch64, string_ptr);
+ CMach_InitIntMem(type, ch64, string_ptr);
string_ptr += type->size;
- r20 += type->size;
+ size += type->size;
} else {
*string_ptr = c;
string_ptr++;
- r20++;
+ size++;
}
- } while (1);
+ }
if (ispascalstring) {
- if (r20 > 255 && type->size == 1) {
+ if (size > 255 && type->size == 1) {
CPrep_Error(106);
- r20 = 255;
+ size = 255;
}
- CInt64_SetLong(&ch64, r20 / type->size);
- CMach_InitIntMem((Type *) type, ch64, *stringmem);
- r20 += type->size;
+ CInt64_SetLong(&ch64, size / type->size);
+ CMach_InitIntMem(type, ch64, *stringmem);
+ size += type->size;
} else {
- if ((r20 + 1) >= maxstringsize) {
+ if ((size + 1) >= maxstringsize) {
if (!COS_ResizeHandle(stringmem, maxstringsize += 256))
CError_NoMem();
- CMach_InitIntMem((Type *) type, cint64_zero, *stringmem + r20);
- r20 += type->size;
}
+ CMach_InitIntMem(type, cint64_zero, *stringmem + size);
+ size += type->size;
}
- tksize = r20;
- tkstring = galloc(r20);
+ tksize = size;
+ tkstring = galloc(size);
memcpy(tkstring, *stringmem, tksize);
+
if (widestring)
- return TK_STRING_WIDE;
+ c = TK_STRING_WIDE;
else
- return TK_STRING;
+ c = TK_STRING;
+ return (short) c;
}
-static short thash() {
+static short thash(void) {
if (at_linestart) {
preprocessor();
return 0;
@@ -1081,7 +1296,7 @@ static short thash() {
return '#';
}
-static short tmult() {
+static short tmult(void) {
at_linestart = 0;
if (prepcurchar() == '=') {
pos = nextcharpos;
@@ -1090,7 +1305,7 @@ static short tmult() {
return '*';
}
-static short tcolo() {
+static short tcolo(void) {
char t2;
at_linestart = 0;
if (copts.cplusplus) {
@@ -1107,7 +1322,7 @@ static short tcolo() {
return ':';
}
-static short tless() {
+static short tless(void) {
short t2;
at_linestart = 0;
t2 = prepcurchar();
@@ -1165,10 +1380,9 @@ static short tgrea(short) {
}
static short tatsg(short) {
- char *start_pos;
- Boolean save_idarray;
+ char save_idarray;
+ char *start_pos = pos;
- start_pos = pos;
at_linestart = 0;
if (copts.objective_c || in_assembler) {
@@ -1226,7 +1440,7 @@ static short tperc(short) {
return '%';
}
-static short texcl() {
+static short texcl(void) {
at_linestart = 0;
if (prepcurchar() == '=') {
pos = nextcharpos;
@@ -1235,7 +1449,7 @@ static short texcl() {
return '!';
}
-static short tplus() {
+static short tplus(void) {
short t2;
at_linestart = 0;
t2 = prepcurchar();
@@ -1250,7 +1464,7 @@ static short tplus() {
return '+';
}
-static short tminu() {
+static short tminu(void) {
short t2;
at_linestart = 0;
t2 = prepcurchar();
@@ -1273,7 +1487,7 @@ static short tminu() {
return '-';
}
-static short torrr() {
+static short torrr(void) {
short t2;
at_linestart = 0;
t2 = prepcurchar();
@@ -1288,7 +1502,7 @@ static short torrr() {
return '|';
}
-static short tampe() {
+static short tampe(void) {
short t2;
at_linestart = 0;
t2 = prepcurchar();
@@ -1303,7 +1517,7 @@ static short tampe() {
return '&';
}
-static short tpowe() {
+static short tpowe(void) {
at_linestart = 0;
if (prepcurchar() == '=') {
pos = nextcharpos;
@@ -1312,7 +1526,7 @@ static short tpowe() {
return '^';
}
-static short tdivi() {
+static short tdivi(void) {
at_linestart = 0;
if (prepcurchar() == '=') {
pos = nextcharpos;
@@ -1321,11 +1535,117 @@ static short tdivi() {
return '/';
}
-static short tzero() {}
-static short tpoin() {}
-static short tnumb() {}
+// forward decl
+static short tnumb(short t);
+
+static short tzero(short t) {
+ char *p;
+ short ch;
+ Boolean failed;
+ Boolean floatFailed;
+
+ if (InlineAsm_gccmode && InlineAsm_labelref)
+ return tnumb(t);
+
+ at_linestart = 0;
+
+ p = pos - 1;
+ ch = prepnextchar();
+ if (ch == 'x' || ch == 'X') {
+ p = CInt64_ScanHexString(&tkintconst, pos, &failed);
+ if (pos == p)
+ CError_Error(CErrorStr105);
+ pos = p;
+ } else if (!copts.ANSI_strict && (ch == 'b' || ch == 'B')) {
+ p = CInt64_ScanBinString(&tkintconst, pos, &failed);
+ if (pos == p)
+ CError_Error(CErrorStr105);
+ pos = p;
+ } else {
+ while (ch >= '0' && ch <= '9')
+ ch = prepnextchar();
+
+ switch (ch) {
+ case '.':
+ case 'E':
+ case 'e':
+ pos = CMach_FloatScan(p, &tkfloatconst, &floatFailed);
+ if (floatFailed)
+ CPrep_Error(154);
+ tksize = floatsuffix(prepcurchar());
+ return TK_FLOATCONST;
+ }
+
+ pos = CInt64_ScanOctString(&tkintconst, p, &failed);
+ }
+
+ if (failed) {
+ CPrep_Error(154);
+ tkintconst = cint64_zero;
+ }
+
+ tksize = intsuffix(prepcurchar(), 1);
+ return TK_INTCONST;
+}
+
+static short tpoin(void) {
+ char *p;
+ short ch;
+ Boolean failed;
+
+ at_linestart = 0;
+
+ p = pos - 1;
+ ch = prepnextchar();
+
+ if (ch >= '0' && ch <= '9') {
+ pos = CMach_FloatScan(p, &tkfloatconst, &failed);
+ if (failed)
+ CPrep_Error(154);
+ tksize = floatsuffix(prepcurchar());
+ return TK_FLOATCONST;
+ }
+
+ if (copts.cplusplus && ch == '*')
+ return TK_DOT_STAR;
+
+ if (ch == '.' && prepnextchar() == '.')
+ return TK_ELLIPSIS;
+
+ pos = p + 1;
+ return '.';
+}
+
+static short tnumb(short t) {
+ char *p;
+ short ch;
+ Boolean failed;
+ Boolean floatFailed;
-static short tiden() {
+ at_linestart = 0;
+
+ p = pos - 1;
+ pos = CInt64_ScanDecString(&tkintconst, p, &failed);
+
+ ch = prepcurchar();
+ if (ch == '.' || ch == 'e' || ch == 'E') {
+ pos = CMach_FloatScan(p, &tkfloatconst, &floatFailed);
+ if (floatFailed)
+ CPrep_Error(154);
+ tksize = floatsuffix(prepcurchar());
+ return TK_FLOATCONST;
+ }
+
+ if (failed) {
+ CPrep_Error(154);
+ tkintconst = cint64_zero;
+ }
+
+ tksize = intsuffix(prepcurchar(), 0);
+ return TK_INTCONST;
+}
+
+static short tiden(void) {
at_linestart = 0;
pos = ReadIdentifier(pos - 1);
if (macrocheck && macrotest())
@@ -1334,9 +1654,37 @@ static short tiden() {
return TK_IDENTIFIER;
}
-static short tchrL() {}
+static short tchrL(void) {
+ short ch;
+
+ at_linestart = 0;
+
+ if ((ch = prepcurchar()) == '\'') {
+ widestring = 1;
+ pos = nextcharpos;
+ ch = tapos(ch);
+ widestring = 0;
+
+ tksize = (copts.wchar_type && copts.cplusplus) ? IT_WCHAR_T : IT_INT;
+ return ch;
+ }
+
+ if (ch == '"') {
+ widestring = 1;
+ pos = nextcharpos;
+ ch = tquot(ch);
+ widestring = 0;
+ return ch;
+ }
+
+ pos = ReadIdentifier(pos - 1);
+ if (macrocheck && macrotest())
+ return 0;
+
+ return TK_IDENTIFIER;
+}
-static short tchra() {
+static short tchra(void) {
at_linestart = 0;
pos = ReadIdentifier(pos - 1);
if (macrocheck && macrotest())
@@ -1354,7 +1702,7 @@ static short tchra() {
return TK_IDENTIFIER;
}
-static short tchrb() {
+static short tchrb(void) {
at_linestart = 0;
pos = ReadIdentifier(pos - 1);
if (macrocheck && macrotest())
@@ -1380,7 +1728,7 @@ static short tchrb() {
return TK_IDENTIFIER;
}
-static short tchrc() {
+static short tchrc(void) {
at_linestart = 0;
pos = ReadIdentifier(pos - 1);
if (macrocheck && macrotest())
@@ -1414,7 +1762,7 @@ static short tchrc() {
return TK_IDENTIFIER;
}
-static short tchrd() {
+static short tchrd(void) {
at_linestart = 0;
pos = ReadIdentifier(pos - 1);
if (macrocheck && macrotest())
@@ -1437,7 +1785,7 @@ static short tchrd() {
return TK_IDENTIFIER;
}
-static short tchre() {
+static short tchre(void) {
at_linestart = 0;
pos = ReadIdentifier(pos - 1);
if (macrocheck && macrotest())
@@ -1457,7 +1805,7 @@ static short tchre() {
return TK_IDENTIFIER;
}
-static short tchrf() {
+static short tchrf(void) {
at_linestart = 0;
pos = ReadIdentifier(pos - 1);
if (macrocheck && macrotest())
@@ -1475,7 +1823,7 @@ static short tchrf() {
return TK_IDENTIFIER;
}
-static short tchrg() {
+static short tchrg(void) {
at_linestart = 0;
pos = ReadIdentifier(pos - 1);
if (macrocheck && macrotest())
@@ -1485,7 +1833,7 @@ static short tchrg() {
return TK_IDENTIFIER;
}
-static short tchri() {
+static short tchri(void) {
at_linestart = 0;
pos = ReadIdentifier(pos - 1);
if (macrocheck && macrotest())
@@ -1510,7 +1858,7 @@ static short tchri() {
return TK_IDENTIFIER;
}
-static short tchrl() {
+static short tchrl(void) {
at_linestart = 0;
pos = ReadIdentifier(pos - 1);
if (macrocheck && macrotest())
@@ -1520,7 +1868,7 @@ static short tchrl() {
return TK_IDENTIFIER;
}
-static short tchrm() {
+static short tchrm(void) {
at_linestart = 0;
pos = ReadIdentifier(pos - 1);
if (macrocheck && macrotest())
@@ -1556,7 +1904,7 @@ static short tchrn(short t) {
return TK_IDENTIFIER;
}
-static short tchro() {
+static short tchro(void) {
at_linestart = 0;
pos = ReadIdentifier(pos - 1);
if (macrocheck && macrotest())
@@ -1598,7 +1946,7 @@ static short tchrp(short t) {
return TK_IDENTIFIER;
}
-static short tchrr() {
+static short tchrr(void) {
at_linestart = 0;
pos = ReadIdentifier(pos - 1);
if (macrocheck && macrotest())
@@ -1617,7 +1965,7 @@ static short tchrr() {
return TK_IDENTIFIER;
}
-static short tchrs() {
+static short tchrs(void) {
at_linestart = 0;
pos = ReadIdentifier(pos - 1);
if (macrocheck && macrotest())
@@ -1642,7 +1990,7 @@ static short tchrs() {
return TK_IDENTIFIER;
}
-static short tchrt() {
+static short tchrt(void) {
at_linestart = 0;
pos = ReadIdentifier(pos - 1);
if (macrocheck && macrotest())
@@ -1685,7 +2033,7 @@ static short tchrt() {
return TK_IDENTIFIER;
}
-static short tchru() {
+static short tchru(void) {
at_linestart = 0;
pos = ReadIdentifier(pos - 1);
if (macrocheck && macrotest())
@@ -1702,7 +2050,7 @@ static short tchru() {
return TK_IDENTIFIER;
}
-static short tchrv() {
+static short tchrv(void) {
at_linestart = 0;
pos = ReadIdentifier(pos - 1);
if (macrocheck && macrotest())
@@ -1716,7 +2064,7 @@ static short tchrv() {
return TK_IDENTIFIER;
}
-static short tchrw() {
+static short tchrw(void) {
at_linestart = 0;
pos = ReadIdentifier(pos - 1);
if (macrocheck && macrotest())
@@ -1744,7 +2092,7 @@ static short tchrx(short t) {
return TK_IDENTIFIER;
}
-static short tchr_() {
+static short tchr_(void) {
at_linestart = 0;
pos = ReadIdentifier(pos - 1);
if (macrocheck && macrotest())
@@ -1801,7 +2149,7 @@ static short tdoll(short t) {
return t;
}
-static short tisid() {
+static short tisid(void) {
if (!tokenstacklevel)
CError_Error(105);
return 0;
@@ -1817,7 +2165,7 @@ static short tnull(short t) {
}
}
-static short t0x1a() {
+static short t0x1a(void) {
if (*pos == 0)
return 0;
else
@@ -1862,7 +2210,7 @@ static TokenizePtr cprep_tokenize[256] = {
F(tille), F(tille), F(tille), F(tille), F(tille), F(tille), F(tille), F(tille)
};
-short lookahead() {
+short lookahead(void) {
SInt32 state;
short t;
@@ -1873,7 +2221,7 @@ short lookahead() {
return t;
}
-short lookahead_noeol() {
+short lookahead_noeol(void) {
SInt32 state;
short t;
@@ -1886,14 +2234,215 @@ short lookahead_noeol() {
return t;
}
+typedef struct StringChunk {
+ struct StringChunk *next;
+ char *data;
+ SInt32 offset;
+ SInt32 size;
+} StringChunk;
+
static void CPrep_StringConCat(Boolean flag) {
+ StringPtr buffer;
+ StringChunk *chunks;
+ StringChunk *chunk;
+ char *saveString;
+ SInt32 saveSize;
+ SInt32 offset;
+ Boolean savePascalString;
+ TStreamElement *elem;
+ short ch;
+
+ saveString = tkstring;
+ saveSize = tksize;
+ savePascalString = ispascalstring;
+
+ cprep_strconcat = 1;
+
+ chunks = NULL;
+ offset = tksize;
+
+ while (1) {
+ ch = lookahead_noeol();
+ if (ch != TK_STRING && ch != TK_STRING_WIDE) {
+ ispascalstring = savePascalString;
+ if (chunks) {
+ tksize = offset;
+ buffer = galloc(offset);
+ tkstring = (char *) buffer;
+
+ memcpy(buffer, saveString, saveSize);
+ for (chunk = chunks; chunk; chunk = chunk->next)
+ memcpy(buffer + chunk->offset, chunk->data, chunk->size);
+
+ if (savePascalString) {
+ if (offset > 256) {
+ CError_Error(CErrorStr106);
+ offset = 256;
+ }
+ buffer[0] = offset - 1;
+ } else if (flag) {
+ CMach_InitIntMem(TYPE(&stwchar), cint64_zero, buffer + offset - stwchar.size);
+ } else {
+ CMach_InitIntMem(TYPE(&stchar), cint64_zero, buffer + offset - stchar.size);
+ }
+
+ elem = ts_current - 1;
+ elem->data.tkstring.data = (char *) buffer;
+ elem->data.tkstring.size = offset;
+ elem->subtype = ispascalstring;
+ cprep_strconcat = 0;
+ } else {
+ tkstring = saveString;
+ tksize = saveSize;
+ cprep_strconcat = 0;
+ }
+ break;
+ }
+
+ do {
+ ch = lex();
+ elem = --ts_current;
+ memmove(elem, elem + 1, sizeof(TStreamElement) * ts_preread_elements);
+ } while (ch == TK_NEG7);
+
+ chunk = lalloc(sizeof(StringChunk));
+ chunk->next = chunks;
+ chunk->data = tkstring;
+ chunk->size = tksize - 1;
+ chunk->offset = offset - 1;
+ chunks = chunk;
+
+ if (ispascalstring)
+ chunk->data++;
+ if (savePascalString)
+ chunk->offset++;
+
+ if (ch == TK_STRING_WIDE)
+ chunk->size = chunk->size + 1 - stwchar.size;
+ if (flag)
+ chunk->offset = chunk->offset + 1 - stwchar.size;
+
+ offset += chunk->size;
+ }
}
-short lex() {
+short lex(void) {
+ short t;
+
+ while (1) {
+ if (ts_preread_elements > 0)
+ break;
+
+ t = ts_current->tokentype;
+ if (t < 0) {
+ switch (t) {
+ case TK_INTCONST:
+ tkintconst = ts_current->data.tkintconst;
+ tksize = ts_current->subtype;
+ break;
+ case TK_FLOATCONST:
+ tkfloatconst = ts_current->data.tkfloatconst;
+ tksize = ts_current->subtype;
+ break;
+ case TK_IDENTIFIER:
+ tkidentifier = ts_current->data.tkidentifier;
+ break;
+ case TK_STRING:
+ case TK_STRING_WIDE:
+ tkstring = ts_current->data.tkstring.data;
+ tksize = ts_current->data.tkstring.size;
+ ispascalstring = ts_current->subtype;
+ break;
+ case TK_NEG7:
+ nlflag = 1;
+ if (!cprep_eoltokens) {
+ ts_current++;
+ ts_preread_elements--;
+ continue;
+ }
+ break;
+ default:
+ CError_FATAL(3007);
+ }
+ }
+
+ ts_current++;
+ ts_preread_elements--;
+ return t;
+ }
+
+ while (1) {
+ t = prepskipnextchar();
+
+ ts_current->tokenfile = prep_file;
+ if (tokenstacklevel > 0) {
+ ts_current->tokenoffset = tokenstack[0].pos - prep_file_start;
+ macropos = pos;
+ } else {
+ ts_current->tokenoffset = pos - prep_file_start;
+ }
+ ts_current->tokenline = linenumber;
+ pos = nextcharpos;
+
+ t = cprep_tokenize[t](t);
+ if (t != 0) {
+ if (ts_current >= ts_last)
+ CPrep_TSBufferGrow(1024);
+ ts_current->tokentype = t;
+
+ if ((t = ts_current->tokentype) < 0) {
+ switch (t) {
+ case TK_INTCONST:
+ ts_current->data.tkintconst = tkintconst;
+ ts_current->subtype = tksize;
+ break;
+ case TK_FLOATCONST:
+ ts_current->data.tkfloatconst = tkfloatconst;
+ ts_current->subtype = tksize;
+ break;
+ case TK_IDENTIFIER:
+ ts_current->data.tkidentifier = tkidentifier;
+ break;
+ case TK_STRING:
+ case TK_STRING_WIDE:
+ ts_current->data.tkstring.data = tkstring;
+ ts_current->data.tkstring.size = tksize;
+ ts_current->subtype = ispascalstring;
+ if (!cprep_strconcat) {
+ ts_current++;
+ CPrep_StringConCat(t == TK_STRING_WIDE);
+ return t;
+ }
+ break;
+ case TK_NEG6:
+ ts_current++;
+ CError_Error(CErrorStr105);
+ ts_current--;
+ break;
+ }
+ }
+
+ ts_current++;
+ return t;
+ }
+
+ if (*pos == 0) {
+ if (tokenstacklevel > 0) {
+ poptokenseq();
+ } else if (tokenstacklevel > 0 || pos >= prep_file_end) {
+ if (filesp > 0)
+ popfile();
+ else
+ return 0;
+ } else {
+ ts_current++;
+ CError_ErrorTerm(CErrorStr105);
+ }
+ }
+ }
}
-short plex() {
- // does not match - global refs in wrong order
+short plex(void) {
short t;
while (1) {
@@ -1916,7 +2465,7 @@ short plex() {
return 0;
}
-short lexidentifier() {
+short lexidentifier(void) {
short t;
char *save_pos;
diff --git a/compiler_and_linker/FrontEnd/C/CScope.c b/compiler_and_linker/FrontEnd/C/CScope.c
index 06cbd6c..f15787c 100644
--- a/compiler_and_linker/FrontEnd/C/CScope.c
+++ b/compiler_and_linker/FrontEnd/C/CScope.c
@@ -93,7 +93,7 @@ void CScope_SetFunctionScope(Object *function, CScopeSave *save) {
}
}
-void CScope_SetMethodScope(Object *function, TypeClass *cls, Boolean unknownFlag, CScopeSave *save) {
+void CScope_SetMethodScope(Object *function, TypeClass *cls, Boolean is_static, CScopeSave *save) {
save->current = cscope_current;
save->currentclass = cscope_currentclass;
save->currentfunc = cscope_currentfunc;
@@ -102,7 +102,7 @@ void CScope_SetMethodScope(Object *function, TypeClass *cls, Boolean unknownFlag
cscope_currentfunc = function;
cscope_currentclass = cls;
cscope_current = cls->nspace;
- cscope_is_member_func = !unknownFlag;
+ cscope_is_member_func = !is_static;
}
void CScope_RestoreScope(CScopeSave *saved) {