aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbtypes.c
diff options
context:
space:
mode:
authorStan Shebs <shebs@codesourcery.com>1994-08-19 21:59:05 +0000
committerStan Shebs <shebs@codesourcery.com>1994-08-19 21:59:05 +0000
commita91a61923d82c39ebeb9971635b76c7da494cab4 (patch)
tree5d26199b5455ca2369b432d008da29521e861908 /gdb/gdbtypes.c
parentf3806e3b6ceead276a3acba85ff944fde6668e39 (diff)
downloadgdb-a91a61923d82c39ebeb9971635b76c7da494cab4.zip
gdb-a91a61923d82c39ebeb9971635b76c7da494cab4.tar.gz
gdb-a91a61923d82c39ebeb9971635b76c7da494cab4.tar.bz2
Initial Fortran language support, adapted from work by Farooq Butt
(fmbutt@engage.sps.mot.com). * Makefile.in: Add Fortran-related files and dependencies. * defs.h (language_fortran): New language enum. * language.h (_LANG_fortran): Define. (MAX_FORTRAN_DIMS): Define. * expression.h: Reformat to standard. (MULTI_F77_SUBSCRIPT, OP_F77_UNDETERMINED_ARGLIST, OP_F77_LITERAL_COMPLEX, OP_F77_SUBSTR): New expression opcodes. * gdbtypes.h (TYPE_CODE_COMPLEX, TYPE_CODE_LITERAL_COMPLEX, TYPE_CODE_LITERAL_STRING): New type codes. (type): New fields upper_bound_type and lower_bound_type. (TYPE_ARRAY_UPPER_BOUND_TYPE, TYPE_ARRAY_LOWER_BOUND_TYPE, TYPE_ARRAY_UPPER_BOUND_VALUE, TYPE_ARRAY_LOWER_BOUND_VALUE): New macros. (builtin_type_f_character, etc): Declare. * value.h (VALUE_LITERAL_DATA, VALUE_SUBSTRING_START): Define. * f-exp.y: New file, Fortran expression grammar. * f-lang.c: New file, Fortran language support functions. * f-lang.h: New file, Fortran language support declarations. * f-typeprint.c: New file, Fortran type printing. * f-valprint.c: New file, Fortran value printing. * eval.c (evaluate_subexp): Add code for new expression opcodes, fix wording of error message. * gdbtypes.c (f77_create_literal_complex_type, f77_create_literal_string_type): New functions. * language.c (set_language_command): Add Fortran info. (calc_f77_array_dims): New function. * parse.c (length_of_subexp, prefixify_subexp): Add cases for new expression opcodes. * symfile.c (deduce_language_from_filename): Recognize .f and .F as Fortran source files. * valops.c (f77_value_literal_string, f77_value_substring, f77_value_literal_complex): New functions.
Diffstat (limited to 'gdb/gdbtypes.c')
-rw-r--r--gdb/gdbtypes.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index b891237..a87d9a1 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -487,6 +487,86 @@ create_set_type (result_type, domain_type)
return (result_type);
}
+/* Create an F77 literal complex type composed of the two types we are
+ given as arguments. */
+
+struct type *
+f77_create_literal_complex_type (type_arg1, type_arg2)
+ struct type *type_arg1;
+ struct type *type_arg2;
+{
+ struct type *result;
+
+ /* First make sure that the 2 components of the complex
+ number both have the same type */
+
+ if (TYPE_CODE (type_arg1) != TYPE_CODE (type_arg2))
+ error ("Both components of a F77 complex number must have the same type!");
+
+ result = alloc_type (TYPE_OBJFILE (type_arg1));
+
+ TYPE_CODE (result) = TYPE_CODE_LITERAL_COMPLEX;
+ TYPE_LENGTH (result) = TYPE_LENGTH(type_arg1) * 2;
+
+ return result;
+}
+
+/* Create a F77 LITERAL string type supplied by the user from the keyboard.
+
+ Elements will be of type ELEMENT_TYPE, the indices will be of type
+ RANGE_TYPE.
+
+ FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make
+ sure it is TYPE_CODE_UNDEF before we bash it into an array type?
+
+ This is a total clone of create_array_type() except that there are
+ a few simplyfing assumptions (e.g all bound types are simple). */
+
+struct type *
+f77_create_literal_string_type (result_type, range_type)
+ struct type *result_type;
+ struct type *range_type;
+{
+ int low_bound;
+ int high_bound;
+
+ if (TYPE_CODE (range_type) != TYPE_CODE_RANGE)
+ {
+ /* FIXME: We only handle range types at the moment. Complain and
+ create a dummy range type to use. */
+ warning ("internal error: array index type must be a range type");
+ range_type = lookup_fundamental_type (TYPE_OBJFILE (range_type),
+ FT_INTEGER);
+ range_type = create_range_type ((struct type *) NULL, range_type, 0, 0);
+ }
+ if (result_type == NULL)
+ result_type = alloc_type (TYPE_OBJFILE (range_type));
+ TYPE_CODE (result_type) = TYPE_CODE_LITERAL_STRING;
+ TYPE_TARGET_TYPE (result_type) = builtin_type_f_character;
+ low_bound = TYPE_FIELD_BITPOS (range_type, 0);
+ high_bound = TYPE_FIELD_BITPOS (range_type, 1);
+
+ /* Safely can assume that all bound types are simple */
+
+ TYPE_LENGTH (result_type) =
+ TYPE_LENGTH (builtin_type_f_character) * (high_bound - low_bound + 1);
+
+ TYPE_NFIELDS (result_type) = 1;
+ TYPE_FIELDS (result_type) =
+ (struct field *) TYPE_ALLOC (result_type, sizeof (struct field));
+ memset (TYPE_FIELDS (result_type), 0, sizeof (struct field));
+ TYPE_FIELD_TYPE (result_type, 0) = range_type;
+ TYPE_VPTR_FIELDNO (result_type) = -1;
+
+ /* Remember that all literal strings in F77 are of the
+ character*N type. */
+
+ TYPE_ARRAY_LOWER_BOUND_TYPE (result_type) = BOUND_SIMPLE;
+ TYPE_ARRAY_UPPER_BOUND_TYPE (result_type) = BOUND_SIMPLE;
+
+ return result_type;
+}
+
/* Smash TYPE to be a type of members of DOMAIN with type TO_TYPE.
A MEMBER is a wierd thing -- it amounts to a typed offset into
a struct, e.g. "an int at offset 8". A MEMBER TYPE doesn't