Fixed build issue with xgl header. Implemented preferred units on variable properties.

This commit is contained in:
claudiol 2021-04-14 08:43:35 -04:00
parent baa3bd31c5
commit da23f4a999
5 changed files with 116 additions and 4 deletions

View file

@ -4,10 +4,11 @@
// Select the proper library according to the target (4-bit grayscale or full color)
#ifdef TARGET_PC
#include "ggl.h"
#endif
#ifdef TARGET_PC_PRIMEG1
#include "cgl.h"
#else
#include "ggl.h"
#endif
#endif
#ifdef TARGET_PRIME1

View file

@ -1301,6 +1301,60 @@ void rplDoAutoEval(WORDPTR varname, WORDPTR * indir)
DSTop = stksave;
return;
}
// CHECK IF THE VARIABLE HAS A PREFERRED UNIT
if(attr & IDATTR_PREFUNIT) {
WORDPTR *varcalc =
rplFindGlobalPropInDir(*stkptr, IDPROP_UNIT, indir, 0);
if(varcalc) {
// FOUND PREFERRED UNIT
rplPushData(varcalc[1]);
rplRunAtomic(CMD_CONVERT);
if(Exceptions) {
if( (Exceptions & EX_ERRORCODE) && (ErrorCode == ERR_INCONSISTENTUNITS)) {
if(!(attr & IDATTR_FORCEUNIT) ) {
// DON'T CONVERT TO PREFERRED UNITS IF INCONSISTENT, BUT DON'T REPORT THE PROBLEM
rplClearErrors();
rplDropData(1);
}
else {
// UNITS ARE FORCED, APPLY THE UNIT IF THE RESULT DIDN'T HAVE ANY UNITS
if(!ISUNIT(*rplPeekData(2)))
{
rplClearErrors();
rplRunAtomic(CMD_OVR_MUL);
}
if(Exceptions) {
if(!((Exceptions & EX_ERRORCODE)
&& (ErrorCode == ERR_UNDEFINEDVARIABLE)))
rplBlameError(varcalc[0]); // AT LEAST SHOW WHERE THE ERROR CAME FROM
if(DSTop > stksave)
DSTop = stksave;
return;
}
}
}
else {
if(!((Exceptions & EX_ERRORCODE)
&& (ErrorCode == ERR_UNDEFINEDVARIABLE)))
rplBlameError(varcalc[0]); // AT LEAST SHOW WHERE THE ERROR CAME FROM
if(DSTop > stksave)
DSTop = stksave;
return;
}
}
}
}
// STORE THE NEW RESULT AND CONTINUE
var[1] = rplPopData();
}

View file

