added new functag keyword for fast funcenums
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40343
This commit is contained in:
parent
e596003b94
commit
23a2d86140
@ -288,7 +288,7 @@ typedef struct s_stringpair {
|
||||
*/
|
||||
#define tFIRST 256 /* value of first multi-character operator */
|
||||
#define tMIDDLE 280 /* value of last multi-character operator */
|
||||
#define tLAST 332 /* value of last multi-character match-able token */
|
||||
#define tLAST 333 /* value of last multi-character match-able token */
|
||||
/* multi-character operators */
|
||||
#define taMULT 256 /* *= */
|
||||
#define taDIV 257 /* /= */
|
||||
@ -334,41 +334,42 @@ typedef struct s_stringpair {
|
||||
#define tFOR 296
|
||||
#define tFORWARD 297
|
||||
#define tFUNCENUM 298
|
||||
#define tGOTO 299
|
||||
#define tIF 300
|
||||
#define tNATIVE 301
|
||||
#define tNEW 302
|
||||
#define tDECL 303
|
||||
#define tOPERATOR 304
|
||||
#define tPUBLIC 305
|
||||
#define tRETURN 306
|
||||
#define tSIZEOF 307
|
||||
#define tSLEEP 308
|
||||
#define tSTATE 309
|
||||
#define tSTATIC 310
|
||||
#define tSTOCK 311
|
||||
#define tSTRUCT 312
|
||||
#define tSWITCH 313
|
||||
#define tTAGOF 314
|
||||
#define tTHEN 315
|
||||
#define tWHILE 316
|
||||
#define tFUNCTAG 299
|
||||
#define tGOTO 300
|
||||
#define tIF 301
|
||||
#define tNATIVE 302
|
||||
#define tNEW 303
|
||||
#define tDECL 304
|
||||
#define tOPERATOR 305
|
||||
#define tPUBLIC 306
|
||||
#define tRETURN 307
|
||||
#define tSIZEOF 308
|
||||
#define tSLEEP 309
|
||||
#define tSTATE 310
|
||||
#define tSTATIC 311
|
||||
#define tSTOCK 312
|
||||
#define tSTRUCT 313
|
||||
#define tSWITCH 314
|
||||
#define tTAGOF 315
|
||||
#define tTHEN 316
|
||||
#define tWHILE 317
|
||||
/* compiler directives */
|
||||
#define tpASSERT 317 /* #assert */
|
||||
#define tpDEFINE 318
|
||||
#define tpELSE 319 /* #else */
|
||||
#define tpELSEIF 320 /* #elseif */
|
||||
#define tpEMIT 321
|
||||
#define tpENDIF 322
|
||||
#define tpENDINPUT 323
|
||||
#define tpENDSCRPT 324
|
||||
#define tpERROR 325
|
||||
#define tpFILE 326
|
||||
#define tpIF 327 /* #if */
|
||||
#define tINCLUDE 328
|
||||
#define tpLINE 329
|
||||
#define tpPRAGMA 330
|
||||
#define tpTRYINCLUDE 331
|
||||
#define tpUNDEF 332
|
||||
#define tpASSERT 318 /* #assert */
|
||||
#define tpDEFINE 319
|
||||
#define tpELSE 320 /* #else */
|
||||
#define tpELSEIF 321 /* #elseif */
|
||||
#define tpEMIT 322
|
||||
#define tpENDIF 323
|
||||
#define tpENDINPUT 324
|
||||
#define tpENDSCRPT 325
|
||||
#define tpERROR 326
|
||||
#define tpFILE 327
|
||||
#define tpIF 328 /* #if */
|
||||
#define tINCLUDE 329
|
||||
#define tpLINE 330
|
||||
#define tpPRAGMA 331
|
||||
#define tpTRYINCLUDE 332
|
||||
#define tpUNDEF 333
|
||||
/* semicolon is a special case, because it can be optional */
|
||||
#define tTERM 333 /* semicolon or newline */
|
||||
#define tENDEXPR 334 /* forced end of expression */
|
||||
|
@ -133,7 +133,7 @@ static void doswitch(void);
|
||||
static void dogoto(void);
|
||||
static void dolabel(void);
|
||||
static void doreturn(void);
|
||||
static void dofuncenum(void);
|
||||
static void dofuncenum(int listmode);
|
||||
static void dobreak(void);
|
||||
static void docont(void);
|
||||
static void dosleep(void);
|
||||
@ -1418,7 +1418,10 @@ static void parse(void)
|
||||
decl_enum(sGLOBAL);
|
||||
break;
|
||||
case tFUNCENUM:
|
||||
dofuncenum();
|
||||
dofuncenum(TRUE);
|
||||
break;
|
||||
case tFUNCTAG:
|
||||
dofuncenum(FALSE);
|
||||
break;
|
||||
case tSTRUCT:
|
||||
declstruct();
|
||||
@ -2970,7 +2973,7 @@ static void declstruct(void)
|
||||
/**
|
||||
* dofuncenum - declare function enumerations
|
||||
*/
|
||||
static void dofuncenum(void)
|
||||
static void dofuncenum(int listmode)
|
||||
{
|
||||
cell val;
|
||||
char *str,*ptr;
|
||||
@ -3005,11 +3008,14 @@ static void dofuncenum(void)
|
||||
|
||||
fenum = funcenums_add(tagname);
|
||||
|
||||
needtoken('{');
|
||||
if (listmode)
|
||||
{
|
||||
needtoken('{');
|
||||
}
|
||||
do
|
||||
{
|
||||
functag_t func;
|
||||
if (matchtoken('}'))
|
||||
if (listmode && matchtoken('}'))
|
||||
{
|
||||
/* Quick exit */
|
||||
lexpush();
|
||||
@ -3018,13 +3024,13 @@ static void dofuncenum(void)
|
||||
memset(&func, 0, sizeof(func));
|
||||
func.ret_tag = pc_addtag(NULL); /* Get the return tag */
|
||||
l = lex(&val, &str);
|
||||
if (l == tFORWARD)
|
||||
if (l == tSTOCK)
|
||||
{
|
||||
func.type = uFORWARD;
|
||||
func.type = uSTOCK;
|
||||
} else if (l == tPUBLIC) {
|
||||
func.type = uPUBLIC;
|
||||
} else {
|
||||
error(1, "-forward,public-", str);
|
||||
error(1, "-stock,public-", str);
|
||||
}
|
||||
needtoken('(');
|
||||
do
|
||||
@ -3145,8 +3151,15 @@ static void dofuncenum(void)
|
||||
}
|
||||
}
|
||||
functags_add(fenum, &func);
|
||||
if (!listmode)
|
||||
{
|
||||
break;
|
||||
}
|
||||
} while (matchtoken(','));
|
||||
needtoken('}');
|
||||
if (listmode)
|
||||
{
|
||||
needtoken('}');
|
||||
}
|
||||
matchtoken(';'); /* eat an optional semicolon. nom nom nom */
|
||||
errorset(sRESET, 0);
|
||||
}
|
||||
@ -4130,7 +4143,7 @@ static int declargs(symbol *sym,int chkshadow)
|
||||
ident=iVARIABLE;
|
||||
numtags=0;
|
||||
fconst=FALSE;
|
||||
fpublic= (sym->usage & uPUBLIC)!=0;
|
||||
fpublic= (sym->usage & (uPUBLIC|uSTOCK))!=0;
|
||||
/* the '(' parantheses has already been parsed */
|
||||
if (!matchtoken(')')){
|
||||
do { /* there are arguments; process them */
|
||||
@ -4188,7 +4201,8 @@ static int declargs(symbol *sym,int chkshadow)
|
||||
* So the offset of each argument is "(argcnt+3) * sizeof(cell)".
|
||||
*/
|
||||
doarg(name,ident,(argcnt+3)*sizeof(cell),tags,numtags,fpublic,fconst,chkshadow,&arg);
|
||||
if (fpublic && arg.hasdefault)
|
||||
/* :TODO: fix this so stocks that are func pointers can't have default arguments? */
|
||||
if ((sym->usage & uPUBLIC) && arg.hasdefault)
|
||||
error(59,name); /* arguments of a public function may not have a default value */
|
||||
if ((sym->usage & uPROTOTYPED)==0) {
|
||||
/* redimension the argument list, add the entry */
|
||||
|
@ -1878,7 +1878,7 @@ char *sc_tokens[] = {
|
||||
"||", "&&", "==", "!=", "<=", ">=", "<<", ">>>", ">>", "++", "--",
|
||||
"...", "..", "::",
|
||||
"assert", "*begin", "break", "case", "cellsof", "chars", "const", "continue", "default",
|
||||
"defined", "do", "else", "*end", "enum", "exit", "for", "forward", "funcenum", "goto",
|
||||
"defined", "do", "else", "*end", "enum", "exit", "for", "forward", "funcenum", "functag", "goto",
|
||||
"if", "native", "new", "decl", "operator", "public", "return", "sizeof",
|
||||
"sleep", "state", "static", "stock", "struct", "switch", "tagof", "*then", "while",
|
||||
"#assert", "#define", "#else", "#elseif", "#emit", "#endif", "#endinput",
|
||||
|
@ -359,7 +359,7 @@ SC_FUNC int matchtag(int formaltag,int actualtag,int allowcoerce)
|
||||
{
|
||||
usage = uPUBLIC;
|
||||
} else if (v->name[5] = '!') {
|
||||
usage = uFORWARD;
|
||||
usage = uSTOCK;
|
||||
}
|
||||
|
||||
index = atoi(&v->name[6]);
|
||||
@ -379,7 +379,7 @@ SC_FUNC int matchtag(int formaltag,int actualtag,int allowcoerce)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (usage == uFORWARD) {
|
||||
} else if (usage == uSTOCK) {
|
||||
for (sym=glbtab.next; sym!=NULL; sym=sym->next) {
|
||||
if (sym->ident==iFUNCTN && (sym->vclass == sGLOBAL))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user