if (ilist->type == INIT_NODE)
{
if (IS_PTR (type))
- resultType = RESULT_TYPE_NONE;
+ resultType = RESULT_TYPE_INT;
else
resultType = getResultTypeFromType (getSpec (type));
ilist->init.node = decorateType (resolveSymbols (ilist->init.node),
/* create a new value */
val = newValue ();
- val->type = val->etype = newLink (SPECIFIER);
- SPEC_NOUN (val->type) = (IS_FLOAT (lval->etype) ||
- IS_FLOAT (rval->etype) ? V_FLOAT : V_INT);
- SPEC_SCLS (val->type) = S_LITERAL; /* will remain literal */
- SPEC_LONG (val->type) = (SPEC_LONG (lval->etype) | SPEC_LONG (rval->etype));
- SPEC_USIGN (val->type) = SPEC_USIGN (computeType (lval->etype,
- rval->etype,
- TRUE));
+ val->type = val->etype = computeType (lval->etype,
+ rval->etype,
+ RESULT_TYPE_INT,
+ '*');
+ SPEC_SCLS (val->etype) = S_LITERAL; /* will remain literal */
+
if (IS_FLOAT (val->type))
SPEC_CVAL (val->type).v_float = floatFromVal (lval) * floatFromVal (rval);
/* signed and unsigned mul are the same, as long as the precision of the
/* create a new value */
val = newValue ();
- val->type = val->etype = newLink(SPECIFIER);
- SPEC_NOUN (val->type) = (IS_FLOAT (lval->etype) ||
- IS_FLOAT (rval->etype) ? V_FLOAT : V_INT);
- SPEC_SCLS (val->etype) = S_LITERAL;
- SPEC_LONG (val->type) = (SPEC_LONG (lval->etype) | SPEC_LONG (rval->etype));
- SPEC_USIGN (val->type) = SPEC_USIGN (computeType (lval->etype,
- rval->etype,
- FALSE));
+ val->type = val->etype = computeType (lval->etype,
+ rval->etype,
+ RESULT_TYPE_INT,
+ '/');
+ SPEC_SCLS (val->etype) = S_LITERAL; /* will remain literal */
if (IS_FLOAT (val->type))
SPEC_CVAL (val->type).v_float = floatFromVal (lval) / floatFromVal (rval);
value *val;
/* create a new value */
- val = newValue ();
- val->type = val->etype = newLink (SPECIFIER);
- SPEC_NOUN (val->type) = V_INT; /* type is int */
- SPEC_SCLS (val->type) = S_LITERAL; /* will remain literal */
- SPEC_LONG (val->type) = (SPEC_LONG (lval->etype) | SPEC_LONG (rval->etype));
- SPEC_USIGN (val->type) = SPEC_USIGN (computeType (lval->etype,
- rval->etype,
- TRUE));
+ val = newValue();
+ val->type = val->etype = computeType (lval->etype,
+ rval->etype,
+ RESULT_TYPE_INT,
+ '%');
+ SPEC_SCLS (val->etype) = S_LITERAL; /* will remain literal */
if (SPEC_LONG (val->type))
{
value *val;
/* create a new value */
- val = newValue ();
- val->type = val->etype = newLink (SPECIFIER);
- SPEC_NOUN (val->type) = (IS_FLOAT (lval->etype) ||
- IS_FLOAT (rval->etype) ? V_FLOAT : V_INT);
- SPEC_SCLS (val->type) = S_LITERAL; /* will remain literal */
- SPEC_LONG (val->type) = (SPEC_LONG (lval->etype) | SPEC_LONG (rval->etype));
- SPEC_USIGN (val->type) = SPEC_USIGN (computeType (lval->etype,
- rval->etype,
- TRUE));
+ val = newValue();
+ val->type = val->etype = computeType (lval->etype,
+ rval->etype,
+ RESULT_TYPE_INT,
+ '+');
+ SPEC_SCLS (val->etype) = S_LITERAL; /* will remain literal */
+
if (IS_FLOAT (val->type))
SPEC_CVAL (val->type).v_float = floatFromVal (lval) + floatFromVal (rval);
else if (SPEC_LONG (val->type))
value *val;
/* create a new value */
- val = newValue ();
- val->type = val->etype = newLink (SPECIFIER);
- SPEC_NOUN (val->type) = (IS_FLOAT (lval->etype) ||
- IS_FLOAT (rval->etype) ? V_FLOAT : V_INT);
- SPEC_SCLS (val->type) = S_LITERAL; /* will remain literal */
- SPEC_LONG (val->type) = (SPEC_LONG (lval->etype) | SPEC_LONG (rval->etype));
- SPEC_USIGN (val->type) = SPEC_USIGN (computeType (lval->etype,
- rval->etype,
- TRUE));
+ val = newValue();
+ val->type = val->etype = computeType (lval->etype,
+ rval->etype,
+ RESULT_TYPE_INT,
+ '-');
+ SPEC_SCLS (val->etype) = S_LITERAL; /* will remain literal */
+
if (IS_FLOAT (val->type))
SPEC_CVAL (val->type).v_float = floatFromVal (lval) - floatFromVal (rval);
else if (SPEC_LONG (val->type))
value *val;
/* create a new value */
- val = newValue ();
- val->type = val->etype = newIntLink ();
- SPEC_SCLS (val->type) = S_LITERAL; /* will remain literal */
- SPEC_NOUN (val->etype) = V_INT;
- /* 'unsigned char' promotes to 'signed int' */
- if (!IS_CHAR (lval->etype))
- SPEC_USIGN (val->type) = SPEC_USIGN (lval->etype);
- SPEC_LONG (val->type) = SPEC_LONG (lval->etype);
+ val = newValue();
+ val->type = val->etype = computeType (lval->etype,
+ NULL,
+ RESULT_TYPE_INT,
+ 'S');
+ SPEC_SCLS (val->etype) = S_LITERAL; /* will remain literal */
if (getSize (val->type) * 8 <= (TYPE_UDWORD) floatFromVal (rval) &&
/* left shift */
/* create a new value */
val = newValue ();
- val->type = computeType (lval->etype, rval->etype, FALSE);
+ val->type = computeType (lval->etype, rval->etype, RESULT_TYPE_CHAR, op);
val->etype = getSpec (val->type);
SPEC_SCLS (val->etype) = S_LITERAL;
if (SPEC_NOUN (val->etype) == V_FLOAT)
SPEC_CVAL (val->etype).v_float = fval;
+ else if (SPEC_NOUN (val->etype) == V_BIT ||
+ SPEC_NOUN (val->etype) == V_SBIT)
+ SPEC_CVAL (val->etype).v_uint = l & 1;
+ else if (SPEC_NOUN (val->etype) == V_BITFIELD)
+ SPEC_CVAL (val->etype).v_uint = l &
+ (0xffffu >> (16 - SPEC_BLEN (val->etype)));
else if (SPEC_NOUN (val->etype) == V_CHAR) {
if (SPEC_USIGN (val->etype))
SPEC_CVAL (val->etype).v_uint= (TYPE_UBYTE) l;