* inftarg.c (child_thread_alive): New function to see if a
[deliverable/binutils-gdb.git] / gdb / parse.c
index f53be7ea0639dcbb892054affd7cb8f9bc3477c8..36f7c3917b4d23d9a2c23bf0a5fe4587900ddb20 100644 (file)
@@ -29,6 +29,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
    come first in the result.  */
    
 #include "defs.h"
+#include <string.h>
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "frame.h"
@@ -37,7 +38,21 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "command.h"
 #include "language.h"
 #include "parser-defs.h"
-
+\f
+/* Global variables declared in parser-defs.h (and commented there).  */
+struct expression *expout;
+int expout_size;
+int expout_ptr;
+struct block *expression_context_block;
+struct block *innermost_block;
+int arglist_len;
+union type_stack_elt *type_stack;
+int type_stack_depth, type_stack_size;
+char *lexptr;
+char *namecopy;
+int paren_depth;
+int comma_terminates;
+\f
 static void
 free_funcalls PARAMS ((void));
 
@@ -339,12 +354,16 @@ write_exp_bitstring (str)
   write_exp_elt_longcst ((LONGEST) bits);
 }
 
-/* Type that corresponds to the address given in a minimal symbol.  */
-
-static struct type *msymbol_addr_type;
-
 /* Add the appropriate elements for a minimal symbol to the end of
-   the expression.  */
+   the expression.  The rationale behind passing in text_symbol_type and
+   data_symbol_type was so that Modula-2 could pass in WORD for
+   data_symbol_type.  Perhaps it still is useful to have those types vary
+   based on the language, but they no longer have names like "int", so
+   the initial rationale is gone.  */
+
+static struct type *msym_text_symbol_type;
+static struct type *msym_data_symbol_type;
+static struct type *msym_unknown_symbol_type;
 
 void
 write_exp_msymbol (msymbol, text_symbol_type, data_symbol_type)
