/************************************************************************/
/*                                                                      */
/* Copyright (c) 1988 -                                                 */
/*     The Rector and Visitors of the University of Virginia            */
/*                                                                      */
/* This code may not be distributed further without permission          */
/*      from the University of Virginia.                                */
/* This code is distributed WITHOUT ANY WARRANTY.  No claims are        */
/*      made as to whether it serves any particular purpose or even     */
/*      works at all.                                                   */
/*                                                                      */
/************************************************************************/

#define STOPSIZE 2
#define ID_NULL ((IDENT*)0)
#define LB_NULL ((LGRAPH*)0)
#define ND_NULL ((NODE*)0)
#define OB_NULL ((OBJECT*)0)

typedef struct idlist IDENT;
typedef struct lgraph LGRAPH;
typedef struct nodest NODE;
typedef struct object OBJECT;
typedef unsigned long STOPBUF[STOPSIZE];
typedef unsigned long *STOPSET;
typedef unsigned int TWORD;

struct idlist {
	char	*id_name;
	int		id_symbol;
	IDENT	*id_next;
	OBJECT	*id_object;
	int		id_cacherev;
};


struct lgraph {
	LGRAPH *lb_outer, *lb_prev;
	int lb_level;
};

#define  MAXLINE 256

struct src_line {
	char *s_name;
	int s_linenum;
	char s_line[MAXLINE];
};

struct src_sy {
	struct src_line *s_line;
	int s_column;
};


struct nodest {
	int nd_op;
	TWORD nd_type;
	OBJECT *nd_object;
	union {
		union {		/* leaf node */
			int ival;
			double rval;
			char *runtime;
		} tn;
		struct {	/* internal node */
			NODE *left, *right;
		} in;
	} nd;
};

struct object {
	OBJECT *ob_prev, *ob_type;
	int  ob_kind, ob_flags, ob_size, ob_level;
	char *ob_name;
	TWORD ob_tword;

	union {

		struct {	/* array */
			OBJECT *indextype;
			int lower, upper;
		} array;

		struct {	/* conformant array */
			OBJECT *indextype, *lower, *upper, *size;
		} confarray;

		struct {	/* constant */
			int cslab;
			union {
				int    i;
				double r;
			} val;
		} const;

		struct {	/* field */
			OBJECT *tag, *tagval;
			int offset;
		} field;

		struct {	/* function or procedure */
			OBJECT *parameter, *retval;
			int standard;
		} subp;

		struct {	/* label */
			LGRAPH *gotolist, *stmt;
			int id;
		} label;

		struct {	/* pointer */
			IDENT *ident;
		} pointer;

		struct {	/* record */
			OBJECT *field;
		} record;

		struct {	/* subrange or enumeration */
			int	min, max;
		} subrange;

		struct {	/* subprogram parameter */
			int section;
		} parameter;

	} ob;
};
