__emit: Allow negative offsets for arguments of type 'local variable'
This commit is contained in:
parent
3c370ffde2
commit
4c260e6c60
@ -6286,9 +6286,11 @@ static void SC_FASTCALL emit_param_local(emit_outval *p,int allow_ref)
|
|||||||
cell val;
|
cell val;
|
||||||
char *str;
|
char *str;
|
||||||
symbol *sym;
|
symbol *sym;
|
||||||
int tok;
|
int tok,negate;
|
||||||
|
|
||||||
|
negate=FALSE;
|
||||||
p->type=eotNUMBER;
|
p->type=eotNUMBER;
|
||||||
|
fetchtok:
|
||||||
tok=lex(&val,&str);
|
tok=lex(&val,&str);
|
||||||
switch (tok) {
|
switch (tok) {
|
||||||
case tNUMBER:
|
case tNUMBER:
|
||||||
@ -6309,6 +6311,10 @@ static void SC_FASTCALL emit_param_local(emit_outval *p,int allow_ref)
|
|||||||
tok=teREFERENCE;
|
tok=teREFERENCE;
|
||||||
goto invalid_token;
|
goto invalid_token;
|
||||||
} /* if */
|
} /* if */
|
||||||
|
if (negate && sym->ident!=iCONSTEXPR) {
|
||||||
|
tok=(sym->ident==iREFERENCE || sym->ident==iREFARRAY) ? teREFERENCE : teLOCAL;
|
||||||
|
goto invalid_token_neg;
|
||||||
|
} /* if */
|
||||||
} else {
|
} else {
|
||||||
sym=findglb(str,sSTATEVAR);
|
sym=findglb(str,sSTATEVAR);
|
||||||
if (sym==NULL) {
|
if (sym==NULL) {
|
||||||
@ -6326,15 +6332,33 @@ static void SC_FASTCALL emit_param_local(emit_outval *p,int allow_ref)
|
|||||||
} /* if */
|
} /* if */
|
||||||
val=sym->addr;
|
val=sym->addr;
|
||||||
break;
|
break;
|
||||||
|
case '-':
|
||||||
|
if (!negate) {
|
||||||
|
negate=TRUE;
|
||||||
|
goto fetchtok;
|
||||||
|
} else {
|
||||||
|
extern char *sc_tokens[];
|
||||||
|
char ival[sNAMEMAX+2];
|
||||||
|
invalid_token_neg:
|
||||||
|
if (tok<tFIRST)
|
||||||
|
sprintf(ival,"-%c",tok);
|
||||||
|
else
|
||||||
|
sprintf(ival,"-(%s)",sc_tokens[tok-tFIRST]);
|
||||||
|
error(1,sc_tokens[teLOCAL-tFIRST],ival);
|
||||||
|
return;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
invalid_token:
|
invalid_token:
|
||||||
|
if (negate)
|
||||||
|
goto invalid_token_neg;
|
||||||
emit_invalid_token(teLOCAL,tok);
|
emit_invalid_token(teLOCAL,tok);
|
||||||
return;
|
return;
|
||||||
} /* switch */
|
} /* switch */
|
||||||
if ((val % sizeof(cell))==0)
|
if ((val % sizeof(cell))!=0) {
|
||||||
p->value.ucell=(ucell)val;
|
|
||||||
else
|
|
||||||
error(11); /* must be a multiple of cell size */
|
error(11); /* must be a multiple of cell size */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
p->value.ucell=(ucell)(negate ? -val : val);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SC_FASTCALL emit_param_label(emit_outval *p)
|
static void SC_FASTCALL emit_param_label(emit_outval *p)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user