/*
 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
 * See the copyright notice in the ACK home directory, in the file "Copyright".
 */
/* $Header$ */
/* TYPE DESCRIPTOR */

#include	"nobitfield.h"
#include	"dbsymtab.h"

struct type	{
	struct type *next;	/* used for ARRAY and for qualifiers */
	short tp_fund;		/* fundamental type */
	char tp_unsigned;
	char tp_typequal;	/* type qualifier */
	int tp_align;
	arith tp_size;		/* -1 if declared but not defined */
	struct type *tp_pointer;	/* to POINTER */
	struct type *tp_array;		/* to ARRAY */
#ifdef DBSYMTAB
	int tp_dbindex;
#endif
#if 0
/* This field is not needed now; see comment in function_of() routine. */
	struct type *tp_function;	/* to FUNCTION */
#endif
	union {
	    struct {
		struct idf *tp__idf;	/* name of STRUCT, UNION or ENUM */
		struct sdef *tp__sdef;	/* to first selector */
	    } tp_istagged;		/* used with STRUCT, UNION & ENUM */
	    struct {
		/* tp__up: from FIELD, POINTER, ARRAY or FUNCTION to fund. */
		struct type *tp__up;
		union {
		    arith tp__nel;	/* # of elements for array */
		    /* tp__field: field descriptor if fund == FIELD */
		    struct field *tp__field;
		    struct {
			/* prototype list (pseudoproto for old_style def) */
			struct proto *tp__proto;
			struct proto *tp__pseudoproto;
		    } tp_isfunc;
		} tp_f;		/* FIELD or FUNCTION */
	    } tp_nottagged;	/* used with POINTER, FIELD, ARRAY & FUNCTION */
	} tp_union;
};

#define tp_idf		tp_union.tp_istagged.tp__idf
#define tp_sdef		tp_union.tp_istagged.tp__sdef
#define tp_up		tp_union.tp_nottagged.tp__up
#define tp_field	tp_union.tp_nottagged.tp_f.tp__field
#define tp_nel		tp_union.tp_nottagged.tp_f.tp__nel
#define tp_proto	tp_union.tp_nottagged.tp_f.tp_isfunc.tp__proto
#define tp_pseudoproto	tp_union.tp_nottagged.tp_f.tp_isfunc.tp__pseudoproto

/*	Type qualifiers. Note: TQ_VOLATILE and TQ_CONST can be
	'ored' to specify: extern const volatile int a;
*/
#define	TQ_VOLATILE	0x01
#define	TQ_CONST	0x02

extern struct type
	*create_type(), *standard_type(), *construct_type(), *pointer_to(),
	*array_of(), *function_of(), *promoted_type();

#ifndef NOBITFIELD
extern struct type *field_of();
#endif /* NOBITFIELD */

extern struct type
	*schar_type, *uchar_type,
	*short_type, *ushort_type,
	*word_type, *uword_type,
	*int_type, *uint_type,
	*long_type, *ulong_type,
	*float_type, *double_type, *lngdbl_type,
	*void_type,
	*string_type, *funint_type, *error_type;

extern struct type *pa_type;	/* type.c	*/

extern arith size_of_type(), align();

/* ALLOCDEF "type" 50 */
