}
LRVAL (tree) = RRVAL (tree) = 1;
- /* promote result to int if left & right are char / short
+ /* promote result to int if left & right are char
this will facilitate hardware multiplies 8bit x 8bit = 16bit */
- if ((IS_CHAR(LETYPE(tree)) || IS_SHORT(LETYPE(tree))) &&
- (IS_CHAR(RETYPE(tree)) || IS_SHORT(RETYPE(tree)))) {
- TETYPE (tree) = getSpec (TTYPE (tree) =
- computeType (LTYPE (tree),
- RTYPE (tree)));
- SPEC_NOUN(TETYPE(tree)) = V_INT;
- SPEC_SHORT(TETYPE(tree))=0;
+ if (IS_CHAR(LETYPE(tree)) && IS_CHAR(RETYPE(tree))) {
+ TETYPE (tree) = getSpec (TTYPE (tree) =
+ computeType (LTYPE (tree),
+ RTYPE (tree)));
+ SPEC_NOUN(TETYPE(tree)) = V_INT;
} else {
- TETYPE (tree) = getSpec (TTYPE (tree) =
- computeType (LTYPE (tree),
- RTYPE (tree)));
+ TETYPE (tree) = getSpec (TTYPE (tree) =
+ computeType (LTYPE (tree),
+ RTYPE (tree)));
}
return tree;
{
case V_INT: {
if (SPEC_LONG(sl)) return "long";
- if (SPEC_SHORT(sl)) return "short";
+ if (sl->select.s._short) return "short";
return "int";
}
case V_FLOAT: return "float";
SPEC_NOUN(etype)==V_FLOAT ||
SPEC_NOUN(etype)==V_DOUBLE ||
SPEC_NOUN(etype)==V_VOID) &&
- (SPEC_SHORT(etype) || SPEC_LONG(etype))) {
+ (etype->select.s._short || SPEC_LONG(etype))) {
// long or short for char float double or void
werror (E_LONG_OR_SHORT_INVALID, noun, name);
}
if ((SPEC_NOUN(etype)==V_FLOAT ||
SPEC_NOUN(etype)==V_DOUBLE ||
SPEC_NOUN(etype)==V_VOID) &&
- (SPEC_SIGNED(etype) || SPEC_USIGN(etype))) {
+ (etype->select.s._signed || SPEC_USIGN(etype))) {
// signed or unsigned for float double or void
werror (E_SIGNED_OR_UNSIGNED_INVALID, noun, name);
}
if (!SPEC_NOUN(etype)) {
// special case for just "signed" or "unsigned" or "long"
- if (SPEC_SIGNED(etype) || SPEC_USIGN(etype) || SPEC_LONG(etype)) {
+ if (etype->select.s._signed || SPEC_USIGN(etype) || SPEC_LONG(etype)) {
SPEC_NOUN(etype)=V_INT;
}
// special case for just "short"
- if (SPEC_SHORT(etype)) {
+ if (etype->select.s._short) {
SPEC_NOUN(etype)=V_CHAR; // or maybe V_INT
- SPEC_SHORT(etype)=0;
}
}
SPEC_NOUN(etype)=V_INT;
}
- if (SPEC_SIGNED(etype) && SPEC_USIGN(etype)) {
+ if (etype->select.s._signed && SPEC_USIGN(etype)) {
// signed AND unsigned
werror (E_SIGNED_AND_UNSIGNED_INVALID, noun, name);
}
- if (SPEC_SHORT(etype) && SPEC_LONG(etype)) {
+ if (etype->select.s._short && SPEC_LONG(etype)) {
// short AND long
werror (E_LONG_AND_SHORT_INVALID, noun, name);
}
/* we shouldn't redeclare the type */
if (getenv("DEBUG_SANITY")) {
fprintf (stderr, "mergeSpec: ");
- werror(E_TWO_OR_MORE_DATA_TYPES, yylval.yychar);
}
+ werror(E_TWO_OR_MORE_DATA_TYPES, yylval.yychar);
}
}
}
#endif
// but there are more important thing right now
-
+
SPEC_LONG (dest) |= SPEC_LONG (src);
- SPEC_SHORT (dest) |= SPEC_SHORT (src);
+ dest->select.s._short=src->select.s._short;
SPEC_USIGN (dest) |= SPEC_USIGN (src);
- SPEC_SIGNED (dest) |= SPEC_SIGNED (src);
+ dest->select.s._signed=src->select.s._signed;
SPEC_STAT (dest) |= SPEC_STAT (src);
SPEC_EXTR (dest) |= SPEC_EXTR (src);
SPEC_ABSA (dest) |= SPEC_ABSA (src);
switch (SPEC_NOUN (p))
{ /* depending on the specifier type */
case V_INT:
- return (IS_LONG (p) ? LONGSIZE : (IS_SHORT (p) ? SHORTSIZE : INTSIZE));
+ return (IS_LONG (p) ? LONGSIZE : INTSIZE);
case V_FLOAT:
return FLOATSIZE;
case V_CHAR:
switch (SPEC_NOUN (p))
{ /* depending on the specifier type */
case V_INT:
- return (IS_LONG (p) ? LONGSIZE * 8 : (IS_SHORT (p) ? SHORTSIZE * 8 : INTSIZE * 8));
+ return (IS_LONG (p) ? LONGSIZE * 8 : INTSIZE * 8);
case V_FLOAT:
return FLOATSIZE * 8;
case V_CHAR:
SPEC_NOUN (src) == V_VOID)
return -1;
- /* char === to short */
- if (SPEC_NOUN (dest) == V_CHAR &&
- SPEC_NOUN (src) == V_INT &&
- SPEC_SHORT (src))
- return (SPEC_USIGN (src) == SPEC_USIGN (dest) ? 1 : -2);
-
- if (SPEC_NOUN (src) == V_CHAR &&
- SPEC_NOUN (dest) == V_INT &&
- SPEC_SHORT (dest))
- return (SPEC_USIGN (src) == SPEC_USIGN (dest) ? 1 : -2);
-
/* if they are both bitfields then if the lengths
and starts don't match */
if (IS_BITFIELD (dest) && IS_BITFIELD (src) &&
if (SPEC_LONG (dest) != SPEC_LONG (src))
return -1;
- if (SPEC_SHORT (dest) != SPEC_SHORT (src))
- return -1;
-
if (SPEC_USIGN (dest) != SPEC_USIGN (src))
return -2;
case V_INT:
if (IS_LONG (type))
fprintf (of, "long ");
- if (IS_SHORT (type))
- fprintf (of, "short ");
fprintf (of, "int ");
break;
case V_INT:
if (IS_LONG (type))
fprintf (of, "SL");
- else if (IS_SHORT (type))
- fprintf (of, "SS");
else
fprintf (of, "SI");
break;
#define DCL_TSPEC(l) l->select.d.tspec
#define SPEC_NOUN(x) x->select.s.noun
#define SPEC_LONG(x) x->select.s._long
-#define SPEC_SHORT(x) x->select.s._short
+//#define SPEC_SHORT(x) x->select.s._short // only for type checking
#define SPEC_USIGN(x) x->select.s._unsigned
-#define SPEC_SIGNED(x) x->select.s._signed
+//#define SPEC_SIGNED(x) x->select.s._signed // only for type checking
#define SPEC_SCLS(x) x->select.s.sclass
#define SPEC_ENUM(x) x->select.s._isenum
#define SPEC_OCLS(x) x->select.s.oclass
#define IS_GENPTR(x) (IS_DECL(x) && DCL_TYPE(x) == GPOINTER)
#define IS_FUNC(x) (IS_DECL(x) && DCL_TYPE(x) == FUNCTION)
#define IS_LONG(x) (IS_SPEC(x) && x->select.s._long)
-#define IS_SHORT(x) (IS_SPEC(x) && x->select.s._short)
+//#define IS_SHORT(x) (IS_SPEC(x) && x->select.s._short)
#define IS_TYPEDEF(x)(IS_SPEC(x) && x->select.s._typedef)
#define IS_CONSTANT(x) (IS_SPEC(x) && ( x->select.s._const == 1))
#define IS_STRUCT(x) (IS_SPEC(x) && x->select.s.noun == V_STRUCT)