899d1405bc38c2901c0d828b483ecb1d296199b3
1 /* Evaluate expressions for GDB.
2 Copyright (C) 1986, 1987 Free Software Foundation, Inc.
4 GDB is distributed in the hope that it will be useful, but WITHOUT ANY
5 WARRANTY. No author or distributor accepts responsibility to anyone
6 for the consequences of using it or for whether it serves any
7 particular purpose or works at all, unless he says so in writing.
8 Refer to the GDB General Public License for full details.
10 Everyone is granted permission to copy, modify and redistribute GDB,
11 but only under the conditions described in the GDB General Public
12 License. A copy of this license is supposed to have been given to you
13 along with GDB so you can know your rights and responsibilities. It
14 should be in a file named COPYING. Among other things, the copyright
15 notice and this notice must be preserved on all copies.
17 In other words, go ahead and share GDB, but don't try to stop
18 anyone else from sharing it farther. Help stamp out software hoarding!
22 #include "initialize.h"
25 #include "expression.h"
29 /* Parse the string EXP as a C expression, evaluate it,
30 and return the result as a number. */
33 parse_and_eval_address (exp
)
36 struct expression
*expr
= parse_c_expression (exp
);
37 register CORE_ADDR addr
;
38 register struct cleanup
*old_chain
39 = make_cleanup (free_current_contents
, &expr
);
41 addr
= value_as_long (evaluate_expression (expr
));
42 do_cleanups (old_chain
);
46 /* Like parse_and_eval_address but takes a pointer to a char * variable
47 and advanced that variable across the characters parsed. */
50 parse_and_eval_address_1 (expptr
)
53 struct expression
*expr
= parse_c_1 (expptr
, 0, 0);
54 register CORE_ADDR addr
;
55 register struct cleanup
*old_chain
56 = make_cleanup (free_current_contents
, &expr
);
58 addr
= value_as_long (evaluate_expression (expr
));
59 do_cleanups (old_chain
);
67 struct expression
*expr
= parse_c_expression (exp
);
69 register struct cleanup
*old_chain
70 = make_cleanup (free_current_contents
, &expr
);
72 val
= evaluate_expression (expr
);
73 do_cleanups (old_chain
);
77 /* Parse up to a comma (or to a closeparen)
78 in the string EXPP as an expression, evaluate it, and return the value.
79 EXPP is advanced to point to the comma. */
82 parse_to_comma_and_eval (expp
)
85 struct expression
*expr
= parse_c_1 (expp
, 0, 1);
87 register struct cleanup
*old_chain
88 = make_cleanup (free_current_contents
, &expr
);
90 val
= evaluate_expression (expr
);
91 do_cleanups (old_chain
);
95 /* Evaluate an expression in internal prefix form
96 such as is constructed by expread.y.
98 See expression.h for info on the format of an expression. */
100 static value
evaluate_subexp ();
101 static value
evaluate_subexp_for_address ();
102 static value
evaluate_subexp_for_sizeof ();
103 static value
evaluate_subexp_with_coercion ();
105 /* Values of NOSIDE argument to eval_subexp. */
109 EVAL_AVOID_SIDE_EFFECTS
,
113 evaluate_expression (exp
)
114 struct expression
*exp
;
117 return evaluate_subexp (exp
, &pc
, EVAL_NORMAL
);
120 /* Evaluate an expression, avoiding all memory references
121 and getting a value whose type alone is correct. */
125 struct expression
*exp
;
128 return evaluate_subexp (exp
, &pc
, EVAL_AVOID_SIDE_EFFECTS
);
132 evaluate_subexp (exp
, pos
, noside
)
133 register struct expression
*exp
;
139 register int pc
, pc2
, *oldpos
;
140 register value arg1
, arg2
, arg3
;
145 op
= exp
->elts
[pc
].opcode
;
150 tem
= strlen (&exp
->elts
[pc
+ 2].string
);
151 (*pos
) += 3 + (tem
+ sizeof (union exp_element
)) / sizeof (union exp_element
);
152 return value_static_field (exp
->elts
[pc
+ 1].type
,
153 &exp
->elts
[pc
+ 2].string
, -1);
157 return value_from_long (exp
->elts
[pc
+ 1].type
,
158 exp
->elts
[pc
+ 2].longconst
);
162 return value_from_double (exp
->elts
[pc
+ 1].type
,
163 exp
->elts
[pc
+ 2].doubleconst
);
167 if (noside
== EVAL_SKIP
)
169 return value_of_variable (exp
->elts
[pc
+ 1].symbol
);
173 return access_value_history (exp
->elts
[pc
+ 1].longconst
);
177 return value_of_register (exp
->elts
[pc
+ 1].longconst
);
181 return value_of_internalvar (exp
->elts
[pc
+ 1].internalvar
);
184 tem
= strlen (&exp
->elts
[pc
+ 1].string
);
185 (*pos
) += 2 + (tem
+ sizeof (union exp_element
)) / sizeof (union exp_element
);
186 if (noside
== EVAL_SKIP
)
188 return value_string (&exp
->elts
[pc
+ 1].string
, tem
);
191 /* Skip third and second args to evaluate the first one. */
192 arg1
= evaluate_subexp (exp
, pos
, noside
);
193 if (value_zerop (arg1
))
195 evaluate_subexp (exp
, pos
, EVAL_SKIP
);
196 return evaluate_subexp (exp
, pos
, noside
);
200 arg2
= evaluate_subexp (exp
, pos
, noside
);
201 evaluate_subexp (exp
, pos
, EVAL_SKIP
);
207 op
= exp
->elts
[*pos
].opcode
;
208 if (op
== STRUCTOP_MEMBER
|| op
== STRUCTOP_MPTR
)
213 nargs
= exp
->elts
[pc
+ 1].longconst
+ 1;
214 /* First, evaluate the structure into arg2 */
217 if (noside
== EVAL_SKIP
)
220 if (op
== STRUCTOP_MEMBER
)
222 arg2
= evaluate_subexp_for_address (exp
, pos
, noside
);
226 arg2
= evaluate_subexp (exp
, pos
, noside
);
229 /* If the function is a virtual function, then the
230 aggregate value (providing the structure) plays
231 its part by providing the vtable. Otherwise,
232 it is just along for the ride: call the function
235 arg1
= evaluate_subexp (exp
, pos
, noside
);
237 fnptr
= value_as_long (arg1
);
240 struct type
*basetype
;
242 basetype
= TYPE_TARGET_TYPE (VALUE_TYPE (arg2
));
243 basetype
= TYPE_VPTR_BASETYPE (basetype
);
244 for (i
= TYPE_NFN_FIELDS (basetype
) - 1; i
>= 0; i
--)
246 struct fn_field
*f
= TYPE_FN_FIELDLIST1 (basetype
, i
);
247 /* If one is virtual, then all are virtual. */
248 if (TYPE_FN_FIELD_VIRTUAL_P (f
, 0))
249 for (j
= TYPE_FN_FIELDLIST_LENGTH (basetype
, i
) - 1; j
>= 0; --j
)
250 if (TYPE_FN_FIELD_VOFFSET (f
, j
) == fnptr
)
253 value base
= value_ind (arg2
);
254 struct type
*fntype
= lookup_pointer_type (TYPE_FN_FIELD_TYPE (f
, j
));
256 if (TYPE_VPTR_FIELDNO (basetype
) < 0)
257 TYPE_VPTR_FIELDNO (basetype
)
258 = fill_in_vptr_fieldno (basetype
);
260 VALUE_TYPE (base
) = basetype
;
261 vtbl
= value_field (base
, TYPE_VPTR_FIELDNO (basetype
));
262 VALUE_TYPE (vtbl
) = lookup_pointer_type (fntype
);
263 VALUE_TYPE (arg1
) = builtin_type_int
;
264 arg1
= value_subscript (vtbl
, arg1
);
265 VALUE_TYPE (arg1
) = fntype
;
270 error ("virtual function at index %d not found", fnptr
);
274 VALUE_TYPE (arg1
) = lookup_pointer_type (TYPE_TARGET_TYPE (VALUE_TYPE (arg1
)));
278 /* Now, say which argument to start evaluating from */
281 else if (op
== STRUCTOP_STRUCT
|| op
== STRUCTOP_PTR
)
283 /* Hair for method invocations */
286 nargs
= exp
->elts
[pc
+ 1].longconst
+ 1;
287 /* First, evaluate the structure into arg2 */
289 tem2
= strlen (&exp
->elts
[pc2
+ 1].string
);
290 *pos
+= 2 + (tem2
+ sizeof (union exp_element
)) / sizeof (union exp_element
);
291 if (noside
== EVAL_SKIP
)
294 if (op
== STRUCTOP_STRUCT
)
296 arg2
= evaluate_subexp_for_address (exp
, pos
, noside
);
300 arg2
= evaluate_subexp (exp
, pos
, noside
);
302 /* Now, say which argument to start evaluating from */
307 nargs
= exp
->elts
[pc
+ 1].longconst
;
310 argvec
= (value
*) alloca (sizeof (value
) * (nargs
+ 2));
311 for (; tem
<= nargs
; tem
++)
312 /* Ensure that array expressions are coerced into pointer objects. */
313 argvec
[tem
] = evaluate_subexp_with_coercion (exp
, pos
, noside
);
315 /* signal end of arglist */
318 if (op
== STRUCTOP_STRUCT
|| op
== STRUCTOP_PTR
)
322 value_struct_elt (arg2
, argvec
+1, &exp
->elts
[pc2
+ 1].string
,
323 op
== STRUCTOP_STRUCT
324 ? "structure" : "structure pointer");
326 else if (op
== STRUCTOP_MEMBER
|| op
== STRUCTOP_MPTR
)
332 if (noside
== EVAL_SKIP
)
334 if (noside
== EVAL_AVOID_SIDE_EFFECTS
)
335 return allocate_value (TYPE_TARGET_TYPE (VALUE_TYPE (argvec
[0])));
336 return call_function (argvec
[0], nargs
, argvec
+ 1);
338 case STRUCTOP_STRUCT
:
339 tem
= strlen (&exp
->elts
[pc
+ 1].string
);
340 (*pos
) += 2 + (tem
+ sizeof (union exp_element
)) / sizeof (union exp_element
);
341 arg1
= evaluate_subexp (exp
, pos
, noside
);
342 if (noside
== EVAL_SKIP
)
344 return value_struct_elt (arg1
, 0, &exp
->elts
[pc
+ 1].string
,
348 tem
= strlen (&exp
->elts
[pc
+ 1].string
);
349 (*pos
) += 2 + (tem
+ sizeof (union exp_element
)) / sizeof (union exp_element
);
350 arg1
= evaluate_subexp (exp
, pos
, noside
);
351 if (noside
== EVAL_SKIP
)
353 return value_struct_elt (arg1
, 0, &exp
->elts
[pc
+ 1].string
,
354 "structure pointer");
356 case STRUCTOP_MEMBER
:
357 arg1
= evaluate_subexp_for_address (exp
, pos
, noside
);
358 arg2
= evaluate_subexp (exp
, pos
, noside
);
359 if (noside
== EVAL_SKIP
)
361 /* Now, convert these values to an address.
362 @@ We do not know what type we are looking for,
363 @@ so we must assume that the value requested is a
364 @@ member address (as opposed to a member function address). */
365 arg3
= value_from_long (builtin_type_long
,
366 value_as_long (arg1
) + value_as_long (arg2
));
367 VALUE_TYPE (arg3
) = lookup_pointer_type (TYPE_TARGET_TYPE (VALUE_TYPE (arg2
)));
368 return value_ind (arg3
);
371 arg1
= evaluate_subexp (exp
, pos
, noside
);
372 arg2
= evaluate_subexp (exp
, pos
, noside
);
373 if (noside
== EVAL_SKIP
)
375 /* Now, convert these values to an address.
376 @@ We do not know what type we are looking for,
377 @@ so we must assume that the value requested is a
378 @@ member address (as opposed to a member function address). */
379 arg3
= value_from_long (builtin_type_long
,
380 value_as_long (arg1
) + value_as_long (arg2
));
381 VALUE_TYPE (arg3
) = lookup_pointer_type (TYPE_TARGET_TYPE (VALUE_TYPE (arg2
)));
382 return value_ind (arg3
);
385 arg1
= evaluate_subexp (exp
, pos
, noside
);
386 arg2
= evaluate_subexp (exp
, pos
, noside
);
387 if (noside
== EVAL_SKIP
|| noside
== EVAL_AVOID_SIDE_EFFECTS
)
389 if (binop_must_be_user_defined (arg1
, arg2
))
390 return value_x_binop (arg1
, arg2
, op
, 0);
392 return value_assign (arg1
, arg2
);
394 case BINOP_ASSIGN_MODIFY
:
396 arg1
= evaluate_subexp (exp
, pos
, noside
);
397 arg2
= evaluate_subexp (exp
, pos
, noside
);
398 if (noside
== EVAL_SKIP
|| noside
== EVAL_AVOID_SIDE_EFFECTS
)
400 op
= exp
->elts
[pc
+ 1].opcode
;
401 if (binop_must_be_user_defined (arg1
, arg2
))
402 return value_x_binop (arg1
, arg2
, BINOP_ASSIGN_MODIFY
, op
);
403 else if (op
== BINOP_ADD
)
404 arg2
= value_add (arg1
, arg2
);
405 else if (op
== BINOP_SUB
)
406 arg2
= value_sub (arg1
, arg2
);
408 arg2
= value_binop (arg1
, arg2
, op
);
409 return value_assign (arg1
, arg2
);
412 arg1
= evaluate_subexp_with_coercion (exp
, pos
, noside
);
413 arg2
= evaluate_subexp_with_coercion (exp
, pos
, noside
);
414 if (noside
== EVAL_SKIP
)
416 if (binop_must_be_user_defined (arg1
, arg2
))
417 return value_x_binop (arg1
, arg2
, op
, 0);
419 return value_add (arg1
, arg2
);
422 arg1
= evaluate_subexp_with_coercion (exp
, pos
, noside
);
423 arg2
= evaluate_subexp_with_coercion (exp
, pos
, noside
);
424 if (noside
== EVAL_SKIP
)
426 if (binop_must_be_user_defined (arg1
, arg2
))
427 return value_x_binop (arg1
, arg2
, op
, 0);
429 return value_sub (arg1
, arg2
);
439 arg1
= evaluate_subexp (exp
, pos
, noside
);
440 arg2
= evaluate_subexp (exp
, pos
, noside
);
441 if (noside
== EVAL_SKIP
)
443 if (binop_must_be_user_defined (arg1
, arg2
))
444 return value_x_binop (arg1
, arg2
, op
, 0);
446 return value_binop (arg1
, arg2
, op
);
448 case BINOP_SUBSCRIPT
:
449 arg1
= evaluate_subexp_with_coercion (exp
, pos
, noside
);
450 arg2
= evaluate_subexp_with_coercion (exp
, pos
, noside
);
451 if (noside
== EVAL_SKIP
)
453 if (binop_must_be_user_defined (arg1
, arg2
))
454 return value_x_binop (arg1
, arg2
, op
, 0);
456 return value_subscript (arg1
, arg2
, op
);
459 arg1
= evaluate_subexp (exp
, pos
, noside
);
460 if (binop_must_be_user_defined (arg1
, arg2
))
462 arg2
= evaluate_subexp (exp
, pos
, noside
);
463 return value_x_binop (arg1
, arg2
, op
, 0);
467 tem
= value_zerop (arg1
);
468 arg2
= evaluate_subexp (exp
, pos
,
469 (tem
? EVAL_SKIP
: noside
));
470 return value_from_long (builtin_type_int
,
471 !tem
&& !value_zerop (arg2
));
475 arg1
= evaluate_subexp (exp
, pos
, noside
);
476 if (binop_must_be_user_defined (arg1
, arg2
))
478 arg2
= evaluate_subexp (exp
, pos
, noside
);
479 return value_x_binop (arg1
, arg2
, op
, 0);
483 tem
= value_zerop (arg1
);
484 arg2
= evaluate_subexp (exp
, pos
,
485 (!tem
? EVAL_SKIP
: noside
));
486 return value_from_long (builtin_type_int
,
487 !tem
|| !value_zerop (arg2
));
491 arg1
= evaluate_subexp (exp
, pos
, noside
);
492 arg2
= evaluate_subexp (exp
, pos
, noside
);
493 if (noside
== EVAL_SKIP
)
495 if (binop_must_be_user_defined (arg1
, arg2
))
497 return value_x_binop (arg1
, arg2
, op
, 0);
501 tem
= value_equal (arg1
, arg2
);
502 return value_from_long (builtin_type_int
, tem
);
506 arg1
= evaluate_subexp (exp
, pos
, noside
);
507 arg2
= evaluate_subexp (exp
, pos
, noside
);
508 if (noside
== EVAL_SKIP
)
510 if (binop_must_be_user_defined (arg1
, arg2
))
512 return value_x_binop (arg1
, arg2
, op
, 0);
516 tem
= value_equal (arg1
, arg2
);
517 return value_from_long (builtin_type_int
, ! tem
);
521 arg1
= evaluate_subexp (exp
, pos
, noside
);
522 arg2
= evaluate_subexp (exp
, pos
, noside
);
523 if (noside
== EVAL_SKIP
)
525 if (binop_must_be_user_defined (arg1
, arg2
))
527 return value_x_binop (arg1
, arg2
, op
, 0);
531 tem
= value_less (arg1
, arg2
);
532 return value_from_long (builtin_type_int
, tem
);
536 arg1
= evaluate_subexp (exp
, pos
, noside
);
537 arg2
= evaluate_subexp (exp
, pos
, noside
);
538 if (noside
== EVAL_SKIP
)
540 if (binop_must_be_user_defined (arg1
, arg2
))
542 return value_x_binop (arg1
, arg2
, op
, 0);
546 tem
= value_less (arg2
, arg1
);
547 return value_from_long (builtin_type_int
, tem
);
551 arg1
= evaluate_subexp (exp
, pos
, noside
);
552 arg2
= evaluate_subexp (exp
, pos
, noside
);
553 if (noside
== EVAL_SKIP
)
555 if (binop_must_be_user_defined (arg1
, arg2
))
557 return value_x_binop (arg1
, arg2
, op
, 0);
561 tem
= value_less (arg1
, arg2
);
562 return value_from_long (builtin_type_int
, ! tem
);
566 arg1
= evaluate_subexp (exp
, pos
, noside
);
567 arg2
= evaluate_subexp (exp
, pos
, noside
);
568 if (noside
== EVAL_SKIP
)
570 if (binop_must_be_user_defined (arg1
, arg2
))
572 return value_x_binop (arg1
, arg2
, op
, 0);
576 tem
= value_less (arg2
, arg1
);
577 return value_from_long (builtin_type_int
, ! tem
);
581 arg1
= evaluate_subexp (exp
, pos
, noside
);
582 arg2
= evaluate_subexp (exp
, pos
, noside
);
583 if (noside
== EVAL_SKIP
)
585 return value_repeat (arg1
, value_as_long (arg2
));
588 evaluate_subexp (exp
, pos
, noside
);
589 return evaluate_subexp (exp
, pos
, noside
);
592 arg1
= evaluate_subexp (exp
, pos
, noside
);
593 if (noside
== EVAL_SKIP
)
595 if (unop_must_be_user_defined (arg1
))
596 return value_x_unop (arg1
, op
, 0);
598 return value_neg (arg1
);
601 arg1
= evaluate_subexp (exp
, pos
, noside
);
602 if (noside
== EVAL_SKIP
)
604 if (unop_must_be_user_defined (arg1
))
605 return value_x_unop (arg1
, op
, 0);
607 return value_lognot (arg1
);
610 arg1
= evaluate_subexp (exp
, pos
, noside
);
611 if (noside
== EVAL_SKIP
)
613 if (unop_must_be_user_defined (arg1
))
614 return value_x_unop (arg1
, op
, 0);
616 return value_from_long (builtin_type_int
, value_zerop (arg1
));
619 arg1
= evaluate_subexp (exp
, pos
, noside
);
620 if (noside
== EVAL_SKIP
)
622 return value_ind (arg1
);
625 if (noside
== EVAL_SKIP
)
627 evaluate_subexp (exp
, pos
, EVAL_SKIP
);
630 /* C++: check for and handle pointer to members. */
632 op
= exp
->elts
[*pos
].opcode
;
635 char *name
= &exp
->elts
[pc
+3].string
;
636 int tem
= strlen (name
);
637 struct type
*domain
= exp
->elts
[pc
+2].type
;
638 (*pos
) += 2 + (tem
+ sizeof (union exp_element
)) / sizeof (union exp_element
);
639 arg1
= value_struct_elt_for_address (domain
, 0, name
);
642 error ("no field `%s' in structure", name
);
645 return evaluate_subexp_for_address (exp
, pos
, noside
);
648 if (noside
== EVAL_SKIP
)
650 evaluate_subexp (exp
, pos
, EVAL_SKIP
);
653 return evaluate_subexp_for_sizeof (exp
, pos
);
657 arg1
= evaluate_subexp (exp
, pos
, noside
);
658 if (noside
== EVAL_SKIP
)
660 return value_cast (exp
->elts
[pc
+ 1].type
, arg1
);
664 arg1
= evaluate_subexp (exp
, pos
, noside
);
665 if (noside
== EVAL_SKIP
)
667 return value_at (exp
->elts
[pc
+ 1].type
, value_as_long (arg1
));
669 case UNOP_PREINCREMENT
:
670 arg1
= evaluate_subexp (exp
, pos
, noside
);
671 if (noside
== EVAL_SKIP
|| noside
== EVAL_AVOID_SIDE_EFFECTS
)
673 else if (unop_must_be_user_defined (arg1
))
675 return value_x_unop (arg1
, op
, 0);
679 arg2
= value_add (arg1
, value_from_long (builtin_type_char
, 1));
680 return value_assign (arg1
, arg2
);
683 case UNOP_PREDECREMENT
:
684 arg1
= evaluate_subexp (exp
, pos
, noside
);
685 if (noside
== EVAL_SKIP
|| noside
== EVAL_AVOID_SIDE_EFFECTS
)
687 else if (unop_must_be_user_defined (arg1
))
689 return value_x_unop (arg1
, op
, 0);
693 arg2
= value_sub (arg1
, value_from_long (builtin_type_char
, 1));
694 return value_assign (arg1
, arg2
);
697 case UNOP_POSTINCREMENT
:
698 arg1
= evaluate_subexp (exp
, pos
, noside
);
699 if (noside
== EVAL_SKIP
|| noside
== EVAL_AVOID_SIDE_EFFECTS
)
701 else if (unop_must_be_user_defined (arg1
))
703 return value_x_unop (arg1
, op
, 0);
707 arg2
= value_add (arg1
, value_from_long (builtin_type_char
, 1));
708 value_assign (arg1
, arg2
);
712 case UNOP_POSTDECREMENT
:
713 arg1
= evaluate_subexp (exp
, pos
, noside
);
714 if (noside
== EVAL_SKIP
|| noside
== EVAL_AVOID_SIDE_EFFECTS
)
716 else if (unop_must_be_user_defined (arg1
))
718 return value_x_unop (arg1
, op
, 0);
722 arg2
= value_sub (arg1
, value_from_long (builtin_type_char
, 1));
723 value_assign (arg1
, arg2
);
729 return value_of_this (1);
732 error ("internal error: I dont know how to evaluation what you gave me");
736 return value_from_long (builtin_type_long
, 1);
739 /* Evaluate a subexpression of EXP, at index *POS,
740 and return the address of that subexpression.
741 Advance *POS over the subexpression.
742 If the subexpression isn't an lvalue, get an error.
743 NOSIDE may be EVAL_AVOID_SIDE_EFFECTS;
744 then only the type of the result need be correct. */
747 evaluate_subexp_for_address (exp
, pos
, noside
)
748 register struct expression
*exp
;
756 op
= exp
->elts
[pc
].opcode
;
762 return evaluate_subexp (exp
, pos
, noside
);
766 return value_cast (lookup_pointer_type (exp
->elts
[pc
+ 1].type
),
767 evaluate_subexp (exp
, pos
, noside
));
771 return locate_var_value (exp
->elts
[pc
+ 1].symbol
, (CORE_ADDR
) 0);
774 return value_addr (evaluate_subexp (exp
, pos
, noside
));
778 /* Evaluate like `evaluate_subexp' except coercing arrays to pointers.
779 When used in contexts where arrays will be coerced anyway,
780 this is equivalent to `evaluate_subexp'
781 but much faster because it avoids actually fetching array contents. */
784 evaluate_subexp_with_coercion (exp
, pos
, noside
)
785 register struct expression
*exp
;
789 register enum exp_opcode op
;
794 op
= exp
->elts
[pc
].opcode
;
799 if (TYPE_CODE (SYMBOL_TYPE (exp
->elts
[pc
+ 1].symbol
)) == TYPE_CODE_ARRAY
)
802 val
= locate_var_value (exp
->elts
[pc
+ 1].symbol
, (CORE_ADDR
) 0);
803 return value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (SYMBOL_TYPE (exp
->elts
[pc
+ 1].symbol
))),
808 return evaluate_subexp (exp
, pos
, noside
);
811 /* Evaluate a subexpression of EXP, at index *POS,
812 and return a value for the size of that subexpression.
813 Advance *POS over the subexpression. */
816 evaluate_subexp_for_sizeof (exp
, pos
)
817 register struct expression
*exp
;
825 op
= exp
->elts
[pc
].opcode
;
829 /* This case is handled specially
830 so that we avoid creating a value for the result type.
831 If the result type is very big, it's desirable not to
832 create a value unnecessarily. */
835 val
= evaluate_subexp (exp
, pos
, EVAL_AVOID_SIDE_EFFECTS
);
836 return value_from_long (builtin_type_int
,
837 TYPE_LENGTH (TYPE_TARGET_TYPE (VALUE_TYPE (val
))));
841 return value_from_long (builtin_type_int
,
842 TYPE_LENGTH (exp
->elts
[pc
+ 1].type
));
846 return value_from_long (builtin_type_int
,
847 TYPE_LENGTH (SYMBOL_TYPE (exp
->elts
[pc
+ 1].symbol
)));
850 val
= evaluate_subexp (exp
, pos
, EVAL_AVOID_SIDE_EFFECTS
);
851 return value_from_long (builtin_type_int
,
852 TYPE_LENGTH (VALUE_TYPE (val
)));
This page took 0.048169 seconds and 4 git commands to generate.