/*
 * |-----------------------------------------------------------|
 * | Copyright (c) 1991, 1990 MIPS Computer Systems, Inc.      |
 * | All Rights Reserved                                       |
 * |-----------------------------------------------------------|
 * |          Restricted Rights Legend                         |
 * | Use, duplication, or disclosure by the Government is      |
 * | subject to restrictions as set forth in                   |
 * | subparagraph (c)(1)(ii) of the Rights in Technical        |
 * | Data and Computer Software Clause of DFARS 252.227-7013.  |
 * |         MIPS Computer Systems, Inc.                       |
 * |         950 DeGuigne Avenue                               |
 * |         Sunnyvale, California 94088-3650, USA             |
 * |-----------------------------------------------------------|
 */
/* $Header: mfile1,v 1.7.2.1 92/06/24 13:27:40 marker Exp $ */
/* $Log:	mfile1,v $
# Revision 1.7.2.1  92/06/24  13:27:40  marker
# Branch RISCOS_5_01_2_FIXES off of trunk.
# 
# Revision 1.6  89/12/10  18:42:15  jay
# replaced with files from 2.0 C compiler's lint, modified to support cxref.
# closes bugs 1373
# 
# Revision 2000.7  89/03/26  14:48:15  bettina
# 2.0G
# 
# Revision 1040.6  88/09/29  15:53:03  bettina
# bootstraped 1.40
# 
 * Revision 1.2  87/12/09  11:41:49  gb
 * added $Log keyword
 *  */
/* ref.		data		description				*/
/* !01		09apr85		initialization implementation		*/
/* !02		09sep85		label generated for the optimizer when a */
/*				'do' immediately follows a 'then-part' of*/
/*				a 'if'.					*/

# include "macdefs"
# include "manifest"
# include "prototype.h"



# define checkst(x)
# ifndef CHARCAST
/* to make character constants into character connstants */
/* this is a macro to defend against cross-compilers, etc. */
# define CHARCAST(x) (char)(x)
# endif

#	define BCSZ 100		/* table size to save break, continue labels */
#	define SYMTSZ 3000	/* size of the symbol table */
#	define DIMTABSZ 4200	/* size of the dimension/size table */
#	define PARAMSZ 1020	/* size of the parameter stack */
#	define SWITSZ 500	/* size of switch table */
#	define FILE_NAME_LENGTH 100  /* maximum size of input file name */



/*	storage classes  */
# define SNULL 0
# define AUTO 1
# define EXTERN 2
# define STATIC 3
# define REGISTER 4
# define EXTDEF 5
# define LABEL 6
# define ULABEL 7
# define MOS 8
# define PARAM 9
# define STNAME 10
# define MOU 11
# define UNAME 12
# define TYPEDEF 13
# define FORTRAN 14
# define ENAME 15
# define MOE 16
# define UFORTRAN 17
# define USTATIC 18
	/* field size is ORed in */
# define FIELD 0100
# define FLDSIZ 077
# ifndef BUG1
extern char *scnames();
# endif

/*	location counters */
# define PROG 0
# define DATA 1
# define ADATA 2
# define STRNG 3
# define ISTRNG 4
# define STAB 5


/* symbol table flags */
# define SMOS 01
# define SHIDDEN 02
# define SHIDES 04
# define SSET 010
/* Unused
# define SDELETED_LOCAL_SYMBOL 020
*/
# define SNONUNIQ 040
# define STAG 0100
# define SFUNCTION_DEF_WITH_PROTOTYPE 0200
# ifndef FIXDEF
# define FIXDEF(p)
#endif
# ifndef FIXARG
# define FIXARG(p)
# endif
# ifndef FIXSTRUCT
# define FIXSTRUCT(a,b)
# endif

# ifdef ONEPASS
# ifndef SETDCON
# define SETDCON(p) 0
# endif
# else
# define SETDCON(p) 0
# endif

	/* alignment of initialized quantities */
# ifndef AL_INIT
#	define	AL_INIT ALINT
# endif


struct symtab {
	char *sname;
	struct	symtab *snext;	/* link to other symbols in the same scope */
	TWORD stype;  /* type word */
	char sclass;  /* storage class */
	char slevel;  /* scope level */
	char sflags;  /* flags for set, use, hidden, mos, etc. */
	int offset;  /* offset or value */
	short dimoff; /* offset into the dimension table */
	short sizoff; /* offset into the size table */
	short suse;  /* line number of last use of the variable */
	function_prototype_list sprototype; /* parameter description */
};


