X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=rmac;a=blobdiff_plain;f=token.c;h=1722f63ee5bf8c4d8785fb7d551fda4528796f53;hp=27eedc3d849b500d57305740b9d8d910cba6f476;hb=947f081dd25aeed2f6b86ab5d70f4ce159e87fd2;hpb=c9541a9d4f01e190ffefc20ce07896c7f04d9557 diff --git a/token.c b/token.c index 27eedc3..1722f63 100644 --- a/token.c +++ b/token.c @@ -36,6 +36,7 @@ TOKEN * tok; // Ptr to current token TOKEN * etok; // Ptr past last token in tokbuf[] TOKEN tokeol[1] = {EOL}; // Bailout end-of-line token char * string[TOKBUFSIZE*2]; // Token buffer string pointer storage +int optimizeOff; // Optimization override flag // File record, used to maintain a list of every include file ever visited #define FILEREC struct _filerec @@ -48,12 +49,12 @@ FILEREC FILEREC * filerec; FILEREC * last_fr; -INOBJ * cur_inobj; // Ptr current input obj (IFILE/IMACRO) -static INOBJ * f_inobj; // Ptr list of free INOBJs -static IFILE * f_ifile; // Ptr list of free IFILEs -static IMACRO * f_imacro; // Ptr list of free IMACROs +INOBJ * cur_inobj; // Ptr current input obj (IFILE/IMACRO) +static INOBJ * f_inobj; // Ptr list of free INOBJs +static IFILE * f_ifile; // Ptr list of free IFILEs +static IMACRO * f_imacro; // Ptr list of free IMACROs -static TOKEN tokbuf[TOKBUFSIZE]; // Token buffer (stack-like, all files) +static TOKEN tokbuf[TOKBUFSIZE]; // Token buffer (stack-like, all files) uint8_t chrtab[0x100] = { ILLEG, ILLEG, ILLEG, ILLEG, // NUL SOH STX ETX @@ -475,24 +476,18 @@ copy_d: // macro invocation) then it is ignored. i = (int)arg->svalue; arg_num: - DEBUG { printf("~argnumber=%d (argBase=%u)\n", i, imacro->argBase); } + DEBUG { printf("~argnumber=%d\n", i); } tk = NULL; if (i < imacro->im_nargs) { -#if 0 -// tk = argp[i]; -// tk = argPtrs[i]; - tk = argPtrs[imacro->argBase + i]; -#else tk = imacro->argument[i].token; symbolString = imacro->argument[i].string; //DEBUG //{ // printf("ExM: Preparing to parse argument #%u...\n", i); -// dumptok(tk); +// DumpTokens(tk); //} -#endif } // \?arg yields: @@ -830,17 +825,11 @@ DEBUG { printf("[fpop: (post) cfileno=%d ifile->ifno=%d]\n", (int)cfileno, (int) case SRC_IREPT: // Pop and release an IREPT { DEBUG { printf("dealloc IREPT\n"); } -// LONG * p = inobj->inobj.irept->ir_firstln; LLIST * p = inobj->inobj.irept->ir_firstln; // Deallocate repeat lines while (p != NULL) { -// Shamus: ggn confirmed that this will cause a segfault on 64-bit versions of -// RMAC. This is just stupid and wrong anyway, so we need to fix crapola -// like this... -// LONG * p1 = (LONG *)*p; -// p = p1; free(p->line); p = p->next; } @@ -1039,7 +1028,7 @@ DEBUG { printf("TokenizeLine: Calling fpop() from SRC_IFILE...\n"); } case SRC_IREPT: if ((ln = GetNextRepeatLine()) == NULL) { -DEBUG { printf("TokenizeLine: Calling fpop() from SRC_IREPT...\n"); } + DEBUG { printf("TokenizeLine: Calling fpop() from SRC_IREPT...\n"); } fpop(); goto retry; } @@ -1065,6 +1054,16 @@ DEBUG { printf("TokenizeLine: Calling fpop() from SRC_IREPT...\n"); } if (*ln == '*' || *ln == ';' || ((*ln == '/') && (*(ln + 1) == '/'))) goto goteol; + // And here we have a very ugly hack for signalling a single line 'turn off + // optimization'. There's really no nice way to do this, so hack it is! + optimizeOff = 0; // Default is to take optimizations as they come + + if (*ln == '!') + { + optimizeOff = 1; // Signal that we don't want to optimize this line + ln++; // & skip over the darned thing + } + // Main tokenization loop; // o skip whitespace; // o handle end-of-line; @@ -1661,10 +1660,9 @@ int d_goto(WORD unused) void DumpTokenBuffer(void) { - TOKEN * t; printf("Tokens [%X]: ", sloc); - for(t=tokbuf; *t!=EOL; t++) + for(TOKEN * t=tokbuf; *t!=EOL; t++) { if (*t == COLON) printf("[COLON]"); @@ -1674,7 +1672,10 @@ void DumpTokenBuffer(void) printf("[CONST: $%X]", (uint32_t)*t); } else if (*t == ACONST) - printf("[ACONST]"); + { + printf("[ACONST: $%X, $%X]", (uint32_t)t[1], (uint32_t)t[2]); + t += 2; + } else if (*t == STRING) { t++;