/*

  Copyright (C) 2000, 2001 Silicon Graphics, Inc.  All Rights Reserved.

   Path64 is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2, or (at your option)
   any later version.

   Path64 is distributed in the hope that it will be useful, but WITHOUT
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
   License for more details.

   You should have received a copy of the GNU General Public License
   along with Path64; see the file COPYING.  If not, write to the Free
   Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
   02110-1301, USA.

   Special thanks goes to SGI for their continued support to open source

*/


#ifndef ty2c_INCLUDED
#define ty2c_INCLUDED
/* ====================================================================
 * ====================================================================
 *
 * Module: ty2c.c
 * $Revision$
 * $Date$
 * $Author$
 * $Source$
 *
 * Revision history:
 *  07-Oct-94 - Original Version
 *
 * Description:
 *
 *    For complex types we use the Complex_Type, Double_Complex_Type,
 *    Quad_Complex_Type, Complex_Type_Split and Complex_Type_Inverted
 *    ... all of which is defined in "stab.h".
 *
 *    TY2C_initialize:
 *    TY2C_finalize:
 *       This will initialize and terminate usage of this module().
 *       Initialization sets any internal state used in tokenizing
 *       types, and will also write to file a set of predefined
 *       typedef declarations, including the complex types defined
 *       in stab.h.
 *
 *    TY2C_translate:
 *       Add a C language type corresponding to the given TY node
 *       into the token_buffer, assuming the TOKEN_BUFFER already
 *       holds a construct to be declared of this type.  The type
 *       may surround the current contents of the given TOKEN_BUFFER
 *       as though these contents where declared to be of the given
 *       type; i.e. for an array or function type.  The qualifiers
 *       are not written out for the top-level ty, but will be written
 *       for component tys.
 *
 *    TY2C_translate_qualified:
 *       Same as TY2C_translate, but the qualifiers of the top-level
 *       ty will be written out.
 *
 *    TY2C_get_field_info:
 *       Return information about a field within the given struct/union 
 *       type at the given offset and of the given type or mtype.  If a
 *       field of the given TY is found, it will be selected; otherwise
 *       the first field of the given mtype will be selected.  If 
 *       no appropriate field is found found_fld will be NULL and
 *       the returned TOKEN_BUFFER is uninitialized; otherwise, the 
 *       field and a token buffer denoting the field selection
 *       will be returned.  Note that we can use this routine to
 *       search for a field of a given TY only, by setting the mtype
 *       to MTYPE_V.
 *
 *    TY2C_builtin:
 *       Returns TRUE if the given ty is given a builtin special name
 *       in whirl2c (i.e. it is a type not to be declared).
 *
 *    TY2C_Complex_Realpart_Name:
 *    TY2C_Complex_Imagpart_Name:
 *       Denotes the names of the real and imaginary components in
 *       a complex (struct) type.
 *
 * ====================================================================
 * ====================================================================
 */

extern void TY2C_initialize(CONTEXT context);
extern void TY2C_finalize(void);

extern void TY2C_translate(TOKEN_BUFFER decl_tokens,
                           TY_IDX ty,
                           CONTEXT context);
extern void TY2C_translate_unqualified(TOKEN_BUFFER decl_tokens, TY_IDX ty);

typedef struct TY2C_Fld_Info
{
   TOKEN_BUFFER select_tokens;
   FLD_HANDLE   found_fld;
} TY2C_FLD_INFO;

extern TY2C_FLD_INFO 
   TY2C_get_field_info(TY_IDX struct_ty,  /* base type */
		       TY_IDX field_ty,   /* preferred field type */
		       MTYPE  field_mty,  /* preferred field mtype */
		       INT64  offset);

extern BOOL TY2C_builtin(TY_IDX ty);

extern const char *TY2C_Complex_Realpart_Name;
extern const char *TY2C_Complex_Imagpart_Name;

#endif /* ty2c_INCLUDED */
