Improved autosimplify during EVAL.

This commit is contained in:
claudio 2014-09-10 22:00:00 -04:00
parent f0a277f4ac
commit b1c70ca7b5
3 changed files with 37 additions and 33 deletions

View file

@ -189,6 +189,12 @@ void LIB_HANDLER()
// IN ORDER TO KEEP THE LOOP RUNNING
rplPushRet(IPtr);
if((rplPeekRet(1)<symbeval_seco)||(rplPeekRet(1)>symbeval_seco+4))
{
// THIS EVAL IS NOT INSIDE A RECURSIVE LOOP
// PUSH AUTOSIMPLIFY TO BE EXECUTED AFTER EVAL
*rplPushRet(symbeval_seco+4);
}
IPtr=(WORDPTR) symbeval_seco;
CurOpcode=MKOPCODE(LIB_OVERLOADABLE,OVR_EVAL); // SET TO AN ARBITRARY COMMAND, SO IT WILL SKIP THE PROLOG OF THE SECO
@ -433,10 +439,7 @@ void LIB_HANDLER()
rplDropData(1);
// CLEANUP AND RETURN
rplCleanupLAMs(0);
// DONE WITH CLASSIC EVAL, NOW DO AUTOSIMPLIFY IF USER SETTING REQUIRES IT
// TODO: IMPLEMENT USER SETTING, LEAVE ENABLED FOR NOW
if(1) IPtr=symbeval_seco+4; // THIS WILL MAKE THE NEXT EXECUTED OPCODE TO BE AUTOSIMPLIFY
else IPtr=rplPopRet();
IPtr=rplPopRet();
CurOpcode=MKOPCODE(LIB_OVERLOADABLE,OVR_EVAL);
return;

View file

@ -338,6 +338,7 @@ void LIB_HANDLER()
rplNewRealFromRRegPush(0);
return;
case OVR_NEG:
case OVR_UMINUS:
mpd_qminus(&RReg[0],&Darg1,&Context,(uint32_t *)&status);
rplNewRealFromRRegPush(0);
return;

View file

@ -1001,35 +1001,6 @@ WORDPTR rplSymbCanonicalForm(WORDPTR object)
}
//*******************************************
// SCAN THE SYMBOLIC FOR ITEM C.2)
// C) ALL NEG(NEG(...)) = (...)
stkptr=DSTop-1;
while(stkptr!=endofstk) {
sobj=*stkptr;
if(*sobj==MKOPCODE(LIB_OVERLOADABLE,OVR_UMINUS)) {
WORDPTR *nextarg=stkptr-2;
if(**nextarg==MKOPCODE(LIB_OVERLOADABLE,OVR_UMINUS)) {
// NEG/NEG = REMOVE THE NEGATION
WORDPTR *ptr=nextarg-1;
// AND REMOVE THE GAP
while(ptr!=DSTop-4) {
*ptr=*(ptr+4);
++ptr;
}
DSTop-=4;
stkptr-=4;
}
else stkptr--;
}
--stkptr;
}
@ -1256,6 +1227,35 @@ WORDPTR rplSymbCanonicalForm(WORDPTR object)
--stkptr;
}
//*******************************************
// SCAN THE SYMBOLIC FOR ITEM G.3)
// G.3) ALL NEG(NEG(...)) = (...)
stkptr=DSTop-1;
while(stkptr!=endofstk) {
sobj=*stkptr;
if(*sobj==MKOPCODE(LIB_OVERLOADABLE,OVR_UMINUS)) {
WORDPTR *nextarg=stkptr-2;
if(**nextarg==MKOPCODE(LIB_OVERLOADABLE,OVR_UMINUS)) {
// NEG/NEG = REMOVE THE NEGATION
WORDPTR *ptr=nextarg-1;
// AND REMOVE THE GAP
while(ptr!=DSTop-4) {
*ptr=*(ptr+4);
++ptr;
}
DSTop-=4;
stkptr-=4;
}
else stkptr--;
}
--stkptr;
}
//*******************************************
// SCAN THE SYMBOLIC FOR ITEM H)