----------------->  GNU Sather - compiler configuration file  <----------------
-- Copyright (C) 199x by International Computer Science Institute            --
-- 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 FORTRAN_CONFIG
#define FORTRAN_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 $$;"

F_INTEGER_CREATE_INT:	PP,exec		"INTF_INTEGER($1)"; 
F_INTEGER_INT:		PP,exec		"F_INTEGERINT($0)";
F_INTEGER_ZERO:		PP,exec		"F_INTEGER_zero";
F_INTEGER_PLUS:		APP,VSTD, exec "$$=F_INTEGERPLUS($0,$1);" "$$";
F_INTEGER_MINUS:	APP,VSTD, exec "$$=F_INTEGERMINUS($0,$1);" "$$";
F_INTEGER_TIMES:	APP,VSTD, exec "$$=F_INTEGERTIMES($0,$1);" "$$";
F_INTEGER_DIV:		APP,VSTD, exec "$$=F_INTEGERDIV($0,$1);" "$$";
F_INTEGER_IS_EQ:	PP,VSTD,exec	"$$=F_INTEGER_IS_EQ($0,$1);" "$$";
F_INTEGER_IS_LT:	PP,VSTD,exec	"$$=F_INTEGERIS_LT($0,$1);" "$$";

F_REAL_CREATE_FLT:	PP,exec		"FLTF_REAL($1)";
F_REAL_FLT:		PP,exec		"F_REALFLT($0)";
F_REAL_ZERO:		PP,exec		"F_REAL_zero";
F_REAL_PLUS:		APP,VSTD,exec	"$$=F_REALPLUS($0,$1);" "$$";
F_REAL_MINUS:		APP,VSTD,exec	"$$=F_REALMINUS($0,$1);" "$$";
F_REAL_TIMES:		APP,VSTD,exec	"$$=F_REALTIMES($0,$1);" "$$";
F_REAL_DIV:		APP,VSTD,exec	"$$=F_REALDIV($0,$1);" "$$";
F_REAL_IS_EQ:		PP,VSTD,exec	"$$=F_REAL_IS_EQ($0,$1);" "$$";
F_REAL_IS_LT:		PP,VSTD,exec	"$$=F_REALIS_LT($0,$1);" "$$";


F_DOUBLE_CREATE_FLTD:	PP,exec		"FLTDF_DOUBLE($1)";
F_DOUBLE_FLTD:		PP,exec		"F_DOUBLEFLTD($0)";
F_DOUBLE_ZERO:		PP,exec		"F_DOUBLE_zero";
F_DOUBLE_PLUS:		APP,VSTD,exec "$$=F_DOUBLEPLUS($0,$1);" "$$";
F_DOUBLE_MINUS:		APP,VSTD,exec "$$=F_DOUBLEMINUS($0,$1);" "$$";
F_DOUBLE_TIMES:		APP,VSTD,exec "$$=F_DOUBLETIMES($0,$1);" "$$";
F_DOUBLE_DIV:		APP,VSTD,exec "$$=F_DOUBLEDIV($0,$1);" "$$";
F_DOUBLE_IS_EQ:		PP,VSTD,exec	"$$=F_DOUBLE_IS_EQ($0,$1);" "$$";
F_DOUBLE_IS_LT:		PP,VSTD,exec	"$$=F_DOUBLEIS_LT($0,$1);" "$$";


F_LOGICAL_CREATE_BOOL:	PP,exec		"BOOLF_LOGICAL($1)";
F_LOGICAL_BOOL:		PP,exec		"F_LOGICALBOOL($0)";
F_LOGICAL_ZERO:		PP,exec		"F_LOGICAL_zero";
F_LOGICAL_NOT:		PP,VSTD,exec	"$$=F_LOGICALNOT($0);" "$$";
F_LOGICAL_IS_EQ:	PP,VSTD,exec	"$$=F_LOGICAL_IS_EQ($0,$1);" "$$";
F_LOGICAL_OR:		PP,VSTD,exec	"$$=F_LOGICALOR($0,$1);" "$$";
F_LOGICAL_AND:		PP,VSTD,exec	"$$=F_LOGICALAND($0,$1);" "$$";


