
/* 
 * $Copyright:	$
 * Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990 
 * Sequent Computer Systems, Inc.   All rights reserved.
 *  
 * This software is furnished under a license and may be used
 * only in accordance with the terms of that license and with the
 * inclusion of the above copyright notice.   This software may not
 * be provided or otherwise made available to, or used by, any
 * other person.  No title to or ownership of the software is
 * hereby transferred.
 */

/*	Copyright (c) 1984 AT&T	*/
/*	  All Rights Reserved  	*/

/*	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T	*/
/*	The copyright notice above does not evidence any   	*/
/*	actual or intended publication of such source code.	*/
#ident "$Header: types.h 1.1 90/01/19 $@(#)types.h	1.1 89/12/01"
/*
 * Type tables description
 * The same table holds entries for
 *  types:
 *	- typedefs
 *	- system types
 *	- struct/union types
 *  type_decl_list (in a struct/union declaration)
 *  declarators with a list of values for indices
 *  replacements
 *  identifiers
 */

typedef struct typep {
  TYPEP ty_snext;
  char *ty_sname;
  char ty_stype;		/* type, type_dcl_list, declarator,...	*/
  union {
    struct {			/* attributes				*/
      TYPEP at_scl;		/*   class				*/
      TYPEP at_sty;		/*   type				*/
      long  at_soff;		/*   type offset			*/
      int   at_slen;		/*   type length			*/
    } at;
    struct {			/* identifier				*/
      TYPEP id_sat;		/*   attributes				*/
      TYPEP id_sde;		/*   declarator				*/
      int id_sflag;		/*   flag (used, defined, declared,...) */
      TYPEP id_sre;		/*   replacement list			*/
      TYPEP id_ec;		/*   extern decl. chaining list		*/
    } id;
    struct {			/* replacement list			*/
      char *re_sna;		/*   actual name			*/
      long re_soff;		/*   expr offset			*/
      int re_slen;		/*   expr len				*/
      long re_szero;		/*   position of zero for sizeof replace*/
      char *re_ssi;		/*   sizeof var name			*/
      char re_sflag;		/*   flag				*/
      int re_salen;		/*   table length			*/
      int re_snr;		/*   string number			*/
      TYPEP re_snext;		/*   next in list			*/
    } re;
    struct {			/* types				*/
      char ty_sflag;		/*   system, struct/union, typedef	*/
      union {
        int ty_ssys;		/*   system types			*/
        struct {		/*   struct/union			*/
          TYPEP ssu_tl; 	/*     declarator list			*/
          TYPEP ssu_ctl;	/*     current tl			*/
          TYPEP ssu_cdl;	/*     current dl			*/
          char ssu_fl;		/*     flag used by init		*/
        } su;
        struct {		/*   typedefs				*/
          TYPEP std_ty;		/*     attributes			*/
          TYPEP std_de;		/*     declarator			*/
        } td;
      } ty;
    } ty;
    struct {			/* class				*/
      int cl_sval;		/*   class name				*/
    } cl;
    struct {			/* type_dcl_list			*/
      TYPEP tl_sty;		/*   type				*/
      TYPEP tl_sdl;		/*   declarator_list			*/
      TYPEP tl_snext;		/*   next in list			*/
    } tl;
    struct {			/* declarator_list			*/
      TYPEP dl_sde;		/*   declarator				*/
      TYPEP dl_snext;		/*   next in list			*/
    } dl;
    struct {			/* declarator				*/
      char de_sflag;		/*   name, function, ptr, array, size	*/
      char de_sfl;		/*   flag used by init			*/
      int de_in_smax;		/*   maximum index value		*/
      int de_in_scur;		/*   current index value		*/
      long de_soff;		/*   offset of token 			*/
      int de_slen;		/*   len of token			*/
      TYPEP de_snext;		/*   next in list			*/
      TYPEP de_sty;		/*   ptr to type			*/
    } de;
    struct {			/* external defs chaining		*/
      long  ec_off;		/*    attribute offset			*/
      int   ec_len;		/*    attribute length			*/
      long  ec_a_off;		/*    declarator offset			*/
      int   ec_a_len;		/*    declarator length			*/
      bool  ec_typedef;		/*    is a typedef			*/
      TYPEP ec_next;
    } ec;
  } t;
} TYPET;

