union
{ /* Values if constant or enum */
- int v_int; /* int and char values */
+ short int v_int; /* int and char values */
char *v_char; /* character string */
- unsigned v_uint; /* unsigned int const value */
+ unsigned short v_uint; /* unsigned int const value */
long v_long; /* long constant value */
unsigned long v_ulong; /* unsigned long constant val */
double v_float; /* floating point constant value */
if (sval<0) {
if (sval>=-128) {
SPEC_NOUN(val->type)=V_CHAR;
+ SPEC_CVAL(val->type).v_int &= 0xff;
SPEC_LONG(val->type)=0;
} else {
if (sval>=-32768) {
if (SPEC_NOUN (val->etype) == V_FLOAT)
return (double) SPEC_CVAL (val->etype).v_float;
- else
+
+ if (SPEC_LONG (val->etype))
{
- if (SPEC_LONG (val->etype))
- {
- if (SPEC_USIGN (val->etype))
- return (double) SPEC_CVAL (val->etype).v_ulong;
- else
- return (double) SPEC_CVAL (val->etype).v_long;
- }
+ if (SPEC_USIGN (val->etype))
+ return (double) SPEC_CVAL (val->etype).v_ulong;
else
- {
- if (SPEC_USIGN (val->etype))
- return (double) SPEC_CVAL (val->etype).v_uint;
- else
- return (double) SPEC_CVAL (val->etype).v_int;
- }
+ return (double) SPEC_CVAL (val->etype).v_long;
}
+
+ if (SPEC_NOUN(val->etype)==V_INT) {
+ if (SPEC_USIGN (val->etype))
+ return (double) SPEC_CVAL (val->etype).v_uint;
+ else
+ return (double) SPEC_CVAL (val->etype).v_int;
+ } else { // SPEC_NOUN==V_CHAR
+ if (SPEC_USIGN (val->etype))
+ return (double) ((unsigned char)SPEC_CVAL (val->etype).v_uint);
+ else
+ return (double) ((signed char)SPEC_CVAL (val->etype).v_int);
+ }
}
SPEC_CVAL (val->etype).v_uint = 0-SPEC_CVAL (val->etype).v_uint;
else
SPEC_CVAL (val->etype).v_int = -SPEC_CVAL (val->etype).v_int;
+ if (SPEC_NOUN (val->etype)==V_CHAR) {
+ SPEC_CVAL (val->etype).v_uint &= 0xff;
+ }
}
}
+ // -(unsigned 3) now really is signed
+ SPEC_USIGN(val->etype)=0;
return val;
}
SPEC_CVAL (val->etype).v_uint = ~SPEC_CVAL (val->etype).v_uint;
else
SPEC_CVAL (val->etype).v_int = ~SPEC_CVAL (val->etype).v_int;
+ if (SPEC_NOUN (val->etype)==V_CHAR) {
+ SPEC_CVAL (val->etype).v_uint &= 0xff;
+ }
}
return val;
}
SPEC_CVAL (val->etype).v_uint = !SPEC_CVAL (val->etype).v_uint;
else
SPEC_CVAL (val->etype).v_int = !SPEC_CVAL (val->etype).v_int;
+ if (SPEC_NOUN (val->etype)==V_CHAR) {
+ SPEC_CVAL (val->etype).v_uint &= 0xff;
+ }
}
return val;
}
else
{
if (SPEC_USIGN (val->etype))
- if (SPEC_NOUN (val->etype)==V_CHAR) {
- SPEC_CVAL (val->etype).v_uint = (unsigned char)fval;
- } else {
- SPEC_CVAL (val->etype).v_uint = (unsigned short)fval;
- }
+ SPEC_CVAL (val->etype).v_uint = (unsigned short)fval;
else
- if (SPEC_NOUN (val->etype)==V_CHAR) {
- SPEC_CVAL (val->etype).v_int = (char)fval;
- } else {
- SPEC_CVAL (val->etype).v_int = (short)fval;
- }
+ SPEC_CVAL (val->etype).v_int = (short)fval;
+ if (SPEC_NOUN (val->etype)==V_CHAR) {
+ SPEC_CVAL (val->etype).v_uint &= 0xff;
+ }
}
}
return val;