core will now ignore missing natives starting with '@'

the compiler will now resolve aliased natives to single references and export '@' natives for each redundant entry

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40804
This commit is contained in:
David Anderson 2007-05-15 04:59:24 +00:00
parent 82e07a9bf0
commit c9bc46e770
3 changed files with 25 additions and 14 deletions

View File

@ -1037,7 +1037,8 @@ bool CPluginManager::RunSecondPass(CPlugin *pPlugin, char *error, size_t maxleng
{
break;
}
if (native->status == SP_NATIVE_UNBOUND)
if (native->status == SP_NATIVE_UNBOUND
&& native->name[0] != '@')
{
if (error)
{

View File

@ -738,6 +738,7 @@ SC_FUNC void ffcase(cell value,char *labelname,int newtable)
SC_FUNC void ffcall(symbol *sym,const char *label,int numargs)
{
char symname[2*sNAMEMAX+16];
char aliasname[sNAMEMAX+1];
assert(sym!=NULL);
assert(sym->ident==iFUNCTN);
@ -749,6 +750,14 @@ SC_FUNC void ffcall(symbol *sym,const char *label,int numargs)
if (sc_status==statWRITE && (sym->usage & uREAD)==0 && sym->addr>=0)
sym->addr=ntv_funcid++;
stgwrite("\tsysreq.c ");
/* Look for an alias */
if (lookup_alias(aliasname, sym->name)) {
symbol *asym = findglb(aliasname, sGLOBAL);
if (asym && asym->ident==iFUNCTN && ((sym->usage & uNATIVE) != 0)) {
sym = asym;
}
}
assert(sym->addr != 0x1d);
outval(sym->addr,FALSE);
if (sc_asmfile) {
stgwrite("\t; ");

View File

@ -676,6 +676,7 @@ SC_FUNC int assemble(FILE *fout,FILE *fin)
constvalue *constptr;
cell mainaddr;
char nullchar;
char testalias[sNAMEMAX+1];
/* if compression failed, restart the assembly with compaction switched off */
if (setjmp(compact_err)!=0) {
@ -706,8 +707,9 @@ SC_FUNC int assemble(FILE *fout,FILE *fin)
for (sym=glbtab.next; sym!=NULL; sym=sym->next) {
int match=0;
if (sym->ident==iFUNCTN) {
if ((sym->usage & uNATIVE)!=0 && (sym->usage & uREAD)!=0 && sym->addr>=0)
if ((sym->usage & uNATIVE)!=0 && (sym->usage & uREAD)!=0 && sym->addr>=0) {
match=++numnatives;
}
if ((sym->usage & uPUBLIC)!=0 && (sym->usage & uDEFINE)!=0)
match=++numpublics;
if (strcmp(sym->name,uMAINFUNC)==0) {
@ -719,13 +721,12 @@ SC_FUNC int assemble(FILE *fout,FILE *fin)
match=++numpubvars;
} /* if */
if (match) {
char alias[sNAMEMAX+1];
const char *aliasptr = sym->name;
assert(sym!=NULL);
if ((sym->usage & uNATIVE)==0 || !lookup_alias(alias,sym->name)) {
assert(strlen(sym->name)<=sNAMEMAX);
strcpy(alias,sym->name);
if (((sym->usage & uNATIVE)!=0) && lookup_alias(testalias,sym->name)) {
aliasptr = "@";
} /* if */
nametablesize+=strlen(alias)+1;
nametablesize+=strlen(aliasptr)+1;
} /* if */
} /* for */
assert(numnatives==ntv_funcid);
@ -843,13 +844,13 @@ SC_FUNC int assemble(FILE *fout,FILE *fin)
} /* for */
count=0;
for (i=0; i<numnatives; i++) {
char alias[sNAMEMAX+1];
const char *aliasptr;
sym=nativelist[i];
assert(sym!=NULL);
if (!lookup_alias(alias,sym->name)) {
assert(strlen(sym->name)<=sNAMEMAX);
strcpy(alias,sym->name);
} /* if */
aliasptr = sym->name;
if (lookup_alias(testalias,sym->name)) {
aliasptr = "@";
}
assert(sym->vclass==sGLOBAL);
func.address=0;
func.nameofs=nameofs;
@ -860,8 +861,8 @@ SC_FUNC int assemble(FILE *fout,FILE *fin)
pc_resetbin(fout,hdr.natives+count*sizeof(AMX_FUNCSTUBNT));
pc_writebin(fout,&func,sizeof func);
pc_resetbin(fout,nameofs);
pc_writebin(fout,alias,strlen(alias)+1);
nameofs+=strlen(alias)+1;
pc_writebin(fout,(void *)aliasptr,strlen(aliasptr)+1);
nameofs+=strlen(aliasptr)+1;
count++;
} /* for */
free(nativelist);