26f096f9e5
* bad.c (_ffebad_message_, ffebad_string_, ffebad_message_, ffebad_bufputs_, ffebad_bufputs_, ffebad_start_, ffebad_string, ffebad_finish): Const-ify a char*. * bld.c (ffebld_op_string_, ffebld_op_string): Likewise. * bld.h (ffebld_op_string): Likewise. * com.c (ffecom_arglist_expr_, ffecom_build_f2c_string_, ffecom_debug_kludge_, ffecom_f2c_make_type_, ffecom_get_appended_identifier_, ffecom_get_identifier_, ffecom_gfrt_args_): Likewise. (ffecom_convert_narrow_, ffecom_convert_widen_): Add prototype. (builtin_function, ffecom_gfrt_name_, ffecom_gfrt_argstring_, ffecom_arglist_expr_, ffecom_build_f2c_string_, ffecom_debug_kludge_, ffecom_f2c_make_type_, ffecom_get_appended_identifier_, ffecom_get_external_identifier_, ffecom_get_identifier_, ffecom_decl_field, ffecom_get_invented_identifier, lang_print_error_function, skip_redundant_dir_prefix, read_name_map, print_containing_files): Const-ify a char*. (savestring): Remove, use `xstrdup' instead. * com.h (ffecom_decl_field, ffecom_get_invented_identifier): Const-ify a char*. * data.c (ffebld, ffedata_gather_): Make explicitly static. * expr.c (ffeexpr_isdigits_, ffeexpr_percent_, ffeexpr_reduced_concatenate_, ffeexpr_nil_real_, ffeexpr_nil_number_, ffeexpr_nil_number_period_, ffeexpr_nil_number_real_, ffeexpr_token_real_, ffeexpr_token_number_, ffeexpr_token_number_period_, ffeexpr_token_number_real_): Const-ify a char*. * fini.c (xspaces): Likewise. * global.c (ffeglobal_type_string_): Likewise. (ffeglobal_drive): Protoize. (ffeglobal_proc_def_arg): Const-ify a char*. * global.h (ffeglobal_drive): Protoize. (ffeglobal_proc_def_arg): Const-ify a char*. * implic.c (ffeimplic_none, ffeimplic_peek_symbol_type): Likewise. * implic.h (ffeimplic_peek_symbol_type): Likewise. * info.c (ffeinfo_basictype_string_, ffeinfo_kind_message_, ffeinfo_kind_string_, ffeinfo_kindtype_string_, ffeinfo_where_string_, ffeinfo_basictype_string, ffeinfo_kind_message, ffeinfo_kind_string, ffeinfo_kindtype_string, ffeinfo_where_string): Likewise. * info.h (ffeinfo_basictype_string, ffeinfo_kind_message, ffeinfo_kind_string, ffeinfo_kindtype_string, ffeinfo_where_string): Likewise. * intrin.c (_ffeintrin_name_, _ffeintrin_gen_, _ffeintrin_spec_, _ffeintrin_imp_, ffeintrin_check_, ffeintrin_cmp_name_, ffeintrin_fulfill_specific, ffeintrin_init_0, ffeintrin_is_actualarg, ffeintrin_is_intrinsic, ffeintrin_name_generic, ffeintrin_name_implementation, ffeintrin_name_specific): Likewise. * intrin.h (ffeintrin_is_intrinsic, ffeintrin_name_generic, ffeintrin_name_implementation, ffeintrin_name_specific): Likewise. * lex.c (ffelex_type_string_, ffelex_token_new_character, ffelex_token_new_name, ffelex_token_new_names, ffelex_token_new_number): Likewise. * lex.h (ffelex_token_new_character, ffelex_token_new_name, ffelex_token_new_names, ffelex_token_new_number): Likewise. * malloc.c (malloc_types_, malloc_pool_new, malloc_new_inpool_, malloc_new_zinpool_): Likewise. * malloc.h (malloc_new_inpool_, malloc_new_zinpool_, malloc_pool_new): Likewise. * name.c (ffename_space_drive_global, ffename_space_drive_symbol): Protoize. * name.h (ffename_space_drive_global, ffename_space_drive_symbol): Likewise. * symbol.c (ffesymbol_state_name_, ffesymbol_attr_name_, ffesymbol_attrs_string): Const-ify a char*. (ffesymbol_drive, ffesymbol_drive_sfnames): Protoize. (ffesymbol_state_string): Const-ify a char*. * symbol.h (ffesymbol_attrs_string): Likewise. (ffesymbol_drive, ffesymbol_drive_sfnames): Protoize. (ffesymbol_state_string): Const-ify a char*. * target.c (ffetarget_layout): Likewise. * target.h (ffetarget_layout): Likewise. From-SVN: r26013
305 lines
7.2 KiB
C
305 lines
7.2 KiB
C
/* info.c -- Implementation File (module.c template V1.0)
|
||
Copyright (C) 1995 Free Software Foundation, Inc.
|
||
Contributed by James Craig Burley.
|
||
|
||
This file is part of GNU Fortran.
|
||
|
||
GNU Fortran 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.
|
||
|
||
GNU Fortran 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 GNU Fortran; see the file COPYING. If not, write to
|
||
the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||
02111-1307, USA.
|
||
|
||
Related Modules:
|
||
None
|
||
|
||
Description:
|
||
An abstraction for information maintained on a per-operator and per-
|
||
operand basis in expression trees.
|
||
|
||
Modifications:
|
||
30-Aug-90 JCB 2.0
|
||
Extensive rewrite for new cleaner approach.
|
||
*/
|
||
|
||
/* Include files. */
|
||
|
||
#include "proj.h"
|
||
#include "info.h"
|
||
#include "target.h"
|
||
#include "type.h"
|
||
|
||
/* Externals defined here. */
|
||
|
||
|
||
/* Simple definitions and enumerations. */
|
||
|
||
|
||
/* Internal typedefs. */
|
||
|
||
|
||
/* Private include files. */
|
||
|
||
|
||
/* Internal structure definitions. */
|
||
|
||
|
||
/* Static objects accessed by functions in this module. */
|
||
|
||
static const char *ffeinfo_basictype_string_[]
|
||
=
|
||
{
|
||
#define FFEINFO_BASICTYPE(KWD,LNAM,SNAM) SNAM,
|
||
#include "info-b.def"
|
||
#undef FFEINFO_BASICTYPE
|
||
};
|
||
static const char *ffeinfo_kind_message_[]
|
||
=
|
||
{
|
||
#define FFEINFO_KIND(KWD,LNAM,SNAM) LNAM,
|
||
#include "info-k.def"
|
||
#undef FFEINFO_KIND
|
||
};
|
||
static const char *ffeinfo_kind_string_[]
|
||
=
|
||
{
|
||
#define FFEINFO_KIND(KWD,LNAM,SNAM) SNAM,
|
||
#include "info-k.def"
|
||
#undef FFEINFO_KIND
|
||
};
|
||
static ffeinfoBasictype ffeinfo_combine_[FFEINFO_basictype][FFEINFO_basictype];
|
||
static const char *ffeinfo_kindtype_string_[]
|
||
=
|
||
{
|
||
"",
|
||
"1",
|
||
"2",
|
||
"3",
|
||
"4",
|
||
"5",
|
||
"6",
|
||
"7",
|
||
"8",
|
||
"*",
|
||
};
|
||
static const char *ffeinfo_where_string_[]
|
||
=
|
||
{
|
||
#define FFEINFO_WHERE(KWD,LNAM,SNAM) SNAM,
|
||
#include "info-w.def"
|
||
#undef FFEINFO_WHERE
|
||
};
|
||
static ffetype ffeinfo_types_[FFEINFO_basictype][FFEINFO_kindtype]
|
||
= { { NULL } };
|
||
|
||
/* Static functions (internal). */
|
||
|
||
|
||
/* Internal macros. */
|
||
|
||
|
||
/* ffeinfo_basictype_combine -- Combine two basictypes into highest rank type
|
||
|
||
ffeinfoBasictype i, j, k;
|
||
k = ffeinfo_basictype_combine(i,j);
|
||
|
||
Returns a type based on "standard" operation between two given types. */
|
||
|
||
ffeinfoBasictype
|
||
ffeinfo_basictype_combine (ffeinfoBasictype l, ffeinfoBasictype r)
|
||
{
|
||
assert (l < FFEINFO_basictype);
|
||
assert (r < FFEINFO_basictype);
|
||
return ffeinfo_combine_[l][r];
|
||
}
|
||
|
||
/* ffeinfo_basictype_string -- Return tiny string showing the basictype
|
||
|
||
ffeinfoBasictype i;
|
||
printf("%s",ffeinfo_basictype_string(dt));
|
||
|
||
Returns the string based on the basic type. */
|
||
|
||
const char *
|
||
ffeinfo_basictype_string (ffeinfoBasictype basictype)
|
||
{
|
||
if (basictype >= ARRAY_SIZE (ffeinfo_basictype_string_))
|
||
return "?\?\?";
|
||
return ffeinfo_basictype_string_[basictype];
|
||
}
|
||
|
||
/* ffeinfo_init_0 -- Initialize
|
||
|
||
ffeinfo_init_0(); */
|
||
|
||
void
|
||
ffeinfo_init_0 ()
|
||
{
|
||
ffeinfoBasictype i;
|
||
ffeinfoBasictype j;
|
||
|
||
assert (FFEINFO_basictype == ARRAY_SIZE (ffeinfo_basictype_string_));
|
||
assert (FFEINFO_kind == ARRAY_SIZE (ffeinfo_kind_message_));
|
||
assert (FFEINFO_kind == ARRAY_SIZE (ffeinfo_kind_string_));
|
||
assert (FFEINFO_kindtype == ARRAY_SIZE (ffeinfo_kindtype_string_));
|
||
assert (FFEINFO_where == ARRAY_SIZE (ffeinfo_where_string_));
|
||
|
||
/* Make array that, given two basic types, produces resulting basic type. */
|
||
|
||
for (i = 0; i < FFEINFO_basictype; ++i)
|
||
for (j = 0; j < FFEINFO_basictype; ++j)
|
||
if ((i == FFEINFO_basictypeANY) || (j == FFEINFO_basictypeANY))
|
||
ffeinfo_combine_[i][j] = FFEINFO_basictypeANY;
|
||
else
|
||
ffeinfo_combine_[i][j] = FFEINFO_basictypeNONE;
|
||
|
||
#define same(bt) ffeinfo_combine_[bt][bt] = bt
|
||
#define use2(bt1,bt2) ffeinfo_combine_[bt1][bt2] \
|
||
= ffeinfo_combine_[bt2][bt1] = bt2
|
||
|
||
same (FFEINFO_basictypeINTEGER);
|
||
same (FFEINFO_basictypeLOGICAL);
|
||
same (FFEINFO_basictypeREAL);
|
||
same (FFEINFO_basictypeCOMPLEX);
|
||
same (FFEINFO_basictypeCHARACTER);
|
||
use2 (FFEINFO_basictypeINTEGER, FFEINFO_basictypeREAL);
|
||
use2 (FFEINFO_basictypeINTEGER, FFEINFO_basictypeCOMPLEX);
|
||
use2 (FFEINFO_basictypeREAL, FFEINFO_basictypeCOMPLEX);
|
||
|
||
#undef same
|
||
#undef use2
|
||
}
|
||
|
||
/* ffeinfo_kind_message -- Return helpful string showing the kind
|
||
|
||
ffeinfoKind kind;
|
||
printf("%s",ffeinfo_kind_message(kind));
|
||
|
||
Returns the string based on the kind. */
|
||
|
||
const char *
|
||
ffeinfo_kind_message (ffeinfoKind kind)
|
||
{
|
||
if (kind >= ARRAY_SIZE (ffeinfo_kind_message_))
|
||
return "?\?\?";
|
||
return ffeinfo_kind_message_[kind];
|
||
}
|
||
|
||
/* ffeinfo_kind_string -- Return tiny string showing the kind
|
||
|
||
ffeinfoKind kind;
|
||
printf("%s",ffeinfo_kind_string(kind));
|
||
|
||
Returns the string based on the kind. */
|
||
|
||
const char *
|
||
ffeinfo_kind_string (ffeinfoKind kind)
|
||
{
|
||
if (kind >= ARRAY_SIZE (ffeinfo_kind_string_))
|
||
return "?\?\?";
|
||
return ffeinfo_kind_string_[kind];
|
||
}
|
||
|
||
ffeinfoKindtype
|
||
ffeinfo_kindtype_max(ffeinfoBasictype bt,
|
||
ffeinfoKindtype k1,
|
||
ffeinfoKindtype k2)
|
||
{
|
||
if ((bt == FFEINFO_basictypeANY)
|
||
|| (k1 == FFEINFO_kindtypeANY)
|
||
|| (k2 == FFEINFO_kindtypeANY))
|
||
return FFEINFO_kindtypeANY;
|
||
|
||
if (ffetype_size (ffeinfo_types_[bt][k1])
|
||
> ffetype_size (ffeinfo_types_[bt][k2]))
|
||
return k1;
|
||
return k2;
|
||
}
|
||
|
||
/* ffeinfo_kindtype_string -- Return tiny string showing the kind type
|
||
|
||
ffeinfoKindtype kind_type;
|
||
printf("%s",ffeinfo_kindtype_string(kind));
|
||
|
||
Returns the string based on the kind type. */
|
||
|
||
const char *
|
||
ffeinfo_kindtype_string (ffeinfoKindtype kind_type)
|
||
{
|
||
if (kind_type >= ARRAY_SIZE (ffeinfo_kindtype_string_))
|
||
return "?\?\?";
|
||
return ffeinfo_kindtype_string_[kind_type];
|
||
}
|
||
|
||
void
|
||
ffeinfo_set_type (ffeinfoBasictype basictype, ffeinfoKindtype kindtype,
|
||
ffetype type)
|
||
{
|
||
assert (basictype < FFEINFO_basictype);
|
||
assert (kindtype < FFEINFO_kindtype);
|
||
assert (ffeinfo_types_[basictype][kindtype] == NULL);
|
||
|
||
ffeinfo_types_[basictype][kindtype] = type;
|
||
}
|
||
|
||
ffetype
|
||
ffeinfo_type (ffeinfoBasictype basictype, ffeinfoKindtype kindtype)
|
||
{
|
||
assert (basictype < FFEINFO_basictype);
|
||
assert (kindtype < FFEINFO_kindtype);
|
||
|
||
return ffeinfo_types_[basictype][kindtype];
|
||
}
|
||
|
||
/* ffeinfo_where_string -- Return tiny string showing the where
|
||
|
||
ffeinfoWhere where;
|
||
printf("%s",ffeinfo_where_string(where));
|
||
|
||
Returns the string based on the where. */
|
||
|
||
const char *
|
||
ffeinfo_where_string (ffeinfoWhere where)
|
||
{
|
||
if (where >= ARRAY_SIZE (ffeinfo_where_string_))
|
||
return "?\?\?";
|
||
return ffeinfo_where_string_[where];
|
||
}
|
||
|
||
/* ffeinfo_new -- Return object representing datatype, kind, and where info
|
||
|
||
ffeinfo i;
|
||
i = ffeinfo_new(FFEINFO_datatypeINTEGER,FFEINFO_kindSCALAR,
|
||
FFEINFO_whereLOCAL);
|
||
|
||
Returns the string based on the data type. */
|
||
|
||
#ifndef __GNUC__
|
||
ffeinfo
|
||
ffeinfo_new (ffeinfoBasictype basictype, ffeinfoKindtype kindtype,
|
||
ffeinfoRank rank, ffeinfoKind kind, ffeinfoWhere where,
|
||
ffetargetCharacterSize size)
|
||
{
|
||
ffeinfo i;
|
||
|
||
i.basictype = basictype;
|
||
i.kindtype = kindtype;
|
||
i.rank = rank;
|
||
i.size = size;
|
||
i.kind = kind;
|
||
i.where = where;
|
||
i.size = size;
|
||
|
||
return i;
|
||
}
|
||
#endif
|