35 #ifndef TRUNCATION_TOWARDS_ZERO
36 #define TRUNCATION_TOWARDS_ZERO ((-5 / 2) == -2)
52 struct type *ptr_target;
70 error (
_(
"Cannot perform pointer math on incomplete types, "
71 "try casting to a known type, or void *."));
73 error (
_(
"Cannot perform pointer math on incomplete type \"%s\", "
74 "try casting to a known type, or void *."), name);
86 struct type *valptrtype;
107 struct type *type1, *type2;
120 error (
_(
"First argument of `-' is a pointer and "
121 "second argument is neither\n"
122 "an integer nor a pointer of the same type."));
127 warning (
_(
"Type size unknown, assuming 1. "
128 "Try casting to a known type, or void *."));
158 LONGEST lowerbound, upperbound;
166 if (index >= lowerbound && index <= upperbound)
171 warning (
_(
"array or string index out of range"));
183 error (
_(
"not an array or string"));
196 unsigned int elt_offs = elt_size *
longest_to_int (index - lowerbound);
201 error (
_(
"no such vector element"));
229 struct type *type1,
struct type *type2)
231 if (op == BINOP_ASSIGN || op == BINOP_CONCAT)
286 static struct value *
291 struct symbol *symp = NULL;
292 struct value *valp = NULL;
297 &valp, &symp, static_memfuncp, 0, noside);
311 error (
_(
"Could not find %s."), oper);
317 static struct value *
321 struct value *result = NULL;
348 struct value **argvec;
360 error (
_(
"Can't do that binary op on that type"));
362 argvec = (
struct value **) alloca (
sizeof (
struct value *) * 4);
368 strcpy (tstr,
"operator__");
393 case BINOP_BITWISE_AND:
396 case BINOP_BITWISE_IOR:
399 case BINOP_BITWISE_XOR:
402 case BINOP_LOGICAL_AND:
405 case BINOP_LOGICAL_OR:
417 case BINOP_ASSIGN_MODIFY:
435 case BINOP_BITWISE_AND:
438 case BINOP_BITWISE_IOR:
441 case BINOP_BITWISE_XOR:
446 error (
_(
"Invalid binary operation specified."));
449 case BINOP_SUBSCRIPT:
472 error (
_(
"Invalid binary operation specified."));
476 &static_memfuncp, 2, noside);
482 argvec[1] = argvec[0];
491 struct type *return_type
494 if (return_type == NULL)
495 error (
_(
"Xmethod is missing return type."));
502 struct type *return_type;
512 _(
"member function %s not found"), tstr);
528 struct value **argvec;
530 char tstr[13], mangle_tstr[13];
531 int static_memfuncp, nargs;
539 error (
_(
"Can't do that unary op on that type"));
541 argvec = (
struct value **) alloca (
sizeof (
struct value *) * 4);
548 strcpy (tstr,
"operator__");
550 strcpy (mangle_tstr,
"__");
553 case UNOP_PREINCREMENT:
556 case UNOP_PREDECREMENT:
559 case UNOP_POSTINCREMENT:
565 case UNOP_POSTDECREMENT:
571 case UNOP_LOGICAL_NOT:
574 case UNOP_COMPLEMENT:
590 error (
_(
"Invalid unary operation specified."));
594 &static_memfuncp, nargs, noside);
600 argvec[1] = argvec[0];
610 struct type *return_type
613 if (return_type == NULL)
614 error (
_(
"Xmethod is missing return type."));
621 struct type *return_type;
630 _(
"member function %s not found"), tstr);
659 struct value *inval1;
660 struct value *inval2;
661 struct value *outval = NULL;
662 int inval1len, inval2len;
668 struct type *char_type;
678 struct type *tmp = type1;
704 ptr = (
char *)
xmalloc (count * inval2len);
712 for (idx = 0; idx < count; idx++)
714 *(ptr + idx) = inchar;
721 for (idx = 0; idx < count; idx++)
727 outval =
value_string (ptr, count * inval2len, char_type);
732 error (
_(
"unimplemented support for boolean repeats"));
736 error (
_(
"can't repeat values of that type"));
748 error (
_(
"Strings can only be concatenated with other strings."));
752 ptr = (
char *)
xmalloc (inval1len + inval2len);
775 outval =
value_string (ptr, inval1len + inval2len, char_type);
783 error (
_(
"Booleans can only be concatenated "
784 "with other bitstrings or booleans."));
786 error (
_(
"unimplemented support for boolean concatenation."));
791 error (
_(
"illegal operands for concatenation."));
805 error (
_(
"Attempt to raise 0 to negative power."));
836 error (
_(
"Attempt to raise 0 to negative power."));
862 gdb_byte *x,
int *len_x,
enum bfd_endian *byte_order_x,
863 gdb_byte *y,
int *len_y,
enum bfd_endian *byte_order_y)
865 struct type *type1, *type2;
879 error (
_(
"Mixing decimal floating types with "
880 "other floating types is not allowed."));
898 error (
_(
"Don't know how to convert from %s to %s."),
TYPE_NAME (type1),
917 error (
_(
"Don't know how to convert from %s to %s."),
TYPE_NAME (type1),
927 static struct value *
931 struct type *type1, *type2, *result_type;
945 error (
_(
"Argument to arithmetic operation not a number or boolean."));
950 int len_v1, len_v2, len_v;
951 enum bfd_endian byte_order_v1, byte_order_v2, byte_order_v;
970 v2, &len_v2, &byte_order_v2);
980 v2, len_v2, byte_order_v2,
981 v, len_v, byte_order_v);
985 error (
_(
"Operation not valid for decimal floating point number."));
1023 error (
_(
"Cannot perform exponentiation: %s"),
1028 v = v1 < v2 ? v1 : v2;
1032 v = v1 > v2 ? v1 : v2;
1036 error (
_(
"Integer-only operation on floating point number."));
1042 result_type = type2;
1044 result_type = type1;
1046 result_type = type2;
1048 result_type = type1;
1063 case BINOP_BITWISE_AND:
1067 case BINOP_BITWISE_IOR:
1071 case BINOP_BITWISE_XOR:
1079 case BINOP_NOTEQUAL:
1084 error (
_(
"Invalid operation on booleans."));
1087 result_type = type1;
1104 if (op == BINOP_RSH || op == BINOP_LSH || op == BINOP_EXP)
1105 result_type = type1;
1107 result_type = type1;
1109 result_type = type2;
1111 result_type = type1;
1113 result_type = type2;
1115 result_type = type1;
1144 error (
_(
"Division by zero"));
1155 error (
_(
"Division by zero"));
1181 case BINOP_BITWISE_AND:
1185 case BINOP_BITWISE_IOR:
1189 case BINOP_BITWISE_XOR:
1193 case BINOP_LOGICAL_AND:
1197 case BINOP_LOGICAL_OR:
1202 v = v1 < v2 ? v1 : v2;
1206 v = v1 > v2 ? v1 : v2;
1213 case BINOP_NOTEQUAL:
1234 error (
_(
"Invalid binary operation on numbers."));
1270 error (
_(
"Division by zero"));
1281 error (
_(
"Division by zero"));
1311 case BINOP_BITWISE_AND:
1315 case BINOP_BITWISE_IOR:
1319 case BINOP_BITWISE_XOR:
1323 case BINOP_LOGICAL_AND:
1327 case BINOP_LOGICAL_OR:
1332 v = v1 < v2 ? v1 : v2;
1336 v = v1 > v2 ? v1 : v2;
1343 case BINOP_NOTEQUAL:
1364 error (
_(
"Invalid binary operation on numbers."));
1389 struct type *eltype, *scalar_type;
1390 struct value *val, *elval;
1391 LONGEST low_bound, high_bound;
1400 error (
_(
"Could not determine the vector bounds"));
1411 error (
_(
"conversion of scalar to vector involves truncation"));
1414 for (i = 0; i < high_bound - low_bound + 1; i++)
1425 static struct value *
1428 struct value *val, *tmp, *mark;
1429 struct type *type1, *type2, *eltype1, *eltype2;
1430 int t1_is_vec, t2_is_vec, elsize, i;
1431 LONGEST low_bound1, high_bound1, low_bound2, high_bound2;
1441 if (!t1_is_vec || !t2_is_vec)
1442 error (
_(
"Vector operations are only supported among vectors"));
1446 error (
_(
"Could not determine the vector bounds"));
1455 || low_bound1 != low_bound2 || high_bound1 != high_bound2)
1456 error (
_(
"Cannot perform operation on vectors with different types"));
1460 for (i = 0; i < high_bound1 - low_bound1 + 1; i++)
1486 if (!t1_is_vec && !t2_is_vec)
1488 else if (t1_is_vec && t2_is_vec)
1493 struct value **v = t1_is_vec ? &arg2 : &arg1;
1494 struct type *t = t1_is_vec ? type2 : type1;
1499 error (
_(
"Argument to operation not a number or boolean."));
1550 int i,
len = len1 < len2 ? len1 : len2;
1552 for (i = 0; i <
len; i++)
1556 else if (s1[i] > s2[i])
1564 else if (len1 > len2)
1579 struct type *type1, *type2;
1582 int is_int1, is_int2;
1594 if (is_int1 && is_int2)
1611 enum bfd_endian byte_order_v1, byte_order_v2;
1614 v2, &len_v2, &byte_order_v2);
1617 v2, len_v2, byte_order_v2) == 0;
1627 else if (code1 == code2
1646 error (
_(
"Invalid type combination in equality test."));
1658 struct type *type1, *type2;
1677 struct type *type1, *type2;
1678 int is_int1, is_int2;
1690 if (is_int1 && is_int2)
1707 enum bfd_endian byte_order_v1, byte_order_v2;
1710 v2, &len_v2, &byte_order_v2);
1713 v2, len_v2, byte_order_v2) == -1;
1728 error (
_(
"Invalid type combination in ordering comparison."));
1761 error (
_(
"Argument to positive operation not a number."));
1783 decbytes[len-1] = decbytes[len - 1] | 0x80;
1785 decbytes[0] = decbytes[0] | 0x80;
1801 LONGEST low_bound, high_bound;
1804 error (
_(
"Could not determine the vector bounds"));
1806 for (i = 0; i < high_bound - low_bound + 1; i++)
1816 error (
_(
"Argument to negate operation not a number."));
1837 LONGEST low_bound, high_bound;
1840 error (
_(
"Could not determine the vector bounds"));
1843 for (i = 0; i < high_bound - low_bound + 1; i++)
1851 error (
_(
"Argument to complement operation not an integer, boolean."));
1864 LONGEST low_bound, high_bound;
1871 if (index < low_bound || index > high_bound)
1873 rel_index = index - low_bound;
1879 return (word >> rel_index) & 1;
1892 error (
_(
"Second argument of 'IN' has wrong type"));
1897 error (
_(
"First argument of 'IN' has wrong type"));
1901 error (
_(
"First argument of 'IN' not in range"));
struct value * value_zero(struct type *type, enum lval_type lv)
ULONGEST extract_unsigned_integer(const gdb_byte *, int, enum bfd_endian)
struct value * value_mark(void)
struct value * value_subscripted_rvalue(struct value *array, LONGEST index, int lowerbound)
struct value * call_function_by_hand(struct value *function, int nargs, struct value **args)
static LONGEST integer_pow(LONGEST v1, LONGEST v2)
struct value * value_addr(struct value *arg1)
#define VALUE_FRAME_ID(val)
void value_free_to_mark(struct value *mark)
struct value * value_subscript(struct value *array, LONGEST index)
int value_equal_contents(struct value *arg1, struct value *arg2)
void value_contents_copy(struct value *dst, int dst_offset, struct value *src, int src_offset, int length)
int value_offset(const struct value *value)
void store_signed_integer(gdb_byte *, int, enum bfd_endian, LONGEST)
LONGEST value_as_long(struct value *val)
void warning(const char *fmt,...)
struct value * value_coerce_array(struct value *arg1)
#define TYPE_NAME(thistype)
LONGEST value_ptrdiff(struct value *arg1, struct value *arg2)
struct value * call_xmethod(struct value *method, int argc, struct value **argv)
struct value * allocate_value_lazy(struct type *type)
int binop_types_user_defined_p(enum exp_opcode op, struct type *type1, struct type *type2)
int value_in(struct value *element, struct value *set)
struct value * coerce_ref(struct value *arg)
static int value_strcmp(struct value *arg1, struct value *arg2)
struct value * value_ind(struct value *arg1)
enum language la_language
struct value * value_pos(struct value *arg1)
struct value * value_string(char *ptr, ssize_t len, struct type *char_type)
static void value_args_as_decimal(struct value *arg1, struct value *arg2, gdb_byte *x, int *len_x, enum bfd_endian *byte_order_x, gdb_byte *y, int *len_y, enum bfd_endian *byte_order_y)
struct value * allocate_value(struct type *type)
void store_unsigned_integer(gdb_byte *, int, enum bfd_endian, ULONGEST)
int longest_to_int(LONGEST)
struct value * value_ptradd(struct value *arg1, LONGEST arg2)
struct value * value_struct_elt(struct value **argp, struct value **args, const char *name, int *static_memfuncp, const char *err)
struct type * check_typedef(struct type *type)
struct type * result_type_of_xmethod(struct value *method, int argc, struct value **argv)
const gdb_byte * value_contents(struct value *value)
static ULONGEST uinteger_pow(ULONGEST v1, LONGEST v2)
struct value * value_from_decfloat(struct type *type, const gdb_byte *dec)
int value_lazy(struct value *value)
void decimal_binop(enum exp_opcode op, const gdb_byte *x, int len_x, enum bfd_endian byte_order_x, const gdb_byte *y, int len_y, enum bfd_endian byte_order_y, gdb_byte *result, int len_result, enum bfd_endian byte_order_result)
const gdb_byte * value_contents_all(struct value *value)
int is_integral_type(struct type *t)
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
struct cleanup * make_cleanup(make_cleanup_ftype *function, void *arg)
static LONGEST find_size_for_pointer_math(struct type *ptr_type)
#define VALUE_REGNUM(val)
int decimal_is_zero(const gdb_byte *x, int len, enum bfd_endian byte_order)
struct gdbarch * get_type_arch(const struct type *type)
gdb_byte * value_contents_writeable(struct value *value)
struct value * coerce_array(struct value *arg)
struct value * value_from_longest(struct type *type, LONGEST num)
void set_value_offset(struct value *value, int offset)
struct value * value_cast(struct type *type, struct value *arg2)
#define TRUNCATION_TOWARDS_ZERO
static struct value * value_user_defined_cpp_op(struct value **args, int nargs, char *oper, int *static_memfuncp, enum noside noside)
#define TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED(arraytype)
struct value * value_from_double(struct type *type, DOUBLEST num)
int value_equal(struct value *arg1, struct value *arg2)
LONGEST unpack_long(struct type *type, const gdb_byte *valaddr)
int value_bit_index(struct type *type, const gdb_byte *valaddr, int index)
int find_overload_match(struct value **args, int nargs, const char *name, enum oload_search_type method, struct value **objp, struct symbol *fsym, struct value **valp, struct symbol **symp, int *staticp, const int no_adl, const enum noside noside)
struct value * value_from_pointer(struct type *type, CORE_ADDR addr)
const struct language_defn * current_language
#define TYPE_TARGET_TYPE(thistype)
int decimal_compare(const gdb_byte *x, int len_x, enum bfd_endian byte_order_x, const gdb_byte *y, int len_y, enum bfd_endian byte_order_y)
struct value * value_neg(struct value *arg1)
#define TYPE_CODE(thistype)
#define TYPE_INDEX_TYPE(type)
struct value * value_of_variable(struct symbol *var, const struct block *b)
char * safe_strerror(int)
void decimal_from_integral(struct value *from, gdb_byte *to, int len, enum bfd_endian byte_order)
static struct value * vector_binop(struct value *val1, struct value *val2, enum exp_opcode op)
int value_less(struct value *arg1, struct value *arg2)
struct value * value_complement(struct value *arg1)
#define CHECK_TYPEDEF(TYPE)
int value_logical_not(struct value *arg1)
struct value * value_vector_widen(struct value *scalar_value, struct type *vector_type)
struct value * value_binop(struct value *arg1, struct value *arg2, enum exp_opcode op)
#define TYPE_TAG_NAME(type)
int binop_user_defined_p(enum exp_opcode op, struct value *arg1, struct value *arg2)
int gdbarch_bits_big_endian(struct gdbarch *gdbarch)
unsigned long long ULONGEST
int value_embedded_offset(struct value *value)
struct value * value_x_unop(struct value *arg1, enum exp_opcode op, enum noside noside)
struct type * value_type(const struct value *value)
CORE_ADDR value_as_address(struct value *val)
gdb_byte * value_contents_raw(struct value *value)
#define TYPE_LENGTH(thistype)
struct value * value_x_binop(struct value *arg1, struct value *arg2, enum exp_opcode op, enum exp_opcode otherop, enum noside noside)
int unop_user_defined_p(enum exp_opcode op, struct value *arg1)
static struct value * value_user_defined_op(struct value **argp, struct value **args, char *name, int *static_memfuncp, int nargs, enum noside noside)
int get_array_bounds(struct type *type, LONGEST *low_bound, LONGEST *high_bound)
static struct value * scalar_binop(struct value *arg1, struct value *arg2, enum exp_opcode op)
int get_discrete_bounds(struct type *type, LONGEST *lowp, LONGEST *highp)
void error(const char *fmt,...)
DOUBLEST value_as_double(struct value *val)
void store_typed_floating(void *addr, const struct type *type, DOUBLEST val)
void _initialize_valarith(void)
void throw_error(enum errors error, const char *fmt,...)
struct value * value_concat(struct value *arg1, struct value *arg2)
void do_cleanups(struct cleanup *old_chain)
void set_value_component_location(struct value *component, const struct value *whole)
const ULONGEST const LONGEST len