/* NOPREF must be defined for use in first pass tree machine */
# define NOPREF 020000  /* no preference for register assignment */

struct sw {
	CONSZ sval;
	int slab;
	TWORD addr;/* address where switch value is */
	} ;

extern struct sw *swtab;
extern struct sw *swp;
extern int swx;

extern int ftnno;
extern int blevel;
extern int instruct, stwart;

extern int lineno, nerrors;
typedef struct  {
	int in_sz;   /* size of array element */
	int in_x;    /* current index for structure member in structure initializations */
	int in_n;    /* number of initializations seen */
	int in_s;    /* sizoff */
	int in_d;    /* dimoff */
	TWORD in_t;    /* type */
	int in_id;   /* stab index */
	int in_fl;   /* flag which says if this level is controlled by {} */
	OFFSZ in_off;  /* offset of the beginning of this level */
} INSTK;


typedef struct 
{
	char	**ht_low;
	char	**ht_high;
	int	ht_used;
} HT;

typedef union {
	int intval;
	NODE * nodep;
	function_prototype_list prototype; /* parameter description */
	} YYSTYPE;
extern YYSTYPE yylval;

extern CONSZ lastcon;
extern double dcon;

extern char *ftitle;
extern char ititle[];
extern struct symtab *stab;
extern int curftn;
extern int curclass;
extern int curdim;
extern int *dimtab;
struct dnode {
	int index;
	short cextern;
	};
extern struct dnode *dimptr, *dimrec;
extern int *paramstk;
extern int paramno;
extern int autooff, argoff, strucoff;
extern int regvar;
extern int minrvar;
extern int brkflag;
extern char yytext[];

extern int strflg;

extern OFFSZ inoff;
extern int   indblkno;							/*!01*/

extern int reached;
extern int reachflg;

/*	tunnel to buildtree for name id's */

extern int idname;

extern NODE *node;
extern NODE *lastfree;

extern int cflag, hflag, pflag;

/* various labels */
extern int brklab;
extern int contlab;
extern int flostat;
extern int retlab;
extern int retstat;
extern int *asavbc, *psavbc;

/*	flags used in structures/unions */

# define SEENAME 01
# define INSTRUCT 02
# define INUNION 04
# define FUNNYNAME 010
# define TAGNAME 020

/*	flags used in the (elementary) flow analysis ... */

# define FBRK 02
# define FCONT 04
# define FDEF 010
# define FLOOP 020
# define FIFDO 040							/*!02*/
/*	flags used for return status */

# define RETVAL 1
# define NRETVAL 2

/*	used to mark a constant with no name field */

# define NONAME 040000

	/* mark an offset which is undefined */

# define NOOFFSET (-10201)

/*	declarations of various functions */

extern NODE
	*buildtree(),
	*bdty(),
	*mkty(),
	*rstruct(),
	*dclstruct(),
	*getstr(),
	*tymerge(),
	*stref(),
	*offcon(),
	*bcon(),
	*bpsize(),
	*convert(),
	*pconvert(),
	*oconvert(),
	*ptmatch(),
	*tymatch(),
	*makety(),
	*block(),
	*doszof(),
	*talloc(),
	*optim(),
	*strargs(),
	*clocal();

OFFSZ	tsize(),
	psize();

TWORD	types();



double atof();

char *exname(), *exdcon();

/*	special interfaces for yacc alone */
/*	These serve as abbreviations of 2 or more ops:
	ASOP	=, = ops
	RELOP	LE,LT,GE,GT
	EQUOP	EQ,NE
	DIVOP	DIV,MOD
	SHIFTOP	LS,RS
	ICOP	ICR,DECR
	UNOP	NOT,COMPL
	STROP	DOT,STREF

	*/
# define ASOP 25
# define RELOP 26
# define EQUOP 27
# define DIVOP 28
# define SHIFTOP 29
# define INCOP 30
# define UNOP 31
# define STROP 32

# define LP 50
# define RP 51
# define LC 52
# define RC 53

/*
* These defines control "while" and "for" loop code generation.
* wloop_level and floop_level each must be set to one of these values.
*/
#define LL_TOP	0	/* test at loop top */
#define LL_BOT	1	/* test at loop bottom */
#define LL_DUP	2	/* duplicate loop test at top and bottom */
