diff --git a/sourcepawn/compiler/libpawnc.c b/sourcepawn/compiler/libpawnc.c index 32a47c9c..fed7f800 100644 --- a/sourcepawn/compiler/libpawnc.c +++ b/sourcepawn/compiler/libpawnc.c @@ -73,7 +73,7 @@ static char *prefix[3]={ "error", "fatal error", "warning" }; char *pre; int idx; - if (number < 120) + if (number < 160) idx = 0; else if (number < 200) idx = 1; diff --git a/sourcepawn/compiler/sc.h b/sourcepawn/compiler/sc.h index a3ccfc09..48859abc 100644 --- a/sourcepawn/compiler/sc.h +++ b/sourcepawn/compiler/sc.h @@ -256,6 +256,8 @@ typedef struct svalue_s { int lvalue; } svalue; +#define DECLFLAG_ONLY_NEW_TYPES 0x1 + /* For parsing declarations. */ typedef struct { char type[sNAMEMAX + 1]; diff --git a/sourcepawn/compiler/sc1.c b/sourcepawn/compiler/sc1.c index ee9a0c06..9a941739 100644 --- a/sourcepawn/compiler/sc1.c +++ b/sourcepawn/compiler/sc1.c @@ -118,7 +118,7 @@ static int getstates(const char *funcname); static void attachstatelist(symbol *sym, int state_id); static symbol *funcstub(int fnative, const funcstub_setup_t *setup); static int newfunc(char *firstname,int firsttag,int fpublic,int fstatic,int stock); -static int declargs(symbol *sym,int chkshadow); +static int declargs(symbol *sym, int chkshadow, const int *thistag); static void doarg(char *name,int ident,int offset,int tags[],int numtags, int fpublic,int fconst,int chkshadow,arginfo *arg); static void make_report(symbol *root,FILE *log,char *sourcefile); @@ -221,17 +221,17 @@ int pc_compile(int argc, char *argv[]) sp_Globals = NewHashTable(); if (!sp_Globals) - error(123); + error(163); /* allocate memory for fixed tables */ inpfname=(char*)malloc(_MAX_PATH); if (inpfname==NULL) - error(123); /* insufficient memory */ + error(163); /* insufficient memory */ litq=(cell*)malloc(litmax*sizeof(cell)); if (litq==NULL) - error(123); /* insufficient memory */ + error(163); /* insufficient memory */ if (!phopt_init()) - error(123); /* insufficient memory */ + error(163); /* insufficient memory */ setopt(argc,argv,outfname,errfname,incfname,reportname,codepage); strcpy(binfname,outfname); @@ -256,7 +256,7 @@ int pc_compile(int argc, char *argv[]) lcl_tabsize=sc_tabsize; #if !defined NO_CODEPAGE if (!cp_set(codepage)) /* set codepage */ - error(128); /* codepage mapping file not found */ + error(168); /* codepage mapping file not found */ #endif /* optionally create a temporary input file that is a collection of all * input files @@ -273,7 +273,7 @@ int pc_compile(int argc, char *argv[]) tname=tempnam(NULL,"pawn"); #elif defined(MACOS) && !defined(__MACH__) /* tempnam is not supported for the Macintosh CFM build. */ - error(124,get_sourcefile(1)); + error(164,get_sourcefile(1)); tname=NULL; sname=NULL; #else @@ -289,7 +289,7 @@ int pc_compile(int argc, char *argv[]) pc_closesrc(ftmp); remove(tname); strcpy(inpfname,sname); /* avoid invalid filename */ - error(120,sname); + error(160,sname); } /* if */ pc_writesrc(ftmp,(unsigned char*)"#file \""); pc_writesrc(ftmp,(unsigned char*)sname); @@ -308,18 +308,18 @@ int pc_compile(int argc, char *argv[]) } /* if */ inpf_org=(FILE*)pc_opensrc(inpfname); if (inpf_org==NULL) - error(120,inpfname); + error(160,inpfname); freading=TRUE; outf=(FILE*)pc_openasm(outfname); /* first write to assembler file (may be temporary) */ if (outf==NULL) - error(121,outfname); + error(161,outfname); /* immediately open the binary file, for other programs to check */ if (sc_asmfile || sc_listing) { binf=NULL; } else { binf=(FILE*)pc_openbin(binfname); if (binf==NULL) - error(121,binfname); + error(161,binfname); } /* if */ setconstants(); /* set predefined constants and tagnames */ for (i=0; i INT_MAX) - error(125); /* overflow, exceeding capacity */ + error(165); /* overflow, exceeding capacity */ #endif #if 0 /* We don't actually care */ if (ispublic) @@ -2386,7 +2386,7 @@ static int declloc(int fstatic) idxtag[numdim] = dim_sym ? dim_sym->tag : 0; #if INT_MAX < LONG_MAX if (dim[numdim] > INT_MAX) - error(125); /* overflow, exceeding capacity */ + error(165); /* overflow, exceeding capacity */ #endif } else { error(29); /* invalid expression, assumed 0 */ @@ -3277,8 +3277,15 @@ int parse_typeexpr(declinfo_t *decl, const token_t *first, int flags) lextok(&tok); } - if (tok.id == tLABEL || tok.id == '[') + if (tok.id == tLABEL && (flags & DECLFLAG_ONLY_NEW_TYPES)) { + error(120); return FALSE; + } + + if (tok.id == '[') { + error(121); + return FALSE; + } switch (tok.id) { case tINT: @@ -3306,7 +3313,9 @@ int parse_typeexpr(declinfo_t *decl, const token_t *first, int flags) else if (decl->tag == 0) error(98, "_", "int"); } + break; default: + error(122); return FALSE; } @@ -3443,20 +3452,26 @@ methodmap_method_t *parse_method(methodmap_t *map) if (!is_bind) { // All we know at this point is that we do NOT have a method bind. Keep // pattern matching for an inline constructor, destructor, or method. - if (!got_symbol) { - // We never saw an initial symbol, so it should be a destructor. If we - // don't see a '~', the current token (which is not a symbol) will fail - // the needsymbol() check, and we'll bail out. - is_dtor = matchtoken('~'); + if (!got_symbol && matchtoken('~')) { + // ::= '~' ident + is_dtor = TRUE; if (!needsymbol(&ident)) return NULL; - } else if (matchtoken('(')) { - // There's no type expression. this is probably a constructor. + } else if (got_symbol && matchtoken('(')) { + // ::= ident '(' + + // Push the '(' token back for declargs(). is_ctor = TRUE; + lexpush(); } else { + // The first token of the type expression is either the symbol we + // predictively parsed earlier, or it's been pushed back into the + // lex buffer. + const token_t *first = got_symbol ? &ident.tok : NULL; + // Parse for type expression, priming it with the token we predicted // would be an identifier. - if (!parse_decl(&decl, &ident.tok, 0)) + if (!parse_decl(&decl, first, DECLFLAG_ONLY_NEW_TYPES)) return NULL; // Now, we should get an identifier. @@ -3477,6 +3492,10 @@ methodmap_method_t *parse_method(methodmap_t *map) if (is_dtor) { if (strcmp(ident.name, map->name) != 0) error(114, "destructor", spectype, map->name); + + // Make sure the final name has "~" in it. + strcpy(ident.name, "~"); + strcat(ident.name, map->name); } else if (is_ctor) { if (strcmp(ident.name, map->name) != 0) error(114, "constructor", spectype, map->name); @@ -3484,28 +3503,35 @@ methodmap_method_t *parse_method(methodmap_t *map) symbol *target = NULL; if (is_bind) { + // Find an existing symbol. target = findglb(bindsource.name, sGLOBAL); if (!target) error(17, bindsource.name); else if (target->ident != iFUNCTN) error(10); - // if (decl.usage & uCONST) - // error(112, map->name); - - // funcstub_setup_t setup; - // if (is_dtor) - // setup.return_tag = -1; - // else if (is_ctor) - // setup.return_tag = map->tag; - // else - // setup.return_tag = pc_addtag(decl.tag); - - // setup.this_tag = map->tag; - - // if (is_native) - // target = funcstub(TRUE, &setup); } else { - error(10); + funcstub_setup_t setup; + if (is_dtor) + setup.return_tag = -1; + else if (is_ctor) + setup.return_tag = map->tag; + else + setup.return_tag = decl.tag; + + if (is_ctor) + setup.this_tag = 0; + else + setup.this_tag = map->tag; + + // Build a new symbol. Construct a temporary name including the class. + char fullname[METHOD_NAMEMAX + 1]; + strcpy(fullname, map->name); + strcat(fullname, "."); + strcat(fullname, ident.name); + setup.name = fullname; + + if (is_native) + target = funcstub(TRUE, &setup); } if (!target) @@ -3530,10 +3556,6 @@ methodmap_method_t *parse_method(methodmap_t *map) error(119); return NULL; } - - // Make sure the final name has "~" in it. - strcpy(ident.name, "~"); - strcat(ident.name, map->name); } // Verify constructor targets. @@ -3553,8 +3575,6 @@ methodmap_method_t *parse_method(methodmap_t *map) methodmap_method_t *method = (methodmap_method_t *)calloc(1, sizeof(methodmap_method_t)); strcpy(method->name, ident.name); method->target = target; - if (is_dtor) - map->dtor = method; // If the symbol is a constructor, we bypass the initial argument checks. if (is_ctor) { @@ -3587,6 +3607,9 @@ methodmap_method_t *parse_method(methodmap_t *map) if (!ok) error(108, spectype, map->name); + if (is_dtor) + map->dtor = method; + return method; } @@ -3668,7 +3691,7 @@ static void domethodmap(LayoutSpec spec) methods = (methodmap_method_t **)realloc(map->methods, sizeof(methodmap_method_t *) * (map->nummethods + 1)); if (!methods) { - error(123); + error(163); return; } map->methods = methods; @@ -4043,7 +4066,7 @@ static void decl_enum(int vclass) enumsym->usage |= uENUMROOT; /* start a new list for the element names */ if ((enumroot=(constvalue*)malloc(sizeof(constvalue)))==NULL) - error(123); /* insufficient memory (fatal error) */ + error(163); /* insufficient memory (fatal error) */ memset(enumroot,0,sizeof(constvalue)); } else { enumsym=NULL; @@ -4193,7 +4216,7 @@ static void attachstatelist(symbol *sym, int state_id) constvalue *stateptr; if (sym->states==NULL) { if ((sym->states=(constvalue*)malloc(sizeof(constvalue)))==NULL) - error(123); /* insufficient memory (fatal error) */ + error(163); /* insufficient memory (fatal error) */ memset(sym->states,0,sizeof(constvalue)); } /* if */ /* see whether the id already exists (add new state only if it does not @@ -4549,7 +4572,7 @@ static symbol *funcstub(int fnative, const funcstub_setup_t *setup) int tok,tag,fpublic; char *str; cell val,size; - char symbolname[sNAMEMAX+1]; + char symbolname[METHOD_NAMEMAX+1]; int idxtag[sDIMEN_MAX]; int dim[sDIMEN_MAX]; int numdim; @@ -4585,7 +4608,7 @@ static symbol *funcstub(int fnative, const funcstub_setup_t *setup) error(9); /* invalid array size */ #if INT_MAX < LONG_MAX if (size > INT_MAX) - error(125); /* overflow, exceeding capacity */ + error(165); /* overflow, exceeding capacity */ #endif dim[numdim++]=(int)size; } /* while */ @@ -4594,28 +4617,32 @@ static symbol *funcstub(int fnative, const funcstub_setup_t *setup) if (tag == pc_tag_string && numdim && dim[numdim-1]) dim[numdim-1] = (size + sizeof(cell)-1) / sizeof(cell); - tok=lex(&val,&str); - fpublic=(tok==tPUBLIC) || (tok==tSYMBOL && str[0]==PUBLIC_CHAR); - if (fnative) { - if (fpublic || tok==tSTOCK || tok==tSTATIC || (tok==tSYMBOL && *str==PUBLIC_CHAR)) - error(42); /* invalid combination of class specifiers */ - } else { - if (tok==tPUBLIC || tok==tSTOCK || tok==tSTATIC) - tok=lex(&val,&str); - } /* if */ - - if (tok==tOPERATOR) { - opertok=operatorname(symbolname); - if (opertok==0) - return NULL; /* error message already given */ - check_operatortag(opertok,tag,symbolname); - } else { - if (tok!=tSYMBOL && freading) { - error(10); /* illegal function or declaration */ - return NULL; + if (!setup || !setup->name) { + tok=lex(&val,&str); + fpublic=(tok==tPUBLIC) || (tok==tSYMBOL && str[0]==PUBLIC_CHAR); + if (fnative) { + if (fpublic || tok==tSTOCK || tok==tSTATIC || (tok==tSYMBOL && *str==PUBLIC_CHAR)) + error(42); /* invalid combination of class specifiers */ + } else { + if (tok==tPUBLIC || tok==tSTOCK || tok==tSTATIC) + tok=lex(&val,&str); } /* if */ - strcpy(symbolname,str); - } /* if */ + + if (tok==tOPERATOR) { + opertok=operatorname(symbolname); + if (opertok==0) + return NULL; /* error message already given */ + check_operatortag(opertok,tag,symbolname); + } else { + if (tok!=tSYMBOL && freading) { + error(10); /* illegal function or declaration */ + return NULL; + } /* if */ + strcpy(symbolname,str); + } /* if */ + } else { + strcpy(symbolname, setup->name); + } needtoken('('); /* only functions may be native/forward */ sym=fetchfunc(symbolname,tag);/* get a pointer to the function entry */ @@ -4629,7 +4656,11 @@ static symbol *funcstub(int fnative, const funcstub_setup_t *setup) } /* if */ sym->usage|=uFORWARD; - declargs(sym,FALSE); + const int *thistag = NULL; + if (setup && setup->this_tag) + thistag = &setup->this_tag; + + declargs(sym, FALSE, thistag); /* "declargs()" found the ")" */ sc_attachdocumentation(sym); /* attach any documenation to the function */ if (!operatoradjust(opertok,sym,symbolname,tag)) @@ -4782,7 +4813,7 @@ static int newfunc(char *firstname,int firsttag,int fpublic,int fstatic,int stoc error(235,symbolname); #endif /* declare all arguments */ - argcnt=declargs(sym,TRUE); + argcnt=declargs(sym, TRUE, NULL); opererror=!operatoradjust(opertok,sym,symbolname,tag); if (strcmp(symbolname,uMAINFUNC)==0 || strcmp(symbolname,uENTRYFUNC)==0) { if (argcnt>0) @@ -4959,7 +4990,7 @@ static int argcompare(arginfo *a1,arginfo *a2) * This routine adds an entry in the local symbol table for each argument * found in the argument list. It returns the number of arguments. */ -static int declargs(symbol *sym,int chkshadow) +static int declargs(symbol *sym, int chkshadow, const int *thistag) { #define MAXTAGS 16 char *ptr; @@ -4981,7 +5012,23 @@ static int declargs(symbol *sym,int chkshadow) ident=iVARIABLE; numtags=0; fconst=FALSE; - fpublic= (sym->usage & (uPUBLIC|uSTOCK))!=0; + fpublic = (sym->usage & (uPUBLIC|uSTOCK))!=0; + + if (thistag) { + // Allocate space for a new argument, then terminate. + sym->dim.arglist = (arginfo *)realloc(sym->dim.arglist, (argcnt + 2) * sizeof(arginfo)); + memset(&sym->dim.arglist[argcnt + 1], 0, sizeof(arginfo)); + + arginfo *argptr = &sym->dim.arglist[argcnt]; + memset(argptr, 0, sizeof(*argptr)); + strcpy(argptr->name, "this"); + argptr->ident = iVARIABLE; + argptr->tags = malloc(sizeof(int)); + argptr->tags[0] = *thistag; + argptr->numtags = 1; + argcnt++; + } + /* the '(' parantheses has already been parsed */ if (!matchtoken(')')){ do { /* there are arguments; process them */ @@ -5046,7 +5093,7 @@ static int declargs(symbol *sym,int chkshadow) /* redimension the argument list, add the entry */ sym->dim.arglist=(arginfo*)realloc(sym->dim.arglist,(argcnt+2)*sizeof(arginfo)); if (sym->dim.arglist==0) - error(123); /* insufficient memory */ + error(163); /* insufficient memory */ memset(&sym->dim.arglist[argcnt+1],0,sizeof(arginfo)); /* keep the list terminated */ sym->dim.arglist[argcnt]=arg; } else { @@ -5075,7 +5122,7 @@ static int declargs(symbol *sym,int chkshadow) /* redimension the argument list, add the entry iVARARGS */ sym->dim.arglist=(arginfo*)realloc(sym->dim.arglist,(argcnt+2)*sizeof(arginfo)); if (sym->dim.arglist==0) - error(123); /* insufficient memory */ + error(163); /* insufficient memory */ memset(&sym->dim.arglist[argcnt+1],0,sizeof(arginfo)); /* keep the list terminated */ sym->dim.arglist[argcnt].ident=iVARARGS; sym->dim.arglist[argcnt].hasdefault=FALSE; @@ -5084,7 +5131,7 @@ static int declargs(symbol *sym,int chkshadow) sym->dim.arglist[argcnt].numtags=numtags; sym->dim.arglist[argcnt].tags=(int*)malloc(numtags*sizeof tags[0]); if (sym->dim.arglist[argcnt].tags==NULL) - error(123); /* insufficient memory */ + error(163); /* insufficient memory */ memcpy(sym->dim.arglist[argcnt].tags,tags,numtags*sizeof tags[0]); } else { if (argcnt>oldargcnt || sym->dim.arglist[argcnt].ident!=iVARARGS) @@ -5179,7 +5226,7 @@ static void doarg(char *name,int ident,int offset,int tags[],int numtags, size=needsub(&arg->idxtag[arg->numdim],&enumroot);/* may be zero here, it is a pointer anyway */ #if INT_MAX < LONG_MAX if (size > INT_MAX) - error(125); /* overflow, exceeding capacity */ + error(165); /* overflow, exceeding capacity */ #endif arg->dim[arg->numdim]=(int)size; arg->numdim+=1; @@ -5261,7 +5308,7 @@ static void doarg(char *name,int ident,int offset,int tags[],int numtags, cell val; tokeninfo(&val,&name); if ((arg->defvalue.size.symname=duplicatestring(name)) == NULL) - error(123); /* insufficient memory */ + error(163); /* insufficient memory */ arg->defvalue.size.level=0; if (size_tag_token==uSIZEOF || size_tag_token==uCOUNTOF) { while (matchtoken('[')) { @@ -5287,7 +5334,7 @@ static void doarg(char *name,int ident,int offset,int tags[],int numtags, arg->numtags=numtags; arg->tags=(int*)malloc(numtags*sizeof tags[0]); if (arg->tags==NULL) - error(123); /* insufficient memory */ + error(163); /* insufficient memory */ memcpy(arg->tags,tags,numtags*sizeof tags[0]); argsym=findloc(name); if (argsym!=NULL) { @@ -6035,7 +6082,7 @@ static constvalue *insert_constval(constvalue *prev,constvalue *next,const char constvalue *cur; if ((cur=(constvalue*)malloc(sizeof(constvalue)))==NULL) - error(123); /* insufficient memory (fatal error) */ + error(163); /* insufficient memory (fatal error) */ memset(cur,0,sizeof(constvalue)); if (name!=NULL) { assert(strlen(name)<=sNAMEMAX); @@ -7283,7 +7330,7 @@ static void addwhile(int *ptr) ptr[wqLOOP]=getlabel(); ptr[wqEXIT]=getlabel(); if (wqptr>=(wq+wqTABSZ-wqSIZE)) - error(122,"loop table"); /* loop table overflow (too many active loops)*/ + error(162,"loop table"); /* loop table overflow (too many active loops)*/ k=0; while (kstktop); newstack=(stkitem*)malloc(newsize*sizeof(stkitem)); if (newstack==NULL) - error(122,"parser stack"); /* stack overflow (recursive include?) */ + error(162,"parser stack"); /* stack overflow (recursive include?) */ /* swap the stacks */ memcpy(newstack,stack,stkidx*sizeof(stkitem)); if (stack!=NULL) @@ -171,7 +171,7 @@ static char *extensions[] = { ".inc", ".p", ".pawn" }; PUSHSTK_I(fline); inpfname=duplicatestring(name);/* set name of include file */ if (inpfname==NULL) - error(123); /* insufficient memory */ + error(163); /* insufficient memory */ inpf=fp; /* set input file pointer to include file */ fnumber++; fline=0; /* set current line number to 0 */ @@ -275,7 +275,7 @@ static void doinclude(int silent) result=plungefile(name,(c!='>'),TRUE); if (!result && !silent) - error(120,name); /* cannot read from ... (fatal error) */ + error(160,name); /* cannot read from ... (fatal error) */ } /* readline @@ -889,7 +889,7 @@ static int command(void) ret=CMD_IF; assert(iflevel>=0); if (iflevel>=sCOMP_STACK) - error(122,"Conditional compilation stack"); /* table overflow */ + error(162,"Conditional compilation stack"); /* table overflow */ iflevel++; if (SKIPPING) break; /* break out of switch */ @@ -978,7 +978,7 @@ static int command(void) free(inpfname); inpfname=duplicatestring(pathname); if (inpfname==NULL) - error(123); /* insufficient memory */ + error(163); /* insufficient memory */ fline=0; } /* if */ } /* if */ @@ -998,7 +998,7 @@ static int command(void) /* nothing */; /* save start of expression */ preproc_expr(&val,NULL); /* get constant expression (or 0 on error) */ if (!val) - error(130,str); /* assertion failed */ + error(170,str); /* assertion failed */ check_empty(lptr); } /* if */ break; @@ -1022,7 +1022,7 @@ static int command(void) name[i]='\0'; } /* if */ if (!cp_set(name)) - error(128); /* codepage mapping file not found */ + error(168); /* codepage mapping file not found */ } else if (strcmp(str,"compress")==0) { cell val; preproc_expr(&val,NULL); @@ -1288,7 +1288,7 @@ static int command(void) /* store matched pattern */ pattern=(char*)malloc(count+1); if (pattern==NULL) - error(123); /* insufficient memory */ + error(163); /* insufficient memory */ lptr=start; count=0; while (lptr!=end) { @@ -1322,7 +1322,7 @@ static int command(void) /* store matched substitution */ substitution=(char*)malloc(count+1); /* +1 for '\0' */ if (substitution==NULL) - error(123); /* insufficient memory */ + error(163); /* insufficient memory */ lptr=start; count=0; while (lptr!=end) { @@ -1373,7 +1373,7 @@ static int command(void) while (*lptr<=' ' && *lptr!='\0') lptr++; if (!SKIPPING) - error(131,lptr); /* user error */ + error(171,lptr); /* user error */ break; default: error(31); /* unknown compiler directive */ @@ -1538,7 +1538,7 @@ static int substpattern(unsigned char *line,size_t buffersize,char *pattern,char len=(int)(e-s); args[arg]=(unsigned char*)malloc(len+1); if (args[arg]==NULL) - error(123); /* insufficient memory */ + error(163); /* insufficient memory */ strlcpy((char*)args[arg],(char*)s,len+1); /* character behind the pattern was matched too */ if (*e==*p) { @@ -2326,10 +2326,10 @@ SC_FUNC int needtoken(int token) strcpy(s1,sc_tokens[token-tFIRST]); /* multi-character symbol */ if (!freading) strcpy(s2,"-end of file-"); - else if (current_token()->id < 256) - sprintf(s2,"%c",(char)current_token()->id); + else if (last_token()->id < 256) + sprintf(s2,"%c",(char)last_token()->id); else - strcpy(s2, sc_tokens[current_token()->id - tFIRST]); + strcpy(s2, sc_tokens[last_token()->id - tFIRST]); error(1,s1,s2); /* expected ..., but found ... */ return FALSE; } /* if */ @@ -2376,7 +2376,7 @@ static void chk_grow_litq(void) litmax+=sDEF_LITMAX; p=(cell *)realloc(litq,litmax*sizeof(cell)); if (p==NULL) - error(122,"literal table"); /* literal table overflow (fatal error) */ + error(162,"literal table"); /* literal table overflow (fatal error) */ litq=p; } /* if */ } @@ -2569,7 +2569,7 @@ static symbol *add_symbol(symbol *root,symbol *entry,int sort) root=root->next; if ((newsym=(symbol *)malloc(sizeof(symbol)))==NULL) { - error(123); + error(163); return NULL; } /* if */ memcpy(newsym,entry,sizeof(symbol)); @@ -2968,7 +2968,7 @@ SC_FUNC symbol *addsym(const char *name,cell addr,int ident,int vclass,int tag,i /* create an empty referrer list */ if ((refer=(symbol**)malloc(sizeof(symbol*)))==NULL) { - error(123); /* insufficient memory */ + error(163); /* insufficient memory */ return NULL; } /* if */ *refer=NULL; diff --git a/sourcepawn/compiler/sc3.c b/sourcepawn/compiler/sc3.c index e2236b1a..8f54d5a1 100644 --- a/sourcepawn/compiler/sc3.c +++ b/sourcepawn/compiler/sc3.c @@ -2040,7 +2040,7 @@ restart: */ sym=fetchfunc(lastsymbol,0); if (sym==NULL) - error(123); /* insufficient memory */ + error(163); /* insufficient memory */ markusage(sym,uREAD); } else { return error(12); /* invalid function call */ @@ -2192,7 +2192,7 @@ static int primary(value *lval) assert(sc_status==statFIRST); sym=fetchfunc(st,0); if (sym==NULL) - error(123); /* insufficient memory */ + error(163); /* insufficient memory */ } /* if */ assert(sym!=NULL); assert(sym->ident==iFUNCTN || sym->ident==iREFFUNC); diff --git a/sourcepawn/compiler/sc5.c b/sourcepawn/compiler/sc5.c index 1b7dd665..e5db4db0 100644 --- a/sourcepawn/compiler/sc5.c +++ b/sourcepawn/compiler/sc5.c @@ -86,7 +86,7 @@ static short lastfile; * the error reporting is enabled only in the second pass (and only when * actually producing output). Fatal errors may never be ignored. */ - if ((errflag || sc_status!=statWRITE) && (number<120 || number>=200)) + if ((errflag || sc_status!=statWRITE) && (number<160 || number>=200)) return 0; /* also check for disabled warnings */ @@ -97,13 +97,13 @@ static short lastfile; return 0; } /* if */ - if (number<120){ + if (number<160){ msg=errmsg[number-1]; pre=prefix[0]; errflag=TRUE; /* set errflag (skip rest of erroneous expression) */ errnum++; } else if (number<200){ - msg=fatalmsg[number-120]; + msg=fatalmsg[number-160]; pre=prefix[1]; errnum++; /* a fatal error also counts as an error */ } else { @@ -141,7 +141,7 @@ static short lastfile; } /* if */ va_end(argptr); - if ((number>=120 && number<200) || errnum>25){ + if ((number>=160 && number<200) || errnum>25){ if (strlen(errfname)==0) { va_start(argptr,number); pc_error(0,"\nCompilation aborted.",NULL,0,0,argptr); @@ -162,7 +162,7 @@ static short lastfile; if (number<200) errorcount++; if (errorcount>=3) - error(127); /* too many error/warning messages on one line */ + error(167); /* too many error/warning messages on one line */ return 0; } diff --git a/sourcepawn/compiler/sc5.scp b/sourcepawn/compiler/sc5.scp index 07a266fd..9a6de437 100644 --- a/sourcepawn/compiler/sc5.scp +++ b/sourcepawn/compiler/sc5.scp @@ -32,13 +32,13 @@ SC_FUNC int strexpand(char *dest, unsigned char *source, int maxlen, unsigned ch /*-*SCPACK start of pair table, do not change or remove this line */ unsigned char errstr_table [][2] = { {101,32}, {116,32}, {111,110}, {115,32}, {105,110}, {97,114}, {100,32}, {116,105}, {37,115}, {101,114}, {101,110}, {97,108}, {110,111}, {135,130}, {34,136}, {142,34}, - {117,110}, {111,114}, {114,101}, {97,110}, {121,32}, {115,116}, {100,101}, {115,105}, {97,116}, {140,129}, {32,143}, {109,98}, {109,138}, {41,10}, {101,134}, {141,32}, - {98,108}, {144,99}, {116,104}, {102,161}, {114,97}, {111,108}, {117,115}, {145,32}, {118,139}, {97,32}, {115,121}, {170,155}, {171,165}, {103,32}, {137,32}, {103,117}, - {101,120}, {175,156}, {133,164}, {133,177}, {102,132}, {105,134}, {115,151}, {97,160}, {99,104}, {163,159}, {168,181}, {111,102}, {105,131}, {115,10}, {132,186}, {101,100}, - {101,131}, {166,129}, {172,154}, {109,193}, {104,97}, {99,130}, {118,133}, {99,147}, {187,32}, {105,183}, {198,201}, {109,97}, {116,111}, {99,116}, {98,128}, {112,146}, - {178,148}, {199,153}, {150,180}, {116,97}, {109,101}, {179,129}, {44,32}, {130,32}, {133,97}, {149,152}, {102,105}, {118,128}, {154,10}, {101,10}, {109,152}, {194,157}, - {110,32}, {40,223}, {100,105}, {117,108}, {99,111}, {97,115}, {202,128}, {197,149}, {34,32}, {139,32}, {119,105}, {151,122}, {136,10}, {98,101}, {108,111}, {111,112}, - {108,128}, {163,141}, {102,145}, {132,32}, {140,32}, {147,32}, {211,173}, {132,173}, {222,184}, {195,206}, {196,219}, {58,220}, {100,111}, {149,114}, {109,112} + {114,101}, {117,110}, {111,114}, {97,110}, {121,32}, {115,116}, {100,101}, {115,105}, {97,116}, {140,129}, {32,143}, {109,98}, {109,138}, {41,10}, {101,134}, {116,104}, + {141,32}, {98,108}, {117,115}, {145,99}, {102,163}, {114,97}, {111,108}, {146,32}, {115,121}, {118,139}, {97,32}, {168,155}, {171,166}, {103,32}, {101,120}, {137,32}, + {103,117}, {176,156}, {133,165}, {133,177}, {105,131}, {102,132}, {105,134}, {115,151}, {97,161}, {99,104}, {164,160}, {169,182}, {101,100}, {111,102}, {162,129}, {115,10}, + {132,187}, {109,190}, {104,97}, {101,131}, {172,154}, {109,97}, {99,130}, {118,133}, {189,32}, {105,184}, {199,201}, {116,97}, {109,101}, {116,111}, {98,128}, {112,144}, + {99,147}, {178,148}, {44,32}, {150,181}, {133,97}, {179,129}, {208,153}, {130,32}, {99,116}, {118,128}, {101,10}, {149,152}, {102,105}, {117,108}, {97,115}, {154,10}, + {109,152}, {196,157}, {110,32}, {40,225}, {100,105}, {99,111}, {202,128}, {198,149}, {34,32}, {139,32}, {119,105}, {99,108}, {151,122}, {108,128}, {136,10}, {147,32}, + {132,173}, {194,217}, {98,101}, {111,112}, {116,121}, {37,131}, {164,141}, {102,146}, {132,32}, {140,32}, {203,173}, {224,185}, {193,206}, {58,223}, {100,111} }; /*-*SCPACK end of pair table, do not change or remove this line */ @@ -157,168 +157,173 @@ static char *errmsg[] = { /*111*/ "expected identifier - did you forget a type?\n", /*112*/ "constructor function must return tag %s\n", /*113*/ "cannot define constructor for \"%s\"; already exists as a %s\n", -/*114*/ "%s must have the same name as %s \"%s\"\n", +/*114*/ "missing type, or %s must have the same name as %s \"%s\"\n", /*115*/ "cannot use delete, %s %s has no destructor\n", /*116*/ "no methodmap or class was found for %s\n", /*117*/ "no destructor was found for %s %s\n", /*118*/ "destructors must be native functions\n", /*119*/ "destructors cannot have extra arguments\n", +/*120*/ "methodmap and class signatures must use new-style declarations\n", +/*121*/ "this syntax is not yet supported\n", +/*122*/ "expected type expression\n", #else - "\260pe\315\236\314k\212:\232\326bu\201fo\220\206\217\012", - "\202l\224\251s\204g\360\331e\234\201(\247\260\317\266\202) \307 f\245\356w ea\270 \042c\345e\042\012", - "\226cl\330\237\310\251\356c\351\346\303appe\205 \363\251\344\376o\220\206\240ock\012", - "\361\232 \274\231i\376le\234t\277\012", - "\271\313\224\231\372\263t\275", - "\371a\266gn\236\314 \365\262y\012", - "\357\211\230\247\321\316\222\322\277\012", - "\371\251\347\223\201\260\317\266\202; \345sum\236z\211o\012", - "\276\320\353\200(nega\207ve\326z\211o \247ou\201\310bo\220ds\235", - "\276\271\247\226cl\330\215\012", - "\276out\227d\200\361\275", - "\276\271c\213l\326\231\251\272add\222s\275", - "\364\212tr\224po\204\201(\364pu\240ic \361s\235", - "\276\331e\234t; \231\363s\352t\270\012", - "\042\226fa\343t\350c\345\200\371\242\200l\345\201c\345\200\363s\352t\270 \331e\234t\012", - "m\343\207p\360\226fa\343t\203\363\042s\352t\270\042\012", - "\220\322\236\302\012", - "\204i\207\213iza\237d\230\251\260ce\277\203\226cl\205\236\353\335", - "\231\251la\355l\373", - "\276\254 nam\200\217\012", - "\254 \213\222ad\224\322\277\373", - "\371l\250u\200(n\202-\347\223t\235", - "\320a\266gn\234\201\371\227\376\360a\266gn\234t\012", - "\042b\222ak\350\247\042\305t\204ue\350\274ou\201\310\305t\260t\012", - "\271head\367\342ff\211\203from pro\314typ\335", - "\364\370\367\042#if...\042\012", - "\276\270\330\315\256\347\223t\012", - "\276subscrip\201(\231\365\320\247\314o m\223\224subscripts)\373", - "\276\260\317\266\202\326\345sum\236z\211o\012", - "\344\376o\220\206\331e\234\201\231c\356s\236a\201\242\200\212\206\310\332\360(\225\205t\236a\201l\204\200%d\235", - "\220k\214w\340\342\222c\207v\335", - "\320\204\226x ou\201\310bo\220d\203(\346\217\235", - "\320\371\204\226x\236(\346\217\235", - "\325\374\300\231\372\251\226fa\343\201\250u\200(\325%d\235", - "\325typ\200mis\370 (\325%d\235", - "e\376t\224\331e\234t\012", - "\276\375\367(po\266\240\224n\202-t\211m\204\230\236\375\204g\235", - "\260t\244 \270\330\315\211\203\327l\204\335", - "\347\223\201\254 \304\203\364\353\335", - "duplic\230\200\042c\345e\350la\355l (\250u\200%d\235", - "\276ellip\227s\326\320\353\200\274\231k\214wn\012", - "\276\344\233\204a\237\310cl\345\203speci\332\211\275", - "\270\330\315\256\347\223\201\260ce\277\203r\223g\200f\247pack\236\375\204g\012", - "po\227\215\351p\330\324t\211\203\303\317c\277\200\213l nam\236p\330\324t\211\275", - "\314o m\223\224\271\263t\275", - "\220k\214w\340\320\353\200(\346\217\235", - "\320\353\300\374 \231\370\326\247\226\225\204a\237\320\274\314o sm\213l\012", - "\320(\203\374 \231\370\012", - "\276l\204\200\305t\204ua\215\012", - "\276r\223g\335", - "\276subscript\326\246\200\042[ ]\350\357\211\230\221\203\327\313j\247\342\234\227\202\275", - "m\343\207-\342\234\227\202\351\262y\203\371f\343l\224\204i\207\213iz\277\012", - "\260ce\277\367\313ximum nu\233\256\310\342\234\227\202\275", - "\220\370\236c\356s\367b\244c\200(\042}\042\235", - "\225\205\201\310\271bod\224\352\242ou\201\271head\211\012", - "\262ys\326\356c\351\312\300\223\206\271\263t\203\321\316pu\240ic (\346\217\235", - "\220\264ish\236\260\317\266\327\355\362\200\344\376il\256\342\222c\207v\335", - "duplic\230\200\263t; sam\200\325\274p\345s\236t\352c\335", - "\271\325\313\224\231\372\251\226fa\343\201\250u\200(\346\217\235", - "m\343\207p\360\042#else\350\342\222c\207v\300\355twe\212 \042#if ... #\212\342f\042\012", - "\042#elseif\350\342\222c\207\333f\245\356w\203\365\042#else\350\342\222c\207v\335", - "nu\233\256\310\357\211\223d\203\374\300\231\332\201\242\200\357\211\230\221\012", - "\271\222s\343\201\366\310\357\211\230\221\232 \371\217\012", - "\321\270\223g\200\317\322\236\357\211\230\221\275", - "\271\325\313\224\202l\224\372\251s\204g\360\366(\325%d\235", - "\271\325\313\224\231\316\251\222f\211\212c\200\325\247\365\320(\325\217\235", - "\346\321\316bo\242 \251\222f\211\212c\200\223\206\365\320(\346\217\235", - "\276\244\215\351nu\233\256\317ci\227\327\363#p\244g\313\012", - "\244\215\351nu\233\256\362\313\201\213\222ad\224\322\277\012", - "\244\215\351nu\233\256supp\221\201wa\203\231\212\267\277\012", - "\246\211-\322\236\357\211\230\247\371\226cl\205\236\355\362\200\246\200(\361\232\235", - "\042\353e\273\350\357\211\230\247\274\276\327\042\361\350\254\275", - "\271\325\371\365\320(\325\217\235", - "#\322\200p\230t\211\340\303\225\205\201\352\242 \365\213p\304\355\207c \270\330\315\211\012", - "\204pu\201l\204\200\314o l\202\255(aft\256subs\207tu\215s\235", - "\252n\323x \211r\247\363\242\200\260\317\266\202\326\247\276\271c\213l\012", - "m\213\362m\236UTF-8 \212\344d\204g\326\247c\221rupt\236\332le: \354", - "\271\246\300bo\242 \042\222turn\350\223\206\042\222tur\340<\250ue>\042\012", - "\204\305\227\225\212\201\222tur\340typ\300(\320& n\202-\262y\235", - "\220k\214w\340\254\326\247\231\251\347\223\201\254 \341", - "\321\323k\200\251\366a\203\251\226fa\343\201\250u\200f\247\365\204\226x\236\320p\330\324t\256\341", - "\246\211-\322\236\357\211\230\221\203\223\206na\207\333\361\203\313\224\231\372\331e\275", - "\251\271\247\346\313\224\202l\224\355l\202\255\314 \251s\204g\360au\314\336\327\341", - "\331\200\305fli\315: \202\200\310\242\200\331\300\274\213\222ad\224a\266gn\236\314 a\214\242\256i\376le\234\323\237\341", - "\364\331\300\205\200\322\236f\247\302\012", - "\220k\214w\340au\314\336\202\334", - "\220k\214w\340\331\200\217 f\247au\314\336\202\334", - "pu\240ic \312\300\223\206\356c\351\312\300\313\224\231\372\331\300\341", - "\331\200\312\300\313\224\231\316\204i\207\213iz\236\341", - "pu\240ic \361\203\313\224\231\222tur\340\262y\203\341", - "a\233i\257ou\203\347\223t; \366ov\211rid\200\274\222qui\222\206\341", - "nu\233\256\310\263t\203\374\300\231\370 \322i\215\012", - "\260pe\315\236\366nam\200id\212\207\332\211\012", - "\271\212um\211a\237\222qui\222\203\220iqu\200\323g\012", - "\321\372\222qui\222\206p\330\324t\211\203aft\256\357\215\351p\330\324t\211\275", - "\344\343\206\231\264\206\324\233\211\232 \363\375uc\201\217\012", - "\302 \374\300\231\372\251\370\367typ\335", - "typ\200\217 sho\343\206\316\217 \363new-\225y\360\226cl\330\215\275", - "\226\375u\315\221\203\321\222tur\340\250ue\275", - "\271pro\314typ\300\374 \231\370\012", - "specif\224ei\242\256\213l \342\234\227\202\203\247\202l\224\242\200l\345\201\342\234\227\202\012", - "\321\264\206%\203\354", - "%\203wa\203\213\222ad\224\322\236\327\242\274\354", - "\321\264\206\223\224\324\242od\203f\247\354", - "\321\264\206\324\242o\206\210.\354", - "\321c\213l \324\242od\203\327\365\262y\012", - "\321c\213l \324\242od\203\327\251\361\012", - "\324\242o\206\303\372\251\332rs\201\325\344\376a\207\240\200\352\242 \242\200%\203typ\200(\210\235", - "%\203nam\200\303\225\205\201\352\242 \365upp\211c\345\200lett\211\012", - "%\203\304\203\213\222ad\224\355\212 \322\236(\317vio\246l\224se\212 a\203\210\235", - "\260pe\315\236id\212\207\332\256- d\265you \362ge\201\251type?\012", - "\347ru\315\247\271\303\222tur\340\366\354", - "\321\322\200\347ru\315\247\362\232; \213\222ad\224\260i\225\203a\203\251\354", - "\226\375u\315\247\303\372\242\200sam\200nam\200a\203%\203\217\012", - "\321\246\200\226lete\326%\203%\203\304\203\364\226\375u\315\221\012", - "\364\324\242od\313p \247cl\345\203wa\203fo\220\206f\247\354", - "\364\226\375u\315\247wa\203fo\220\206f\247%\203\354", - "\226\375u\315\221\203\371na\207\333\361\275", - "\226\375u\315\221\203\321\372\260t\244 \263t\275" + "\256pe\330\236\315k\212:\232\322bu\201fo\221\206\217\012", + "\202l\224\252s\204g\355\333e\234\201(\247\256\317\267\202) \320 f\246low ea\271 \042c\336e\042\012", + "\226\353\324\240\310\252loc\351\346\301appe\205 \370\252\345mpo\221\206\241ock\012", + "\366\232 \264\231imple\234t\274\012", + "\272\305\224\231\361\263t\277", + "\374a\267gn\236\315 \357\262y\012", + "\363\211\230\247\326\316\220\323\274\012", + "\374\252\347\223\201\256\317\267\202; \336sum\236z\211o\012", + "\300\321\354\200(nega\207ve\322z\211o \247ou\201\310bo\221ds\235", + "\300\272\247\226\353\324\215\012", + "\300out\227d\200\366\277", + "\300\272c\213l\322\231\252\273add\220s\277", + "\371\212tr\224po\204\201(\371pu\241ic \366s\235", + "\300\333e\234t; \231\370s\352t\271\012", + "\042\226fa\335t\350c\336\200\374\237\200l\336\201c\336\200\370s\352t\271 \333e\234t\012", + "m\335\207p\355\226fa\335t\203\370\042s\352t\271\042\012", + "\221\323\236\304\012", + "\204i\207\213iza\240d\230\252\256ce\274\203\226\353\205\236\354\332", + "\231\252la\362l\375", + "\300\254 nam\200\217\012", + "\254 \213\220ad\224\323\274\375", + "\374l\251u\200(n\202-\347\223t\235", + "\321a\267gn\234\201\374\227mp\355a\267gn\234t\012", + "\042b\220ak\350\247\042\306t\204ue\350\264ou\201\310\306t\256t\012", + "\272head\360\344ff\211\203from pro\315\364p\332", + "\371\373\360\042#if...\042\012", + "\300\271\324\330\257\347\223t\012", + "\300subscrip\201(\231\357\321\247\315o m\223\224subscripts)\375", + "\300\256\317\267\202\322\336sum\236z\211o\012", + "\345mpo\221\206\333e\234\201\231\353os\236a\201\237\200\212\206\310\334\355(\225\205t\236a\201l\204\200%d\235", + "\221k\214w\342\344\220c\207v\332", + "\321\204\226x ou\201\310bo\221d\203(\346\217\235", + "\321\374\204\226x\236(\346\217\235", + "\325\376\303\231\361\252\226fa\335\201\251u\200(\325%d\235", + "\325\364p\200mis\373 (\325%d\235", + "empt\224\333e\234t\012", + "\300\225r\360(po\267\241\224n\202-t\211m\204\230\236\225r\204g\235", + "\256t\245 \271\324\330\211\203\327l\204\332", + "\347\223\201\254 \302\203\371\354\332", + "duplic\230\200\042c\336e\350la\362l (\251u\200%d\235", + "\300ellip\227s\322\321\354\200\264\231k\214wn\012", + "\300\345\233\204a\240\310\353\336\203speci\334\211\277", + "\271\324\330\257\347\223\201\256ce\274\203r\223g\200f\247pack\236\225r\204g\012", + "po\227\215\351p\324\314t\211\203\301\317c\274\200\213l nam\236p\324\314t\211\277", + "\315o m\223\224\272\263t\277", + "\221k\214w\342\321\354\200(\346\217\235", + "\321\354\303\376 \231\373\322\247\226\225\204a\240\321\264\315o sm\213l\012", + "\321(\203\376 \231\373\012", + "\300l\204\200\306t\204ua\215\012", + "\300r\223g\332", + "\300subscript\322\242\200\042[ ]\350\363\211\230\222\203\327\305j\247\344\234\227\202\277", + "m\335\207-\344\234\227\202\351\262y\203\374f\335l\224\204i\207\213iz\274\012", + "\256ce\274\360\305ximum nu\233\257\310\344\234\227\202\277", + "\221\373\236\353os\360b\245c\200(\042}\042\235", + "\225\205\201\310\272bod\224\352\237ou\201\272head\211\012", + "\262ys\322loc\351\312\303\223\206\272\263t\203\326\316pu\241ic (\346\217\235", + "\221\265ish\236\256\317\267\327\362\367\200\345mpil\257\344\220c\207v\332", + "duplic\230\200\263t; sam\200\325\264p\336s\236t\352c\332", + "\272\325\305\224\231\361\252\226fa\335\201\251u\200(\346\217\235", + "m\335\207p\355\042#else\350\344\220c\207v\303\362twe\212 \042#if ... #\212\344f\042\012", + "\042#elseif\350\344\220c\207\331f\246low\203\357\042#else\350\344\220c\207v\332", + "nu\233\257\310\363\211\223d\203\376\303\231\334\201\237\200\363\211\230\222\012", + "\272\220s\335\201\372\310\363\211\230\222\232 \374\217\012", + "\326\271\223g\200\317\323\236\363\211\230\222\277", + "\272\325\305\224\202l\224\361\252s\204g\355\372(\325%d\235", + "\272\325\305\224\231\316\252\220f\211\212c\200\325\247\357\321(\325\217\235", + "\346\326\316bo\237 \252\220f\211\212c\200\223\206\357\321(\346\217\235", + "\300\245\215\351nu\233\257\317ci\227\327\370#p\245g\305\012", + "\245\215\351nu\233\257\367\305\201\213\220ad\224\323\274\012", + "\245\215\351nu\233\257supp\222\201wa\203\231\212\270\274\012", + "\242\211-\323\236\363\211\230\247\374\226\353\205\236\362\367\200\242\200(\366\232\235", + "\042\354e\275\350\363\211\230\247\264\300\327\042\366\350\254\277", + "\272\325\374\357\321(\325\217\235", + "#\323\200p\230t\211\342\301\225\205\201\352\237 \357\213p\302\362\207c \271\324\330\211\012", + "\204pu\201l\204\200\315o l\202\255(aft\257subs\207tu\215s\235", + "\250n\313x \211r\247\370\237\200\256\317\267\202\322\247\300\272c\213l\012", + "m\213\367m\236UTF-8 \212\345d\204g\322\247c\222rupt\236\334le: \356", + "\272\242\303bo\237 \042\220turn\350\223\206\042\220tur\342<\251ue>\042\012", + "\204\306\227\225\212\201\220tur\342\364p\303(\321& n\202-\262y\235", + "\221k\214w\342\254\322\247\231\252\347\223\201\254 \343", + "\326\313k\200\252\372a\203\252\226fa\335\201\251u\200f\247\357\204\226x\236\321p\324\314t\257\343", + "\242\211-\323\236\363\211\230\222\203\223\206na\207\331\366\203\305\224\231\361\333e\277", + "\252\272\247\346\305\224\202l\224\362l\202\255\315 \252s\204g\355au\315\340\327\343", + "\333\200\306fli\330: \202\200\310\237\200\333\303\264\213\220ad\224a\267gn\236\315 a\214\237\257imple\234\313\240\343", + "\371\333\303\205\200\323\236f\247\304\012", + "\221k\214w\342au\315\340\202\337", + "\221k\214w\342\333\200\217 f\247au\315\340\202\337", + "pu\241ic \312\303\223\206loc\351\312\303\305\224\231\361\333\303\343", + "\333\200\312\303\305\224\231\316\204i\207\213iz\236\343", + "pu\241ic \366\203\305\224\231\220tur\342\262y\203\343", + "a\233i\260ou\203\347\223t; \372ov\211rid\200\264\220qui\220\206\343", + "nu\233\257\310\263t\203\376\303\231\373 \323i\215\012", + "\256pe\330\236\372nam\200id\212\207\334\211\012", + "\272\212um\211a\240\220qui\220\203\221iqu\200\313g\012", + "\326\361\220qui\220\206p\324\314t\211\203aft\257\363\215\351p\324\314t\211\277", + "\345\335\206\231\265\206\314\233\211\232 \370\225ruc\201\217\012", + "\304 \376\303\231\361\252\373\360\364p\332", + "\364p\200\217 sho\335\206\316\217 \370new-\225y\355\226\353\324\215\277", + "\365sho\335\206\231\361\357\256plici\201\220tur\342\364p\332", + "\272pro\315\364p\303\376 \231\373\012", + "specif\224ei\237\257\213l \344\234\227\202\203\247\202l\224\237\200l\336\201\344\234\227\202\012", + "\326\265\206\365\356", + "\365wa\203\213\220ad\224\323\236\327\237\264\356", + "\326\265\206\223\224\314\237od\203f\247\356", + "\326\265\206\314\237o\206\210.\356", + "\326c\213l \314\237od\203\327\357\262y\012", + "\326c\213l \314\237od\203\327\252\366\012", + "\314\237o\206\301\361\252\334rs\201\325\345mpa\207\241\200\352\237 \237\200\365\364p\200(\210\235", + "\365nam\200\301\225\205\201\352\237 \357upp\211c\336\200lett\211\012", + "\365\302\203\213\220ad\224\362\212 \323\236(\317vio\242l\224se\212 a\203\210\235", + "\256pe\330\236id\212\207\334\257- d\266you \367ge\201\252\364pe?\012", + "\347ru\330\247\272\301\220tur\342\372\356", + "\326\323\200\347ru\330\247\367\232; \213\220ad\224\256i\225\203a\203\252\356", + "miss\360\364pe\322\247\365\301\361\237\200sam\200nam\200a\203\365\217\012", + "\326\242\200\226lete\322\365\365\302\203\371\226\225ru\330\222\012", + "\371\314\237od\305p \247\353\336\203wa\203fo\221\206f\247\356", + "\371\226\225ru\330\247wa\203fo\221\206f\247\365\356", + "\226\225ru\330\222\203\374na\207\331\366\277", + "\226\225ru\330\222\203\326\361\256t\245 \263t\277", + "\314\237od\305p \223\206\353\336\203\227gn\230u\220\203\301\242\200new-\225y\355\226\353\324\215\277", + "\237\264\250n\313x \264\231ye\201supp\222t\274\012" #endif }; static char *fatalmsg[] = { #ifdef SCPACK -/*120*/ "cannot read from file: \"%s\"\n", -/*121*/ "cannot write to file: \"%s\"\n", -/*122*/ "table overflow: \"%s\"\n", +/*160*/ "cannot read from file: \"%s\"\n", +/*161*/ "cannot write to file: \"%s\"\n", +/*162*/ "table overflow: \"%s\"\n", /* table can be: loop table * literal table * staging buffer * option table (response file) * peephole optimizer table */ -/*123*/ "insufficient memory\n", -/*124*/ "invalid assembler instruction \"%s\"\n", -/*125*/ "numeric overflow, exceeding capacity\n", -/*126*/ "compiled script exceeds the maximum memory size (%ld bytes)\n", -/*127*/ "too many error messages on one line\n", -/*128*/ "codepage mapping file not found\n", -/*129*/ "invalid path: \"%s\"\n", -/*130*/ "assertion failed: %s\n", -/*131*/ "user error: %s\n", +/*163*/ "insufficient memory\n", +/*164*/ "invalid assembler instruction \"%s\"\n", +/*165*/ "numeric overflow, exceeding capacity\n", +/*166*/ "compiled script exceeds the maximum memory size (%ld bytes)\n", +/*167*/ "too many error messages on one line\n", +/*168*/ "codepage mapping file not found\n", +/*169*/ "invalid path: \"%s\"\n", +/*170*/ "assertion failed: %s\n", +/*171*/ "user error: %s\n", #else - "\321\222a\206from \332le\373", - "\321writ\200\314 \332le\373", - "t\267\200ov\211f\356w\373", - "\204suf\332ci\212\201\324m\221y\012", - "\276\345se\233l\256\204\375uc\215\334", - "num\211ic ov\211f\356w\326\260ce\277\367capacity\012", - "\344\376il\236scrip\201\260ce\277\203\242\200\313ximum \324m\221\224\353\200(%l\206bytes\235", - "\314o m\223\224\211r\247\324ssag\300\327\202\200l\204\335", - "\344\226pag\200\313pp\367\332\360\231fo\220d\012", - "\276p\230h\373", - "\345s\211\237fail\277: \354", - "\246\256\211r\221: \354" + "\326\220a\206from \334le\375", + "\326writ\200\315 \334le\375", + "t\270\200ov\211flow\375", + "\204suf\334ci\212\201\314m\222y\012", + "\300\336se\233l\257\204\225ruc\215\337", + "num\211ic ov\211flow\322\256ce\274\360capaci\364\012", + "\345mpil\236scrip\201\256ce\274\203\237\200\305ximum \314m\222\224\354\200(%l\206bytes\235", + "\315o m\223\224\211r\247\314ssag\303\327\202\200l\204\332", + "\345\226pag\200\305pp\360\334\355\231fo\221d\012", + "\300p\230h\375", + "\336s\211\240fail\274: \356", + "\242\257\211r\222: \356" #endif }; @@ -362,43 +367,43 @@ static char *warnmsg[] = { /*235*/ "public function lacks forward declaration (symbol \"%s\")\n", /*236*/ "unknown parameter in substitution (incorrect #define pattern)\n" #else - "\302 \274tr\241\230\236\314 %\206\270\330\315\211\275", - "\222\322i\237\310\347\223t/\313cro \341", - "nu\233\256\310\263t\203\374\300\231\370 \322i\215\012", - "\254 \274nev\256\246\277\373", - "\254 \274a\266gn\236\251\250u\200\242a\201\274nev\256\246\277\373", - "\222d\220d\223\201\344\226: \347\223\201\260\317\266\327\274z\211o\012", - "\222d\220d\223\201te\225: \347\223\201\260\317\266\327\274n\202-z\211o\012", - "\220k\214w\340#p\244g\313\012", - "\271\352\242 \366\222s\343\201\246\236\355\362\200\322i\215\326\362c\367\222p\205s\335", - "\361\232 sho\343\206\222tur\340\251\250u\335", - "po\266\240\200\246\200\310\254 \355\362\200\204i\207\213iza\215\373", - "po\266\240\224\220\204t\212\226\206a\266gn\234t\012", - "po\266\240\224\220\204t\212\226\206bit\352s\200\357\211a\215\012", - "\366mis\370\012", - "po\266\240\224\251\042\347\350\320\325wa\203\204t\212\226d\373", - "\260\317\266\327\304\203\364effe\315\012", - "ne\225\236\344m\234t\012", - "\356os\200\204d\212\323\215\012", - "\245\206\225y\360pro\314typ\300\246\236\352\242 \357\215\351semic\245umn\275", - "\356c\351\346\217 s\304\374w\203\251\346a\201\251\317c\277\367level\012", - "\260\317\266\327\352\242 \366ov\211rid\200\303appe\205 \355twe\212 p\205\212\242ese\275", - "la\355l nam\200\217 s\304\374w\203\366na\324\012", - "nu\233\256\310\342git\203\260ce\277\203\244\215\351nu\233\256\317ci\227\202\012", - "\222d\220d\223\201\042\353e\273\042: \325\353\200\274\213way\2031 \341", - "\204\226t\211m\204\230\200\320\353\200\363\042\353e\273\350\260\317\266\327\341", - "\220\222a\270\267\200\344\226\012", - "\251\346\274a\266gn\236\314 itself \341", - "m\221\200\204i\207\213iz\211\203\242\365\212um \332eld\275", - "l\212g\242 \310\204i\207\213iz\256\260ce\277\203\353\200\310\242\200\212um \332eld\012", - "\204\226x \366mis\370 \341", - "\364i\376le\234\323\237f\247\331\200\217 \363\361\232\326\364f\213l-back\012", - "\331\200speci\332ca\237\327\362w\205\206\226cl\330\237\274ig\214\222d\012", - "outpu\201\332\360\274writt\212\326bu\201\352\242 \344\376ac\201\212\344d\367\342s\267\277\012", - "\331\200\346\217 s\304\374w\203\251g\356b\351\312\335", - "\302 \274m\205k\236a\203\226\317c\230\277: \354", - "pu\240ic \271lack\203\362w\205\206\226cl\330\237\341", - "\220k\214w\340p\330\324t\256\363subs\207tu\237(\204c\221\222c\201#\322\200p\230t\211n\235" + "\304 \264tr\243\230\236\315 %\206\271\324\330\211\277", + "\220\323i\240\310\347\223t/\305cro \343", + "nu\233\257\310\263t\203\376\303\231\373 \323i\215\012", + "\254 \264nev\257\242\274\375", + "\254 \264a\267gn\236\252\251u\200\237a\201\264nev\257\242\274\375", + "\220d\221d\223\201\345\226: \347\223\201\256\317\267\327\264z\211o\012", + "\220d\221d\223\201te\225: \347\223\201\256\317\267\327\264n\202-z\211o\012", + "\221k\214w\342#p\245g\305\012", + "\272\352\237 \372\220s\335\201\242\236\362\367\200\323i\215\322\367c\360\220p\205s\332", + "\366\232 sho\335\206\220tur\342\252\251u\332", + "po\267\241\200\242\200\310\254 \362\367\200\204i\207\213iza\215\375", + "po\267\241\224\221\204t\212\226\206a\267gn\234t\012", + "po\267\241\224\221\204t\212\226\206bit\352s\200\363\211a\215\012", + "\372mis\373\012", + "po\267\241\224\252\042\347\350\321\325wa\203\204t\212\226d\375", + "\256\317\267\327\302\203\371effe\330\012", + "ne\225\236\345m\234t\012", + "loos\200\204d\212\313\215\012", + "\246\206\225y\355pro\315\364p\303\242\236\352\237 \363\215\351semic\246umn\277", + "loc\351\346\217 s\302\376w\203\252\346a\201\252\317c\274\360level\012", + "\256\317\267\327\352\237 \372ov\211rid\200\301appe\205 \362twe\212 p\205\212\237ese\277", + "la\362l nam\200\217 s\302\376w\203\372na\314\012", + "nu\233\257\310\344git\203\256ce\274\203\245\215\351nu\233\257\317ci\227\202\012", + "\220d\221d\223\201\042\354e\275\042: \325\354\200\264\213way\2031 \343", + "\204\226t\211m\204\230\200\321\354\200\370\042\354e\275\350\256\317\267\327\343", + "\221\220a\271\270\200\345\226\012", + "\252\346\264a\267gn\236\315 itself \343", + "m\222\200\204i\207\213iz\211\203\237\357\212um \334eld\277", + "l\212g\237 \310\204i\207\213iz\257\256ce\274\203\354\200\310\237\200\212um \334eld\012", + "\204\226x \372mis\373 \343", + "\371imple\234\313\240f\247\333\200\217 \370\366\232\322\371f\213l-back\012", + "\333\200speci\334ca\240\327\367w\205\206\226\353\324\240\264ig\214\220d\012", + "outpu\201\334\355\264writt\212\322bu\201\352\237 \345mpac\201\212\345d\360\344s\270\274\012", + "\333\200\346\217 s\302\376w\203\252glob\351\312\332", + "\304 \264m\205k\236a\203\226\317c\230\274: \356", + "pu\241ic \272lack\203\367w\205\206\226\353\324\240\343", + "\221k\214w\342p\324\314t\257\370subs\207tu\240(\204c\222\220c\201#\323\200p\230t\211n\235" #endif }; diff --git a/sourcepawn/compiler/sp_symhash.c b/sourcepawn/compiler/sp_symhash.c index 49c3c7e0..bb35a5ac 100644 --- a/sourcepawn/compiler/sp_symhash.c +++ b/sourcepawn/compiler/sp_symhash.c @@ -197,7 +197,7 @@ AddToHashTable(HashTable *ht, symbol *sym) he = (HashEntry *)malloc(sizeof(HashEntry)); if (!he) - error(123); + error(163); he->sym = sym; he->next = NULL; *hep = he; diff --git a/sourcepawn/compiler/tests/fail-old-decl-new-types.sp b/sourcepawn/compiler/tests/fail-old-decl-new-types.sp new file mode 100644 index 00000000..deaf3c96 --- /dev/null +++ b/sourcepawn/compiler/tests/fail-old-decl-new-types.sp @@ -0,0 +1,8 @@ +methodmap X { + public native Float X(); + public native String Z(); + public native T:Z(); +} + +public main() { +} diff --git a/sourcepawn/compiler/tests/fail-old-decl-new-types.txt b/sourcepawn/compiler/tests/fail-old-decl-new-types.txt new file mode 100644 index 00000000..d6d17b6a --- /dev/null +++ b/sourcepawn/compiler/tests/fail-old-decl-new-types.txt @@ -0,0 +1,3 @@ +type "Float" should be "float" in new-style declarations +type "String" should be "char" in new-style declarations +methodmap and class signatures must use new-style declarations diff --git a/sourcepawn/compiler/tests/ok-inline-natives.sp b/sourcepawn/compiler/tests/ok-inline-natives.sp new file mode 100644 index 00000000..733d816b --- /dev/null +++ b/sourcepawn/compiler/tests/ok-inline-natives.sp @@ -0,0 +1,17 @@ +methodmap Handle { + public native Handle(); + public native ~Handle(); + public native Handle Clone(); + public native int Size(); + public native float SizeF(); + public native bool Ok(x, y, z); +}; + +public main() { + new Handle:handle = Handle(); + handle.Clone(); + new x = handle.Size(); + new Float:f = handle.SizeF(); + new bool:b = handle.Ok(1, 2, 3); + delete handle; +} diff --git a/sourcepawn/compiler/tests/runtests.py b/sourcepawn/compiler/tests/runtests.py index 23f1d836..981fdd6f 100644 --- a/sourcepawn/compiler/tests/runtests.py +++ b/sourcepawn/compiler/tests/runtests.py @@ -14,7 +14,6 @@ def run_tests(args): failed = False for test in tests: - print('Testing {0}...'.format(test)) if test.startswith('fail-'): kind = 'fail' elif test.startswith('warn-'): @@ -41,27 +40,33 @@ def run_tests(args): status = 'fail' if status == 'ok' and kind != 'pass': + lines = [] with open(os.path.join(testdir, test + '.txt')) as fp: - text = fp.read().strip() - if text not in stdout: - print('Expected to find text in stdout: >>>') - print(text) - print('<<<') - status = 'fail' + for line in fp: + lines.append(line.strip()) + for line in lines: + if line not in stdout: + sys.stderr.write('Expected to find text in stdout: >>>\n') + sys.stderr.write(text) + sys.stderr.write('<<<\n') + status = 'fail' + break if status == 'fail': + print('Test {0} ... FAIL'.format(test)) failed = True - print('FAILED! Dumping stdout/stderr:') - print(stdout) - print(stderr) + sys.stderr.write('FAILED! Dumping stdout/stderr:\n') + sys.stderr.write(stdout) + sys.stderr.write(stderr) else: - print('... OK!') + print('Test {0} ... OK'.format(test)) except Exception as exn: raise sys.stderr.write('FAILED! {0}\n'.format(exn.message)) if failed: + sys.stderr.write('One or more tests failed!\n') sys.exit(1) def main():