From: Tim Wiederhake <tim.wiederhake@intel.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 2/5] Fortran: Move value_f90_subarray.
Date: Mon, 11 Sep 2017 12:58:00 -0000 [thread overview]
Message-ID: <1505134663-29374-3-git-send-email-tim.wiederhake@intel.com> (raw)
In-Reply-To: <1505134663-29374-1-git-send-email-tim.wiederhake@intel.com>
2017-09-11 Tim Wiederhake <tim.wiederhake@intel.com>
gdb/ChangeLog:
* eval.c (Evaluate_subexp_standard): Use new function name.
(value_f90_subarray): Move ...
* f-lang.c (f90_value_subarray): ... here.
* f-lang.h (f90_value_subarray): New declaration.
---
gdb/eval.c | 30 ++----------------------------
gdb/f-lang.c | 27 +++++++++++++++++++++++++++
gdb/f-lang.h | 5 +++++
3 files changed, 34 insertions(+), 28 deletions(-)
diff --git a/gdb/eval.c b/gdb/eval.c
index 7a808a0..557ac02 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -384,32 +384,6 @@ init_array_element (struct value *array, struct value *element,
return index;
}
-static struct value *
-value_f90_subarray (struct value *array,
- struct expression *exp, int *pos, enum noside noside)
-{
- int pc = (*pos) + 1;
- LONGEST low_bound, high_bound;
- struct type *range = check_typedef (TYPE_INDEX_TYPE (value_type (array)));
- enum range_type range_type
- = (enum range_type) longest_to_int (exp->elts[pc].longconst);
-
- *pos += 3;
-
- if (range_type == LOW_BOUND_DEFAULT || range_type == BOTH_BOUND_DEFAULT)
- low_bound = TYPE_LOW_BOUND (range);
- else
- low_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside));
-
- if (range_type == HIGH_BOUND_DEFAULT || range_type == BOTH_BOUND_DEFAULT)
- high_bound = TYPE_HIGH_BOUND (range);
- else
- high_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside));
-
- return value_slice (array, low_bound, high_bound - low_bound + 1);
-}
-
-
/* Promote value ARG1 as appropriate before performing a unary operation
on this argument.
If the result is not appropriate for any particular language then it
@@ -1916,13 +1890,13 @@ evaluate_subexp_standard (struct type *expect_type,
{
case TYPE_CODE_ARRAY:
if (exp->elts[*pos].opcode == OP_RANGE)
- return value_f90_subarray (arg1, exp, pos, noside);
+ return f90_value_subarray (arg1, exp, pos, noside);
else
goto multi_f77_subscript;
case TYPE_CODE_STRING:
if (exp->elts[*pos].opcode == OP_RANGE)
- return value_f90_subarray (arg1, exp, pos, noside);
+ return f90_value_subarray (arg1, exp, pos, noside);
else
{
arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 77b759b..63caf65 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -386,3 +386,30 @@ f77_get_array_dims (const struct type *array_type)
return ndimen;
}
+
+/* See f-lang.h. */
+
+struct value *
+f90_value_subarray (struct value *array, struct expression *exp, int *pos,
+ enum noside noside)
+{
+ int pc = (*pos) + 1;
+ LONGEST low_bound, high_bound;
+ struct type *range = check_typedef (TYPE_INDEX_TYPE (value_type (array)));
+ enum range_type range_type
+ = (enum range_type) longest_to_int (exp->elts[pc].longconst);
+
+ *pos += 3;
+
+ if (range_type == LOW_BOUND_DEFAULT || range_type == BOTH_BOUND_DEFAULT)
+ low_bound = TYPE_LOW_BOUND (range);
+ else
+ low_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside));
+
+ if (range_type == HIGH_BOUND_DEFAULT || range_type == BOTH_BOUND_DEFAULT)
+ high_bound = TYPE_HIGH_BOUND (range);
+ else
+ high_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside));
+
+ return value_slice (array, low_bound, high_bound - low_bound + 1);
+}
diff --git a/gdb/f-lang.h b/gdb/f-lang.h
index cfe667b..013ea5e 100644
--- a/gdb/f-lang.h
+++ b/gdb/f-lang.h
@@ -59,6 +59,11 @@ extern void f77_get_dynamic_array_length (struct type *);
* the type of an array. */
extern int f77_get_array_dims (const struct type *array_type);
+/* Evaluates any subarray operation on Fortran arrays with at least one user
+ provided parameter. Expects the input ARRAY to be an array. */
+extern struct value *f90_value_subarray (struct value *array,
+ struct expression *exp,
+ int *pos, enum noside noside);
/* Fortran (F77) types */
--
2.7.4
next prev parent reply other threads:[~2017-09-11 12:58 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-11 12:58 [PATCH 0/5] Fortran: Array strides Tim Wiederhake
2017-09-11 12:58 ` [PATCH 4/5] Fortran: Change subrange enum to bit field Tim Wiederhake
2017-09-15 22:29 ` Simon Marchi
2017-09-11 12:58 ` [PATCH 1/5] Fortran: Move calc_f77_array_dims Tim Wiederhake
2017-09-15 20:22 ` Simon Marchi
2017-09-15 20:28 ` Simon Marchi
2017-09-11 12:58 ` [PATCH 5/5] Fortran: Enable parsing of stride parameter for subranges Tim Wiederhake
2017-09-11 12:58 ` Tim Wiederhake [this message]
2017-09-15 20:27 ` [PATCH 2/5] Fortran: Move value_f90_subarray Simon Marchi
2017-09-11 12:58 ` [PATCH 3/5] Fortran: Allow multi-dimensional subarrays Tim Wiederhake
2017-09-15 22:08 ` Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1505134663-29374-3-git-send-email-tim.wiederhake@intel.com \
--to=tim.wiederhake@intel.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox