* target.h: Add enum target_waitkind, enum target_signal, and
[deliverable/binutils-gdb.git] / gdb / parse.c
index 94e467e3d220e8f46487f9baf89d958c3dbeb4d6..ca9bcc8c9b011fd36689b640eedad801c5095ff9 100644 (file)
@@ -338,6 +338,42 @@ write_exp_bitstring (str)
   expout_ptr += lenelt - 2;
   write_exp_elt_longcst ((LONGEST) bits);
 }
+
+/* Add the appropriate elements for a minimal symbol to the end of
+   the expression.  */
+
+void
+write_exp_msymbol (msymbol, text_symbol_type, data_symbol_type)
+     struct minimal_symbol *msymbol;
+     struct type *text_symbol_type;
+     struct type *data_symbol_type;
+{
+  write_exp_elt_opcode (OP_LONG);
+  write_exp_elt_type (builtin_type_long);
+  write_exp_elt_longcst ((LONGEST) SYMBOL_VALUE_ADDRESS (msymbol));
+  write_exp_elt_opcode (OP_LONG);
+
+  write_exp_elt_opcode (UNOP_MEMVAL);
+  switch (msymbol -> type)
+    {
+    case mst_text:
+    case mst_file_text:
+      write_exp_elt_type (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);
+      break;
+
+    default:
+      write_exp_elt_type (builtin_type_char);
+      break;
+    }
+  write_exp_elt_opcode (UNOP_MEMVAL);
+}
 \f
 /* Return a null-terminated temporary copy of the name
    of a string token.  */
@@ -705,9 +741,9 @@ parse_exp_1 (stringptr, block, comma)
   /* Convert expression from postfix form as generated by yacc
      parser, to a prefix form. */
 
-  DUMP_EXPRESSION (expout, stdout, "before conversion to prefix form");
+  DUMP_EXPRESSION (expout, gdb_stdout, "before conversion to prefix form");
   prefixify_expression (expout);
-  DUMP_EXPRESSION (expout, stdout, "after conversion to prefix form");
+  DUMP_EXPRESSION (expout, gdb_stdout, "after conversion to prefix form");
 
   *stringptr = lexptr;
   return expout;
@@ -726,6 +762,9 @@ parse_expression (string)
     error ("Junk after end of expression.");
   return exp;
 }
+\f
+/* Stuff for maintaining a stack of types.  Currently just used by C, but
+   probably useful for any language which declares its types "backwards".  */
 
 void 
 push_type (tp)
@@ -770,6 +809,50 @@ pop_type_int ()
   return 0;
 }
 
+/* Pop the type stack and return the type which corresponds to FOLLOW_TYPE
+   as modified by all the stuff on the stack.  */
+struct type *
+follow_types (follow_type)
+     struct type *follow_type;
+{
+  int done = 0;
+  int array_size;
+  struct type *range_type;
+
+  while (!done)
+    switch (pop_type ())
+      {
+      case tp_end:
+       done = 1;
+       break;
+      case tp_pointer:
+       follow_type = lookup_pointer_type (follow_type);
+       break;
+      case tp_reference:
+       follow_type = lookup_reference_type (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);
+       break;
+      case tp_function:
+       follow_type = lookup_function_type (follow_type);
+       break;
+      }
+  return follow_type;
+}
+\f
 void
 _initialize_parse ()
 {
This page took 0.025874 seconds and 4 git commands to generate.