
/* 
 * $Copyright:	$
 * Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990 
 * Sequent Computer Systems, Inc.   All rights reserved.
 *  
 * This software is furnished under a license and may be used
 * only in accordance with the terms of that license and with the
 * inclusion of the above copyright notice.   This software may not
 * be provided or otherwise made available to, or used by, any
 * other person.  No title to or ownership of the software is
 * hereby transferred.
 */

/*	Copyright (c) 1984 AT&T	*/
/*	  All Rights Reserved  	*/

/*	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T	*/
/*	The copyright notice above does not evidence any   	*/
/*	actual or intended publication of such source code.	*/
#ident "$Header: expr.c 1.1 90/01/19 $@(#)expr.c	1.1 89/12/01"
/*
 * expressions computation (for index evaluation)
 */
#include "xs.h"
#include "names.h"
#include "stack.h"
#include "types.h"
#include "anal.h"
#include "mfile1.h"

expr_relop(op, op1, op2)
  int op, op1, op2;
{
  switch (op){
  case LE:
    return op1 <= op2;
  case GE:
    return op1 >= op2;
  case GT:
    return op1 > op2;
  case LT:
    return op < op2;
  }
}

expr_divop(op, op1, op2)
  int op, op1, op2;
{
  if (op2 == 0)
    return 0;
  if (op == DIV)
    return op1 / op2;
  else
    return op1 % op2;
}

expr_shiftop(op, op1, op2)
  int op, op1, op2;
{
  if (op == LS)
    return op1 << op2;
  else
    return op1 >> op2;
}

expr_equop(op, op1, op2)
  int op, op1, op2;
{
  if (op == EQ)
    return op1 == op2;
  else
    return op1 != op2;
}

expr_unop(op, op1)
  int op, op1;
{
  if (op == NOT)
    return !op1;
  else
    return ~op1;
}
