return FALSE;
}
- if (!IS_AST_LIT_VALUE(decorateType(resolveSymbols(iLoop->init.node), RESULT_CHECK)))
+ if (!IS_AST_LIT_VALUE(decorateType(resolveSymbols(iLoop->init.node), RESULT_TYPE_NONE)))
{
return FALSE;
}
TYPE_DWORD sval=0;
TYPE_UDWORD uval=0;
- if (IS_FLOAT(val->type) || IS_CHAR(val->type))
+ if (IS_FLOAT(val->type) || IS_FIXED(val->type) || IS_CHAR(val->type))
return val;
if (SPEC_LONG(val->type)) {
static value *cheapestVal (value *val)
{
- if (IS_FLOAT (val->type) || IS_CHAR (val->type))
+ if (IS_FLOAT (val->type) || IS_FIXED (val->type) || IS_CHAR (val->type))
return val;
/* - signed/unsigned must not be changed.
return val;
}
+/*-----------------------------------------------------------------*/
+/* constFixed16x16Val - converts a FIXED16X16 constant to value */
+/*-----------------------------------------------------------------*/
+value *
+constFixed16x16Val (char *s)
+{
+ value *val = newValue ();
+ double sval;
+
+ if (sscanf (s, "%lf", &sval) != 1)
+ {
+ werror (E_INVALID_FLOAT_CONST, s);
+ return constVal ("0");
+ }
+
+ val->type = val->etype = newLink (SPECIFIER);
+ SPEC_NOUN (val->type) = V_FLOAT;
+ SPEC_SCLS (val->type) = S_LITERAL;
+ SPEC_CVAL (val->type).v_fixed16x16 = fixed16x16FromDouble ( sval );
+
+ return val;
+}
+
/*-----------------------------------------------------------------*/
/* constVal - converts an INTEGER constant into a cheapest value */
/*-----------------------------------------------------------------*/
}
/* Setup the flags first */
- /* set the _long flag if 'lL' is found */
+ /* set the b_long flag if 'lL' is found */
if (strchr (s, 'l') || strchr (s, 'L')) {
SPEC_NOUN (val->type) = V_INT;
SPEC_LONG (val->type) = 1;
if (SPEC_NOUN (val->etype) == V_FLOAT)
return (double) SPEC_CVAL (val->etype).v_float;
+ if (SPEC_NOUN (val->etype) == V_FIXED16X16)
+ return (double) doubleFromFixed16x16( SPEC_CVAL (val->etype).v_fixed16x16 );
+
if (SPEC_LONG (val->etype))
{
if (SPEC_USIGN (val->etype))
/* depending on type */
if (SPEC_NOUN (val->etype) == V_FLOAT)
SPEC_CVAL (val->etype).v_float = -1.0 * SPEC_CVAL (val->etype).v_float;
+ if (SPEC_NOUN (val->etype) == V_FIXED16X16)
+ SPEC_CVAL (val->etype).v_fixed16x16 = -SPEC_CVAL (val->etype).v_fixed16x16;
else
{
if (SPEC_LONG (val->etype))
if (IS_FLOAT (val->type))
SPEC_CVAL (val->type).v_float = floatFromVal (lval) * floatFromVal (rval);
+ else
+ if (IS_FIXED16X16 (val->type))
+ SPEC_CVAL (val->type).v_fixed16x16 = fixed16x16FromDouble(floatFromVal (lval) * floatFromVal (rval));
/* signed and unsigned mul are the same, as long as the precision of the
result isn't bigger than the precision of the operands. */
else if (SPEC_LONG (val->type))
if (IS_FLOAT (val->type))
SPEC_CVAL (val->type).v_float = floatFromVal (lval) / floatFromVal (rval);
+ else
+ if (IS_FIXED16X16 (val->type))
+ SPEC_CVAL (val->type).v_fixed16x16 = fixed16x16FromDouble( floatFromVal (lval) / floatFromVal (rval) );
else if (SPEC_LONG (val->type))
{
if (SPEC_USIGN (val->type))
if (IS_FLOAT (val->type))
SPEC_CVAL (val->type).v_float = floatFromVal (lval) + floatFromVal (rval);
+ else
+ if (IS_FIXED16X16 (val->type))
+ SPEC_CVAL (val->type).v_fixed16x16 = fixed16x16FromDouble( floatFromVal (lval) + floatFromVal (rval) );
else if (SPEC_LONG (val->type))
{
if (SPEC_USIGN (val->type))
if (IS_FLOAT (val->type))
SPEC_CVAL (val->type).v_float = floatFromVal (lval) - floatFromVal (rval);
+ else
+ if (IS_FIXED16X16 (val->type))
+ SPEC_CVAL (val->type).v_fixed16x16 = fixed16x16FromDouble( floatFromVal (lval) - floatFromVal (rval) );
else if (SPEC_LONG (val->type))
{
if (SPEC_USIGN (val->type))
{
SPEC_CVAL (val->type).v_int = floatFromVal (lval) == floatFromVal (rval);
}
+ else
+ if (SPEC_NOUN(lval->type) == V_FIXED16X16 ||
+ SPEC_NOUN(rval->type) == V_FIXED16X16)
+ {
+ SPEC_CVAL (val->type).v_int = floatFromVal (lval) == floatFromVal (rval);
+ }
else
{
/* integrals: ignore signedness */
{
SPEC_CVAL (val->type).v_int = floatFromVal (lval) != floatFromVal (rval);
}
+ else
+ if (SPEC_NOUN(lval->type) == V_FIXED16X16 ||
+ SPEC_NOUN(rval->type) == V_FIXED16X16)
+ {
+ SPEC_CVAL (val->type).v_int = floatFromVal (lval) != floatFromVal (rval);
+ }
else
{
/* integrals: ignore signedness */
if (SPEC_NOUN (val->etype) == V_FLOAT)
SPEC_CVAL (val->etype).v_float = fval;
+ else if (SPEC_NOUN (val->etype) == V_FIXED16X16)
+ SPEC_CVAL (val->etype).v_fixed16x16 = fixed16x16FromDouble( fval );
else if (SPEC_NOUN (val->etype) == V_BIT ||
SPEC_NOUN (val->etype) == V_SBIT)
SPEC_CVAL (val->etype).v_uint = l ? 1 : 0;