* language.h (struct language_defn): New field evaluate_exp.
authorPer Bothner <per@bothner.com>
Sun, 12 Feb 1995 19:21:04 +0000 (19:21 +0000)
committerPer Bothner <per@bothner.com>
Sun, 12 Feb 1995 19:21:04 +0000 (19:21 +0000)
* c-lang.c (c_language_defn, cplus_language_defn, asm_langauge_defn),
f-lang.c (f_language_defn), language.c (unknown_language_defn,
auto_language_defn, local_language_defn), m2-lang.c (m2_language_defn):
Set evaluate_exp to evaluate_subexp_standard.
* ch-lang.c (evaluate_subexp_chill):  New function.  Chill-specific
support for MULTI_SUBSCRIPT.
(chill_language_defn):  Set evaluate_exp to evaluate_subexp_chill.
* eval.c (enum noside):  Move from here ....
* expression.h (enum noside):  ... to here.
(evaluate_subexp_standard):  New prototype.
* eval.c (evaluate_subexp):  Renamed to evaluate_subexp_standard.
Removed lo-longer-needed test for chill_varying_type.
(evaluate_subexp):  New.  Calls exp->language_defn->evaluate_exp.

gdb/ChangeLog
gdb/c-lang.c
gdb/ch-lang.c
gdb/eval.c
gdb/expression.h
gdb/f-lang.c
gdb/language.c
gdb/language.h
gdb/m2-lang.c

index fea812f8924d85a2e019a751cb8b7013c54fec83..f2c495bf9d35e271e5d5a73389d0ed28dad507ef 100644 (file)
@@ -1,5 +1,20 @@
 Sun Feb 12 11:03:47 1995  Per Bothner  <bothner@kalessin.cygnus.com>
 
+       * language.h (struct language_defn):  New field evaluate_exp.
+       * c-lang.c (c_language_defn, cplus_language_defn, asm_langauge_defn),
+       f-lang.c (f_language_defn), language.c (unknown_language_defn,
+       auto_language_defn, local_language_defn), m2-lang.c (m2_language_defn):
+       Set evaluate_exp to evaluate_subexp_standard.
+       * ch-lang.c (evaluate_subexp_chill):  New function.  Chill-specific
+       support for MULTI_SUBSCRIPT.
+       (chill_language_defn):  Set evaluate_exp to evaluate_subexp_chill.
+       * eval.c (enum noside):  Move from here ....
+       * expression.h (enum noside):  ... to here.
+       (evaluate_subexp_standard):  New prototype.
+       * eval.c (evaluate_subexp):  Renamed to evaluate_subexp_standard.
+       Removed lo-longer-needed test for chill_varying_type.
+       (evaluate_subexp):  New.  Calls exp->language_defn->evaluate_exp.
+
        * ch-exp.y (maybe_expression_list):  New non-terminal.
        (primitive_value):  Allow empty parameter list.
 
