Introduce reset_locator function in tui-layout.c
[deliverable/binutils-gdb.git] / gdb / f-exp.y
index da4732237d344f1b178bb9259037e7e1ea78b38a..14ea3869bb2d01c5c80e77af26e3937c24353fab 100644 (file)
@@ -54,6 +54,7 @@
 #include "block.h"
 #include <ctype.h>
 #include <algorithm>
+#include "type-stack.h"
 
 #define parse_type(ps) builtin_type (ps->gdbarch ())
 #define parse_f_type(ps) builtin_f_type (ps->gdbarch ())
@@ -71,6 +72,9 @@ static struct parser_state *pstate = NULL;
 /* Depth of parentheses.  */
 static int paren_depth;
 
+/* The current type stack.  */
+static struct type_stack *type_stack;
+
 int yyparse (void);
 
 static int yylex (void);
@@ -170,7 +174,7 @@ static int parse_number (struct parser_state *, const char *, int,
 %token <voidval> DOLLAR_VARIABLE
 
 %token <opcode> ASSIGN_MODIFY
-%token <opcode> UNOP_INTRINSIC
+%token <opcode> UNOP_INTRINSIC BINOP_INTRINSIC
 
 %left ','
 %left ABOVE_COMMA
@@ -236,7 +240,7 @@ exp :       SIZEOF exp       %prec UNARY
        ;
 
 exp    :       KIND '(' exp ')'       %prec UNARY
-                       { write_exp_elt_opcode (pstate, UNOP_KIND); }
+                       { write_exp_elt_opcode (pstate, UNOP_FORTRAN_KIND); }
        ;
 
 /* No more explicit array operators, we treat everything in F77 as 
@@ -259,6 +263,10 @@ exp        :       UNOP_INTRINSIC '(' exp ')'
                        { write_exp_elt_opcode (pstate, $1); }
        ;
 
+exp    :       BINOP_INTRINSIC '(' exp ',' exp ')'
+                       { write_exp_elt_opcode (pstate, $1); }
+       ;
+
 arglist        :
        ;
 
@@ -476,7 +484,7 @@ variable:   name_not_typename
                          if (sym.symbol)
                            {
                              if (symbol_read_needs_frame (sym.symbol))
-                               innermost_block.update (sym);
+                               pstate->block_tracker->update (sym);
                              write_exp_elt_opcode (pstate, OP_VAR_VALUE);
                              write_exp_elt_block (pstate, sym.block);
                              write_exp_elt_sym (pstate, sym.symbol);
@@ -486,17 +494,17 @@ variable: name_not_typename
                          else
                            {
                              struct bound_minimal_symbol msymbol;
-                             char *arg = copy_name ($1.stoken);
+                             std::string arg = copy_name ($1.stoken);
 
                              msymbol =
-                               lookup_bound_minimal_symbol (arg);
+                               lookup_bound_minimal_symbol (arg.c_str ());
                              if (msymbol.minsym != NULL)
                                write_exp_msymbol (pstate, msymbol);
                              else if (!have_full_symbols () && !have_partial_symbols ())
                                error (_("No symbol table is loaded.  Use the \"file\" command."));
                              else
                                error (_("No symbol \"%s\" in current context."),
-                                      copy_name ($1.stoken));
+                                      arg.c_str ());
                            }
                        }
        ;
@@ -515,7 +523,7 @@ ptype       :       typebase
                  struct type *range_type;
                  
                  while (!done)
-                   switch (pop_type ())
+                   switch (type_stack->pop ())
                      {
                      case tp_end:
                        done = 1;
@@ -527,7 +535,7 @@ ptype       :       typebase
                        follow_type = lookup_lvalue_reference_type (follow_type);
                        break;
                      case tp_array:
-                       array_size = pop_type_int ();
+                       array_size = type_stack->pop_int ();
                        if (array_size != -1)
                          {
                            range_type =
@@ -547,7 +555,7 @@ ptype       :       typebase
                        break;
                      case tp_kind:
                        {
-                         int kind_val = pop_type_int ();
+                         int kind_val = type_stack->pop_int ();
                          follow_type
                            = convert_to_kind_type (follow_type, kind_val);
                        }
@@ -558,13 +566,13 @@ ptype     :       typebase
        ;
 
 abs_decl:      '*'
-                       { push_type (tp_pointer); $$ = 0; }
+                       { type_stack->push (tp_pointer); $$ = 0; }
        |       '*' abs_decl
-                       { push_type (tp_pointer); $$ = $2; }
+                       { type_stack->push (tp_pointer); $$ = $2; }
        |       '&'
-                       { push_type (tp_reference); $$ = 0; }
+                       { type_stack->push (tp_reference); $$ = 0; }
        |       '&' abs_decl
-                       { push_type (tp_reference); $$ = $2; }
+                       { type_stack->push (tp_reference); $$ = $2; }
        |       direct_abs_decl
        ;
 
@@ -575,9 +583,9 @@ direct_abs_decl: '(' abs_decl ')'
        |       '*' INT
                        { push_kind_type ($2.val, $2.type); }
        |       direct_abs_decl func_mod
-                       { push_type (tp_function); }
+                       { type_stack->push (tp_function); }
        |       func_mod
-                       { push_type (tp_function); }
+                       { type_stack->push (tp_function); }
        ;
 
 func_mod:      '(' ')'
@@ -821,8 +829,8 @@ push_kind_type (LONGEST val, struct type *type)
       ival = static_cast <int> (val);
     }
 
-  push_type_int (ival);
-  push_type (tp_kind);
+  type_stack->push (ival);
+  type_stack->push (tp_kind);
 }
 
 /* Called when a type has a '(kind=N)' modifier after it, for example
@@ -955,7 +963,12 @@ static const struct token f77_keywords[] =
   /* The following correspond to actual functions in Fortran and are case
      insensitive.  */
   { "kind", KIND, BINOP_END, false },
-  { "abs", UNOP_INTRINSIC, UNOP_ABS, false }
+  { "abs", UNOP_INTRINSIC, UNOP_ABS, false },
+  { "mod", BINOP_INTRINSIC, BINOP_MOD, false },
+  { "floor", UNOP_INTRINSIC, UNOP_FORTRAN_FLOOR, false },
+  { "ceiling", UNOP_INTRINSIC, UNOP_FORTRAN_CEILING, false },
+  { "modulo", BINOP_INTRINSIC, BINOP_FORTRAN_MODULO, false },
+  { "cmplx", BINOP_INTRINSIC, BINOP_FORTRAN_CMPLX, false },
 };
 
 /* Implementation of a dynamically expandable buffer for processing input
@@ -1260,7 +1273,7 @@ yylex (void)
      currently as names of types; NAME for other symbols.
      The caller is not constrained to care about the distinction.  */
   {
-    char *tmp = copy_name (yylval.sval);
+    std::string tmp = copy_name (yylval.sval);
     struct block_symbol result;
     struct field_of_this_result is_a_field_of_this;
     enum domain_enum_tag lookup_domains[] =
@@ -1277,7 +1290,7 @@ yylex (void)
           way we can refer to it unconditionally below.  */
        memset (&is_a_field_of_this, 0, sizeof (is_a_field_of_this));
 
-       result = lookup_symbol (tmp, pstate->expression_context_block,
+       result = lookup_symbol (tmp.c_str (), pstate->expression_context_block,
                                lookup_domains[i],
                                pstate->language ()->la_language
                                == language_cplus
@@ -1294,7 +1307,7 @@ yylex (void)
 
     yylval.tsym.type
       = language_lookup_primitive_type (pstate->language (),
-                                       pstate->gdbarch (), tmp);
+                                       pstate->gdbarch (), tmp.c_str ());
     if (yylval.tsym.type != NULL)
       return TYPENAME;
     
@@ -1333,6 +1346,10 @@ f_parse (struct parser_state *par_state)
   pstate = par_state;
   paren_depth = 0;
 
+  struct type_stack stack;
+  scoped_restore restore_type_stack = make_scoped_restore (&type_stack,
+                                                          &stack);
+
   return yyparse ();
 }
 
This page took 0.028953 seconds and 4 git commands to generate.