From 76a0ffb47b50a3c7918eb93b4f5c5871ccdf31ef Mon Sep 17 00:00:00 2001 From: Fred Fish Date: Tue, 5 Jan 1993 01:18:07 +0000 Subject: [PATCH] * expression.h (exp_opcode): Add BINOP_MOD. * eval.c (evaluate_subexp): Handle new BINOP_MOD. * expprint.c (dump_expression): Handle new BINOP_MOD. * language.c (binop_type_check): Handle new BINOP_MOD. * main.c (float_handler): Re-enable float handler when hit. * valarith.c (language.h): Include, need current_language. * valarith.c (TRUNCATION_TOWARDS_ZERO): Define default macro for integer divide truncates towards zero for negative results. * valarith.c (value_x_binop): Handle BINOP_MOD if seen. * valarith.c (value_binop): Allow arithmetic operations on TYPE_CODE_CHAR variables. Add case to handle new BINOP_MOD. **** start-sanitize-chill **** * ch-exp.y (operand_4): Add useful actions for MOD and REM. * ch-exp.y (tokentab3): Add MOD and REM. * ch-exp.y (yylex): Set innermost_block for symbols found in local scopes. Return LOCATION_NAME for local symbols. * ch-lang.c (chill_op_print_tab): Fix MOD entry to use BINOP_MOD instead of BINOP_REM. Add REM entry, using BINOP_REM. **** end-sanitize-chill **** --- gdb/ChangeLog | 22 ++++++++++++++++++++++ gdb/ch-exp.y | 24 ++++++++++++++++++------ gdb/ch-lang.c | 3 ++- gdb/eval.c | 3 ++- gdb/expprint.c | 1 + gdb/expression.h | 1 + gdb/language.c | 1 + gdb/main.c | 1 + 8 files changed, 48 insertions(+), 8 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 2ca09d4..d468d4f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,25 @@ +Mon Jan 4 16:54:18 1993 Fred Fish (fnf@cygnus.com) + + * expression.h (exp_opcode): Add BINOP_MOD. + * eval.c (evaluate_subexp): Handle new BINOP_MOD. + * expprint.c (dump_expression): Handle new BINOP_MOD. + * language.c (binop_type_check): Handle new BINOP_MOD. + * main.c (float_handler): Re-enable float handler when hit. + * valarith.c (language.h): Include, need current_language. + * valarith.c (TRUNCATION_TOWARDS_ZERO): Define default macro + for integer divide truncates towards zero for negative results. + * valarith.c (value_x_binop): Handle BINOP_MOD if seen. + * valarith.c (value_binop): Allow arithmetic operations on + TYPE_CODE_CHAR variables. Add case to handle new BINOP_MOD. + **** start-sanitize-chill **** + * ch-exp.y (operand_4): Add useful actions for MOD and REM. + * ch-exp.y (tokentab3): Add MOD and REM. + * ch-exp.y (yylex): Set innermost_block for symbols found + in local scopes. Return LOCATION_NAME for local symbols. + * ch-lang.c (chill_op_print_tab): Fix MOD entry to use + BINOP_MOD instead of BINOP_REM. Add REM entry, using BINOP_REM. + **** end-sanitize-chill **** + Sun Jan 3 14:24:56 1993 Steve Chamberlain (sac@thepub.cygnus.com) * remote-sim.c: first attempt at general simulator interface diff --git a/gdb/ch-exp.y b/gdb/ch-exp.y index 6d6ebe7..38211d2 100644 --- a/gdb/ch-exp.y +++ b/gdb/ch-exp.y @@ -757,11 +757,11 @@ operand_4 : operand_5 } | operand_4 MOD operand_5 { - $$ = 0; /* FIXME */ + write_exp_elt_opcode (BINOP_MOD); } | operand_4 REM operand_5 { - $$ = 0; /* FIXME */ + write_exp_elt_opcode (BINOP_REM); } ; @@ -1390,6 +1390,8 @@ static const struct token tokentab4[] = static const struct token tokentab3[] = { + { "MOD", MOD }, + { "REM", REM }, { "NOT", NOT }, { "XOR", LOGXOR }, { "AND", LOGAND } @@ -1564,17 +1566,27 @@ yylex () case LOC_STATIC: /* Found a global or local static variable. */ return (LOCATION_NAME); - case LOC_UNDEF: - case LOC_CONST: case LOC_REGISTER: case LOC_ARG: case LOC_REF_ARG: case LOC_REGPARM: case LOC_LOCAL: - case LOC_TYPEDEF: + case LOC_LOCAL_ARG: + if (innermost_block == NULL + || contained_in (block_found, innermost_block)) + { + innermost_block = block_found; + } + return (LOCATION_NAME); + break; + case LOC_CONST: case LOC_LABEL: + return (LOCATION_NAME); + break; + case LOC_UNDEF: + case LOC_TYPEDEF: case LOC_CONST_BYTES: - case LOC_LOCAL_ARG: + error ("Symbol \"%s\" names no location.", simplename); break; } } diff --git a/gdb/ch-lang.c b/gdb/ch-lang.c index e42dc1b..d02d330 100644 --- a/gdb/ch-lang.c +++ b/gdb/ch-lang.c @@ -246,7 +246,8 @@ static const struct op_print chill_op_print_tab[] = { {"AND", BINOP_LOGICAL_AND, PREC_LOGICAL_AND, 0}, {"OR", BINOP_LOGICAL_OR, PREC_LOGICAL_OR, 0}, {"NOT", UNOP_LOGICAL_NOT, PREC_PREFIX, 0}, - {"MOD", BINOP_REM, PREC_MUL, 0}, + {"MOD", BINOP_MOD, PREC_MUL, 0}, + {"REM", BINOP_REM, PREC_MUL, 0}, {":=", BINOP_ASSIGN, PREC_ASSIGN, 1}, {"=", BINOP_EQUAL, PREC_EQUAL, 0}, {"/=", BINOP_NOTEQUAL, PREC_EQUAL, 0}, diff --git a/gdb/eval.c b/gdb/eval.c index fef404a..971ad9a 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -543,6 +543,7 @@ evaluate_subexp (expect_type, exp, pos, noside) case BINOP_MUL: case BINOP_DIV: case BINOP_REM: + case BINOP_MOD: case BINOP_LSH: case BINOP_RSH: case BINOP_BITWISE_AND: @@ -556,7 +557,7 @@ evaluate_subexp (expect_type, exp, pos, noside) return value_x_binop (arg1, arg2, op, OP_NULL); else if (noside == EVAL_AVOID_SIDE_EFFECTS - && (op == BINOP_DIV || op == BINOP_REM)) + && (op == BINOP_DIV || op == BINOP_REM || op == BINOP_MOD)) return value_zero (VALUE_TYPE (arg1), not_lval); else return value_binop (arg1, arg2, op); diff --git a/gdb/expprint.c b/gdb/expprint.c index 5a6986e..44b31e7 100644 --- a/gdb/expprint.c +++ b/gdb/expprint.c @@ -447,6 +447,7 @@ dump_expression (exp, stream, note) case BINOP_MUL: opcode_name = "BINOP_MUL"; break; case BINOP_DIV: opcode_name = "BINOP_DIV"; break; case BINOP_REM: opcode_name = "BINOP_REM"; break; + case BINOP_MOD: opcode_name = "BINOP_MOD"; break; case BINOP_LSH: opcode_name = "BINOP_LSH"; break; case BINOP_RSH: opcode_name = "BINOP_RSH"; break; case BINOP_LOGICAL_AND: opcode_name = "BINOP_LOGICAL_AND"; break; diff --git a/gdb/expression.h b/gdb/expression.h index 8a6cf4b..8c34642 100644 --- a/gdb/expression.h +++ b/gdb/expression.h @@ -52,6 +52,7 @@ enum exp_opcode BINOP_MUL, /* * */ BINOP_DIV, /* / */ BINOP_REM, /* % */ + BINOP_MOD, /* mod (Knuth 1.2.4) */ BINOP_LSH, /* << */ BINOP_RSH, /* >> */ BINOP_LOGICAL_AND, /* && */ diff --git a/gdb/language.c b/gdb/language.c index 445e816..44aea1e 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -842,6 +842,7 @@ binop_type_check(arg1,arg2,op) break; case BINOP_REM: + case BINOP_MOD: if (!integral_type(t1) || !integral_type(t2)) type_op_error ("Arguments to %s must be of integral type.",op); break; diff --git a/gdb/main.c b/gdb/main.c index c937921..284acc3 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -2247,6 +2247,7 @@ int signo; { /* This message is based on ANSI C, section 4.7. Note that integer divide by zero causes this, so "float" is a misnomer. */ + signal (SIGFPE, float_handler); error ("Erroneous arithmetic operation."); } -- 2.7.4