emit: Allow the use of labels in arguments of type 'any'

This commit is contained in:
Daniel_Cortez 2018-01-31 19:15:10 +07:00
parent bc76324d03
commit a19b740a28
4 changed files with 17 additions and 6 deletions

View File

@ -478,6 +478,7 @@ typedef enum s_optmark {
#define eotNUMBER 0
#define eotFUNCTION 1
#define eotLABEL 2
typedef struct s_emit_outval {
int type;
union {

View File

@ -5981,10 +5981,12 @@ fetchtok:
break;
} /* if */
if (sym->ident==iLABEL) {
tok=tLABEL;
goto invalid_token;
} /* if */
if (sym->ident==iFUNCTN || sym->ident==iREFFUNC) {
if (neg!=FALSE)
goto invalid_token_neg;
sym->usage|=uREAD;
p->type=eotLABEL;
p->value.ucell=(ucell)sym->addr;
} else if (sym->ident==iFUNCTN || sym->ident==iREFFUNC) {
if (neg!=FALSE)
goto invalid_token_neg;
if ((sym->usage & uNATIVE)!=0 && (sym->usage & uREAD)==0 && sym->addr>=0)
@ -6024,7 +6026,6 @@ fetchtok:
break;
} /* if */
default:
invalid_token:
emit_invalid_token(teNUMERIC,tok);
} /* switch */
}

View File

@ -1390,6 +1390,9 @@ SC_FUNC void outinstr(const char *name, emit_outval params[],int numparams)
stgwrite(" ");
switch (params[i].type)
{
case eotLABEL:
stgwrite("l.");
/* fallthrough */
case eotNUMBER:
stgwrite(itoh(params[i].value.ucell));
break;

View File

@ -102,7 +102,7 @@ static ucell getparam(const char *s,char **n)
char name[sNAMEMAX+1];
symbol *sym;
if (*s=='.') {
if (s[0]=='.') {
/* this is a function, find it in the global symbol table */
for (i=0; !isspace(*(++s)); i++) {
assert(*s!='\0');
@ -115,6 +115,12 @@ static ucell getparam(const char *s,char **n)
assert(sym->ident==iFUNCTN || sym->ident==iREFFUNC);
assert(sym->vclass==sGLOBAL);
result=sym->addr;
} else if (s[0]=='l' && s[1]=='.') {
/* this is a label */
i=(int)hex2long(s+2,NULL);
assert(i>=0 && i<sc_labnum);
assert(lbltab!=NULL);
result=lbltab[i];
} else {
for ( ;; ) {
result+=hex2long(s,(char**)&s);