@@ -353,7 +372,7 @@ write_exp_msymbol (msymbol, text_symbol_type, data_symbol_type)
      struct type *data_symbol_type;
 {
   write_exp_elt_opcode (OP_LONG);
-  write_exp_elt_type (msymbol_addr_type);
+  write_exp_elt_type (lookup_pointer_type (builtin_type_void));
   write_exp_elt_longcst ((LONGEST) SYMBOL_VALUE_ADDRESS (msymbol));
   write_exp_elt_opcode (OP_LONG);
 
@@ -362,18 +381,19 @@ write_exp_msymbol (msymbol, text_symbol_type, data_symbol_type)
     {
     case mst_text:
     case mst_file_text:
-      write_exp_elt_type (text_symbol_type);
+    case mst_solib_trampoline:
+      write_exp_elt_type (msym_text_symbol_type);
       break;
 
     case mst_data:
     case mst_file_data:
     case mst_bss:
     case mst_file_bss:
-      write_exp_elt_type (data_symbol_type);
+      write_exp_elt_type (msym_data_symbol_type);
       break;
 
     default:
-      write_exp_elt_type (builtin_type_char);
+      write_exp_elt_type (msym_unknown_symbol_type);
       break;
     }
   write_exp_elt_opcode (UNOP_MEMVAL);
@@ -450,7 +470,13 @@ length_of_subexp (expr, endpos)
       oplen = 3;
       break;
 
+    case OP_COMPLEX:
+      oplen = 1; 
+      args = 2;
+      break; 
+
     case OP_FUNCALL:
+    case OP_F77_UNDETERMINED_ARGLIST:
       oplen = 3;
       args = 1 + longest_to_int (expr->elts[endpos - 2].longconst);
       break;
@@ -479,6 +505,7 @@ length_of_subexp (expr, endpos)
       args = 1;
       break;
 
+    case OP_LABELED:
     case STRUCTOP_STRUCT:
     case STRUCTOP_PTR:
       args = 1;
@@ -503,12 +530,14 @@ length_of_subexp (expr, endpos)
       break;
 
     case TERNOP_COND:
+    case TERNOP_SLICE:
+    case TERNOP_SLICE_COUNT:
       args = 3;
       break;
 
       /* Modula-2 */
    case MULTI_SUBSCRIPT:
-      oplen=3;
+      oplen = 3;
       args = 1 + longest_to_int (expr->elts[endpos- 2].longconst);
       break;
 
@@ -579,7 +608,13 @@ prefixify_subexp (inexpr, outexpr, inend, outbeg)
       oplen = 3;
       break;
 
+    case OP_COMPLEX:
+      oplen = 1; 
+      args = 2; 
+      break; 
+
     case OP_FUNCALL:
+    case OP_F77_UNDETERMINED_ARGLIST:
       oplen = 3;
       args = 1 + longest_to_int (inexpr->elts[inend - 2].longconst);
       break;
@@ -609,6 +644,7 @@ prefixify_subexp (inexpr, outexpr, inend, outbeg)
 
     case STRUCTOP_STRUCT:
     case STRUCTOP_PTR:
+    case OP_LABELED:
       args = 1;
       /* fall through */
     case OP_M2_STRING:
@@ -631,6 +667,8 @@ prefixify_subexp (inexpr, outexpr, inend, outbeg)
       break;
 
     case TERNOP_COND:
+    case TERNOP_SLICE:
+    case TERNOP_SLICE_COUNT:
       args = 3;
       break;
 
@@ -641,7 +679,7 @@ prefixify_subexp (inexpr, outexpr, inend, outbeg)
 
       /* Modula-2 */
    case MULTI_SUBSCRIPT:
-      oplen=3;
+      oplen = 3;
       args = 1 + longest_to_int (inexpr->elts[inend - 2].longconst);
       break;
 
@@ -837,20 +875,22 @@ follow_types (follow_type)
        break;
       case tp_array:
        array_size = pop_type_int ();
-       if (array_size != -1)
-         {
-           range_type =
-             create_range_type ((struct type *) NULL,
-                                builtin_type_int, 0,
-                                array_size - 1);
-           follow_type =
-             create_array_type ((struct type *) NULL,
-                                follow_type, range_type);
-         }
-       else
-         follow_type = lookup_pointer_type (follow_type);
+       /* FIXME-type-allocation: need a way to free this type when we are
+          done with it.  */
+       range_type =
+         create_range_type ((struct type *) NULL,
+                            builtin_type_int, 0,
+                            array_size >= 0 ? array_size - 1 : 0);
+       follow_type =
+         create_array_type ((struct type *) NULL,
+                            follow_type, range_type);
+       if (array_size < 0)
+         TYPE_ARRAY_UPPER_BOUND_TYPE(follow_type)
+           = BOUND_CANNOT_BE_DETERMINED;
        break;
       case tp_function:
+       /* FIXME-type-allocation: need a way to free this type when we are
+          done with it.  */
        follow_type = lookup_function_type (follow_type);
        break;
       }
@@ -865,10 +905,14 @@ _initialize_parse ()
   type_stack = (union type_stack_elt *)
     xmalloc (type_stack_size * sizeof (*type_stack));
 
-  /* We don't worry too much about what the name of this type is
-     because the name should rarely appear in output to the user.  */
-
-  msymbol_addr_type =
-    init_type (TYPE_CODE_PTR, TARGET_PTR_BIT / HOST_CHAR_BIT, 0,
-              "void *", NULL);
+  msym_text_symbol_type =
+    init_type (TYPE_CODE_FUNC, 1, 0, "<text variable, no debug info>", NULL);
+  TYPE_TARGET_TYPE (msym_text_symbol_type) = builtin_type_int;
+  msym_data_symbol_type =
+    init_type (TYPE_CODE_INT, TARGET_INT_BIT / HOST_CHAR_BIT, 0,
+              "<data variable, no debug info>", NULL);
+  msym_unknown_symbol_type =
+    init_type (TYPE_CODE_INT, 1, 0,
+              "<variable (not text or data), no debug info>",
+              NULL);
 }
This page took 0.02569 seconds and 4 git commands to generate.