* serial.h (SERIAL_SET_TTY_STATE): Comment return value.
[deliverable/binutils-gdb.git] / gdb / m2-exp.y
index c1d6e70fdcfdeca0cb2c645eca1c85cfba3f403b..e566c67d290cd8b7ebef999ed2084c690e498e9f 100644 (file)
@@ -44,6 +44,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "value.h"
 #include "parser-defs.h"
 #include "m2-lang.h"
+#include "bfd.h" /* Required by objfiles.h.  */
+#include "symfile.h" /* Required by objfiles.h.  */
+#include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
 
 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
    as well as gratuitiously global symbol names, so we can have multiple
@@ -58,16 +61,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #define        yyerror m2_error
 #define        yylval  m2_lval
 #define        yychar  m2_char
-#define        yycheck m2_yycheck
 #define        yydebug m2_debug
-#define        yydefred m2_yydefred
-#define        yydgoto m2_yydgoto
-#define        yygindex m2_yygindex
-#define        yylen   m2_yylen
-#define        yylhs   m2_yylhs
-#define        yyrindex m2_yyrindex
-#define        yysccsid m2_yysccsid
-#define        yysindex m2_yysindex
 #define        yypact  m2_pact
 #define        yyr1    m2_r1
 #define        yyr2    m2_r2
@@ -81,15 +75,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #define        yyps    m2_ps
 #define        yypv    m2_pv
 #define        yys     m2_s
-#define        yyss    m2_yyss
-#define        yyssp   m2_yyssp
 #define        yy_yys  m2_yys
 #define        yystate m2_state
-#define        yytable m2_yytable
 #define        yytmp   m2_tmp
 #define        yyv     m2_v
-#define        yyvs    m2_vs
-#define        yyvss   m2_vss
 #define        yy_yyv  m2_yyv
 #define        yyval   m2_val
 #define        yylloc  m2_lloc
@@ -573,6 +562,7 @@ fblock      :       block COLONCOLON BLOCKNAME
 /* Useful for assigning to PROCEDURE variables */
 variable:      fblock
                        { write_exp_elt_opcode(OP_VAR_VALUE);
+                         write_exp_elt_block (NULL);
                          write_exp_elt_sym ($1);
                          write_exp_elt_opcode (OP_VAR_VALUE); }
        ;
@@ -594,6 +584,8 @@ variable:   block COLONCOLON NAME
                                   copy_name ($3));
 
                          write_exp_elt_opcode (OP_VAR_VALUE);
+                         /* block_found is set by lookup_symbol.  */
+                         write_exp_elt_block (block_found);
                          write_exp_elt_sym (sym);
                          write_exp_elt_opcode (OP_VAR_VALUE); }
        ;
@@ -610,33 +602,19 @@ variable: NAME
                                               NULL);
                          if (sym)
                            {
-                             switch (sym->class)
+                             if (symbol_read_needs_frame (sym))
                                {
-                               case LOC_REGISTER:
-                               case LOC_ARG:
-                               case LOC_LOCAL:
-                               case LOC_REF_ARG:
-                               case LOC_REGPARM:
-                               case LOC_LOCAL_ARG:
                                  if (innermost_block == 0 ||
-                                     contained_in (block_found,
+                                     contained_in (block_found, 
                                                    innermost_block))
                                    innermost_block = block_found;
-                                 break;
-
-                               case LOC_UNDEF:
-                               case LOC_CONST:
-                               case LOC_STATIC:
-                               case LOC_TYPEDEF:
-                               case LOC_LABEL: /* maybe should go above? */
-                               case LOC_BLOCK:
-                               case LOC_CONST_BYTES:
-                               case LOC_OPTIMIZED_OUT:
-                                 /* These are listed so gcc -Wall will reveal
-                                    un-handled cases.  */
-                                 break;
                                }
+
                              write_exp_elt_opcode (OP_VAR_VALUE);
+                             /* We want to use the selected frame, not
+                                another more inner frame which happens to
+                                be in the same block.  */
+                             write_exp_elt_block (NULL);
                              write_exp_elt_sym (sym);
                              write_exp_elt_opcode (OP_VAR_VALUE);
                            }
@@ -645,23 +623,13 @@ variable: NAME
                              struct minimal_symbol *msymbol;
                              register char *arg = copy_name ($1);
 
-                             msymbol = lookup_minimal_symbol (arg,
-                                         (struct objfile *) NULL);
+                             msymbol = lookup_minimal_symbol (arg, NULL);
                              if (msymbol != NULL)
                                {
-                                 write_exp_elt_opcode (OP_LONG);
-                                 write_exp_elt_type (builtin_type_int);
-                                 write_exp_elt_longcst ((LONGEST) SYMBOL_VALUE_ADDRESS (msymbol));
-                                 write_exp_elt_opcode (OP_LONG);
-                                 write_exp_elt_opcode (UNOP_MEMVAL);
-                                 if (msymbol -> type == mst_data ||
-                                     msymbol -> type == mst_bss)
-                                   write_exp_elt_type (builtin_type_int);
-                                 else if (msymbol -> type == mst_text)
-                                   write_exp_elt_type (lookup_function_type (builtin_type_int));
-                                 else
-                                   write_exp_elt_type (builtin_type_char);
-                                 write_exp_elt_opcode (UNOP_MEMVAL);
+                                 write_exp_msymbol
+                                   (msymbol,
+                                    lookup_function_type (builtin_type_int),
+                                    builtin_type_int);
                                }
                              else if (!have_full_symbols () && !have_partial_symbols ())
                                error ("No symbol table is loaded.  Use the \"symbol-file\" command.");
@@ -1124,10 +1092,14 @@ yylex ()
        case LOC_ARG:
        case LOC_REF_ARG:
        case LOC_REGPARM:
+       case LOC_REGPARM_ADDR:
        case LOC_LOCAL:
        case LOC_LOCAL_ARG:
+       case LOC_BASEREG:
+       case LOC_BASEREG_ARG:
        case LOC_CONST:
        case LOC_CONST_BYTES:
+       case LOC_OPTIMIZED_OUT:
          return NAME;
 
        case LOC_TYPEDEF:
@@ -1181,7 +1153,7 @@ void
 yyerror(msg)
      char *msg;        /* unused */
 {
-   printf("Parsing:  %s\n",lexptr);
+   printf_unfiltered("Parsing:  %s\n",lexptr);
    if (yychar < 256)
      error("Invalid syntax in expression near character '%c'.",yychar);
    else
This page took 0.024575 seconds and 4 git commands to generate.