F_CHARACTER_CREATE_CHAR: PP,exec	"CHARF_CHARACTER($1)";
F_CHARACTER_CHAR:	PP,exec		"F_CHARACTERCHAR($0)";
F_CHARACTER_ZERO:	PP,exec		"F_CHARACTER_zero";
F_CHARACTER_IS_EQ:	PP,VSTD,exec	"$$=F_CHARACTER_IS_EQ($0,$1);" "$$";
F_CHARACTER_IS_LT:	PP,VSTD,exec	"$$=F_CHARACTERIS_LT($0,$1);" "$$";



F_STRING_CREATE_CHAR: PP,VSTD,
			exec	
			"$$=(@0)ZALLOC(sizeof(@0_struct));" 
			"$$->address=(F_CHARACTER *)ZALLOC(sizeof(F_CHARACTER));"
			"$$->size=(F_LENGTH)1;"
			"*($$->address)=(F_CHARACTER)$1;"
			"$$";
F_STRING_CREATE_STR:  PP, reads "@1::asize",
			VSTD,
			exec	
			"$$=(@0)ZALLOC(sizeof(@0_struct));" 
			"$$->address=(F_CHARACTER *)ZALLOC($1->asize);"
			"$$->size=(F_LENGTH)$1->asize;"
			"memcpy($$->address,$1->arr_part,$1->asize);"
			"$$";
F_STRING_CREATE_INT:  PP, reads "@1::asize",
			VSTD,
			exec	
			"$$=(@0)ZALLOC(sizeof(@0_struct));" 
			"$$->address=(F_CHARACTER *)ZALLOC($1);"
			"$$->size=(F_LENGTH)$1;"
			"$$";

F_STRING_ADDRESS: PP, exec "$0->address";
F_STRING_SIZE:    PP, exec "$0->size";

F_COMPLEX_READ_RE:	 PP, exec "$0.re";
F_COMPLEX_WRITE_RE:	 PP, exec "$0.re=$1;";
F_COMPLEX_READ_IM:	 PP, exec "$0.im";
F_COMPLEX_WRITE_IM:	 PP, exec "$0.im=$1;";
F_COMPLEX_ZERO:		 PP,exec "F_COMPLEX_zero";

F_DOUBLE_COMPLEX_READ_RE:	 PP, exec "$0.re";
F_DOUBLE_COMPLEX_WRITE_RE:	 PP, exec "$0.re=$1;";
F_DOUBLE_COMPLEX_READ_IM:	 PP, exec "$0.im";
F_DOUBLE_COMPLEX_WRITE_IM:	 PP, exec "$0.im=$1;";
F_DOUBLE_COMPLEX_ZERO:		 PP,exec "F_DOUBLE_COMPLEX_zero";

F_HANDLER_SET_HANDLER:	PP, exec "$0=(@0)$1;";
F_HANDLER_INVOKE_HANDLER: PP, exec "F_HANDLERINVOKE_HANDLER($0)";


-- FORTRAN arrays
F_ARRAY_CREATE_INT:       PP, exec "(@0)ZALLOC($1*sizeof(@P0))";
F_ARRAY_CREATE_AREF:	  PP, exec "(@0)$1->arr_part";
F_ARRAY_AGET:		  PP, exec "*((@P0 *)$0 + $1)";
F_ARRAY_ASET:		  PP, exec "*((@P0 *)$0 + $1)=$2";

F_ARRAY2_CREATE_INT_INT:  PP, exec "(@0)ZALLOC($1*$2*sizeof(@P0))";
F_ARRAY2_CREATE_ARRAY2:   PP, exec "(@0)$1->arr_part";

F_ARRAY3_CREATE_INT_INT_INT: PP, exec "(@0)ZALLOC($1*$2*$3*sizeof(@P0))";
F_ARRAY3_CREATE_ARRAY3:   PP, exec "(@0)$1->arr_part";

F_ARRAY2_CREATE_MAT:	PP, exec "(@0)$1->arr_part";
#endif FORTRAN_CONFIG




