34 #ifndef TRUNCATION_TOWARDS_ZERO 35 #define TRUNCATION_TOWARDS_ZERO ((-5 / 2) == -2) 48 struct type *ptr_target;
66 error (
_(
"Cannot perform pointer math on incomplete types, " 67 "try casting to a known type, or void *."));
69 error (
_(
"Cannot perform pointer math on incomplete type \"%s\", " 70 "try casting to a known type, or void *."),
name);
82 struct type *valptrtype;
103 struct type *type1, *type2;
116 error (
_(
"First argument of `-' is a pointer and " 117 "second argument is neither\n" 118 "an integer nor a pointer of the same type."));
123 warning (
_(
"Type size unknown, assuming 1. " 124 "Try casting to a known type, or void *."));
154 LONGEST lowerbound, upperbound;
162 if (index >= lowerbound && index <= upperbound)
167 warning (
_(
"array or string index out of range"));
179 error (
_(
"not an array or string"));
192 ULONGEST elt_offs = elt_size * (index - lowerbound);
198 error (
_(
"no such vector element (vector not associated)"));
200 error (
_(
"no such vector element (vector not allocated)"));
202 error (
_(
"no such vector element"));
225 struct type *type1,
struct type *type2)
227 if (op == BINOP_ASSIGN || op == BINOP_CONCAT)
282 static struct value *
287 struct symbol *symp = NULL;
288 struct value *valp = NULL;
293 &valp, &symp, static_memfuncp, 0,
noside);
307 error (
_(
"Could not find %s."), oper);
313 static struct value *
317 struct value *result = NULL;
344 struct value **argvec;
356 error (
_(
"Can't do that binary op on that type"));
358 argvec = (
struct value **) alloca (
sizeof (
struct value *) * 4);
364 strcpy (tstr,
"operator__");
389 case BINOP_BITWISE_AND:
392 case BINOP_BITWISE_IOR:
395 case BINOP_BITWISE_XOR:
398 case BINOP_LOGICAL_AND:
401 case BINOP_LOGICAL_OR:
413 case BINOP_ASSIGN_MODIFY:
431 case BINOP_BITWISE_AND:
434 case BINOP_BITWISE_IOR:
437 case BINOP_BITWISE_XOR:
442 error (
_(
"Invalid binary operation specified."));
445 case BINOP_SUBSCRIPT:
468 error (
_(
"Invalid binary operation specified."));
472 &static_memfuncp, 2,
noside);
478 argvec[1] = argvec[0];
487 struct type *return_type
490 if (return_type == NULL)
491 error (
_(
"Xmethod is missing return type."));
498 struct type *return_type;
508 _(
"member function %s not found"), tstr);
524 struct value **argvec;
526 char tstr[13], mangle_tstr[13];
527 int static_memfuncp, nargs;
535 error (
_(
"Can't do that unary op on that type"));
537 argvec = (
struct value **) alloca (
sizeof (
struct value *) * 4);
544 strcpy (tstr,
"operator__");
546 strcpy (mangle_tstr,
"__");
549 case UNOP_PREINCREMENT:
552 case UNOP_PREDECREMENT:
555 case UNOP_POSTINCREMENT:
561 case UNOP_POSTDECREMENT:
567 case UNOP_LOGICAL_NOT:
570 case UNOP_COMPLEMENT:
586 error (
_(
"Invalid unary operation specified."));
590 &static_memfuncp, nargs,
noside);
596 argvec[1] = argvec[0];
606 struct type *return_type
609 if (return_type == NULL)
610 error (
_(
"Xmethod is missing return type."));
617 struct type *return_type;
626 _(
"member function %s not found"), tstr);
655 struct value *inval1;
656 struct value *inval2;
657 struct value *outval = NULL;
658 int inval1len, inval2len;
663 struct type *char_type;
673 struct type *tmp = type1;
697 std::vector<char> ptr (count * inval2len);
704 for (idx = 0; idx < count; idx++)
713 for (idx = 0; idx < count; idx++)
719 outval =
value_string (ptr.data (), count * inval2len, char_type);
723 error (
_(
"unimplemented support for boolean repeats"));
727 error (
_(
"can't repeat values of that type"));
737 error (
_(
"Strings can only be concatenated with other strings."));
741 std::vector<char> ptr (inval1len + inval2len);
763 outval =
value_string (ptr.data (), inval1len + inval2len, char_type);
770 error (
_(
"Booleans can only be concatenated " 771 "with other bitstrings or booleans."));
773 error (
_(
"unimplemented support for boolean concatenation."));
778 error (
_(
"illegal operands for concatenation."));
792 error (
_(
"Attempt to raise 0 to negative power."));
823 error (
_(
"Attempt to raise 0 to negative power."));
852 struct type *type1, *type2;
865 error (
_(
"Mixing decimal floating types with " 866 "other floating types is not allowed."));
884 error (
_(
"Don't know how to convert from %s to %s."),
TYPE_NAME (type1),
903 error (
_(
"Don't know how to convert from %s to %s."),
TYPE_NAME (type1),
913 static struct value *
917 struct type *type1, *type2, *result_type;
927 error (
_(
"Argument to arithmetic operation not a number or boolean."));
944 struct type *eff_type_v1, *eff_type_v2;
950 v1.data (), &eff_type_v1,
951 v2.data (), &eff_type_v2);
953 v2.data (), eff_type_v2,
966 case BINOP_BITWISE_AND:
970 case BINOP_BITWISE_IOR:
974 case BINOP_BITWISE_XOR:
987 error (
_(
"Invalid operation on booleans."));
1007 if (op == BINOP_RSH || op == BINOP_LSH || op == BINOP_EXP)
1008 result_type = type1;
1010 result_type = type1;
1012 result_type = type2;
1014 result_type = type1;
1016 result_type = type2;
1018 result_type = type1;
1047 error (
_(
"Division by zero"));
1058 error (
_(
"Division by zero"));
1084 case BINOP_BITWISE_AND:
1088 case BINOP_BITWISE_IOR:
1092 case BINOP_BITWISE_XOR:
1096 case BINOP_LOGICAL_AND:
1100 case BINOP_LOGICAL_OR:
1105 v = v1 < v2 ? v1 : v2;
1109 v = v1 > v2 ? v1 : v2;
1116 case BINOP_NOTEQUAL:
1137 error (
_(
"Invalid binary operation on numbers."));
1173 error (
_(
"Division by zero"));
1184 error (
_(
"Division by zero"));
1214 case BINOP_BITWISE_AND:
1218 case BINOP_BITWISE_IOR:
1222 case BINOP_BITWISE_XOR:
1226 case BINOP_LOGICAL_AND:
1230 case BINOP_LOGICAL_OR:
1235 v = v1 < v2 ? v1 : v2;
1239 v = v1 > v2 ? v1 : v2;
1246 case BINOP_NOTEQUAL:
1267 error (
_(
"Invalid binary operation on numbers."));
1292 struct type *eltype, *scalar_type;
1293 struct value *val, *elval;
1294 LONGEST low_bound, high_bound;
1303 error (
_(
"Could not determine the vector bounds"));
1314 error (
_(
"conversion of scalar to vector involves truncation"));
1317 for (i = 0; i < high_bound - low_bound + 1; i++)
1328 static struct value *
1331 struct value *val, *tmp, *mark;
1332 struct type *type1, *type2, *eltype1, *eltype2;
1333 int t1_is_vec, t2_is_vec, elsize, i;
1334 LONGEST low_bound1, high_bound1, low_bound2, high_bound2;
1344 if (!t1_is_vec || !t2_is_vec)
1345 error (
_(
"Vector operations are only supported among vectors"));
1349 error (
_(
"Could not determine the vector bounds"));
1358 || low_bound1 != low_bound2 || high_bound1 != high_bound2)
1359 error (
_(
"Cannot perform operation on vectors with different types"));
1363 for (i = 0; i < high_bound1 - low_bound1 + 1; i++)
1389 if (!t1_is_vec && !t2_is_vec)
1391 else if (t1_is_vec && t2_is_vec)
1396 struct value **v = t1_is_vec ? &arg2 : &arg1;
1397 struct type *t = t1_is_vec ? type2 : type1;
1402 error (
_(
"Argument to operation not a number or boolean."));
1450 int i, len = len1 < len2 ? len1 : len2;
1452 for (i = 0; i < len; i++)
1456 else if (s1[i] > s2[i])
1464 else if (len1 > len2)
1479 struct type *type1, *type2;
1482 int is_int1, is_int2;
1494 if (is_int1 && is_int2)
1500 struct type *eff_type_v1, *eff_type_v2;
1506 v1.data (), &eff_type_v1,
1507 v2.data (), &eff_type_v2);
1510 v2.data (), eff_type_v2) == 0;
1520 else if (code1 == code2
1539 error (
_(
"Invalid type combination in equality test."));
1551 struct type *type1, *type2;
1570 struct type *type1, *type2;
1571 int is_int1, is_int2;
1583 if (is_int1 && is_int2)
1589 struct type *eff_type_v1, *eff_type_v2;
1595 v1.data (), &eff_type_v1,
1596 v2.data (), &eff_type_v2);
1599 v2.data (), eff_type_v2) == -1;
1614 error (
_(
"Invalid type combination in ordering comparison."));
1634 error (
_(
"Argument to positive operation not a number."));
1654 LONGEST low_bound, high_bound;
1657 error (
_(
"Could not determine the vector bounds"));
1659 for (i = 0; i < high_bound - low_bound + 1; i++)
1669 error (
_(
"Argument to negate operation not a number."));
1690 LONGEST low_bound, high_bound;
1693 error (
_(
"Could not determine the vector bounds"));
1696 for (i = 0; i < high_bound - low_bound + 1; i++)
1704 error (
_(
"Argument to complement operation not an integer, boolean."));
1717 LONGEST low_bound, high_bound;
1724 if (index < low_bound || index > high_bound)
1726 rel_index = index - low_bound;
1732 return (word >> rel_index) & 1;
1745 error (
_(
"Second argument of 'IN' has wrong type"));
1750 error (
_(
"First argument of 'IN' has wrong type"));
1754 error (
_(
"First argument of 'IN' not in range"));
struct value * value_zero(struct type *type, enum lval_type lv)
struct value * value_mark(void)
struct value * value_subscripted_rvalue(struct value *array, LONGEST index, int lowerbound)
static LONGEST integer_pow(LONGEST v1, LONGEST v2)
struct value * value_addr(struct value *arg1)
struct value * value_subscript(struct value *array, LONGEST index)
int value_equal_contents(struct value *arg1, struct value *arg2)
bool target_float_is_zero(const gdb_byte *addr, const struct type *type)
int type_not_allocated(const struct type *type)
struct value * value_from_contents(struct type *type, const gdb_byte *contents)
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)
int binop_types_user_defined_p(enum exp_opcode op, struct type *type1, struct type *type2)
unsigned int type_length_units(struct type *type)
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 * allocate_value(struct type *type)
int longest_to_int(LONGEST)
#define TYPE_IS_REFERENCE(t)
void target_float_from_longest(gdb_byte *addr, const struct type *type, LONGEST val)
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)
static ULONGEST extract_unsigned_integer(const gdb_byte *addr, int len, enum bfd_endian byte_order)
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)
static LONGEST find_size_for_pointer_math(struct type *ptr_type)
struct gdbarch * get_type_arch(const struct type *type)
int type_not_associated(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)
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)
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)
void target_float_from_ulongest(gdb_byte *addr, const struct type *type, ULONGEST val)
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)
static void value_args_as_target_float(struct value *arg1, struct value *arg2, gdb_byte *x, struct type **eff_type_x, gdb_byte *y, struct type **eff_type_y)
int is_floating_type(struct type *t)
struct value * value_from_pointer(struct type *type, CORE_ADDR addr)
const struct language_defn * current_language
#define TYPE_TARGET_TYPE(thistype)
struct value * value_neg(struct value *arg1)
#define TYPE_CODE(thistype)
#define TYPE_INDEX_TYPE(type)
struct type * resolve_dynamic_type(struct type *type, const gdb_byte *valaddr, CORE_ADDR addr)
struct value * value_of_variable(struct symbol *var, const struct block *b)
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)
int value_logical_not(struct value *arg1)
struct value * value_vector_widen(struct value *scalar_value, struct type *vector_type)
void value_free_to_mark(const struct value *mark)
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)
gdb::def_vector< gdb_byte > byte_vector
struct value * value_string(const char *ptr, ssize_t len, struct type *char_type)
int gdbarch_bits_big_endian(struct gdbarch *gdbarch)
unsigned long long ULONGEST
struct value * call_function_by_hand(struct value *function, type *default_return_type, int nargs, struct value **args)
int target_float_compare(const gdb_byte *x, const struct type *type_x, const gdb_byte *y, const struct type *type_y)
int is_dynamic_type(struct type *type)
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)
void target_float_binop(enum exp_opcode opcode, const gdb_byte *x, const struct type *type_x, const gdb_byte *y, const struct type *type_y, gdb_byte *res, const struct type *type_res)
CORE_ADDR value_address(const struct value *value)
static struct value * value_user_defined_op(struct value **argp, struct value **args, char *name, int *static_memfuncp, int nargs, enum noside noside)
struct value * value_from_component(struct value *whole, struct type *type, LONGEST offset)
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)
static void store_signed_integer(gdb_byte *addr, int len, enum bfd_endian byte_order, LONGEST val)
void error(const char *fmt,...)
void _initialize_valarith(void)
void throw_error(enum errors error, const char *fmt,...)
struct value * value_concat(struct value *arg1, struct value *arg2)
bool is_floating_value(struct value *val)
void set_value_component_location(struct value *component, const struct value *whole)
static void store_unsigned_integer(gdb_byte *addr, int len, enum bfd_endian byte_order, ULONGEST val)