/*------------------------->  Sather - configfile  <-------------------------*/
/* Copyright (C) 2000 by K Hopper, University of Waikato, New Zealand        */
/* This file is part of the GNU Sather library. It is free software; you may */
/* redistribute  and/or modify it under the terms of the GNU Library General */
/* Public  License (LGPL)  as published  by the  Free  Software  Foundation; */
/* either version 2 of the license, or (at your option) any later version.   */
/* This  library  is distributed  in the  hope that it will  be  useful, but */
/* WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY */
/* or FITNESS FOR A PARTICULAR PURPOSE. See Doc/LGPL for more details.       */
/* The license text is also available from:  Free Software Foundation, Inc., */
/* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA                     */
/*------------>  Please email comments to <bug-sather@gnu.org>  <------------*/

#ifndef INT_CONFIG
#define INT_CONFIG

#ifdef PP
#undef PP
#endif

#ifdef APP
#undef APP
#endif

#ifdef FPP
#undef FPP
#endif

#ifdef VSTD
#undef VSTD
#endif

#define PP	no_pre,no_post
#define APP	arith,PP
#define FPP	fragile,PP
#define VSTD	var "@r $$;"

BIN_INT:		PP,exec "(INT)$0";
INT_BIN:		PP,exec "$0";
INT_INT:		PP,exec "$0";
INT_BOOL:		PP,VSTD,exec "$$=(BOOL)$0;" "$$";
INT_CARD:		PP,VSTD,exec "$$=INTCARD($0);" "$$";
INT_FIELD:		PP,VSTD,exec "$$=(FIELD)$0;" "$$";
INT_FLT:		PP,VSTD,exec "$$=INTFLTD($0);" "$$";
INT_FLTD:		PP,VSTD,exec "$$=INTFLTD($0);" "$$";
INT_FLTX:		PP,VSTD,exec "$$=INTFLT($0);" "$$";
INT_FLTDX:		PP,VSTD,exec "$$=INTFLT($0);" "$$";
INT_CHAR:		PP,VSTD,exec "$$=INTCHAR($0);" "$$";
INT_C_UNSIGNED_INT:  PP,VSTD,exec "$$=(unsigned int)$0;" "$$";
INT_PLUS:		APP,VSTD,exec "$$=INTPLUS($0,$1);" "$$";
INT_MINUS:		APP,VSTD,exec "$$=INTMINUS($0,$1);" "$$";
INT_NEGATE:		APP,VSTD,exec "$$=INTMINUS(0,$0);" "$$";
INT_TIMES:		APP,VSTD,exec "$$=INTTIMES($0,$1);" "$$";
INT_DIV:		FPP,VSTD,exec "$$=INTDIV($0,$1);" "$$";
INT_MOD:		FPP,VSTD,exec "$$=INTMOD($0,$1);" "$$";
INT_IS_EQ:		PP,VSTD,exec "$$=($0)==($1);" "$$";
INT_IS_LT:		PP,VSTD,exec "$$=INTISLT($0,$1);" "$$";
INT_ABS:		PP,VSTD,exec "$$=INTABS($0) ;" "$$";
INT_SQUARE:		APP,VSTD,exec "$$=INTTIMES($0,$0);" "$$";
INT_MAX:		PP,VSTD,exec "$$=($0>$1)?$0:$1;" "$$";
INT_MIN:		PP,VSTD,exec "$$=($0<$1)?$0:$1;" "$$";
INT_IS_EVEN:	PP,VSTD,exec "$$=($0&1)==0;" "$$";
INT_IS_ODD:		PP,VSTD,exec "$$=($0&1)!=0;" "$$";
INT_IS_BETWEEN:	     PP,VSTD,exec "$$=($1<=$0&&$0<=$2)||($2<=$0&&$0<=$1);" "$$";
INT_NEG_POSSIBLE:    PP,VSTD,exec "$$=INTNEGPOSSIBLE($0);" "$$";

INT_CREATE_STR:	     FPP,VSTD,exec "$$=atoi(((STR)$1)->arr_part);" "$$";
INT_AGET:		PP,VSTD,exec "$$=((CHAR)(($0&(1<<$1))!=0));" "$$";
INT_ASET:		PP,VSTD,exec "$$=((($0)&(~(1<<($1))))|(($2)<<($1)));" "$$";

INT_MAXINT:		PP,var "INT $$=SINT_MAX;",exec "$$";
INT_MININT:		PP,var "INT $$=SINT_MIN;",exec "$$";

INT_TIMESB:		PP,
		     break "$0";

INT_TIMESB_INT:	     PP,
		     break "$0",
		     temp "@r a$$;",
		     iter "a$$=$#;" "a$$";

INT_FORB:	     PP,
		     var "INT $$,$$m;",
		     init "$$=$0-1;$$m=$1;",
		     iter "if(($1--)<=0) @@;$$++;" "$$";

INT_UPB:	     PP,
		     var "INT $$;",
		     init "$$=$0-1;",
		     iter "$$++;" "$$";

INT_UPTOB:	     PP,
		     var "INT $$,$$m;",
		     init "$$=$0-1;$$m=$1;",
		     iter "if($$++>=$$m) @@;" "$$";

INT_DOWNTOB:	     PP,
		     var "INT $$,$$m;",
		     init "$$=$0+1;$$m=$1;",
		     iter "if($$--<=$$m) @@;" "$$";

#endif 