index 5c6b0b5b66b035b6be201f25bcc01fdcc7c00c54..d7e5536f86949bc397172bba2faebd3e4a351785 100644 (file)
@@ -399,6 +399,7 @@ const struct language_defn c_language_defn = {
   type_check_off,
   c_parse,
   c_error,
+  evaluate_subexp_standard,
   c_printchar,                 /* Print a character constant */
   c_printstr,                  /* Function to print string constant */
   c_create_fundamental_type,   /* Create fundamental type in this language */
@@ -424,6 +425,7 @@ const struct language_defn cplus_language_defn = {
   type_check_off,
   c_parse,
   c_error,
+  evaluate_subexp_standard,
   c_printchar,                 /* Print a character constant */
   c_printstr,                  /* Function to print string constant */
   c_create_fundamental_type,   /* Create fundamental type in this language */
@@ -449,6 +451,7 @@ const struct language_defn asm_language_defn = {
   type_check_off,
   c_parse,
   c_error,
+  evaluate_subexp_standard,
   c_printchar,                 /* Print a character constant */
   c_printstr,                  /* Function to print string constant */
   c_create_fundamental_type,   /* Create fundamental type in this language */
index 7060ce159be6f65a4bb7c4fe6f93ed0e94b7bb35..9bce5880bf550848ae9983e4109293880de3797f 100644 (file)
@@ -20,6 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "defs.h"
 #include "symtab.h"
 #include "gdbtypes.h"
+#include "value.h"
 #include "expression.h"
 #include "parser-defs.h"
 #include "language.h"
@@ -269,7 +270,6 @@ static const struct op_print chill_op_print_tab[] = {
     {"->",  UNOP_ADDR, PREC_PREFIX, 0},
     {NULL,  0, 0, 0}
 };
-
 \f
 /* The built-in types of Chill.  */
 
@@ -289,6 +289,54 @@ struct type ** const (chill_builtin_types[]) =
   0
 };
 
+static value_ptr
+evaluate_subexp_chill (expect_type, exp, pos, noside)
+     struct type *expect_type;
+     register struct expression *exp;
+     register int *pos;
+     enum noside noside;
+{
+  int pc = *pos;
+  int tem, nargs;
+  value_ptr arg1;
+  value_ptr *argvec;
+  switch (exp->elts[*pos].opcode)
+    {
+    case MULTI_SUBSCRIPT:
+      if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS)
+       break;
+      (*pos) += 3;
+      nargs = longest_to_int (exp->elts[pc + 1].longconst);
+      arg1 = evaluate_subexp_with_coercion (exp, pos, noside);
+
+      switch (TYPE_CODE (VALUE_TYPE (arg1)))
+       {
+       case TYPE_CODE_PTR:
+       case TYPE_CODE_FUNC:
+         /* It's a function call. */
+         /* 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));
+         argvec[0] = arg1;
+         tem = 1;
+         for (; tem <= nargs; tem++)
+           argvec[tem] = evaluate_subexp_with_coercion (exp, pos, noside);
+         argvec[tem] = 0; /* signal end of arglist */
+
+         return call_function_by_hand (argvec[0], nargs, argvec + 1);
+       }
+
+      while (nargs-- > 0)
+       {
+         value_ptr index = evaluate_subexp_with_coercion (exp, pos, noside);
+         arg1 = value_subscript (arg1, index);
+       }
+      return (arg1);
+    }
+
+  return evaluate_subexp_standard (expect_type, exp, pos, noside);
+}
+
 const struct language_defn chill_language_defn = {
   "chill",
   language_chill,
@@ -297,6 +345,7 @@ const struct language_defn chill_language_defn = {
   type_check_on,
   chill_parse,                 /* parser */
   chill_error,                 /* parser error function */
+  evaluate_subexp_chill,
   chill_printchar,             /* print a character constant */
   chill_printstr,              /* function to print a string constant */
   chill_create_fundamental_type,/* Create fundamental type in this language */
index 055d5910c2a5b854eeda7b86eb85056b9b5f2ad8..3d3e201bc94189b93bfc20101efbadca930e3323 100644 (file)
@@ -30,37 +30,29 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "language.h"  /* For CAST_IS_CONVERSION */
 #include "f-lang.h" /* for array bound stuff */
 
-/* Values of NOSIDE argument to eval_subexp.  */
-
-enum noside
-{
-  EVAL_NORMAL,
-  EVAL_SKIP,                   /* Only effect is to increment pos.  */
-  EVAL_AVOID_SIDE_EFFECTS      /* Don't modify any variables or
-                                  call any functions.  The value
-                                  returned will have the correct
-                                  type, and will have an
-                                  approximately correct lvalue
-                                  type (inaccuracy: anything that is
-                                  listed as being in a register in
-                                  the function in which it was
-                                  declared will be lval_register).  */
-};
-
 /* Prototypes for local functions. */
 
 static value_ptr evaluate_subexp_for_sizeof PARAMS ((struct expression *,
                                                     int *));
 
-static value_ptr evaluate_subexp_with_coercion PARAMS ((struct expression *,
+value_ptr evaluate_subexp_with_coercion PARAMS ((struct expression *,
                                                        int *, enum noside));
 
 static value_ptr evaluate_subexp_for_address PARAMS ((struct expression *,
                                                      int *, enum noside));
 
-static value_ptr evaluate_subexp PARAMS ((struct type *, struct expression *,
-                                         int *, enum noside));
-
+#ifdef __GNUC__
+inline
+#endif
+static value_ptr
+evaluate_subexp (expect_type, exp, pos, noside)
+     struct type *expect_type;
+     register struct expression *exp;
+     register int *pos;
+     enum noside noside;
+{
+  return (*exp->language_defn->evaluate_exp) (expect_type, exp, pos, noside);
+}
 \f
 /* Parse the string EXP as a C expression, evaluate it,
    and return the result as a number.  */
@@ -223,8 +215,8 @@ evaluate_labeled_field_init (struct_val, fieldnop, exp, pos, noside)
   return val;
 }
 
-static value_ptr
-evaluate_subexp (expect_type, exp, pos, noside)
+value_ptr
+evaluate_subexp_standard (expect_type, exp, pos, noside)
      struct type *expect_type;
      register struct expression *exp;
      register int *pos;
@@ -654,19 +646,7 @@ evaluate_subexp (expect_type, exp, pos, noside)
          at parse time.  We have made all array subscript operations, 
          substring operations as well as function calls  come here 
          and we now have to discover what the heck this thing actually was.  
-         If it is an array, we massage it into a form that the 
-         MULTI_F77_SUBSCRIPT operator can deal with. If it is 
-         a function, we process just as if we got an OP_FUNCALL and 
-         for a subscring operation, we perform the appropriate 
-         substring operation.  */ 
-
-      /* First get the nargs and then jump all the way over the:
-         
-         OP_UNDETERMINED_ARGLIST
-         nargs 
-         OP_UNDETERMINED_ARGLIST 
-            
-         instruction sequence */
+        If it is a function, we process just as if we got an OP_FUNCALL. */
 
       nargs = longest_to_int (exp->elts[pc+1].longconst);
       (*pos) += 2;
@@ -952,8 +932,7 @@ evaluate_subexp (expect_type, exp, pos, noside)
                }
            }
          
-         if (binop_user_defined_p (op, arg1, arg2)
-             && ! chill_varying_type (VALUE_TYPE (arg1)))
+         if (binop_user_defined_p (op, arg1, arg2))
            {
              arg1 = value_x_binop (arg1, arg2, op, OP_NULL);
            }
@@ -1045,9 +1024,7 @@ evaluate_subexp (expect_type, exp, pos, noside)
           returns the correct type value */
 
        VALUE_TYPE (arg1) = tmp_type; 
-
-       arg1 = value_subscript (arg1, arg2);
-       return arg1;
+       return value_ind (value_add (value_coerce_array (arg1), arg2));
       }
 
     case BINOP_LOGICAL_AND:
@@ -1488,7 +1465,7 @@ evaluate_subexp_for_address (exp, pos, noside)
 
    */
 
-static value_ptr
+value_ptr
 evaluate_subexp_with_coercion (exp, pos, noside)
      register struct expression *exp;
      register int *pos;
index 6a166dbe796ac4dccd35ae225da610ee0d02b95b..3a08e1287b035f8a1994bb4ff6b2b2b30886436e 100644 (file)
@@ -132,13 +132,6 @@ enum exp_opcode
      by each of the next following subexpressions, one per dimension. */
    MULTI_SUBSCRIPT,
 
-  /* For Fortran array subscripting (column major style). Like the 
-     Modula operator, we find that the dimensionality is 
-     encoded in the operator.  This operator is distinct 
-     from the above one because it uses column-major array 
-     ordering not row-major.  */ 
-  MULTI_F77_SUBSCRIPT,
-
   /* The OP_... series take immediate following arguments.
      After the arguments come another OP_... (the same one)
      so that the grouping can be recognized from the end.  */
@@ -193,11 +186,6 @@ enum exp_opcode
      literal. It is followed by exactly two args that are doubles.  */ 
   OP_COMPLEX,
 
-  /* The following OP introduces a F77 substring operator.
-     It should have a string type and two integer types that follow 
-     indicating the "from" and "to" for the substring. */ 
-  OP_F77_SUBSTR,
-
   /* OP_STRING represents a string constant.
      Its format is the same as that of a STRUCTOP, but the string
      data is just made into a string constant when the operation
@@ -342,6 +330,28 @@ extern struct expression *parse_exp_1 PARAMS ((char **, struct block *, int));
    parse_<whatever>, then look at it.  */
 extern struct block *innermost_block;
 
+/* From eval.c */
+
+/* Values of NOSIDE argument to eval_subexp.  */
+
+enum noside
+{
+  EVAL_NORMAL,
+  EVAL_SKIP,                   /* Only effect is to increment pos.  */
+  EVAL_AVOID_SIDE_EFFECTS      /* Don't modify any variables or
+                                  call any functions.  The value
+                                  returned will have the correct
+                                  type, and will have an
+                                  approximately correct lvalue
+                                  type (inaccuracy: anything that is
+                                  listed as being in a register in
+                                  the function in which it was
+                                  declared will be lval_register).  */
+};
+
+extern struct value* evaluate_subexp_standard
+PARAMS ((struct type *, struct expression *, int*, enum noside));
+
 /* From expprint.c */
 
 extern void print_expression PARAMS ((struct expression *, GDB_FILE *));
index 7ccae4f1f75707530f38e89fde178d1c7a0c5e40..b296a2002f79c542bc176f6e5773a090d259a322 100644 (file)
@@ -423,6 +423,7 @@ const struct language_defn f_language_defn = {
   type_check_on,
   f_parse,                     /* parser */
   f_error,                     /* parser error function */
+  evaluate_subexp_standard,
   f_printchar,                 /* Print character constant */
   f_printstr,                  /* function to print string constant */
   f_create_fundamental_type,   /* Create fundamental type in this language */
index eb917bc65b10c126706e7ad2191679ff7eb1620c..a2dc7ba1cc59e0d40bc709874a1bf44a1494b057 100644 (file)
@@ -1189,6 +1189,7 @@ const struct language_defn unknown_language_defn = {
   type_check_off,
   unk_lang_parser,
   unk_lang_error,
+  evaluate_subexp_standard,
   unk_lang_printchar,          /* Print character constant */
   unk_lang_printstr,
   unk_lang_create_fundamental_type,
@@ -1215,6 +1216,7 @@ const struct language_defn auto_language_defn = {
   type_check_off,
   unk_lang_parser,
   unk_lang_error,
+  evaluate_subexp_standard,
   unk_lang_printchar,          /* Print character constant */
   unk_lang_printstr,
   unk_lang_create_fundamental_type,
@@ -1240,6 +1242,7 @@ const struct language_defn local_language_defn = {
   type_check_off,
   unk_lang_parser,
   unk_lang_error,
+  evaluate_subexp_standard,
   unk_lang_printchar,          /* Print character constant */
   unk_lang_printstr,
   unk_lang_create_fundamental_type,
index 0e263baf6e092b6bfc93bf9ce0a3ae7490cf72e0..02fccec1ee053671c57a9058b033522e66f2d070 100644 (file)
@@ -25,6 +25,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #ifdef __STDC__                /* Forward decls for prototypes */
 struct value;
 struct objfile;
+struct expression;
 /* enum exp_opcode;    ANSI's `wisdom' didn't include forward enum decls. */
 #endif
 
@@ -132,6 +133,10 @@ struct language_defn
 
   void (*la_error) PARAMS ((char *));
 
+  /* Evaluate an expression. */
+  struct value * (*evaluate_exp) PARAMS ((struct type*, struct expression *, 
+                                         int *, enum noside));
+
   void (*la_printchar) PARAMS ((int, GDB_FILE *));
 
   void (*la_printstr) PARAMS ((GDB_FILE *, char *, unsigned int, int));
index a81282141562fa3a8c16c2ec56d035c7fdbb50d4..1a7fd6d487b4610a2ba47af3b7f10f5f3bbedc32 100644 (file)
@@ -407,6 +407,7 @@ const struct language_defn m2_language_defn = {
   type_check_on,
   m2_parse,                    /* parser */
   m2_error,                    /* parser error function */
+  evaluate_subexp_standard,
   m2_printchar,                        /* Print character constant */
   m2_printstr,                 /* function to print string constant */
   m2_create_fundamental_type,  /* Create fundamental type in this language */
This page took 0.038492 seconds and 4 git commands to generate.