Simplify the code even more

This commit is contained in:
Stanislav Gromov 2021-02-28 15:53:16 +07:00
parent f545d8f5fe
commit 3901a61421

View File

@ -6645,16 +6645,14 @@ invalid_lvalue:
* *
* Looks for an rvalue and generates code to handle expressions. * Looks for an rvalue and generates code to handle expressions.
*/ */
static int SC_FASTCALL emit_getrval(int *identptr,emit_outval *p,int *islocal) static int SC_FASTCALL emit_getrval(int *identptr,cell *val)
{ {
int index,result=TRUE; int index,result=TRUE;
cell cidx; cell cidx;
cell val;
symbol *sym; symbol *sym;
assert(identptr!=NULL); assert(identptr!=NULL);
assert(p!=NULL); assert(val!=NULL);
assert(islocal!=NULL);
if (staging) { if (staging) {
assert((emit_flags & efEXPR)!=0); assert((emit_flags & efEXPR)!=0);
@ -6665,13 +6663,11 @@ static int SC_FASTCALL emit_getrval(int *identptr,emit_outval *p,int *islocal)
} /* if */ } /* if */
errorset(sEXPRMARK,0); errorset(sEXPRMARK,0);
*identptr=expression(&val,NULL,&sym,TRUE); *identptr=expression(val,NULL,&sym,TRUE);
p->type=eotNUMBER;
switch (*identptr) { switch (*identptr) {
case iVARIABLE: case iVARIABLE:
case iREFERENCE: case iREFERENCE:
*islocal=((sym->vclass & sLOCAL)!=0); *val=sym->addr;
p->value.ucell=(ucell)sym->addr;
break; break;
case iCONSTEXPR: case iCONSTEXPR:
/* If the expression result is a constant value or a variable - erase the code /* If the expression result is a constant value or a variable - erase the code
@ -6680,7 +6676,6 @@ static int SC_FASTCALL emit_getrval(int *identptr,emit_outval *p,int *islocal)
*/ */
if (staging) if (staging)
stgdel(index,cidx); stgdel(index,cidx);
p->value.ucell=(ucell)val;
break; break;
case iARRAY: case iARRAY:
case iREFARRAY: case iREFARRAY:
@ -7429,25 +7424,17 @@ static void SC_FASTCALL emit_do_pushn_s_adr(char *name)
static void SC_FASTCALL emit_do_load_u_pri_alt(char *name) static void SC_FASTCALL emit_do_load_u_pri_alt(char *name)
{ {
emit_outval p[1]; cell val;
regid reg; regid reg;
int ident,islocal; int ident;
if (!emit_getrval(&ident,&p[0],&islocal)) if (!emit_getrval(&ident,&val))
return; return;
reg=emit_findreg(name); reg=emit_findreg(name);
switch (ident) { if (ident==iCONSTEXPR)
case iCONSTEXPR: ldconst(val,reg);
if (p[0].value.ucell==(ucell)0) else if (reg==sALT)
outinstr((reg==sPRI) ? "zero.pri" : "zero.alt",NULL,0);
else
outinstr((reg==sPRI) ? "const.pri" : "const.alt",p,1);
break;
default:
if (reg==sALT)
outinstr("move.alt",NULL,0); outinstr("move.alt",NULL,0);
break;
} /* switch */
} }
static void SC_FASTCALL emit_do_stor_u_pri_alt(char *name) static void SC_FASTCALL emit_do_stor_u_pri_alt(char *name)
@ -7518,19 +7505,15 @@ static void SC_FASTCALL emit_do_addr_u_pri_alt(char *name)
static void SC_FASTCALL emit_do_push_u(char *name) static void SC_FASTCALL emit_do_push_u(char *name)
{ {
emit_outval p[1]; cell val;
int ident,islocal; int ident;
if (!emit_getrval(&ident,&p[0],&islocal)) if (!emit_getrval(&ident,&val))
return; return;
switch (ident) { if (ident==iCONSTEXPR)
case iCONSTEXPR: pushval(val);
outinstr("push.c",&p[0],1); else
break;
default:
outinstr("push.pri",NULL,0); outinstr("push.pri",NULL,0);
break;
} /* switch */
} }
static void SC_FASTCALL emit_do_push_u_adr(char *name) static void SC_FASTCALL emit_do_push_u_adr(char *name)