emit/__emit: Check if the argument of instruction 'call' is a Pawn function

This commit is contained in:
Daniel_Cortez 2017-11-17 19:55:27 +07:00
parent abe9c965dc
commit 912376b658
3 changed files with 26 additions and 13 deletions

View File

@ -406,9 +406,11 @@ typedef struct s_valuepair {
#define teNUMBER 339 /* integer/rational number */
#define teDATA 340 /* data (variable name or address) */
#define teLOCAL 341 /* local variable (name or offset) */
#define teFUNCTN 342 /* Pawn function */
#define teNATIVE 343 /* native function */
/* for assigment to "lastst" only (see SC1.C) */
#define tEXPR 342
#define tENDLESS 343 /* endless loop */
#define tEXPR 344
#define tENDLESS 345 /* endless loop */
/* (reversed) evaluation of staging buffer */
#define sSTARTREORDER 0x01

View File

@ -6182,20 +6182,30 @@ static void OPHANDLER_CALL emit_do_call(char *name)
int tok;
tok=lex(&val,&str);
if (tok!=tSYMBOL)
if (tok!=tSYMBOL) {
emit_invalid_token(tSYMBOL,tok);
return;
}
sym=findglb(str,sGLOBAL);
if (sym==NULL) {
error(12); /* invalid function call */
} else {
stgwrite("\t");
stgwrite(name);
stgwrite(" .");
stgwrite(str);
stgwrite("\n");
code_idx+=opcodes(1)+opargs(1);
markusage(sym,uREAD);
error(17,str); /* undefined symbol */
return;
}
if (sym->ident!=iFUNCTN && sym->ident!=iREFFUNC && sym->ident!=iVARARGS) {
emit_invalid_token(teFUNCTN,(sym->ident==iCONSTEXPR) ? teNUMBER : teDATA);
return;
}
if ((sym->usage & uNATIVE)!=0) {
emit_invalid_token(teFUNCTN,teNATIVE);
return;
}
stgwrite("\t");
stgwrite(name);
stgwrite(" .");
stgwrite(str);
stgwrite("\n");
code_idx+=opcodes(1)+opargs(1);
markusage(sym,uREAD);
}
static EMIT_OPCODE emit_opcodelist[] = {

View File

@ -2097,7 +2097,8 @@ char *sc_tokens[] = {
"#tryinclude", "#undef", "#warning",
";", ";", "-integer value-", "-rational value-", "-identifier-",
"-label-", "-string-",
"-numeric value-", "-data offset-", "-local variable-"
"-numeric value-", "-data offset-", "-local variable-", "-function-",
"-native function-"
};
SC_FUNC int lex(cell *lexvalue,char **lexsym)