From d1f4065e6499c42088b36a058b1de4035d051392 Mon Sep 17 00:00:00 2001 From: Per Bothner Date: Thu, 30 Nov 1995 01:07:28 +0000 Subject: * gdbtypes.h (enum type_code): Added TYPE_CODE_TYPEDEF. (check_typedef): New prototype. (CHECK_TYPEDEF): New macro. (TYPE_DUMMY_RANGE): Removed. * gdbtypes.c (get_discrete_bounds): Fix paren error; make more robust. (create_array_type): Don't force_to_range_type; users of the array are responsible for handling non-range index types. (create_set_type): Likewise. (force_to_range_type): Removed. (check_typedef): New function handles stub types and typedefs. (check_stub_type): Just call check_typedef. (To be removed.) (recursive_dump_type): Handle TYPE_CODE_TYPEDEF. * ch-lang.c (type_lower_upper): Use get_discrete_bounds. (evaluate_subexp_chill): Handle string repetition. Re-arrange to handle EVAL_AVOID_SIDE_EFFECTS better. * ch-typeprint.c (chill_type_print_base): Handle TYPE_CODE_TYPEDEF. Pass show=0 in recursive calls various places. (case TYPE_CODE_ARRAY): Don't require index type to have TYPE_CODE_RANGE. (case TYPE_CODE_RANGE): Don't need to support TYPE_DUMMY_RANGE. * gdbtypes.c, ch-lang.c, ch-typeprint.c (numerous places): Add check_typedef/CHECK_TYPEDEF as needed. --- gdb/ch-lang.c | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) (limited to 'gdb/ch-lang.c') diff --git a/gdb/ch-lang.c b/gdb/ch-lang.c index 1e681f5..a76ae46 100644 --- a/gdb/ch-lang.c +++ b/gdb/ch-lang.c @@ -304,11 +304,13 @@ type_lower_upper (op, type, result_type) struct type *type; struct type **result_type; { - LONGEST tmp; - *result_type = builtin_type_int; + LONGEST low, high; + *result_type = type; + CHECK_TYPEDEF (type); switch (TYPE_CODE (type)) { case TYPE_CODE_STRUCT: + *result_type = builtin_type_int; if (chill_varying_type (type)) return type_lower_upper (op, TYPE_FIELD_TYPE (type, 1), result_type); break; @@ -319,29 +321,19 @@ type_lower_upper (op, type, result_type) /* ... fall through ... */ case TYPE_CODE_RANGE: - if (TYPE_DUMMY_RANGE (type) > 0) - return type_lower_upper (op, TYPE_TARGET_TYPE (type), result_type); *result_type = TYPE_TARGET_TYPE (type); return op == UNOP_LOWER ? TYPE_LOW_BOUND (type) : TYPE_HIGH_BOUND (type); case TYPE_CODE_ENUM: - *result_type = type; - if (TYPE_NFIELDS (type) > 0) - return TYPE_FIELD_BITPOS (type, - op == UNOP_LOWER ? 0 - : TYPE_NFIELDS (type) - 1); - case TYPE_CODE_BOOL: - *result_type = type; - return op == UNOP_LOWER ? 0 : 1; case TYPE_CODE_INT: case TYPE_CODE_CHAR: - *result_type = type; - tmp = (LONGEST) 1 << (TARGET_CHAR_BIT * TYPE_LENGTH (type)); - if (TYPE_UNSIGNED (type)) - return op == UNOP_LOWER ? 0 : tmp - (LONGEST) 1; - tmp = tmp >> 1; - return op == UNOP_LOWER ? -tmp : (tmp - 1); + if (get_discrete_bounds (type, &low, &high) >= 0) + { + *result_type = type; + return op == UNOP_LOWER ? low : high; + } + break; case TYPE_CODE_UNDEF: case TYPE_CODE_PTR: case TYPE_CODE_UNION: @@ -367,6 +359,7 @@ value_chill_length (val) LONGEST tmp; struct type *type = VALUE_TYPE (val); struct type *ttype; + CHECK_TYPEDEF (type); switch (TYPE_CODE (type)) { case TYPE_CODE_ARRAY: @@ -404,17 +397,28 @@ evaluate_subexp_chill (expect_type, exp, pos, noside) switch (op) { case MULTI_SUBSCRIPT: - if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS) + if (noside == EVAL_SKIP) break; (*pos) += 3; nargs = longest_to_int (exp->elts[pc + 1].longconst); arg1 = evaluate_subexp_with_coercion (exp, pos, noside); + type = check_typedef (VALUE_TYPE (arg1)); - switch (TYPE_CODE (VALUE_TYPE (arg1))) + if (nargs == 1 && TYPE_CODE (type) == TYPE_CODE_INT) + { + /* Looks like string repetition. */ + value_ptr string = evaluate_subexp_with_coercion (exp, pos, noside); + return value_concat (arg1, string); + } + + switch (TYPE_CODE (type)) { case TYPE_CODE_PTR: case TYPE_CODE_FUNC: /* It's a function call. */ + if (noside == EVAL_AVOID_SIDE_EFFECTS) + break; + /* Allocate arg vector, including space for the function to be called in argvec[0] and a terminating NULL */ argvec = (value_ptr *) alloca (sizeof (value_ptr) * (nargs + 2)); -- cgit v1.1