X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=rmac;a=blobdiff_plain;f=token.c;h=6246a7418f0b98e1e9848c1a2a2289b868926d68;hp=2a8513d899a45f3f3883aaeacf6cd6aafc31afe0;hb=cfd001aea60f54e49d9beae0f941c513f45c202b;hpb=f7f625cf6c2f4b96854ac0e911ca2b1c249f4e05 diff --git a/token.c b/token.c index 2a8513d..6246a74 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 @@ -824,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; } @@ -954,7 +949,7 @@ int TokenizeLine(void) int state = 0; // State for keyword detector int j = 0; // Var for keyword detector uint8_t c; // Random char - VALUE v; // Random value + uint32_t v; // Random value uint8_t * nullspot = NULL; // Spot to clobber for SYMBOL termination int stuffnull; // 1:terminate SYMBOL '\0' at *nullspot uint8_t c1; @@ -1033,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; } @@ -1059,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; @@ -1128,7 +1133,7 @@ DEBUG { printf("TokenizeLine: Calling fpop() from SRC_IREPT...\n"); } if (((chrtab[*ln] & DOT) == 0) || (dotxtab[*ln] == 0)) return error("[bwsl] must follow '.' in symbol"); - v = (VALUE)dotxtab[*ln++]; + v = (uint32_t)dotxtab[*ln++]; if (chrtab[*ln] & CTSYM) return error("misuse of '.'; not allowed in symbols"); @@ -1287,6 +1292,11 @@ dostring: case '\\': c = '\\'; break; + case '!': + // If we're evaluating a macro + // this is valid and expands to + // "dot-size" + break; default: warn("bad backslash code in string"); ln--; @@ -1552,20 +1562,32 @@ dostring: { v &= 0x000000FF; ln += 2; + *tk++ = CONST; + *tk++ = v; + *tk++ = DOTB; } else if ((*(ln + 1) == 'w') || (*(ln + 1) == 'W')) { v &= 0x0000FFFF; ln += 2; + *tk++ = CONST; + *tk++ = v; + *tk++ = DOTW; } else if ((*(ln + 1) == 'l') || (*(ln + 1) == 'L')) { ln += 2; + *tk++ = CONST; + *tk++ = v; + *tk++ = DOTL; } } + else + { + *tk++ = CONST; + *tk++ = v; + } - *tk++ = CONST; - *tk++ = v; //printf("CONST: %i\n", v); continue; }