On 3/14/07, Richard Guenther <[EMAIL PROTECTED]> wrote:
#define LANG_TYPE_CODE (t) (TREE_CODE (t) == LANG_TYPE ?
LANG_TYPE_SUBCODE (t) : INVALID_SUBCODE)

and then INVALID_SUBCODE will fall through to the default case as well.

But that doesn't put the subcodes and the codes into the same
"namespace". We want to be able to write:

 switch (TREE_CODE (t))
 {
   case FUNCTION_TYPE:
     /* do something with function types. */
    break;

   case TYPEOF_TYPE_SUBCODED:
     /* do something with TYPEOF_TYPE. */
    break;
 }

even though FUNCTION_TYPE is (and will always be) a top-level tree
code, whereas TYPEOF_TYPE should be subcoded and stashed away in a
LANG_TYPE.

Of course, one could use TREE_CODE to see through the difference
between these two, e.g.,

 #define TREE_CODE(NODE)
   ((enum tree_code) (NODE)->base.code == LANG_TYPE?
       (enum tree_code)((TYPE_LANG_SPECIFIC (NODE)->base.subcode +
LAST_AND_UNUSED_TREE_CODE))
       : (enum tree_code) (NODE)->base.code)

Then, the opposite for TREE_SET_CODE:
 #define TREE_SET_CODE(NODE, VALUE)
    ((VALUE) >= LAST_AND_USED_TREE_CODE)?
       ((NODE)->base.code = LANG_TYPE, get_type_lang_specific
(NODE)->base.subcode = (VALUE) - LAST_AND_USED_TREE_CODE)
    : ((NODE)->base.code = (VALUE))

Yuck.

 Cheers,
 Doug

Reply via email to