/*
                             N E G A T E . C
*/

#include "iccomp.h"

ESTRUC_ *negate(ESTRUC_ *e)                  /* expression so far */
{
    int i;

    if (test_operand(e, op_umin))            /* test types ok */
    {
        semantic(illegal_type, opstring[op_umin]);
        return (e);
    }

    if (e->type & e_const) {                /* immediate value */
        i = -(int)e->evalue;
        e->evalue = *(unsigned *)(&i);
    }
    else
    {
        etoc(e);                            /* convert to code */
        gencode(e, op_umin);                /* generate instruction */
    }

    return (e);
}
