
/* 
 * $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: symtab.c 1.1 90/01/19 $@(#)symtab.c	1.1 89/12/01"
#include "xs.h"
#include "names.h"
#include "stack.h"
#include "types.h"
#include "anal.h"
#include "xdefs.h"
#include "catalog.h"

static char loc_buf[BUFSIZ];

/*
 * Output the symbol table to the messages files
 * Output global symbols only
 * U : Used but undefined
 * D : Defined
 * I : Defined Initialized strings (for unsized arrays only)
 * V : Undefined Initialized strings (for unsized arrays only)
 * F : Additional function name
 * Side effect : Perform replaces on undefined unsized arrays which are
 * 		 listed in the desc_file as strings.
 */
do_symtab()
{
  TYPEP tptr;
  
  types_rewind();

  sprintf(loc_buf, "SYMBOL TABLE");
  msg_comment(fd_msg, loc_buf);
  sprintf(loc_buf, "F %s", func_name);
  msg_comment(fd_msg, loc_buf);
  while (!is_null_type(tptr = types_next())){
    if (id_flag(tptr) & IDENT_STATIC)
      continue;
    else if (id_flag(tptr) & IDENT_ARRAY &&
                id_flag(tptr) & (IDENT_STRINIT|IDENT_STRUSE)){
      sprintf(loc_buf, "I %s", ty_name(tptr));
      msg_comment(fd_msg, loc_buf);
    } else if (id_flag(tptr) & IDENT_DEF){
      sprintf(loc_buf, "D %s", ty_name(tptr));
      msg_comment(fd_msg, loc_buf);
    } else if (id_flag(tptr) & IDENT_USE && !(id_flag(tptr) & IDENT_ENUM)){
      if (id_flag(tptr) & IDENT_ARRAY && isin_desc(ty_name(tptr))){
        ec_replace(tptr);
        sprintf(loc_buf, "V %s", ty_name(tptr));
      } else
        sprintf(loc_buf, "U %s", ty_name(tptr));
      msg_comment(fd_msg, loc_buf);
    }
  }
}
