]> Git Repo - binutils.git/blob - gdb/valarith.c
bfd/
[binutils.git] / gdb / valarith.c
1 /* Perform arithmetic and other operations on values, for GDB.
2
3    Copyright 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
4    1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software
5    Foundation, Inc.
6
7    This file is part of GDB.
8
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 2 of the License, or
12    (at your option) any later version.
13
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18
19    You should have received a copy of the GNU General Public License
20    along with this program; if not, write to the Free Software
21    Foundation, Inc., 59 Temple Place - Suite 330,
22    Boston, MA 02111-1307, USA.  */
23
24 #include "defs.h"
25 #include "value.h"
26 #include "symtab.h"
27 #include "gdbtypes.h"
28 #include "expression.h"
29 #include "target.h"
30 #include "language.h"
31 #include "gdb_string.h"
32 #include "doublest.h"
33 #include <math.h>
34
35 /* Define whether or not the C operator '/' truncates towards zero for
36    differently signed operands (truncation direction is undefined in C). */
37
38 #ifndef TRUNCATION_TOWARDS_ZERO
39 #define TRUNCATION_TOWARDS_ZERO ((-5 / 2) == -2)
40 #endif
41
42 static struct value *value_subscripted_rvalue (struct value *, struct value *, int);
43
44 void _initialize_valarith (void);
45 \f
46
47 /* Given a pointer, return the size of its target.
48    If the pointer type is void *, then return 1.
49    If the target type is incomplete, then error out.
50    This isn't a general purpose function, but just a 
51    helper for value_sub & value_add.
52 */
53
54 static LONGEST
55 find_size_for_pointer_math (struct type *ptr_type)
56 {
57   LONGEST sz = -1;
58   struct type *ptr_target;
59
60   ptr_target = check_typedef (TYPE_TARGET_TYPE (ptr_type));
61
62   sz = TYPE_LENGTH (ptr_target);
63   if (sz == 0)
64     {
65       if (TYPE_CODE (ptr_type) == TYPE_CODE_VOID)
66         sz = 1;
67       else
68         {
69           char *name;
70           
71           name = TYPE_NAME (ptr_target);
72           if (name == NULL)
73             name = TYPE_TAG_NAME (ptr_target);
74           if (name == NULL)
75             error ("Cannot perform pointer math on incomplete types, "
76                    "try casting to a known type, or void *.");
77           else
78             error ("Cannot perform pointer math on incomplete type \"%s\", "
79                    "try casting to a known type, or void *.", name);
80         }
81     }
82   return sz;
83 }
84
85 struct value *
86 value_add (struct value *arg1, struct value *arg2)
87 {
88   struct value *valint;
89   struct value *valptr;
90   LONGEST sz;
91   struct type *type1, *type2, *valptrtype;
92
93   COERCE_NUMBER (arg1);
94   COERCE_NUMBER (arg2);
95   type1 = check_typedef (VALUE_TYPE (arg1));
96   type2 = check_typedef (VALUE_TYPE (arg2));
97
98   if ((TYPE_CODE (type1) == TYPE_CODE_PTR
99        || TYPE_CODE (type2) == TYPE_CODE_PTR)
100       &&
101       (TYPE_CODE (type1) == TYPE_CODE_INT
102        || TYPE_CODE (type2) == TYPE_CODE_INT))
103     /* Exactly one argument is a pointer, and one is an integer.  */
104     {
105       struct value *retval;
106
107       if (TYPE_CODE (type1) == TYPE_CODE_PTR)
108         {
109           valptr = arg1;
110           valint = arg2;
111           valptrtype = type1;
112         }
113       else
114         {
115           valptr = arg2;
116           valint = arg1;
117           valptrtype = type2;
118         }
119
120       sz = find_size_for_pointer_math (valptrtype);
121
122       retval = value_from_pointer (valptrtype,
123                                    value_as_address (valptr)
124                                    + (sz * value_as_long (valint)));
125       VALUE_BFD_SECTION (retval) = VALUE_BFD_SECTION (valptr);
126       return retval;
127     }
128
129   return value_binop (arg1, arg2, BINOP_ADD);
130 }
131
132 struct value *
133 value_sub (struct value *arg1, struct value *arg2)
134 {
135   struct type *type1, *type2;
136   COERCE_NUMBER (arg1);
137   COERCE_NUMBER (arg2);
138   type1 = check_typedef (VALUE_TYPE (arg1));
139   type2 = check_typedef (VALUE_TYPE (arg2));
140
141   if (TYPE_CODE (type1) == TYPE_CODE_PTR)
142     {
143       if (TYPE_CODE (type2) == TYPE_CODE_INT)
144         {
145           /* pointer - integer.  */
146           LONGEST sz = find_size_for_pointer_math (type1);
147
148           return value_from_pointer (type1,
149                                      (value_as_address (arg1)
150                                       - (sz * value_as_long (arg2))));
151         }
152       else if (TYPE_CODE (type2) == TYPE_CODE_PTR
153                && TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (type1)))
154                == TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (type2))))
155         {
156           /* pointer to <type x> - pointer to <type x>.  */
157           LONGEST sz = TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (type1)));
158           return value_from_longest
159             (builtin_type_long, /* FIXME -- should be ptrdiff_t */
160              (value_as_long (arg1) - value_as_long (arg2)) / sz);
161         }
162       else
163         {
164           error ("\
165 First argument of `-' is a pointer and second argument is neither\n\
166 an integer nor a pointer of the same type.");
167         }
168     }
169
170   return value_binop (arg1, arg2, BINOP_SUB);
171 }
172
173 /* Return the value of ARRAY[IDX].
174    See comments in value_coerce_array() for rationale for reason for
175    doing lower bounds adjustment here rather than there.
176    FIXME:  Perhaps we should validate that the index is valid and if
177    verbosity is set, warn about invalid indices (but still use them). */
178
179 struct value *
180 value_subscript (struct value *array, struct value *idx)
181 {
182   struct value *bound;
183   int c_style = current_language->c_style_arrays;
184   struct type *tarray;
185
186   COERCE_REF (array);
187   tarray = check_typedef (VALUE_TYPE (array));
188   COERCE_VARYING_ARRAY (array, tarray);
189
190   if (TYPE_CODE (tarray) == TYPE_CODE_ARRAY
191       || TYPE_CODE (tarray) == TYPE_CODE_STRING)
192     {
193       struct type *range_type = TYPE_INDEX_TYPE (tarray);
194       LONGEST lowerbound, upperbound;
195       get_discrete_bounds (range_type, &lowerbound, &upperbound);
196
197       if (VALUE_LVAL (array) != lval_memory)
198         return value_subscripted_rvalue (array, idx, lowerbound);
199
200       if (c_style == 0)
201         {
202           LONGEST index = value_as_long (idx);
203           if (index >= lowerbound && index <= upperbound)
204             return value_subscripted_rvalue (array, idx, lowerbound);
205           warning ("array or string index out of range");
206           /* fall doing C stuff */
207           c_style = 1;
208         }
209
210       if (lowerbound != 0)
211         {
212           bound = value_from_longest (builtin_type_int, (LONGEST) lowerbound);
213           idx = value_sub (idx, bound);
214         }
215
216       array = value_coerce_array (array);
217     }
218
219   if (TYPE_CODE (tarray) == TYPE_CODE_BITSTRING)
220     {
221       struct type *range_type = TYPE_INDEX_TYPE (tarray);
222       LONGEST index = value_as_long (idx);
223       struct value *v;
224       int offset, byte, bit_index;
225       LONGEST lowerbound, upperbound;
226       get_discrete_bounds (range_type, &lowerbound, &upperbound);
227       if (index < lowerbound || index > upperbound)
228         error ("bitstring index out of range");
229       index -= lowerbound;
230       offset = index / TARGET_CHAR_BIT;
231       byte = *((char *) VALUE_CONTENTS (array) + offset);
232       bit_index = index % TARGET_CHAR_BIT;
233       byte >>= (BITS_BIG_ENDIAN ? TARGET_CHAR_BIT - 1 - bit_index : bit_index);
234       v = value_from_longest (LA_BOOL_TYPE, byte & 1);
235       VALUE_BITPOS (v) = bit_index;
236       VALUE_BITSIZE (v) = 1;
237       VALUE_LVAL (v) = VALUE_LVAL (array);
238       if (VALUE_LVAL (array) == lval_internalvar)
239         VALUE_LVAL (v) = lval_internalvar_component;
240       VALUE_ADDRESS (v) = VALUE_ADDRESS (array);
241       VALUE_OFFSET (v) = offset + VALUE_OFFSET (array);
242       return v;
243     }
244
245   if (c_style)
246     return value_ind (value_add (array, idx));
247   else
248     error ("not an array or string");
249 }
250
251 /* Return the value of EXPR[IDX], expr an aggregate rvalue
252    (eg, a vector register).  This routine used to promote floats
253    to doubles, but no longer does.  */
254
255 static struct value *
256 value_subscripted_rvalue (struct value *array, struct value *idx, int lowerbound)
257 {
258   struct type *array_type = check_typedef (VALUE_TYPE (array));
259   struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (array_type));
260   unsigned int elt_size = TYPE_LENGTH (elt_type);
261   LONGEST index = value_as_long (idx);
262   unsigned int elt_offs = elt_size * longest_to_int (index - lowerbound);
263   struct value *v;
264
265   if (index < lowerbound || elt_offs >= TYPE_LENGTH (array_type))
266     error ("no such vector element");
267
268   v = allocate_value (elt_type);
269   if (VALUE_LAZY (array))
270     VALUE_LAZY (v) = 1;
271   else
272     memcpy (VALUE_CONTENTS (v), VALUE_CONTENTS (array) + elt_offs, elt_size);
273
274   if (VALUE_LVAL (array) == lval_internalvar)
275     VALUE_LVAL (v) = lval_internalvar_component;
276   else
277     VALUE_LVAL (v) = VALUE_LVAL (array);
278   VALUE_ADDRESS (v) = VALUE_ADDRESS (array);
279   VALUE_OFFSET (v) = VALUE_OFFSET (array) + elt_offs;
280   return v;
281 }
282 \f
283 /* Check to see if either argument is a structure.  This is called so
284    we know whether to go ahead with the normal binop or look for a 
285    user defined function instead.
286
287    For now, we do not overload the `=' operator.  */
288
289 int
290 binop_user_defined_p (enum exp_opcode op, struct value *arg1, struct value *arg2)
291 {
292   struct type *type1, *type2;
293   if (op == BINOP_ASSIGN || op == BINOP_CONCAT)
294     return 0;
295   type1 = check_typedef (VALUE_TYPE (arg1));
296   type2 = check_typedef (VALUE_TYPE (arg2));
297   return (TYPE_CODE (type1) == TYPE_CODE_STRUCT
298           || TYPE_CODE (type2) == TYPE_CODE_STRUCT
299           || (TYPE_CODE (type1) == TYPE_CODE_REF
300               && TYPE_CODE (TYPE_TARGET_TYPE (type1)) == TYPE_CODE_STRUCT)
301           || (TYPE_CODE (type2) == TYPE_CODE_REF
302               && TYPE_CODE (TYPE_TARGET_TYPE (type2)) == TYPE_CODE_STRUCT));
303 }
304
305 /* Check to see if argument is a structure.  This is called so
306    we know whether to go ahead with the normal unop or look for a 
307    user defined function instead.
308
309    For now, we do not overload the `&' operator.  */
310
311 int
312 unop_user_defined_p (enum exp_opcode op, struct value *arg1)
313 {
314   struct type *type1;
315   if (op == UNOP_ADDR)
316     return 0;
317   type1 = check_typedef (VALUE_TYPE (arg1));
318   for (;;)
319     {
320       if (TYPE_CODE (type1) == TYPE_CODE_STRUCT)
321         return 1;
322       else if (TYPE_CODE (type1) == TYPE_CODE_REF)
323         type1 = TYPE_TARGET_TYPE (type1);
324       else
325         return 0;
326     }
327 }
328
329 /* We know either arg1 or arg2 is a structure, so try to find the right
330    user defined function.  Create an argument vector that calls 
331    arg1.operator @ (arg1,arg2) and return that value (where '@' is any
332    binary operator which is legal for GNU C++).
333
334    OP is the operatore, and if it is BINOP_ASSIGN_MODIFY, then OTHEROP
335    is the opcode saying how to modify it.  Otherwise, OTHEROP is
336    unused.  */
337
338 struct value *
339 value_x_binop (struct value *arg1, struct value *arg2, enum exp_opcode op,
340                enum exp_opcode otherop, enum noside noside)
341 {
342   struct value **argvec;
343   char *ptr;
344   char tstr[13];
345   int static_memfuncp;
346
347   COERCE_REF (arg1);
348   COERCE_REF (arg2);
349   COERCE_ENUM (arg1);
350   COERCE_ENUM (arg2);
351
352   /* now we know that what we have to do is construct our
353      arg vector and find the right function to call it with.  */
354
355   if (TYPE_CODE (check_typedef (VALUE_TYPE (arg1))) != TYPE_CODE_STRUCT)
356     error ("Can't do that binary op on that type");     /* FIXME be explicit */
357
358   argvec = (struct value **) alloca (sizeof (struct value *) * 4);
359   argvec[1] = value_addr (arg1);
360   argvec[2] = arg2;
361   argvec[3] = 0;
362
363   /* make the right function name up */
364   strcpy (tstr, "operator__");
365   ptr = tstr + 8;
366   switch (op)
367     {
368     case BINOP_ADD:
369       strcpy (ptr, "+");
370       break;
371     case BINOP_SUB:
372       strcpy (ptr, "-");
373       break;
374     case BINOP_MUL:
375       strcpy (ptr, "*");
376       break;
377     case BINOP_DIV:
378       strcpy (ptr, "/");
379       break;
380     case BINOP_REM:
381       strcpy (ptr, "%");
382       break;
383     case BINOP_LSH:
384       strcpy (ptr, "<<");
385       break;
386     case BINOP_RSH:
387       strcpy (ptr, ">>");
388       break;
389     case BINOP_BITWISE_AND:
390       strcpy (ptr, "&");
391       break;
392     case BINOP_BITWISE_IOR:
393       strcpy (ptr, "|");
394       break;
395     case BINOP_BITWISE_XOR:
396       strcpy (ptr, "^");
397       break;
398     case BINOP_LOGICAL_AND:
399       strcpy (ptr, "&&");
400       break;
401     case BINOP_LOGICAL_OR:
402       strcpy (ptr, "||");
403       break;
404     case BINOP_MIN:
405       strcpy (ptr, "<?");
406       break;
407     case BINOP_MAX:
408       strcpy (ptr, ">?");
409       break;
410     case BINOP_ASSIGN:
411       strcpy (ptr, "=");
412       break;
413     case BINOP_ASSIGN_MODIFY:
414       switch (otherop)
415         {
416         case BINOP_ADD:
417           strcpy (ptr, "+=");
418           break;
419         case BINOP_SUB:
420           strcpy (ptr, "-=");
421           break;
422         case BINOP_MUL:
423           strcpy (ptr, "*=");
424           break;
425         case BINOP_DIV:
426           strcpy (ptr, "/=");
427           break;
428         case BINOP_REM:
429           strcpy (ptr, "%=");
430           break;
431         case BINOP_BITWISE_AND:
432           strcpy (ptr, "&=");
433           break;
434         case BINOP_BITWISE_IOR:
435           strcpy (ptr, "|=");
436           break;
437         case BINOP_BITWISE_XOR:
438           strcpy (ptr, "^=");
439           break;
440         case BINOP_MOD: /* invalid */
441         default:
442           error ("Invalid binary operation specified.");
443         }
444       break;
445     case BINOP_SUBSCRIPT:
446       strcpy (ptr, "[]");
447       break;
448     case BINOP_EQUAL:
449       strcpy (ptr, "==");
450       break;
451     case BINOP_NOTEQUAL:
452       strcpy (ptr, "!=");
453       break;
454     case BINOP_LESS:
455       strcpy (ptr, "<");
456       break;
457     case BINOP_GTR:
458       strcpy (ptr, ">");
459       break;
460     case BINOP_GEQ:
461       strcpy (ptr, ">=");
462       break;
463     case BINOP_LEQ:
464       strcpy (ptr, "<=");
465       break;
466     case BINOP_MOD:             /* invalid */
467     default:
468       error ("Invalid binary operation specified.");
469     }
470
471   argvec[0] = value_struct_elt (&arg1, argvec + 1, tstr, &static_memfuncp, "structure");
472
473   if (argvec[0])
474     {
475       if (static_memfuncp)
476         {
477           argvec[1] = argvec[0];
478           argvec++;
479         }
480       if (noside == EVAL_AVOID_SIDE_EFFECTS)
481         {
482           struct type *return_type;
483           return_type
484             = TYPE_TARGET_TYPE (check_typedef (VALUE_TYPE (argvec[0])));
485           return value_zero (return_type, VALUE_LVAL (arg1));
486         }
487       return call_function_by_hand (argvec[0], 2 - static_memfuncp, argvec + 1);
488     }
489   error ("member function %s not found", tstr);
490 #ifdef lint
491   return call_function_by_hand (argvec[0], 2 - static_memfuncp, argvec + 1);
492 #endif
493 }
494
495 /* We know that arg1 is a structure, so try to find a unary user
496    defined operator that matches the operator in question.  
497    Create an argument vector that calls arg1.operator @ (arg1)
498    and return that value (where '@' is (almost) any unary operator which
499    is legal for GNU C++).  */
500
501 struct value *
502 value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside)
503 {
504   struct value **argvec;
505   char *ptr, *mangle_ptr;
506   char tstr[13], mangle_tstr[13];
507   int static_memfuncp, nargs;
508
509   COERCE_REF (arg1);
510   COERCE_ENUM (arg1);
511
512   /* now we know that what we have to do is construct our
513      arg vector and find the right function to call it with.  */
514
515   if (TYPE_CODE (check_typedef (VALUE_TYPE (arg1))) != TYPE_CODE_STRUCT)
516     error ("Can't do that unary op on that type");      /* FIXME be explicit */
517
518   argvec = (struct value **) alloca (sizeof (struct value *) * 4);
519   argvec[1] = value_addr (arg1);
520   argvec[2] = 0;
521
522   nargs = 1;
523
524   /* make the right function name up */
525   strcpy (tstr, "operator__");
526   ptr = tstr + 8;
527   strcpy (mangle_tstr, "__");
528   mangle_ptr = mangle_tstr + 2;
529   switch (op)
530     {
531     case UNOP_PREINCREMENT:
532       strcpy (ptr, "++");
533       break;
534     case UNOP_PREDECREMENT:
535       strcpy (ptr, "--");
536       break;
537     case UNOP_POSTINCREMENT:
538       strcpy (ptr, "++");
539       argvec[2] = value_from_longest (builtin_type_int, 0);
540       argvec[3] = 0;
541       nargs ++;
542       break;
543     case UNOP_POSTDECREMENT:
544       strcpy (ptr, "--");
545       argvec[2] = value_from_longest (builtin_type_int, 0);
546       argvec[3] = 0;
547       nargs ++;
548       break;
549     case UNOP_LOGICAL_NOT:
550       strcpy (ptr, "!");
551       break;
552     case UNOP_COMPLEMENT:
553       strcpy (ptr, "~");
554       break;
555     case UNOP_NEG:
556       strcpy (ptr, "-");
557       break;
558     case UNOP_IND:
559       strcpy (ptr, "*");
560       break;
561     default:
562       error ("Invalid unary operation specified.");
563     }
564
565   argvec[0] = value_struct_elt (&arg1, argvec + 1, tstr, &static_memfuncp, "structure");
566
567   if (argvec[0])
568     {
569       if (static_memfuncp)
570         {
571           argvec[1] = argvec[0];
572           nargs --;
573           argvec++;
574         }
575       if (noside == EVAL_AVOID_SIDE_EFFECTS)
576         {
577           struct type *return_type;
578           return_type
579             = TYPE_TARGET_TYPE (check_typedef (VALUE_TYPE (argvec[0])));
580           return value_zero (return_type, VALUE_LVAL (arg1));
581         }
582       return call_function_by_hand (argvec[0], nargs, argvec + 1);
583     }
584   error ("member function %s not found", tstr);
585   return 0;                     /* For lint -- never reached */
586 }
587 \f
588
589 /* Concatenate two values with the following conditions:
590
591    (1)  Both values must be either bitstring values or character string
592    values and the resulting value consists of the concatenation of
593    ARG1 followed by ARG2.
594
595    or
596
597    One value must be an integer value and the other value must be
598    either a bitstring value or character string value, which is
599    to be repeated by the number of times specified by the integer
600    value.
601
602
603    (2)  Boolean values are also allowed and are treated as bit string
604    values of length 1.
605
606    (3)  Character values are also allowed and are treated as character
607    string values of length 1.
608  */
609
610 struct value *
611 value_concat (struct value *arg1, struct value *arg2)
612 {
613   struct value *inval1;
614   struct value *inval2;
615   struct value *outval = NULL;
616   int inval1len, inval2len;
617   int count, idx;
618   char *ptr;
619   char inchar;
620   struct type *type1 = check_typedef (VALUE_TYPE (arg1));
621   struct type *type2 = check_typedef (VALUE_TYPE (arg2));
622
623   COERCE_VARYING_ARRAY (arg1, type1);
624   COERCE_VARYING_ARRAY (arg2, type2);
625
626   /* First figure out if we are dealing with two values to be concatenated
627      or a repeat count and a value to be repeated.  INVAL1 is set to the
628      first of two concatenated values, or the repeat count.  INVAL2 is set
629      to the second of the two concatenated values or the value to be 
630      repeated. */
631
632   if (TYPE_CODE (type2) == TYPE_CODE_INT)
633     {
634       struct type *tmp = type1;
635       type1 = tmp;
636       tmp = type2;
637       inval1 = arg2;
638       inval2 = arg1;
639     }
640   else
641     {
642       inval1 = arg1;
643       inval2 = arg2;
644     }
645
646   /* Now process the input values. */
647
648   if (TYPE_CODE (type1) == TYPE_CODE_INT)
649     {
650       /* We have a repeat count.  Validate the second value and then
651          construct a value repeated that many times. */
652       if (TYPE_CODE (type2) == TYPE_CODE_STRING
653           || TYPE_CODE (type2) == TYPE_CODE_CHAR)
654         {
655           count = longest_to_int (value_as_long (inval1));
656           inval2len = TYPE_LENGTH (type2);
657           ptr = (char *) alloca (count * inval2len);
658           if (TYPE_CODE (type2) == TYPE_CODE_CHAR)
659             {
660               inchar = (char) unpack_long (type2,
661                                            VALUE_CONTENTS (inval2));
662               for (idx = 0; idx < count; idx++)
663                 {
664                   *(ptr + idx) = inchar;
665                 }
666             }
667           else
668             {
669               for (idx = 0; idx < count; idx++)
670                 {
671                   memcpy (ptr + (idx * inval2len), VALUE_CONTENTS (inval2),
672                           inval2len);
673                 }
674             }
675           outval = value_string (ptr, count * inval2len);
676         }
677       else if (TYPE_CODE (type2) == TYPE_CODE_BITSTRING
678                || TYPE_CODE (type2) == TYPE_CODE_BOOL)
679         {
680           error ("unimplemented support for bitstring/boolean repeats");
681         }
682       else
683         {
684           error ("can't repeat values of that type");
685         }
686     }
687   else if (TYPE_CODE (type1) == TYPE_CODE_STRING
688            || TYPE_CODE (type1) == TYPE_CODE_CHAR)
689     {
690       /* We have two character strings to concatenate. */
691       if (TYPE_CODE (type2) != TYPE_CODE_STRING
692           && TYPE_CODE (type2) != TYPE_CODE_CHAR)
693         {
694           error ("Strings can only be concatenated with other strings.");
695         }
696       inval1len = TYPE_LENGTH (type1);
697       inval2len = TYPE_LENGTH (type2);
698       ptr = (char *) alloca (inval1len + inval2len);
699       if (TYPE_CODE (type1) == TYPE_CODE_CHAR)
700         {
701           *ptr = (char) unpack_long (type1, VALUE_CONTENTS (inval1));
702         }
703       else
704         {
705           memcpy (ptr, VALUE_CONTENTS (inval1), inval1len);
706         }
707       if (TYPE_CODE (type2) == TYPE_CODE_CHAR)
708         {
709           *(ptr + inval1len) =
710             (char) unpack_long (type2, VALUE_CONTENTS (inval2));
711         }
712       else
713         {
714           memcpy (ptr + inval1len, VALUE_CONTENTS (inval2), inval2len);
715         }
716       outval = value_string (ptr, inval1len + inval2len);
717     }
718   else if (TYPE_CODE (type1) == TYPE_CODE_BITSTRING
719            || TYPE_CODE (type1) == TYPE_CODE_BOOL)
720     {
721       /* We have two bitstrings to concatenate. */
722       if (TYPE_CODE (type2) != TYPE_CODE_BITSTRING
723           && TYPE_CODE (type2) != TYPE_CODE_BOOL)
724         {
725           error ("Bitstrings or booleans can only be concatenated with other bitstrings or booleans.");
726         }
727       error ("unimplemented support for bitstring/boolean concatenation.");
728     }
729   else
730     {
731       /* We don't know how to concatenate these operands. */
732       error ("illegal operands for concatenation.");
733     }
734   return (outval);
735 }
736 \f
737
738
739 /* Perform a binary operation on two operands which have reasonable
740    representations as integers or floats.  This includes booleans,
741    characters, integers, or floats.
742    Does not support addition and subtraction on pointers;
743    use value_add or value_sub if you want to handle those possibilities.  */
744
745 struct value *
746 value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
747 {
748   struct value *val;
749   struct type *type1, *type2;
750
751   COERCE_REF (arg1);
752   COERCE_REF (arg2);
753   COERCE_ENUM (arg1);
754   COERCE_ENUM (arg2);
755   type1 = check_typedef (VALUE_TYPE (arg1));
756   type2 = check_typedef (VALUE_TYPE (arg2));
757
758   if ((TYPE_CODE (type1) != TYPE_CODE_FLT
759        && TYPE_CODE (type1) != TYPE_CODE_CHAR
760        && TYPE_CODE (type1) != TYPE_CODE_INT
761        && TYPE_CODE (type1) != TYPE_CODE_BOOL
762        && TYPE_CODE (type1) != TYPE_CODE_RANGE)
763       ||
764       (TYPE_CODE (type2) != TYPE_CODE_FLT
765        && TYPE_CODE (type2) != TYPE_CODE_CHAR
766        && TYPE_CODE (type2) != TYPE_CODE_INT
767        && TYPE_CODE (type2) != TYPE_CODE_BOOL
768        && TYPE_CODE (type2) != TYPE_CODE_RANGE))
769     error ("Argument to arithmetic operation not a number or boolean.");
770
771   if (TYPE_CODE (type1) == TYPE_CODE_FLT
772       ||
773       TYPE_CODE (type2) == TYPE_CODE_FLT)
774     {
775       /* FIXME-if-picky-about-floating-accuracy: Should be doing this
776          in target format.  real.c in GCC probably has the necessary
777          code.  */
778       DOUBLEST v1, v2, v = 0;
779       v1 = value_as_double (arg1);
780       v2 = value_as_double (arg2);
781       switch (op)
782         {
783         case BINOP_ADD:
784           v = v1 + v2;
785           break;
786
787         case BINOP_SUB:
788           v = v1 - v2;
789           break;
790
791         case BINOP_MUL:
792           v = v1 * v2;
793           break;
794
795         case BINOP_DIV:
796           v = v1 / v2;
797           break;
798
799         case BINOP_EXP:
800           v = pow (v1, v2);
801           if (errno)
802             error ("Cannot perform exponentiation: %s", safe_strerror (errno));
803           break;
804
805         default:
806           error ("Integer-only operation on floating point number.");
807         }
808
809       /* If either arg was long double, make sure that value is also long
810          double.  */
811
812       if (TYPE_LENGTH (type1) * 8 > TARGET_DOUBLE_BIT
813           || TYPE_LENGTH (type2) * 8 > TARGET_DOUBLE_BIT)
814         val = allocate_value (builtin_type_long_double);
815       else
816         val = allocate_value (builtin_type_double);
817
818       store_typed_floating (VALUE_CONTENTS_RAW (val), VALUE_TYPE (val), v);
819     }
820   else if (TYPE_CODE (type1) == TYPE_CODE_BOOL
821            &&
822            TYPE_CODE (type2) == TYPE_CODE_BOOL)
823     {
824       LONGEST v1, v2, v = 0;
825       v1 = value_as_long (arg1);
826       v2 = value_as_long (arg2);
827
828       switch (op)
829         {
830         case BINOP_BITWISE_AND:
831           v = v1 & v2;
832           break;
833
834         case BINOP_BITWISE_IOR:
835           v = v1 | v2;
836           break;
837
838         case BINOP_BITWISE_XOR:
839           v = v1 ^ v2;
840           break;
841               
842         case BINOP_EQUAL:
843           v = v1 == v2;
844           break;
845           
846         case BINOP_NOTEQUAL:
847           v = v1 != v2;
848           break;
849
850         default:
851           error ("Invalid operation on booleans.");
852         }
853
854       val = allocate_value (type1);
855       store_signed_integer (VALUE_CONTENTS_RAW (val),
856                             TYPE_LENGTH (type1),
857                             v);
858     }
859   else
860     /* Integral operations here.  */
861     /* FIXME:  Also mixed integral/booleans, with result an integer. */
862     /* FIXME: This implements ANSI C rules (also correct for C++).
863        What about FORTRAN and (the deleted) chill ?  */
864     {
865       unsigned int promoted_len1 = TYPE_LENGTH (type1);
866       unsigned int promoted_len2 = TYPE_LENGTH (type2);
867       int is_unsigned1 = TYPE_UNSIGNED (type1);
868       int is_unsigned2 = TYPE_UNSIGNED (type2);
869       unsigned int result_len;
870       int unsigned_operation;
871
872       /* Determine type length and signedness after promotion for
873          both operands.  */
874       if (promoted_len1 < TYPE_LENGTH (builtin_type_int))
875         {
876           is_unsigned1 = 0;
877           promoted_len1 = TYPE_LENGTH (builtin_type_int);
878         }
879       if (promoted_len2 < TYPE_LENGTH (builtin_type_int))
880         {
881           is_unsigned2 = 0;
882           promoted_len2 = TYPE_LENGTH (builtin_type_int);
883         }
884
885       /* Determine type length of the result, and if the operation should
886          be done unsigned.
887          Use the signedness of the operand with the greater length.
888          If both operands are of equal length, use unsigned operation
889          if one of the operands is unsigned.  */
890       if (promoted_len1 > promoted_len2)
891         {
892           unsigned_operation = is_unsigned1;
893           result_len = promoted_len1;
894         }
895       else if (promoted_len2 > promoted_len1)
896         {
897           unsigned_operation = is_unsigned2;
898           result_len = promoted_len2;
899         }
900       else
901         {
902           unsigned_operation = is_unsigned1 || is_unsigned2;
903           result_len = promoted_len1;
904         }
905
906       if (unsigned_operation)
907         {
908           ULONGEST v1, v2, v = 0;
909           v1 = (ULONGEST) value_as_long (arg1);
910           v2 = (ULONGEST) value_as_long (arg2);
911
912           /* Truncate values to the type length of the result.  */
913           if (result_len < sizeof (ULONGEST))
914             {
915               v1 &= ((LONGEST) 1 << HOST_CHAR_BIT * result_len) - 1;
916               v2 &= ((LONGEST) 1 << HOST_CHAR_BIT * result_len) - 1;
917             }
918
919           switch (op)
920             {
921             case BINOP_ADD:
922               v = v1 + v2;
923               break;
924
925             case BINOP_SUB:
926               v = v1 - v2;
927               break;
928
929             case BINOP_MUL:
930               v = v1 * v2;
931               break;
932
933             case BINOP_DIV:
934               v = v1 / v2;
935               break;
936
937             case BINOP_EXP:
938               v = pow (v1, v2);
939               if (errno)
940                 error ("Cannot perform exponentiation: %s", safe_strerror (errno));
941               break;
942
943             case BINOP_REM:
944               v = v1 % v2;
945               break;
946
947             case BINOP_MOD:
948               /* Knuth 1.2.4, integer only.  Note that unlike the C '%' op,
949                  v1 mod 0 has a defined value, v1. */
950               if (v2 == 0)
951                 {
952                   v = v1;
953                 }
954               else
955                 {
956                   v = v1 / v2;
957                   /* Note floor(v1/v2) == v1/v2 for unsigned. */
958                   v = v1 - (v2 * v);
959                 }
960               break;
961
962             case BINOP_LSH:
963               v = v1 << v2;
964               break;
965
966             case BINOP_RSH:
967               v = v1 >> v2;
968               break;
969
970             case BINOP_BITWISE_AND:
971               v = v1 & v2;
972               break;
973
974             case BINOP_BITWISE_IOR:
975               v = v1 | v2;
976               break;
977
978             case BINOP_BITWISE_XOR:
979               v = v1 ^ v2;
980               break;
981
982             case BINOP_LOGICAL_AND:
983               v = v1 && v2;
984               break;
985
986             case BINOP_LOGICAL_OR:
987               v = v1 || v2;
988               break;
989
990             case BINOP_MIN:
991               v = v1 < v2 ? v1 : v2;
992               break;
993
994             case BINOP_MAX:
995               v = v1 > v2 ? v1 : v2;
996               break;
997
998             case BINOP_EQUAL:
999               v = v1 == v2;
1000               break;
1001
1002             case BINOP_NOTEQUAL:
1003               v = v1 != v2;
1004               break;
1005
1006             case BINOP_LESS:
1007               v = v1 < v2;
1008               break;
1009
1010             default:
1011               error ("Invalid binary operation on numbers.");
1012             }
1013
1014           /* This is a kludge to get around the fact that we don't
1015              know how to determine the result type from the types of
1016              the operands.  (I'm not really sure how much we feel the
1017              need to duplicate the exact rules of the current
1018              language.  They can get really hairy.  But not to do so
1019              makes it hard to document just what we *do* do).  */
1020
1021           /* Can't just call init_type because we wouldn't know what
1022              name to give the type.  */
1023           val = allocate_value
1024             (result_len > TARGET_LONG_BIT / HOST_CHAR_BIT
1025              ? builtin_type_unsigned_long_long
1026              : builtin_type_unsigned_long);
1027           store_unsigned_integer (VALUE_CONTENTS_RAW (val),
1028                                   TYPE_LENGTH (VALUE_TYPE (val)),
1029                                   v);
1030         }
1031       else
1032         {
1033           LONGEST v1, v2, v = 0;
1034           v1 = value_as_long (arg1);
1035           v2 = value_as_long (arg2);
1036
1037           switch (op)
1038             {
1039             case BINOP_ADD:
1040               v = v1 + v2;
1041               break;
1042
1043             case BINOP_SUB:
1044               v = v1 - v2;
1045               break;
1046
1047             case BINOP_MUL:
1048               v = v1 * v2;
1049               break;
1050
1051             case BINOP_DIV:
1052               v = v1 / v2;
1053               break;
1054
1055             case BINOP_EXP:
1056               v = pow (v1, v2);
1057               if (errno)
1058                 error ("Cannot perform exponentiation: %s", safe_strerror (errno));
1059               break;
1060
1061             case BINOP_REM:
1062               v = v1 % v2;
1063               break;
1064
1065             case BINOP_MOD:
1066               /* Knuth 1.2.4, integer only.  Note that unlike the C '%' op,
1067                  X mod 0 has a defined value, X. */
1068               if (v2 == 0)
1069                 {
1070                   v = v1;
1071                 }
1072               else
1073                 {
1074                   v = v1 / v2;
1075                   /* Compute floor. */
1076                   if (TRUNCATION_TOWARDS_ZERO && (v < 0) && ((v1 % v2) != 0))
1077                     {
1078                       v--;
1079                     }
1080                   v = v1 - (v2 * v);
1081                 }
1082               break;
1083
1084             case BINOP_LSH:
1085               v = v1 << v2;
1086               break;
1087
1088             case BINOP_RSH:
1089               v = v1 >> v2;
1090               break;
1091
1092             case BINOP_BITWISE_AND:
1093               v = v1 & v2;
1094               break;
1095
1096             case BINOP_BITWISE_IOR:
1097               v = v1 | v2;
1098               break;
1099
1100             case BINOP_BITWISE_XOR:
1101               v = v1 ^ v2;
1102               break;
1103
1104             case BINOP_LOGICAL_AND:
1105               v = v1 && v2;
1106               break;
1107
1108             case BINOP_LOGICAL_OR:
1109               v = v1 || v2;
1110               break;
1111
1112             case BINOP_MIN:
1113               v = v1 < v2 ? v1 : v2;
1114               break;
1115
1116             case BINOP_MAX:
1117               v = v1 > v2 ? v1 : v2;
1118               break;
1119
1120             case BINOP_EQUAL:
1121               v = v1 == v2;
1122               break;
1123
1124             case BINOP_LESS:
1125               v = v1 < v2;
1126               break;
1127
1128             default:
1129               error ("Invalid binary operation on numbers.");
1130             }
1131
1132           /* This is a kludge to get around the fact that we don't
1133              know how to determine the result type from the types of
1134              the operands.  (I'm not really sure how much we feel the
1135              need to duplicate the exact rules of the current
1136              language.  They can get really hairy.  But not to do so
1137              makes it hard to document just what we *do* do).  */
1138
1139           /* Can't just call init_type because we wouldn't know what
1140              name to give the type.  */
1141           val = allocate_value
1142             (result_len > TARGET_LONG_BIT / HOST_CHAR_BIT
1143              ? builtin_type_long_long
1144              : builtin_type_long);
1145           store_signed_integer (VALUE_CONTENTS_RAW (val),
1146                                 TYPE_LENGTH (VALUE_TYPE (val)),
1147                                 v);
1148         }
1149     }
1150
1151   return val;
1152 }
1153 \f
1154 /* Simulate the C operator ! -- return 1 if ARG1 contains zero.  */
1155
1156 int
1157 value_logical_not (struct value *arg1)
1158 {
1159   register int len;
1160   register char *p;
1161   struct type *type1;
1162
1163   COERCE_NUMBER (arg1);
1164   type1 = check_typedef (VALUE_TYPE (arg1));
1165
1166   if (TYPE_CODE (type1) == TYPE_CODE_FLT)
1167     return 0 == value_as_double (arg1);
1168
1169   len = TYPE_LENGTH (type1);
1170   p = VALUE_CONTENTS (arg1);
1171
1172   while (--len >= 0)
1173     {
1174       if (*p++)
1175         break;
1176     }
1177
1178   return len < 0;
1179 }
1180
1181 /* Perform a comparison on two string values (whose content are not
1182    necessarily null terminated) based on their length */
1183
1184 static int
1185 value_strcmp (struct value *arg1, struct value *arg2)
1186 {
1187   int len1 = TYPE_LENGTH (VALUE_TYPE (arg1));
1188   int len2 = TYPE_LENGTH (VALUE_TYPE (arg2));
1189   char *s1 = VALUE_CONTENTS (arg1);
1190   char *s2 = VALUE_CONTENTS (arg2);
1191   int i, len = len1 < len2 ? len1 : len2;
1192
1193   for (i = 0; i < len; i++)
1194     {
1195       if (s1[i] < s2[i])
1196         return -1;
1197       else if (s1[i] > s2[i])
1198         return 1;
1199       else
1200         continue;
1201     }
1202
1203   if (len1 < len2)
1204     return -1;
1205   else if (len1 > len2)
1206     return 1;
1207   else
1208     return 0;
1209 }
1210
1211 /* Simulate the C operator == by returning a 1
1212    iff ARG1 and ARG2 have equal contents.  */
1213
1214 int
1215 value_equal (struct value *arg1, struct value *arg2)
1216 {
1217   register int len;
1218   register char *p1, *p2;
1219   struct type *type1, *type2;
1220   enum type_code code1;
1221   enum type_code code2;
1222
1223   COERCE_NUMBER (arg1);
1224   COERCE_NUMBER (arg2);
1225
1226   type1 = check_typedef (VALUE_TYPE (arg1));
1227   type2 = check_typedef (VALUE_TYPE (arg2));
1228   code1 = TYPE_CODE (type1);
1229   code2 = TYPE_CODE (type2);
1230
1231   if ((code1 == TYPE_CODE_INT || code1 == TYPE_CODE_BOOL) &&
1232       (code2 == TYPE_CODE_INT || code2 == TYPE_CODE_BOOL))
1233     return longest_to_int (value_as_long (value_binop (arg1, arg2,
1234                                                        BINOP_EQUAL)));
1235   else if ((code1 == TYPE_CODE_FLT || code1 == TYPE_CODE_INT || code1 == TYPE_CODE_BOOL)
1236            && (code2 == TYPE_CODE_FLT || code2 == TYPE_CODE_INT || code2 == TYPE_CODE_BOOL))
1237     return value_as_double (arg1) == value_as_double (arg2);
1238
1239   /* FIXME: Need to promote to either CORE_ADDR or LONGEST, whichever
1240      is bigger.  */
1241   else if (code1 == TYPE_CODE_PTR && (code2 == TYPE_CODE_INT || code2 == TYPE_CODE_BOOL))
1242     return value_as_address (arg1) == (CORE_ADDR) value_as_long (arg2);
1243   else if (code2 == TYPE_CODE_PTR && (code1 == TYPE_CODE_INT || code1 == TYPE_CODE_BOOL))
1244     return (CORE_ADDR) value_as_long (arg1) == value_as_address (arg2);
1245
1246   else if (code1 == code2
1247            && ((len = (int) TYPE_LENGTH (type1))
1248                == (int) TYPE_LENGTH (type2)))
1249     {
1250       p1 = VALUE_CONTENTS (arg1);
1251       p2 = VALUE_CONTENTS (arg2);
1252       while (--len >= 0)
1253         {
1254           if (*p1++ != *p2++)
1255             break;
1256         }
1257       return len < 0;
1258     }
1259   else if (code1 == TYPE_CODE_STRING && code2 == TYPE_CODE_STRING)
1260     {
1261       return value_strcmp (arg1, arg2) == 0;
1262     }
1263   else
1264     {
1265       error ("Invalid type combination in equality test.");
1266       return 0;                 /* For lint -- never reached */
1267     }
1268 }
1269
1270 /* Simulate the C operator < by returning 1
1271    iff ARG1's contents are less than ARG2's.  */
1272
1273 int
1274 value_less (struct value *arg1, struct value *arg2)
1275 {
1276   register enum type_code code1;
1277   register enum type_code code2;
1278   struct type *type1, *type2;
1279
1280   COERCE_NUMBER (arg1);
1281   COERCE_NUMBER (arg2);
1282
1283   type1 = check_typedef (VALUE_TYPE (arg1));
1284   type2 = check_typedef (VALUE_TYPE (arg2));
1285   code1 = TYPE_CODE (type1);
1286   code2 = TYPE_CODE (type2);
1287
1288   if ((code1 == TYPE_CODE_INT || code1 == TYPE_CODE_BOOL) &&
1289       (code2 == TYPE_CODE_INT || code2 == TYPE_CODE_BOOL))
1290     return longest_to_int (value_as_long (value_binop (arg1, arg2,
1291                                                        BINOP_LESS)));
1292   else if ((code1 == TYPE_CODE_FLT || code1 == TYPE_CODE_INT || code1 == TYPE_CODE_BOOL)
1293            && (code2 == TYPE_CODE_FLT || code2 == TYPE_CODE_INT || code2 == TYPE_CODE_BOOL))
1294     return value_as_double (arg1) < value_as_double (arg2);
1295   else if (code1 == TYPE_CODE_PTR && code2 == TYPE_CODE_PTR)
1296     return value_as_address (arg1) < value_as_address (arg2);
1297
1298   /* FIXME: Need to promote to either CORE_ADDR or LONGEST, whichever
1299      is bigger.  */
1300   else if (code1 == TYPE_CODE_PTR && (code2 == TYPE_CODE_INT || code2 == TYPE_CODE_BOOL))
1301     return value_as_address (arg1) < (CORE_ADDR) value_as_long (arg2);
1302   else if (code2 == TYPE_CODE_PTR && (code1 == TYPE_CODE_INT || code1 == TYPE_CODE_BOOL))
1303     return (CORE_ADDR) value_as_long (arg1) < value_as_address (arg2);
1304   else if (code1 == TYPE_CODE_STRING && code2 == TYPE_CODE_STRING)
1305     return value_strcmp (arg1, arg2) < 0;
1306   else
1307     {
1308       error ("Invalid type combination in ordering comparison.");
1309       return 0;
1310     }
1311 }
1312 \f
1313 /* The unary operators - and ~.  Both free the argument ARG1.  */
1314
1315 struct value *
1316 value_neg (struct value *arg1)
1317 {
1318   register struct type *type;
1319   register struct type *result_type = VALUE_TYPE (arg1);
1320
1321   COERCE_REF (arg1);
1322   COERCE_ENUM (arg1);
1323
1324   type = check_typedef (VALUE_TYPE (arg1));
1325
1326   if (TYPE_CODE (type) == TYPE_CODE_FLT)
1327     return value_from_double (result_type, -value_as_double (arg1));
1328   else if (TYPE_CODE (type) == TYPE_CODE_INT || TYPE_CODE (type) == TYPE_CODE_BOOL)
1329     {
1330       /* Perform integral promotion for ANSI C/C++.  FIXME: What about
1331          FORTRAN and (the deleted) chill ?  */
1332       if (TYPE_LENGTH (type) < TYPE_LENGTH (builtin_type_int))
1333         result_type = builtin_type_int;
1334
1335       return value_from_longest (result_type, -value_as_long (arg1));
1336     }
1337   else
1338     {
1339       error ("Argument to negate operation not a number.");
1340       return 0;                 /* For lint -- never reached */
1341     }
1342 }
1343
1344 struct value *
1345 value_complement (struct value *arg1)
1346 {
1347   register struct type *type;
1348   register struct type *result_type = VALUE_TYPE (arg1);
1349   int typecode;
1350
1351   COERCE_REF (arg1);
1352   COERCE_ENUM (arg1);
1353
1354   type = check_typedef (VALUE_TYPE (arg1));
1355
1356   typecode = TYPE_CODE (type);
1357   if ((typecode != TYPE_CODE_INT) && (typecode != TYPE_CODE_BOOL))
1358     error ("Argument to complement operation not an integer or boolean.");
1359
1360   /* Perform integral promotion for ANSI C/C++.
1361      FIXME: What about FORTRAN ?  */
1362   if (TYPE_LENGTH (type) < TYPE_LENGTH (builtin_type_int))
1363     result_type = builtin_type_int;
1364
1365   return value_from_longest (result_type, ~value_as_long (arg1));
1366 }
1367 \f
1368 /* The INDEX'th bit of SET value whose VALUE_TYPE is TYPE,
1369    and whose VALUE_CONTENTS is valaddr.
1370    Return -1 if out of range, -2 other error. */
1371
1372 int
1373 value_bit_index (struct type *type, char *valaddr, int index)
1374 {
1375   LONGEST low_bound, high_bound;
1376   LONGEST word;
1377   unsigned rel_index;
1378   struct type *range = TYPE_FIELD_TYPE (type, 0);
1379   if (get_discrete_bounds (range, &low_bound, &high_bound) < 0)
1380     return -2;
1381   if (index < low_bound || index > high_bound)
1382     return -1;
1383   rel_index = index - low_bound;
1384   word = unpack_long (builtin_type_unsigned_char,
1385                       valaddr + (rel_index / TARGET_CHAR_BIT));
1386   rel_index %= TARGET_CHAR_BIT;
1387   if (BITS_BIG_ENDIAN)
1388     rel_index = TARGET_CHAR_BIT - 1 - rel_index;
1389   return (word >> rel_index) & 1;
1390 }
1391
1392 struct value *
1393 value_in (struct value *element, struct value *set)
1394 {
1395   int member;
1396   struct type *settype = check_typedef (VALUE_TYPE (set));
1397   struct type *eltype = check_typedef (VALUE_TYPE (element));
1398   if (TYPE_CODE (eltype) == TYPE_CODE_RANGE)
1399     eltype = TYPE_TARGET_TYPE (eltype);
1400   if (TYPE_CODE (settype) != TYPE_CODE_SET)
1401     error ("Second argument of 'IN' has wrong type");
1402   if (TYPE_CODE (eltype) != TYPE_CODE_INT
1403       && TYPE_CODE (eltype) != TYPE_CODE_CHAR
1404       && TYPE_CODE (eltype) != TYPE_CODE_ENUM
1405       && TYPE_CODE (eltype) != TYPE_CODE_BOOL)
1406     error ("First argument of 'IN' has wrong type");
1407   member = value_bit_index (settype, VALUE_CONTENTS (set),
1408                             value_as_long (element));
1409   if (member < 0)
1410     error ("First argument of 'IN' not in range");
1411   return value_from_longest (LA_BOOL_TYPE, member);
1412 }
1413
1414 void
1415 _initialize_valarith (void)
1416 {
1417 }
This page took 0.103102 seconds and 4 git commands to generate.