1 /* Evaluate expressions for GDB.
2 Copyright 1986, 1987, 1989, 1991, 1992, 1993, 1994
3 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
26 #include "expression.h"
30 #include "language.h" /* For CAST_IS_CONVERSION */
31 #include "f-lang.h" /* for array bound stuff */
33 /* Values of NOSIDE argument to eval_subexp. */
38 EVAL_SKIP, /* Only effect is to increment pos. */
39 EVAL_AVOID_SIDE_EFFECTS /* Don't modify any variables or
40 call any functions. The value
41 returned will have the correct
42 type, and will have an
43 approximately correct lvalue
44 type (inaccuracy: anything that is
45 listed as being in a register in
46 the function in which it was
47 declared will be lval_register). */
50 /* Prototypes for local functions. */
52 static value_ptr evaluate_subexp_for_sizeof PARAMS ((struct expression *,
55 static value_ptr evaluate_subexp_with_coercion PARAMS ((struct expression *,
58 static value_ptr evaluate_subexp_for_address PARAMS ((struct expression *,
61 static value_ptr evaluate_subexp PARAMS ((struct type *, struct expression *,
65 /* Parse the string EXP as a C expression, evaluate it,
66 and return the result as a number. */
69 parse_and_eval_address (exp)
72 struct expression *expr = parse_expression (exp);
73 register CORE_ADDR addr;
74 register struct cleanup *old_chain =
75 make_cleanup (free_current_contents, &expr);
77 addr = value_as_pointer (evaluate_expression (expr));
78 do_cleanups (old_chain);
82 /* Like parse_and_eval_address but takes a pointer to a char * variable
83 and advanced that variable across the characters parsed. */
86 parse_and_eval_address_1 (expptr)
89 struct expression *expr = parse_exp_1 (expptr, (struct block *)0, 0);
90 register CORE_ADDR addr;
91 register struct cleanup *old_chain =
92 make_cleanup (free_current_contents, &expr);
94 addr = value_as_pointer (evaluate_expression (expr));
95 do_cleanups (old_chain);
103 struct expression *expr = parse_expression (exp);
104 register value_ptr val;
105 register struct cleanup *old_chain
106 = make_cleanup (free_current_contents, &expr);
108 val = evaluate_expression (expr);
109 do_cleanups (old_chain);
113 /* Parse up to a comma (or to a closeparen)
114 in the string EXPP as an expression, evaluate it, and return the value.
115 EXPP is advanced to point to the comma. */
118 parse_to_comma_and_eval (expp)
121 struct expression *expr = parse_exp_1 (expp, (struct block *) 0, 1);
122 register value_ptr val;
123 register struct cleanup *old_chain
124 = make_cleanup (free_current_contents, &expr);
126 val = evaluate_expression (expr);
127 do_cleanups (old_chain);
131 /* Evaluate an expression in internal prefix form
132 such as is constructed by parse.y.
134 See expression.h for info on the format of an expression. */
137 evaluate_expression (exp)
138 struct expression *exp;
141 return evaluate_subexp (NULL_TYPE, exp, &pc, EVAL_NORMAL);
144 /* Evaluate an expression, avoiding all memory references
145 and getting a value whose type alone is correct. */
149 struct expression *exp;
152 return evaluate_subexp (NULL_TYPE, exp, &pc, EVAL_AVOID_SIDE_EFFECTS);
155 /* Helper function called by evaluate_subexp to initialize a field
156 a structure from a tuple in Chill. This is recursive, to handle
157 more than one field name labels.
159 STRUCT_VAL is the structure value we are constructing.
160 (*FIELDNOP) is the field to set, if there is no label.
161 It is set to the field following this one.
162 EXP, POS, and NOSIDE are as for evaluate_subexp.
164 This function does not handle variant records. FIXME */
167 evaluate_labeled_field_init (struct_val, fieldnop, exp, pos, noside)
168 value_ptr struct_val;
170 register struct expression *exp;
174 int fieldno = *fieldnop;
178 struct type *struct_type = VALUE_TYPE (struct_val);
179 if (exp->elts[*pos].opcode == OP_LABELED)
182 char *name = &exp->elts[pc + 2].string;
183 int tem = longest_to_int (exp->elts[pc + 1].longconst);
184 (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
185 for (fieldno = 0; ; fieldno++)
187 if (fieldno >= TYPE_NFIELDS (struct_type))
188 error ("there is no field named %s", name);
189 if (STREQ (TYPE_FIELD_NAME (struct_type, fieldno), name))
193 val = evaluate_labeled_field_init (struct_val, fieldnop,
198 fieldno = (*fieldnop)++;
199 if (fieldno >= TYPE_NFIELDS (struct_type))
200 error ("too many initializers");
201 val = evaluate_subexp (TYPE_FIELD_TYPE (struct_type, fieldno),
205 /* Assign val to field fieldno. */
206 if (VALUE_TYPE (val) != TYPE_FIELD_TYPE (struct_type, fieldno))
207 val = value_cast (TYPE_FIELD_TYPE (struct_type, fieldno), val);
209 bitsize = TYPE_FIELD_BITSIZE (struct_type, fieldno);
210 bitpos = TYPE_FIELD_BITPOS (struct_type, fieldno);
211 addr = VALUE_CONTENTS (struct_val);
214 modify_field (addr, value_as_long (val),
215 bitpos % 8, bitsize);
217 memcpy (addr, VALUE_CONTENTS (val),
218 TYPE_LENGTH (VALUE_TYPE (val)));
220 value_assign (value_primitive_field (struct_val, 0, fieldno, struct_type),
227 evaluate_subexp (expect_type, exp, pos, noside)
228 struct type *expect_type;
229 register struct expression *exp;
235 register int pc, pc2 = 0, oldpos;
236 register value_ptr arg1 = NULL, arg2 = NULL, arg3;
240 struct symbol *tmp_symbol;
241 int upper, lower, retcode;
243 struct internalvar *var;
245 /* This expect_type crap should not be used for C. C expressions do
246 not have any notion of expected types, never has and (goddess
247 willing) never will. The C++ code uses it for some twisted
248 purpose (I haven't investigated but I suspect it just the usual
249 combination of Stroustrup figuring out some crazy language
250 feature and Tiemann figuring out some crazier way to try to
251 implement it). CHILL has the tuple stuff; I don't know enough
252 about CHILL to know whether expected types is the way to do it.
253 FORTRAN I don't know. */
254 if (exp->language_defn->la_language != language_cplus
255 && exp->language_defn->la_language != language_chill)
256 expect_type = NULL_TYPE;
259 op = exp->elts[pc].opcode;
264 tem = longest_to_int (exp->elts[pc + 2].longconst);
265 (*pos) += 4 + BYTES_TO_EXP_ELEM (tem + 1);
266 arg1 = value_struct_elt_for_reference (exp->elts[pc + 1].type,
268 exp->elts[pc + 1].type,
269 &exp->elts[pc + 3].string,
272 error ("There is no field named %s", &exp->elts[pc + 3].string);
277 return value_from_longest (exp->elts[pc + 1].type,
278 exp->elts[pc + 2].longconst);
282 return value_from_double (exp->elts[pc + 1].type,
283 exp->elts[pc + 2].doubleconst);
287 if (noside == EVAL_SKIP)
289 if (noside == EVAL_AVOID_SIDE_EFFECTS)
291 struct symbol * sym = exp->elts[pc + 2].symbol;
294 switch (SYMBOL_CLASS (sym))
298 case LOC_CONST_BYTES:
312 return value_zero (SYMBOL_TYPE (sym), lv);
315 return value_of_variable (exp->elts[pc + 2].symbol,
316 exp->elts[pc + 1].block);
321 access_value_history (longest_to_int (exp->elts[pc + 1].longconst));
325 return value_of_register (longest_to_int (exp->elts[pc + 1].longconst));
329 if (current_language->la_language == language_fortran)
330 return value_from_longest (builtin_type_f_logical_s2,
331 exp->elts[pc + 1].longconst);
333 return value_from_longest (builtin_type_chill_bool,
334 exp->elts[pc + 1].longconst);
338 return value_of_internalvar (exp->elts[pc + 1].internalvar);
341 tem = longest_to_int (exp->elts[pc + 1].longconst);
342 (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
343 if (noside == EVAL_SKIP)
345 return value_string (&exp->elts[pc + 2].string, tem);
348 tem = longest_to_int (exp->elts[pc + 1].longconst);
350 += 3 + BYTES_TO_EXP_ELEM ((tem + HOST_CHAR_BIT - 1) / HOST_CHAR_BIT);
351 if (noside == EVAL_SKIP)
353 return value_bitstring (&exp->elts[pc + 2].string, tem);
358 tem2 = longest_to_int (exp->elts[pc + 1].longconst);
359 tem3 = longest_to_int (exp->elts[pc + 2].longconst);
360 nargs = tem3 - tem2 + 1;
362 if (expect_type != NULL_TYPE && noside != EVAL_SKIP
363 && TYPE_CODE (expect_type) == TYPE_CODE_STRUCT)
365 value_ptr rec = allocate_value (expect_type);
367 memset (VALUE_CONTENTS_RAW (rec), '\0', TYPE_LENGTH (expect_type));
368 for (tem = 0; tem < nargs; tem++)
369 evaluate_labeled_field_init (rec, &fieldno, exp, pos, noside);
373 if (expect_type != NULL_TYPE && noside != EVAL_SKIP
374 && TYPE_CODE (expect_type) == TYPE_CODE_ARRAY)
376 struct type *range_type = TYPE_FIELD_TYPE (expect_type, 0);
377 struct type *element_type = TYPE_TARGET_TYPE (expect_type);
378 LONGEST low_bound = TYPE_FIELD_BITPOS (range_type, 0);
379 LONGEST high_bound = TYPE_FIELD_BITPOS (range_type, 1);
380 int element_size = TYPE_LENGTH (element_type);
381 value_ptr array = allocate_value (expect_type);
382 if (nargs != (high_bound - low_bound + 1))
383 error ("wrong number of initialiers for array type");
384 for (tem = low_bound; tem <= high_bound; tem++)
386 value_ptr element = evaluate_subexp (element_type,
388 if (VALUE_TYPE (element) != element_type)
389 element = value_cast (element_type, element);
390 memcpy (VALUE_CONTENTS_RAW (array)
391 + (tem - low_bound) * element_size,
392 VALUE_CONTENTS (element),
398 if (expect_type != NULL_TYPE && noside != EVAL_SKIP
399 && TYPE_CODE (expect_type) == TYPE_CODE_SET)
401 value_ptr set = allocate_value (expect_type);
402 struct type *element_type = TYPE_INDEX_TYPE (expect_type);
403 int low_bound = TYPE_LOW_BOUND (element_type);
404 int high_bound = TYPE_HIGH_BOUND (element_type);
405 char *valaddr = VALUE_CONTENTS_RAW (set);
406 memset (valaddr, '\0', TYPE_LENGTH (expect_type));
407 for (tem = 0; tem < nargs; tem++)
409 value_ptr element_val = evaluate_subexp (element_type,
411 LONGEST element = value_as_long (element_val);
413 if (element < low_bound || element > high_bound)
414 error ("POWERSET tuple element out of range");
415 element -= low_bound;
416 bit_index = (unsigned) element % TARGET_CHAR_BIT;
418 bit_index = TARGET_CHAR_BIT - 1 - bit_index;
419 valaddr [(unsigned) element / TARGET_CHAR_BIT] |= 1 << bit_index;
424 argvec = (value_ptr *) alloca (sizeof (value_ptr) * nargs);
425 for (tem = 0; tem < nargs; tem++)
427 /* Ensure that array expressions are coerced into pointer objects. */
428 argvec[tem] = evaluate_subexp_with_coercion (exp, pos, noside);
430 if (noside == EVAL_SKIP)
432 return value_array (tem2, tem3, argvec);
436 value_ptr array = evaluate_subexp (NULL_TYPE, exp, pos, noside);
438 = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside));
440 = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside));
441 return value_slice (array, lowbound, upper - lowbound + 1);
444 case TERNOP_SLICE_COUNT:
446 value_ptr array = evaluate_subexp (NULL_TYPE, exp, pos, noside);
448 = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside));
450 = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside));
451 return value_slice (array, lowbound, length);
455 /* Skip third and second args to evaluate the first one. */
456 arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
457 if (value_logical_not (arg1))
459 evaluate_subexp (NULL_TYPE, exp, pos, EVAL_SKIP);
460 return evaluate_subexp (NULL_TYPE, exp, pos, noside);
464 arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
465 evaluate_subexp (NULL_TYPE, exp, pos, EVAL_SKIP);
471 op = exp->elts[*pos].opcode;
472 if (op == STRUCTOP_MEMBER || op == STRUCTOP_MPTR)
476 nargs = longest_to_int (exp->elts[pc + 1].longconst) + 1;
477 /* First, evaluate the structure into arg2 */
480 if (noside == EVAL_SKIP)
483 if (op == STRUCTOP_MEMBER)
485 arg2 = evaluate_subexp_for_address (exp, pos, noside);
489 arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
492 /* If the function is a virtual function, then the
493 aggregate value (providing the structure) plays
494 its part by providing the vtable. Otherwise,
495 it is just along for the ride: call the function
498 arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
500 fnptr = value_as_long (arg1);
502 if (METHOD_PTR_IS_VIRTUAL(fnptr))
504 int fnoffset = METHOD_PTR_TO_VOFFSET(fnptr);
505 struct type *basetype;
506 struct type *domain_type =
507 TYPE_DOMAIN_TYPE (TYPE_TARGET_TYPE (VALUE_TYPE (arg1)));
509 basetype = TYPE_TARGET_TYPE (VALUE_TYPE (arg2));
510 if (domain_type != basetype)
511 arg2 = value_cast(lookup_pointer_type (domain_type), arg2);
512 basetype = TYPE_VPTR_BASETYPE (domain_type);
513 for (i = TYPE_NFN_FIELDS (basetype) - 1; i >= 0; i--)
515 struct fn_field *f = TYPE_FN_FIELDLIST1 (basetype, i);
516 /* If one is virtual, then all are virtual. */
517 if (TYPE_FN_FIELD_VIRTUAL_P (f, 0))
518 for (j = TYPE_FN_FIELDLIST_LENGTH (basetype, i) - 1; j >= 0; --j)
519 if (TYPE_FN_FIELD_VOFFSET (f, j) == fnoffset)
521 value_ptr temp = value_ind (arg2);
522 arg1 = value_virtual_fn_field (&temp, f, j, domain_type, 0);
523 arg2 = value_addr (temp);
528 error ("virtual function at index %d not found", fnoffset);
532 VALUE_TYPE (arg1) = lookup_pointer_type (TYPE_TARGET_TYPE (VALUE_TYPE (arg1)));
536 /* Now, say which argument to start evaluating from */
539 else if (op == STRUCTOP_STRUCT || op == STRUCTOP_PTR)
541 /* Hair for method invocations */
544 nargs = longest_to_int (exp->elts[pc + 1].longconst) + 1;
545 /* First, evaluate the structure into arg2 */
547 tem2 = longest_to_int (exp->elts[pc2 + 1].longconst);
548 *pos += 3 + BYTES_TO_EXP_ELEM (tem2 + 1);
549 if (noside == EVAL_SKIP)
552 if (op == STRUCTOP_STRUCT)
554 /* If v is a variable in a register, and the user types
555 v.method (), this will produce an error, because v has
558 A possible way around this would be to allocate a
559 copy of the variable on the stack, copy in the
560 contents, call the function, and copy out the
561 contents. I.e. convert this from call by reference
562 to call by copy-return (or whatever it's called).
563 However, this does not work because it is not the
564 same: the method being called could stash a copy of
565 the address, and then future uses through that address
566 (after the method returns) would be expected to
567 use the variable itself, not some copy of it. */
568 arg2 = evaluate_subexp_for_address (exp, pos, noside);
572 arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
574 /* Now, say which argument to start evaluating from */
579 nargs = longest_to_int (exp->elts[pc + 1].longconst);
582 /* Allocate arg vector, including space for the function to be
583 called in argvec[0] and a terminating NULL */
584 argvec = (value_ptr *) alloca (sizeof (value_ptr) * (nargs + 2));
585 for (; tem <= nargs; tem++)
586 /* Ensure that array expressions are coerced into pointer objects. */
587 argvec[tem] = evaluate_subexp_with_coercion (exp, pos, noside);
589 /* signal end of arglist */
592 if (op == STRUCTOP_STRUCT || op == STRUCTOP_PTR)
595 value_ptr temp = arg2;
600 strcpy(tstr, &exp->elts[pc2+2].string);
605 value_struct_elt (&temp, argvec+1, tstr,
607 op == STRUCTOP_STRUCT
608 ? "structure" : "structure pointer");
610 arg2 = value_from_longest (lookup_pointer_type(VALUE_TYPE (temp)),
611 VALUE_ADDRESS (temp)+VALUE_OFFSET (temp));
616 argvec[1] = argvec[0];
621 else if (op == STRUCTOP_MEMBER || op == STRUCTOP_MPTR)
629 if (noside == EVAL_SKIP)
631 if (noside == EVAL_AVOID_SIDE_EFFECTS)
633 /* If the return type doesn't look like a function type, call an
634 error. This can happen if somebody tries to turn a variable into
635 a function call. This is here because people often want to
636 call, eg, strcmp, which gdb doesn't know is a function. If
637 gdb isn't asked for it's opinion (ie. through "whatis"),
638 it won't offer it. */
641 TYPE_TARGET_TYPE (VALUE_TYPE (argvec[0]));
644 return allocate_value (TYPE_TARGET_TYPE (VALUE_TYPE (argvec[0])));
646 error ("Expression of type other than \"Function returning ...\" used as function");
648 return call_function_by_hand (argvec[0], nargs, argvec + 1);
650 case OP_F77_UNDETERMINED_ARGLIST:
652 /* Remember that in F77, functions, substring ops and
653 array subscript operations cannot be disambiguated
654 at parse time. We have made all array subscript operations,
655 substring operations as well as function calls come here
656 and we now have to discover what the heck this thing actually was.
657 If it is an array, we massage it into a form that the
658 MULTI_F77_SUBSCRIPT operator can deal with. If it is
659 a function, we process just as if we got an OP_FUNCALL and
660 for a subscring operation, we perform the appropriate
661 substring operation. */
663 /* First get the nargs and then jump all the way over the:
665 OP_UNDETERMINED_ARGLIST
667 OP_UNDETERMINED_ARGLIST
669 instruction sequence */
671 nargs = longest_to_int (exp->elts[pc+1].longconst);
674 /* First determine the type code we are dealing with. */
675 arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
676 code = TYPE_CODE (VALUE_TYPE (arg1));
680 case TYPE_CODE_ARRAY:
681 goto multi_f77_subscript;
683 case TYPE_CODE_STRING:
688 /* It's a function call. */
689 /* Allocate arg vector, including space for the function to be
690 called in argvec[0] and a terminating NULL */
691 argvec = (value_ptr *) alloca (sizeof (value_ptr) * (nargs + 2));
694 for (; tem <= nargs; tem++)
695 argvec[tem] = evaluate_subexp_with_coercion (exp, pos, noside);
696 argvec[tem] = 0; /* signal end of arglist */
700 error ("Cannot perform substring on this type");
704 /* We have a substring operation on our hands here,
705 let us get the string we will be dealing with */
707 /* Now evaluate the 'from' and 'to' */
709 arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
711 if (TYPE_CODE (VALUE_TYPE (arg2)) != TYPE_CODE_INT)
712 error ("Substring arguments must be of type integer");
715 return value_subscript (arg1, arg2);
717 arg3 = evaluate_subexp_with_coercion (exp, pos, noside);
719 if (TYPE_CODE (VALUE_TYPE (arg3)) != TYPE_CODE_INT)
720 error ("Substring arguments must be of type integer");
722 tem2 = *((int *) VALUE_CONTENTS_RAW (arg2));
723 tem3 = *((int *) VALUE_CONTENTS_RAW (arg3));
725 if ((tem2 < 1) || (tem2 > tem3))
726 error ("Bad 'from' value %d on substring operation", tem2);
728 if ((tem3 < tem2) || (tem3 > (TYPE_LENGTH (VALUE_TYPE (arg1)))))
729 error ("Bad 'to' value %d on substring operation", tem3);
731 if (noside == EVAL_SKIP)
734 return value_slice (arg1, tem2, tem3 - tem2 + 1);
737 /* We have a complex number, There should be 2 floating
738 point numbers that compose it */
739 arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
740 arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
742 return value_literal_complex (arg1, arg2, builtin_type_f_complex_s16);
744 case STRUCTOP_STRUCT:
745 tem = longest_to_int (exp->elts[pc + 1].longconst);
746 (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
747 arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
748 if (noside == EVAL_SKIP)
750 if (noside == EVAL_AVOID_SIDE_EFFECTS)
751 return value_zero (lookup_struct_elt_type (VALUE_TYPE (arg1),
752 &exp->elts[pc + 2].string,
757 value_ptr temp = arg1;
758 return value_struct_elt (&temp, NULL, &exp->elts[pc + 2].string,
763 tem = longest_to_int (exp->elts[pc + 1].longconst);
764 (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
765 arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
766 if (noside == EVAL_SKIP)
768 if (noside == EVAL_AVOID_SIDE_EFFECTS)
769 return value_zero (lookup_struct_elt_type (VALUE_TYPE (arg1),
770 &exp->elts[pc + 2].string,
775 value_ptr temp = arg1;
776 return value_struct_elt (&temp, NULL, &exp->elts[pc + 2].string,
777 NULL, "structure pointer");
780 case STRUCTOP_MEMBER:
781 arg1 = evaluate_subexp_for_address (exp, pos, noside);
782 goto handle_pointer_to_member;
784 arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
785 handle_pointer_to_member:
786 arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
787 if (noside == EVAL_SKIP)
789 if (TYPE_CODE (VALUE_TYPE (arg2)) != TYPE_CODE_PTR)
790 goto bad_pointer_to_member;
791 type = TYPE_TARGET_TYPE (VALUE_TYPE (arg2));
792 if (TYPE_CODE (type) == TYPE_CODE_METHOD)
793 error ("not implemented: pointer-to-method in pointer-to-member construct");
794 if (TYPE_CODE (type) != TYPE_CODE_MEMBER)
795 goto bad_pointer_to_member;
796 /* Now, convert these values to an address. */
797 arg1 = value_cast (lookup_pointer_type (TYPE_DOMAIN_TYPE (type)),
799 arg3 = value_from_longest (lookup_pointer_type (TYPE_TARGET_TYPE (type)),
800 value_as_long (arg1) + value_as_long (arg2));
801 return value_ind (arg3);
802 bad_pointer_to_member:
803 error("non-pointer-to-member value used in pointer-to-member construct");
806 arg1 = evaluate_subexp_with_coercion (exp, pos, noside);
807 arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
808 if (noside == EVAL_SKIP)
810 if (binop_user_defined_p (op, arg1, arg2))
811 return value_x_binop (arg1, arg2, op, OP_NULL);
813 return value_concat (arg1, arg2);
816 arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
817 arg2 = evaluate_subexp (VALUE_TYPE (arg1), exp, pos, noside);
818 if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS)
820 if (binop_user_defined_p (op, arg1, arg2))
821 return value_x_binop (arg1, arg2, op, OP_NULL);
823 return value_assign (arg1, arg2);
825 case BINOP_ASSIGN_MODIFY:
827 arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
828 arg2 = evaluate_subexp (VALUE_TYPE (arg1), exp, pos, noside);
829 if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS)
831 op = exp->elts[pc + 1].opcode;
832 if (binop_user_defined_p (op, arg1, arg2))
833 return value_x_binop (arg1, arg2, BINOP_ASSIGN_MODIFY, op);
834 else if (op == BINOP_ADD)
835 arg2 = value_add (arg1, arg2);
836 else if (op == BINOP_SUB)
837 arg2 = value_sub (arg1, arg2);
839 arg2 = value_binop (arg1, arg2, op);
840 return value_assign (arg1, arg2);
843 arg1 = evaluate_subexp_with_coercion (exp, pos, noside);
844 arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
845 if (noside == EVAL_SKIP)
847 if (binop_user_defined_p (op, arg1, arg2))
848 return value_x_binop (arg1, arg2, op, OP_NULL);
850 return value_add (arg1, arg2);
853 arg1 = evaluate_subexp_with_coercion (exp, pos, noside);
854 arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
855 if (noside == EVAL_SKIP)
857 if (binop_user_defined_p (op, arg1, arg2))
858 return value_x_binop (arg1, arg2, op, OP_NULL);
860 return value_sub (arg1, arg2);
868 case BINOP_BITWISE_AND:
869 case BINOP_BITWISE_IOR:
870 case BINOP_BITWISE_XOR:
871 arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
872 arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
873 if (noside == EVAL_SKIP)
875 if (binop_user_defined_p (op, arg1, arg2))
876 return value_x_binop (arg1, arg2, op, OP_NULL);
878 if (noside == EVAL_AVOID_SIDE_EFFECTS
879 && (op == BINOP_DIV || op == BINOP_REM || op == BINOP_MOD))
880 return value_zero (VALUE_TYPE (arg1), not_lval);
882 return value_binop (arg1, arg2, op);
884 case BINOP_SUBSCRIPT:
885 arg1 = evaluate_subexp_with_coercion (exp, pos, noside);
886 arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
887 if (noside == EVAL_SKIP)
889 if (noside == EVAL_AVOID_SIDE_EFFECTS)
891 /* If the user attempts to subscript something that has no target
892 type (like a plain int variable for example), then report this
895 type = TYPE_TARGET_TYPE (VALUE_TYPE (arg1));
897 return value_zero (type, VALUE_LVAL (arg1));
899 error ("cannot subscript something of type `%s'",
900 TYPE_NAME (VALUE_TYPE (arg1)));
903 if (binop_user_defined_p (op, arg1, arg2))
904 return value_x_binop (arg1, arg2, op, OP_NULL);
906 return value_subscript (arg1, arg2);
909 arg1 = evaluate_subexp_with_coercion (exp, pos, noside);
910 arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
911 if (noside == EVAL_SKIP)
913 return value_in (arg1, arg2);
915 case MULTI_SUBSCRIPT:
917 nargs = longest_to_int (exp->elts[pc + 1].longconst);
918 arg1 = evaluate_subexp_with_coercion (exp, pos, noside);
921 arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
922 /* FIXME: EVAL_SKIP handling may not be correct. */
923 if (noside == EVAL_SKIP)
934 /* FIXME: EVAL_AVOID_SIDE_EFFECTS handling may not be correct. */
935 if (noside == EVAL_AVOID_SIDE_EFFECTS)
937 /* If the user attempts to subscript something that has no target
938 type (like a plain int variable for example), then report this
941 type = TYPE_TARGET_TYPE (VALUE_TYPE (arg1));
944 arg1 = value_zero (type, VALUE_LVAL (arg1));
950 error ("cannot subscript something of type `%s'",
951 TYPE_NAME (VALUE_TYPE (arg1)));
955 if (binop_user_defined_p (op, arg1, arg2)
956 && ! chill_varying_type (VALUE_TYPE (arg1)))
958 arg1 = value_x_binop (arg1, arg2, op, OP_NULL);
962 arg1 = value_subscript (arg1, arg2);
969 int subscript_array[MAX_FORTRAN_DIMS+1]; /* 1-based array of
970 subscripts, max == 7 */
971 int array_size_array[MAX_FORTRAN_DIMS+1];
973 struct type *tmp_type;
974 int offset_item; /* The array offset where the item lives */
977 if (nargs > MAX_FORTRAN_DIMS)
978 error ("Too many subscripts for F77 (%d Max)", MAX_FORTRAN_DIMS);
980 ndimensions = calc_f77_array_dims (VALUE_TYPE (arg1));
982 if (nargs != ndimensions)
983 error ("Wrong number of subscripts");
985 /* Now that we know we have a legal array subscript expression
986 let us actually find out where this element exists in the array. */
988 tmp_type = VALUE_TYPE (arg1);
990 for (i = 1; i <= nargs; i++)
992 /* Evaluate each subscript, It must be a legal integer in F77 */
993 arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
995 if (TYPE_CODE (VALUE_TYPE (arg2)) != TYPE_CODE_INT)
996 error ("Array subscripts must be of type integer");
998 /* Fill in the subscript and array size arrays */
1000 subscript_array[i] = (* (unsigned int *) VALUE_CONTENTS(arg2));
1002 retcode = f77_get_dynamic_upperbound (tmp_type, &upper);
1003 if (retcode == BOUND_FETCH_ERROR)
1004 error ("Cannot obtain dynamic upper bound");
1006 retcode = f77_get_dynamic_lowerbound (tmp_type, &lower);
1007 if (retcode == BOUND_FETCH_ERROR)
1008 error("Cannot obtain dynamic lower bound");
1010 array_size_array[i] = upper - lower + 1;
1012 /* Zero-normalize subscripts so that offsetting will work. */
1014 subscript_array[i] -= lower;
1016 /* If we are at the bottom of a multidimensional
1017 array type then keep a ptr to the last ARRAY
1018 type around for use when calling value_subscript()
1019 below. This is done because we pretend to value_subscript
1020 that we actually have a one-dimensional array
1021 of base element type that we apply a simple
1025 tmp_type = TYPE_TARGET_TYPE (tmp_type);
1028 /* Now let us calculate the offset for this item */
1030 offset_item = subscript_array[ndimensions];
1032 for (i = ndimensions - 1; i >= 1; i--)
1034 array_size_array[i] * offset_item + subscript_array[i];
1036 /* Construct a value node with the value of the offset */
1038 arg2 = value_from_longest (builtin_type_f_integer, offset_item);
1040 /* Let us now play a dirty trick: we will take arg1
1041 which is a value node pointing to the topmost level
1042 of the multidimensional array-set and pretend
1043 that it is actually a array of the final element
1044 type, this will ensure that value_subscript()
1045 returns the correct type value */
1047 VALUE_TYPE (arg1) = tmp_type;
1049 arg1 = value_subscript (arg1, arg2);
1053 case BINOP_LOGICAL_AND:
1054 arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
1055 if (noside == EVAL_SKIP)
1057 arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
1062 arg2 = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
1065 if (binop_user_defined_p (op, arg1, arg2))
1067 arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
1068 return value_x_binop (arg1, arg2, op, OP_NULL);
1072 tem = value_logical_not (arg1);
1073 arg2 = evaluate_subexp (NULL_TYPE, exp, pos,
1074 (tem ? EVAL_SKIP : noside));
1075 return value_from_longest (builtin_type_int,
1076 (LONGEST) (!tem && !value_logical_not (arg2)));
1079 case BINOP_LOGICAL_OR:
1080 arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
1081 if (noside == EVAL_SKIP)
1083 arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
1088 arg2 = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
1091 if (binop_user_defined_p (op, arg1, arg2))
1093 arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
1094 return value_x_binop (arg1, arg2, op, OP_NULL);
1098 tem = value_logical_not (arg1);
1099 arg2 = evaluate_subexp (NULL_TYPE, exp, pos,
1100 (!tem ? EVAL_SKIP : noside));
1101 return value_from_longest (builtin_type_int,
1102 (LONGEST) (!tem || !value_logical_not (arg2)));
1106 arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
1107 arg2 = evaluate_subexp (VALUE_TYPE (arg1), exp, pos, noside);
1108 if (noside == EVAL_SKIP)
1110 if (binop_user_defined_p (op, arg1, arg2))
1112 return value_x_binop (arg1, arg2, op, OP_NULL);
1116 tem = value_equal (arg1, arg2);
1117 return value_from_longest (builtin_type_int, (LONGEST) tem);
1120 case BINOP_NOTEQUAL:
1121 arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
1122 arg2 = evaluate_subexp (VALUE_TYPE (arg1), exp, pos, noside);
1123 if (noside == EVAL_SKIP)
1125 if (binop_user_defined_p (op, arg1, arg2))
1127 return value_x_binop (arg1, arg2, op, OP_NULL);
1131 tem = value_equal (arg1, arg2);
1132 return value_from_longest (builtin_type_int, (LONGEST) ! tem);
1136 arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
1137 arg2 = evaluate_subexp (VALUE_TYPE (arg1), exp, pos, noside);
1138 if (noside == EVAL_SKIP)
1140 if (binop_user_defined_p (op, arg1, arg2))
1142 return value_x_binop (arg1, arg2, op, OP_NULL);
1146 tem = value_less (arg1, arg2);
1147 return value_from_longest (builtin_type_int, (LONGEST) tem);
1151 arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
1152 arg2 = evaluate_subexp (VALUE_TYPE (arg1), exp, pos, noside);
1153 if (noside == EVAL_SKIP)
1155 if (binop_user_defined_p (op, arg1, arg2))
1157 return value_x_binop (arg1, arg2, op, OP_NULL);
1161 tem = value_less (arg2, arg1);
1162 return value_from_longest (builtin_type_int, (LONGEST) tem);
1166 arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
1167 arg2 = evaluate_subexp (VALUE_TYPE (arg1), exp, pos, noside);
1168 if (noside == EVAL_SKIP)
1170 if (binop_user_defined_p (op, arg1, arg2))
1172 return value_x_binop (arg1, arg2, op, OP_NULL);
1176 tem = value_less (arg2, arg1) || value_equal (arg1, arg2);
1177 return value_from_longest (builtin_type_int, (LONGEST) tem);
1181 arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
1182 arg2 = evaluate_subexp (VALUE_TYPE (arg1), exp, pos, noside);
1183 if (noside == EVAL_SKIP)
1185 if (binop_user_defined_p (op, arg1, arg2))
1187 return value_x_binop (arg1, arg2, op, OP_NULL);
1191 tem = value_less (arg1, arg2) || value_equal (arg1, arg2);
1192 return value_from_longest (builtin_type_int, (LONGEST) tem);
1196 arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
1197 arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
1198 if (noside == EVAL_SKIP)
1200 if (TYPE_CODE (VALUE_TYPE (arg2)) != TYPE_CODE_INT)
1201 error ("Non-integral right operand for \"@\" operator.");
1202 if (noside == EVAL_AVOID_SIDE_EFFECTS)
1203 return allocate_repeat_value (VALUE_TYPE (arg1),
1204 longest_to_int (value_as_long (arg2)));
1206 return value_repeat (arg1, longest_to_int (value_as_long (arg2)));
1209 evaluate_subexp (NULL_TYPE, exp, pos, noside);
1210 return evaluate_subexp (NULL_TYPE, exp, pos, noside);
1213 arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
1214 if (noside == EVAL_SKIP)
1216 if (unop_user_defined_p (op, arg1))
1217 return value_x_unop (arg1, op);
1219 return value_neg (arg1);
1221 case UNOP_COMPLEMENT:
1222 /* C++: check for and handle destructor names. */
1223 op = exp->elts[*pos].opcode;
1225 arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
1226 if (noside == EVAL_SKIP)
1228 if (unop_user_defined_p (UNOP_COMPLEMENT, arg1))
1229 return value_x_unop (arg1, UNOP_COMPLEMENT);
1231 return value_complement (arg1);
1233 case UNOP_LOGICAL_NOT:
1234 arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
1235 if (noside == EVAL_SKIP)
1237 if (unop_user_defined_p (op, arg1))
1238 return value_x_unop (arg1, op);
1240 return value_from_longest (builtin_type_int,
1241 (LONGEST) value_logical_not (arg1));
1244 if (expect_type && TYPE_CODE (expect_type) == TYPE_CODE_PTR)
1245 expect_type = TYPE_TARGET_TYPE (expect_type);
1246 arg1 = evaluate_subexp (expect_type, exp, pos, noside);
1247 if (noside == EVAL_SKIP)
1249 if (noside == EVAL_AVOID_SIDE_EFFECTS)
1251 if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_PTR
1252 || TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_REF
1253 /* In C you can dereference an array to get the 1st elt. */
1254 || TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_ARRAY
1256 return value_zero (TYPE_TARGET_TYPE (VALUE_TYPE (arg1)),
1258 else if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_INT)
1259 /* GDB allows dereferencing an int. */
1260 return value_zero (builtin_type_int, lval_memory);
1262 error ("Attempt to take contents of a non-pointer value.");
1264 return value_ind (arg1);
1267 /* C++: check for and handle pointer to members. */
1269 op = exp->elts[*pos].opcode;
1271 if (noside == EVAL_SKIP)
1275 int temm = longest_to_int (exp->elts[pc+3].longconst);
1276 (*pos) += 3 + BYTES_TO_EXP_ELEM (temm + 1);
1279 evaluate_subexp (expect_type, exp, pos, EVAL_SKIP);
1283 return evaluate_subexp_for_address (exp, pos, noside);
1286 if (noside == EVAL_SKIP)
1288 evaluate_subexp (NULL_TYPE, exp, pos, EVAL_SKIP);
1291 return evaluate_subexp_for_sizeof (exp, pos);
1295 type = exp->elts[pc + 1].type;
1296 arg1 = evaluate_subexp (type, exp, pos, noside);
1297 if (noside == EVAL_SKIP)
1299 if (type != VALUE_TYPE (arg1))
1300 arg1 = value_cast (type, arg1);
1305 arg1 = evaluate_subexp (expect_type, exp, pos, noside);
1306 if (noside == EVAL_SKIP)
1308 if (noside == EVAL_AVOID_SIDE_EFFECTS)
1309 return value_zero (exp->elts[pc + 1].type, lval_memory);
1311 return value_at_lazy (exp->elts[pc + 1].type,
1312 value_as_pointer (arg1));
1314 case UNOP_PREINCREMENT:
1315 arg1 = evaluate_subexp (expect_type, exp, pos, noside);
1316 if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS)
1318 else if (unop_user_defined_p (op, arg1))
1320 return value_x_unop (arg1, op);
1324 arg2 = value_add (arg1, value_from_longest (builtin_type_char,
1326 return value_assign (arg1, arg2);
1329 case UNOP_PREDECREMENT:
1330 arg1 = evaluate_subexp (expect_type, exp, pos, noside);
1331 if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS)
1333 else if (unop_user_defined_p (op, arg1))
1335 return value_x_unop (arg1, op);
1339 arg2 = value_sub (arg1, value_from_longest (builtin_type_char,
1341 return value_assign (arg1, arg2);
1344 case UNOP_POSTINCREMENT:
1345 arg1 = evaluate_subexp (expect_type, exp, pos, noside);
1346 if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS)
1348 else if (unop_user_defined_p (op, arg1))
1350 return value_x_unop (arg1, op);
1354 arg2 = value_add (arg1, value_from_longest (builtin_type_char,
1356 value_assign (arg1, arg2);
1360 case UNOP_POSTDECREMENT:
1361 arg1 = evaluate_subexp (expect_type, exp, pos, noside);
1362 if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS)
1364 else if (unop_user_defined_p (op, arg1))
1366 return value_x_unop (arg1, op);
1370 arg2 = value_sub (arg1, value_from_longest (builtin_type_char,
1372 value_assign (arg1, arg2);
1378 return value_of_this (1);
1381 error ("Attempt to use a type name as an expression");
1384 /* Removing this case and compiling with gcc -Wall reveals that
1385 a lot of cases are hitting this case. Some of these should
1386 probably be removed from expression.h (e.g. do we need a BINOP_SCOPE
1387 and an OP_SCOPE?); others are legitimate expressions which are
1388 (apparently) not fully implemented.
1390 If there are any cases landing here which mean a user error,
1391 then they should be separate cases, with more descriptive
1395 GDB does not (yet) know how to evaluate that kind of expression");
1399 return value_from_longest (builtin_type_long, (LONGEST) 1);
1402 /* Evaluate a subexpression of EXP, at index *POS,
1403 and return the address of that subexpression.
1404 Advance *POS over the subexpression.
1405 If the subexpression isn't an lvalue, get an error.
1406 NOSIDE may be EVAL_AVOID_SIDE_EFFECTS;
1407 then only the type of the result need be correct. */
1410 evaluate_subexp_for_address (exp, pos, noside)
1411 register struct expression *exp;
1420 op = exp->elts[pc].opcode;
1426 return evaluate_subexp (NULL_TYPE, exp, pos, noside);
1430 return value_cast (lookup_pointer_type (exp->elts[pc + 1].type),
1431 evaluate_subexp (NULL_TYPE, exp, pos, noside));
1434 var = exp->elts[pc + 2].symbol;
1436 /* C++: The "address" of a reference should yield the address
1437 * of the object pointed to. Let value_addr() deal with it. */
1438 if (TYPE_CODE (SYMBOL_TYPE (var)) == TYPE_CODE_REF)
1442 if (noside == EVAL_AVOID_SIDE_EFFECTS)
1445 lookup_pointer_type (SYMBOL_TYPE (var));
1446 enum address_class sym_class = SYMBOL_CLASS (var);
1448 if (sym_class == LOC_CONST
1449 || sym_class == LOC_CONST_BYTES
1450 || sym_class == LOC_REGISTER
1451 || sym_class == LOC_REGPARM)
1452 error ("Attempt to take address of register or constant.");
1455 value_zero (type, not_lval);
1461 block_innermost_frame (exp->elts[pc + 1].block));
1465 if (noside == EVAL_AVOID_SIDE_EFFECTS)
1467 value_ptr x = evaluate_subexp (NULL_TYPE, exp, pos, noside);
1468 if (VALUE_LVAL (x) == lval_memory)
1469 return value_zero (lookup_pointer_type (VALUE_TYPE (x)),
1472 error ("Attempt to take address of non-lval");
1474 return value_addr (evaluate_subexp (NULL_TYPE, exp, pos, noside));
1478 /* Evaluate like `evaluate_subexp' except coercing arrays to pointers.
1479 When used in contexts where arrays will be coerced anyway, this is
1480 equivalent to `evaluate_subexp' but much faster because it avoids
1481 actually fetching array contents (perhaps obsolete now that we have
1484 Note that we currently only do the coercion for C expressions, where
1485 arrays are zero based and the coercion is correct. For other languages,
1486 with nonzero based arrays, coercion loses. Use CAST_IS_CONVERSION
1487 to decide if coercion is appropriate.
1492 evaluate_subexp_with_coercion (exp, pos, noside)
1493 register struct expression *exp;
1497 register enum exp_opcode op;
1499 register value_ptr val;
1503 op = exp->elts[pc].opcode;
1508 var = exp->elts[pc + 2].symbol;
1509 if (TYPE_CODE (SYMBOL_TYPE (var)) == TYPE_CODE_ARRAY
1510 && CAST_IS_CONVERSION)
1515 (var, block_innermost_frame (exp->elts[pc + 1].block));
1516 return value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (SYMBOL_TYPE (var))),
1522 return evaluate_subexp (NULL_TYPE, exp, pos, noside);
1526 /* Evaluate a subexpression of EXP, at index *POS,
1527 and return a value for the size of that subexpression.
1528 Advance *POS over the subexpression. */
1531 evaluate_subexp_for_sizeof (exp, pos)
1532 register struct expression *exp;
1540 op = exp->elts[pc].opcode;
1544 /* This case is handled specially
1545 so that we avoid creating a value for the result type.
1546 If the result type is very big, it's desirable not to
1547 create a value unnecessarily. */
1550 val = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
1551 return value_from_longest (builtin_type_int, (LONGEST)
1552 TYPE_LENGTH (TYPE_TARGET_TYPE (VALUE_TYPE (val))));
1556 return value_from_longest (builtin_type_int,
1557 (LONGEST) TYPE_LENGTH (exp->elts[pc + 1].type));
1564 (LONGEST) TYPE_LENGTH (SYMBOL_TYPE (exp->elts[pc + 2].symbol)));
1567 val = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
1568 return value_from_longest (builtin_type_int,
1569 (LONGEST) TYPE_LENGTH (VALUE_TYPE (val)));
1573 /* Parse a type expression in the string [P..P+LENGTH). */
1576 parse_and_eval_type (p, length)
1580 char *tmp = (char *)alloca (length + 4);
1581 struct expression *expr;
1583 memcpy (tmp+1, p, length);
1584 tmp[length+1] = ')';
1585 tmp[length+2] = '0';
1586 tmp[length+3] = '\0';
1587 expr = parse_expression (tmp);
1588 if (expr->elts[0].opcode != UNOP_CAST)
1589 error ("Internal error in eval_type.");
1590 return expr->elts[1].type;
1594 calc_f77_array_dims (array_type)
1595 struct type *array_type;
1598 struct type *tmp_type;
1600 if ((TYPE_CODE(array_type) != TYPE_CODE_ARRAY))
1601 error ("Can't get dimensions for a non-array type");
1603 tmp_type = array_type;
1605 while (tmp_type = TYPE_TARGET_TYPE (tmp_type))
1607 if (TYPE_CODE (tmp_type) == TYPE_CODE_ARRAY)