__emit: Fix crash on attempt to reference a native

This commit is contained in:
Daniel_Cortez 2018-11-26 14:47:03 +07:00
parent 69a573ad90
commit 3c1ac1e911

View File

@ -6088,6 +6088,7 @@ fetchtok:
p->type=eotLABEL; p->type=eotLABEL;
p->value.ucell=(ucell)sym->addr; p->value.ucell=(ucell)sym->addr;
} else if (sym->ident==iFUNCTN || sym->ident==iREFFUNC) { } else if (sym->ident==iFUNCTN || sym->ident==iREFFUNC) {
const int ntvref=sym->usage & uREAD;
markusage(sym,uREAD); markusage(sym,uREAD);
if (negate) if (negate)
goto invalid_token_neg; goto invalid_token_neg;
@ -6095,7 +6096,7 @@ fetchtok:
tok=(sym->usage & uNATIVE) ? teNATIVE : teFUNCTN; tok=(sym->usage & uNATIVE) ? teNATIVE : teFUNCTN;
goto invalid_token; goto invalid_token;
} /* if */ } /* if */
if ((sym->usage & uNATIVE)!=0 && (sym->usage & uREAD)==0 && sym->addr>=0) if ((sym->usage & uNATIVE)!=0 && ntvref==0 && sym->addr>=0)
sym->addr=ntv_funcid++; sym->addr=ntv_funcid++;
p->type=eotFUNCTION; p->type=eotFUNCTION;
p->value.string=str; p->value.string=str;
@ -6361,7 +6362,7 @@ static void SC_FASTCALL emit_param_function(emit_outval *p,int isnative)
cell val; cell val;
char *str; char *str;
symbol *sym; symbol *sym;
int tok; int tok,ntvref;
p->type=eotNUMBER; p->type=eotNUMBER;
tok=lex(&val,&str); tok=lex(&val,&str);
@ -6376,6 +6377,7 @@ static void SC_FASTCALL emit_param_function(emit_outval *p,int isnative)
return; return;
} /* if */ } /* if */
if (sym->ident==iFUNCTN || sym->ident==iREFFUNC) { if (sym->ident==iFUNCTN || sym->ident==iREFFUNC) {
ntvref=sym->usage & uREAD;
markusage(sym,uREAD); markusage(sym,uREAD);
if (!!(sym->usage & uNATIVE)==isnative) if (!!(sym->usage & uNATIVE)==isnative)
break; break;
@ -6396,7 +6398,7 @@ static void SC_FASTCALL emit_param_function(emit_outval *p,int isnative)
} /* switch */ } /* switch */
if (isnative!=FALSE) { if (isnative!=FALSE) {
if ((sym->usage & uREAD)==0 && sym->addr>=0) if (ntvref==0 && sym->addr>=0)
sym->addr=ntv_funcid++; sym->addr=ntv_funcid++;
p->value.ucell=(ucell)sym->addr; p->value.ucell=(ucell)sym->addr;
} else { } else {