typedef struct {
  int ty_free;
  int ty_ntab;
  int ty_ltab;
  NAMETAB *ty_nam;
  TYPET **ty_tab;
  int ty_max;
} TYPETAB;

char *ty_name();
char ty_type();
TYPEP ty_next();
TYPEP at_cl();
TYPEP at_ty();
long at_off();
int at_len();
TYPEP id_at();
TYPEP id_de();
TYPEP id_ec();
int id_flag();
TYPEP id_re();
char *re_na();
long re_off();
int re_len();
long re_zero();
char re_flag();
int re_alen();
char *re_si();
TYPEP re_next();
int re_nr();
char ty_flag();
int ty_sys();
TYPEP su_tl();
TYPEP su_ctl();
TYPEP su_cdl();
char su_fl();
TYPEP td_ty();
TYPEP td_de();
int cl_val();
TYPEP tl_ty();
TYPEP tl_dl();
TYPEP tl_next();
TYPEP dl_de();
TYPEP dl_next();
char de_flag();
char de_fl();
int de_in_max();
int de_in_cur();
long de_off();
int de_len();
TYPEP de_next();
TYPEP de_ty();
long ec_off();
int ec_len();
long ec_a_off();
int ec_a_len();
bool ec_typedef();
TYPEP ec_next();

void ty_name_new();
void ty_type_new();
void ty_next_new();
void at_cl_new();
void at_ty_new();
void at_off_new();
void at_len_new();
void id_at_new();
void id_de_new();
void id_ec_new();
void id_flag_new();
void id_re_new();
void re_na_new();
void re_off_new();
void re_len_new();
void re_zero_new();
void re_flag_new();
void re_alen_new();
void re_si_new();
void re_next_new();
void re_nr_new();
void ty_flag_new();
void ty_sys_new();
void su_tl_new();
void su_ctl_new();
void su_cdl_new();
void su_fl_new();
void td_ty_new();
void td_de_new();
void cl_val_new();
void tl_ty_new();
void tl_dl_new();
void tl_next_new();
void dl_de_new();
void dl_next_new();
void de_flag_new();
void de_fl_new();
void de_in_max_new();
void de_in_cur_new();
void de_off_new();
void de_len_new();
void de_next_new();
void de_ty_new();
void ec_off_new();
void ec_len_new();
void ec_a_off_new();
void ec_a_len_new();
void ec_typedef_new();
void ec_next_new();
void ic_ec_new();

/*
 * type table nodes types
 */
#define NODE_TYPE	0
#define NODE_T_DCL_LIST	1
#define NODE_DECL_LIST	2
#define NODE_DECL	3
#define NODE_CLASS	4
#define NODE_IDENT	5
#define NODE_ATTR	6
#define NODE_REPLACE	7
#define NODE_CHAIN	8

/*
 * Subtypes for NODE_TYPE
 */
#define TYPE_SYSTEM	0
#define TYPE_STRUCT	1
#define TYPE_UNION	2
#define TYPE_TYPEDEF	3
#define TYPE_ENUM	4

/*
 * Subtypes for NODE_DECL
 */
#define DECL_NAME	0
#define DECL_FUNC	1
#define DECL_PTR	2
#define DECL_ARRAY	3
#define DECL_SIZE	4
#define DECL_FNAME	5

/*
 * Flag for NODE_IDENT
 */
#define IDENT_USE	1
#define IDENT_DEF	2
#define IDENT_ARRAY	4
#define IDENT_FUNC	8
#define IDENT_STATIC	16
#define IDENT_EXTERN	32
#define IDENT_USIZEOF	64
#define IDENT_STRINIT	128
#define IDENT_STRUSE	256
#define IDENT_ENUM	512

/*
 * Subtypes for NODE_REPLACE
 */
#define REPL_SCALAR	0
#define REPL_ARRAY	1
#define REPL_SIZE	2

TYPETAB *ty_creat();
void types_creat();
void types_free();
void types_push();
void types_pop();
void types_rewind();
TYPEP types_next();

TYPEP types_new();
TYPEP g_types_new();
TYPEP types_systype();
TYPEP types_class();
TYPEP types_check();
TYPEP tdl_locate();
TYPEP ident_isin();
TYPEP g_ident_isin();
TYPEP a_ident_isin();
bool is_global();
bool is_type_null();