@ -703,6 +703,9 @@ void LIB_HANDLER()
*(var + 1) = rplPeekData(1); // STORE THE INCREMENTED COUNTER
rplDropData(5);
WORD valattr = rplGetIdentAttr(var[0]);
if(valattr & IDATTR_DEPEND)
rplDoAutoEval(var[0], rplGetDirfromGlobal(var));
}
else {
@ -795,6 +798,10 @@ void LIB_HANDLER()
*(var + 1) = rplPeekData(1); // STORE THE INCREMENTED COUNTER
rplDropData(5);
WORD valattr = rplGetIdentAttr(var[0]);
if(valattr & IDATTR_DEPEND)
rplDoAutoEval(var[0], rplGetDirfromGlobal(var));
}
else {
@ -887,6 +894,10 @@ void LIB_HANDLER()
*(var + 1) = rplPeekData(1); // STORE THE INCREMENTED COUNTER
rplDropData(5);
WORD valattr = rplGetIdentAttr(var[0]);
if(valattr & IDATTR_DEPEND)
rplDoAutoEval(var[0], rplGetDirfromGlobal(var));
}
else {
@ -979,6 +990,10 @@ void LIB_HANDLER()
*(var + 1) = rplPeekData(1); // STORE THE INCREMENTED COUNTER
rplDropData(5);
WORD valattr = rplGetIdentAttr(var[0]);
if(valattr & IDATTR_DEPEND)
rplDoAutoEval(var[0], rplGetDirfromGlobal(var));
}
else {
@ -1061,6 +1076,10 @@ void LIB_HANDLER()
*(var + 1) = rplPeekData(1); // STORE THE RESULT
rplDropData(3);
WORD valattr = rplGetIdentAttr(var[0]);
if(valattr & IDATTR_DEPEND)
rplDoAutoEval(var[0], rplGetDirfromGlobal(var));
}
else {
@ -1142,6 +1161,10 @@ void LIB_HANDLER()
*(var + 1) = rplPeekData(1); // STORE THE RESULT
rplDropData(3);
WORD valattr = rplGetIdentAttr(var[0]);
if(valattr & IDATTR_DEPEND)
rplDoAutoEval(var[0], rplGetDirfromGlobal(var));
}
else {
@ -1223,6 +1246,10 @@ void LIB_HANDLER()
*(var + 1) = rplPeekData(1); // STORE THE RESULT
rplDropData(3);
WORD valattr = rplGetIdentAttr(var[0]);
if(valattr & IDATTR_DEPEND)
rplDoAutoEval(var[0], rplGetDirfromGlobal(var));
}
else {
@ -1315,6 +1342,10 @@ void LIB_HANDLER()
*(var + 1) = rplPeekData(1); // STORE THE INCREMENTED COUNTER
rplOverwriteData(4, rplPeekData(1));
rplDropData(3);
WORD valattr = rplGetIdentAttr(var[0]);
if(valattr & IDATTR_DEPEND)
rplDoAutoEval(var[0], rplGetDirfromGlobal(var));
}
else {
@ -1407,6 +1438,10 @@ void LIB_HANDLER()
*(var + 1) = rplPeekData(1); // STORE THE INCREMENTED COUNTER
rplOverwriteData(4, rplPeekData(1));
rplDropData(3);
WORD valattr = rplGetIdentAttr(var[0]);
if(valattr & IDATTR_DEPEND)
rplDoAutoEval(var[0], rplGetDirfromGlobal(var));
}
else {
@ -2244,6 +2279,10 @@ void LIB_HANDLER()
*(var + 1) = rplPeekData(1); // STORE THE INCREMENTED COUNTER
rplDropData(5);
WORD valattr = rplGetIdentAttr(var[0]);
if(valattr & IDATTR_DEPEND)
rplDoAutoEval(var[0], rplGetDirfromGlobal(var));
}
else {
@ -2391,6 +2430,20 @@ void LIB_HANDLER()
}
if(prop == IDPROP_UNIT) {
// SET THE ATTRIBUTE MARKER
varname = rplSetIdentAttr(var[0], IDATTR_PREFUNIT, IDATTR_PREFUNIT);
if(!varname) {
return;
}
var[0] = varname;
if(Exceptions)
return;
// AND TRIGGER AUTO EVALUATION
}
// ADD OTHER SYSTEM SIDE EFFECTS HERE
rplDropData(2);
@ -2557,7 +2610,7 @@ void LIB_HANDLER()
}
return;
case OVR_ISTRUE:
if(ISPACKEDDIR(rplPeekData(1))) {
if(ISPACKEDDIR(*rplPeekData(1))) {
if(OBJSIZE(*rplPeekData(1))==0) {
rplOverwriteData(1, (WORDPTR) zero_bint);
return;

View file

@ -1270,7 +1270,7 @@ void LIB_HANDLER()
if((OPCODE(CurOpcode) == OPCODE_DECOMPEDIT)) {
WORD attr = rplGetIdentAttr(DecompileObject);
if(attr) {
if(attr&IDATTR_ALLHINTS) {
BINT noinf = 0;
// APPEND THE ATTRIBUTES TO THE VARIABLE NAME IN SUBSCRIPT
rplDecompAppendChar(':');

View file

@ -185,8 +185,12 @@ WORD libComputeHash2(WORDPTR start, BINT nwords);
#define IDPROP_UNIT TEXT2WORD('U','n','i','t')
#define IDPROP_DEFN TEXT2WORD('D','e','f','n')
#define IDATTR_ALLPROPS 0xffff0000
// IDENTIFIER ATTRIBUTES USED BY THE CAS
// LOWER 16 BITS ARE USED BY THE CAS
#define IDATTR_ALLHINTS 0xffff
#define IDATTR_ISNOTINF 1
#define IDATTR_ISREAL 3