From 63e5ab18ffa475993f35430e720587ccd0b08a9b Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 24 Aug 2014 18:59:51 -0700 Subject: [PATCH 1/2] Remove support for multiple tags on an argument. --- plugins/admin-flatfile/admin-flatfile.sp | 2 +- sourcepawn/compiler/sc1.cpp | 2 ++ sourcepawn/compiler/sc5-in.scp | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/admin-flatfile/admin-flatfile.sp b/plugins/admin-flatfile/admin-flatfile.sp index 250ebb24..12f06711 100644 --- a/plugins/admin-flatfile/admin-flatfile.sp +++ b/plugins/admin-flatfile/admin-flatfile.sp @@ -70,7 +70,7 @@ public OnRebuildAdminCache(AdminCachePart:part) } } -ParseError(const String:format[], {Handle,String,Float,_}:...) +ParseError(const String:format[], any:...) { decl String:buffer[512]; diff --git a/sourcepawn/compiler/sc1.cpp b/sourcepawn/compiler/sc1.cpp index 95114951..1cf291d7 100644 --- a/sourcepawn/compiler/sc1.cpp +++ b/sourcepawn/compiler/sc1.cpp @@ -3192,6 +3192,8 @@ static int parse_old_decl(declinfo_t *decl, int flags) } needtoken(':'); } + if (type->numtags > 1) + error(158); } if (type->numtags == 0) { diff --git a/sourcepawn/compiler/sc5-in.scp b/sourcepawn/compiler/sc5-in.scp index 0478abb2..f7ec5a24 100644 --- a/sourcepawn/compiler/sc5-in.scp +++ b/sourcepawn/compiler/sc5-in.scp @@ -201,6 +201,7 @@ static const char *errmsg[] = { /*155*/ "expected newline, but found '%s'\n", /*156*/ "the 'any' type is not allowed in new-style natives\n", /*157*/ "'%s' is a reserved keyword\n", +/*158*/ "multi-tags are no longer supported\n", #else "\315e\306\227\266k\217:\235\277bu\201fo\220\204\223\012", "\202l\224\250s\205g\346\356e\233\201(\243\315\214\267\202) \253 f\255low ea\305 \042c\353e\042\012", From 6db4f31a1020549f99b8b69668db576d5b8f9ccd Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 24 Aug 2014 20:47:07 -0700 Subject: [PATCH 2/2] Remove weird tag flags. --- sourcepawn/compiler/sc.h | 4 +-- sourcepawn/compiler/sc1.cpp | 53 +++++++++---------------------------- sourcepawn/compiler/sc2.cpp | 1 - sourcepawn/compiler/sc3.cpp | 6 ++--- 4 files changed, 15 insertions(+), 49 deletions(-) diff --git a/sourcepawn/compiler/sc.h b/sourcepawn/compiler/sc.h index 0a6b6fb5..ce91a8f8 100644 --- a/sourcepawn/compiler/sc.h +++ b/sourcepawn/compiler/sc.h @@ -524,16 +524,15 @@ typedef enum s_optmark { #define suSLEEP_INSTR 0x01 /* the "sleep" instruction was used */ -#define PUBLICTAG 0x80000000Lu #define FIXEDTAG 0x40000000Lu #define FUNCTAG 0x20000000Lu #define OBJECTTAG 0x10000000Lu #define ENUMTAG 0x08000000Lu #define METHODMAPTAG 0x04000000Lu #define STRUCTTAG 0x02000000Lu -#define TAGMASK (~PUBLICTAG) #define TAGTYPEMASK (FUNCTAG | OBJECTTAG | ENUMTAG | METHODMAPTAG | STRUCTTAG) #define TAGFLAGMASK (FIXEDTAG | TAGTYPEMASK) +#define TAGID(tag) ((tag) & ~(TAGFLAGMASK)) #define CELL_MAX (((ucell)1 << (sizeof(cell)*8-1)) - 1) @@ -591,7 +590,6 @@ constvalue *append_constval(constvalue *table,const char *name,cell val,int inde constvalue *find_constval(constvalue *table,char *name,int index); void delete_consttable(constvalue *table); symbol *add_constant(const char *name,cell val,int vclass,int tag); -void exporttag(int tag); void sc_attachdocumentation(symbol *sym); constvalue *find_tag_byval(int tag); int get_actual_compound(symbol *sym); diff --git a/sourcepawn/compiler/sc1.cpp b/sourcepawn/compiler/sc1.cpp index 1cf291d7..a5269516 100644 --- a/sourcepawn/compiler/sc1.cpp +++ b/sourcepawn/compiler/sc1.cpp @@ -617,7 +617,7 @@ const char *pc_tagname(int tag) { constvalue *ptr=tagname_tab.next; for (; ptr; ptr=ptr->next) { - if ((int)(ptr->value & TAGMASK) == (tag & TAGMASK)) + if (TAGID(ptr->value) == TAGID(tag)) return ptr->name; } return "__unknown__"; @@ -638,7 +638,7 @@ int pc_findtag(const char *name) constvalue *ptr=tagname_tab.next; for (; ptr; ptr=ptr->next) { if (strcmp(name,ptr->name)==0) - return (int)(ptr->value & TAGMASK); + return ptr->value; } return -1; } @@ -667,27 +667,25 @@ int pc_addtag(const char *name) int pc_addtag_flags(const char *name, int flags) { constvalue *ptr; - int last,tag; + int last; assert((flags & FUNCTAG) || strchr(name,':')==NULL); /* colon should already have been stripped */ last=0; ptr=tagname_tab.next; while (ptr!=NULL) { - tag=(int)(ptr->value & TAGMASK); if (strcmp(name,ptr->name)==0) { + // Update the flag set. ptr->value |= flags; - return ptr->value & TAGMASK; + return ptr->value; } - tag &= ~TAGFLAGMASK; - if (tag>last) - last=tag; - ptr=ptr->next; + if (TAGID(ptr->value) > last) + last = TAGID(ptr->value); + ptr = ptr->next; } /* while */ /* tagname currently unknown, add it */ - tag=last+1; /* guaranteed not to exist already */ - tag|=flags; - append_constval(&tagname_tab,name,(cell)tag,0); + int tag = (last + 1) | flags; + append_constval(&tagname_tab, name, (cell)tag, 0); return tag; } @@ -3942,13 +3940,7 @@ static void domethodmap(LayoutSpec spec) if (matchtoken(tNULLABLE) || (parent && parent->nullable)) map->nullable = TRUE; } else { - constvalue *tagptr = pc_tagptr(mapname); - if (!tagptr) { - map->tag = pc_addtag_flags(mapname, FIXEDTAG | OBJECTTAG); - } else { - tagptr->value |= OBJECTTAG; - map->tag = (tagptr->value & TAGMASK); - } + map->tag = pc_addtag_flags(mapname, FIXEDTAG | OBJECTTAG); } methodmap_add(map); @@ -4907,7 +4899,6 @@ static int check_operatortag(int opertok,int resulttag,char *opername) static char *tag2str(char *dest,int tag) { - tag &= TAGMASK; assert(tag>=0); sprintf(dest,"0%x",tag); return isdigit(dest[1]) ? &dest[1] : dest; @@ -4956,11 +4947,7 @@ static int parse_funcname(char *fname,int *tag1,int *tag2,char *opname) constvalue *find_tag_byval(int tag) { - constvalue *tagsym; - tagsym=find_constval_byval(&tagname_tab,tag & ~PUBLICTAG); - if (tagsym==NULL) - tagsym=find_constval_byval(&tagname_tab,tag | PUBLICTAG); - return tagsym; + return find_constval_byval(&tagname_tab, tag); } char *funcdisplayname(char *dest,char *funcname) @@ -7586,20 +7573,6 @@ static void docont(void) jumplabel(ptr[wqLOOP]); } -void exporttag(int tag) -{ - /* find the tag by value in the table, then set the top bit to mark it - * "public" - */ - if (tag!=0 && (tag & PUBLICTAG)==0) { - constvalue *ptr; - for (ptr=tagname_tab.next; ptr!=NULL && tag!=(int)(ptr->value & TAGMASK); ptr=ptr->next) - /* nothing */; - if (ptr!=NULL) - ptr->value |= PUBLICTAG; - } /* if */ -} - static void doexit(void) { int tag=0; @@ -7611,7 +7584,6 @@ static void doexit(void) ldconst(0,sPRI); } /* if */ ldconst(tag,sALT); - exporttag(tag); destructsymbols(&loctab,0); /* call destructor for *all* locals */ ffabort(xEXIT); } @@ -7627,7 +7599,6 @@ static void dosleep(void) ldconst(0,sPRI); } /* if */ ldconst(tag,sALT); - exporttag(tag); ffabort(xSLEEP); /* for stack usage checking, mark the use of the sleep instruction */ diff --git a/sourcepawn/compiler/sc2.cpp b/sourcepawn/compiler/sc2.cpp index b03d6929..788befd4 100644 --- a/sourcepawn/compiler/sc2.cpp +++ b/sourcepawn/compiler/sc2.cpp @@ -1135,7 +1135,6 @@ static int command(void) } /* if */ /* add the tag (make it public) and check the values */ i=pc_addtag(name); - exporttag(i); if (sc_rationaltag==0 || (sc_rationaltag==i && rational_digits==(int)digits)) { sc_rationaltag=i; rational_digits=(int)digits; diff --git a/sourcepawn/compiler/sc3.cpp b/sourcepawn/compiler/sc3.cpp index 42c49636..6c743c3e 100644 --- a/sourcepawn/compiler/sc3.cpp +++ b/sourcepawn/compiler/sc3.cpp @@ -1806,10 +1806,9 @@ static int hier2(value *lval) else if (level==sym->dim.array.level+1 && idxsym!=NULL) tag= idxsym->x.tags.index; } /* if */ - exporttag(tag); clear_value(lval); lval->ident=iCONSTEXPR; - lval->constval=tag | PUBLICTAG; + lval->constval=tag; ldconst(lval->constval,sPRI); while (paranthese--) needtoken(')'); @@ -2899,8 +2898,7 @@ static int nesting=0; asz=find_constval(&taglst,arg[argidx].defvalue.size.symname, arg[argidx].defvalue.size.level); if (asz != NULL) { - exporttag(asz->value); - array_sz=asz->value | PUBLICTAG; /* must be set, because it just was exported */ + array_sz=asz->value; /* must be set, because it just was exported */ } else { array_sz=0; } /* if */