summaryrefslogtreecommitdiffstats
path: root/gdb/eval.c
diff options
context:
space:
mode:
authorWu Zhou <woodzltc@cn.ibm.com>2005-09-20 06:25:34 +0000
committerWu Zhou <woodzltc@cn.ibm.com>2005-09-20 06:25:34 +0000
commit0b4e13251c935cb507296127d8af1c78fc627bd5 (patch)
tree2d9566d8763fb091f28846503023d46c7a5a899d /gdb/eval.c
parent096f7d00c1d4f1f28990b9546813d3be40589c13 (diff)
downloadppe42-binutils-0b4e13251c935cb507296127d8af1c78fc627bd5.tar.gz
ppe42-binutils-0b4e13251c935cb507296127d8af1c78fc627bd5.zip
* expression.h (enum exp_opcode): Add a new operator for F90
subrange. * f-lang.h (enum f90_range_type): New enumeration type to identify F90 subrange type. * f-exp.y (yyparse): Add support for parsing F90 subrange and change substring parsing to subrange parsing. * parse.c (operator_length_standard): Set the operator length and args number for OP_F90_RANGE. * eval.c (evaluate_subexp_standard): Add code to evaluate F90 array section and substring. (value_f90_subarray): New function to evaluate F90 array section. (evaluate_subexp_standard): Delete label op_f77_substr and its code because the logic is implemented by function value_f90_subarray now.
Diffstat (limited to 'gdb/eval.c')
-rw-r--r--gdb/eval.c58
1 files changed, 35 insertions, 23 deletions
diff --git a/gdb/eval.c b/gdb/eval.c
index 58e77d3348..302e5b88d3 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -378,6 +378,30 @@ init_array_element (struct value *array, struct value *element,
}
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 f90_range_type 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);
+}
+
+struct value *
evaluate_subexp_standard (struct type *expect_type,
struct expression *exp, int *pos,
enum noside noside)
@@ -1267,10 +1291,19 @@ evaluate_subexp_standard (struct type *expect_type,
switch (code)
{
case TYPE_CODE_ARRAY:
- goto multi_f77_subscript;
+ if (exp->elts[*pos].opcode == OP_F90_RANGE)
+ return value_f90_subarray (arg1, exp, pos, noside);
+ else
+ goto multi_f77_subscript;
case TYPE_CODE_STRING:
- goto op_f77_substr;
+ if (exp->elts[*pos].opcode == OP_F90_RANGE)
+ return value_f90_subarray (arg1, exp, pos, noside);
+ else
+ {
+ arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
+ return value_subscript (arg1, arg2);
+ }
case TYPE_CODE_PTR:
case TYPE_CODE_FUNC:
@@ -1289,27 +1322,6 @@ evaluate_subexp_standard (struct type *expect_type,
error (_("Cannot perform substring on this type"));
}
- op_f77_substr:
- /* We have a substring operation on our hands here,
- let us get the string we will be dealing with */
-
- /* Now evaluate the 'from' and 'to' */
-
- arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
-
- if (nargs < 2)
- return value_subscript (arg1, arg2);
-
- arg3 = evaluate_subexp_with_coercion (exp, pos, noside);
-
- if (noside == EVAL_SKIP)
- goto nosideret;
-
- tem2 = value_as_long (arg2);
- tem3 = value_as_long (arg3);
-
- return value_slice (arg1, tem2, tem3 - tem2 + 1);
-
case OP_COMPLEX:
/* We have a complex number, There should be 2 floating
point numbers that compose it */
OpenPOWER on IntegriCloud