2002-11-29 Andrew Cagney <ac131313@redhat.com>
[deliverable/binutils-gdb.git] / gdb / p-exp.y
index 4dc99be8ce451968173cadb846aeb3194c2dc3c8..f15c217383d9094e88a3db7b52530eba6f7bdda7 100644 (file)
@@ -233,7 +233,8 @@ static int search_field;
 start   :      { current_type = NULL;
                  search_field = 0;
                }
-               normal_start;
+               normal_start {}
+       ;
 
 normal_start   :
                exp1
@@ -257,11 +258,13 @@ exp       :       exp '^'   %prec UNARY
                        { write_exp_elt_opcode (UNOP_IND);
                          if (current_type) 
                            current_type = TYPE_TARGET_TYPE (current_type); }
+       ;
 
 exp    :       '@' exp    %prec UNARY
                        { write_exp_elt_opcode (UNOP_ADDR); 
                          if (current_type)
                            current_type = TYPE_POINTER_TYPE (current_type); }
+       ;
 
 exp    :       '-' exp    %prec UNARY
                        { write_exp_elt_opcode (UNOP_NEG); }
@@ -317,6 +320,7 @@ exp :       exp '['
                          write_exp_elt_opcode (BINOP_SUBSCRIPT);
                          if (current_type)
                            current_type = TYPE_TARGET_TYPE (current_type); }
+       ;
 
 exp    :       exp '('
                        /* This is to save the value of arglist_len
@@ -338,7 +342,15 @@ arglist    :
        ;
 
 exp    :       type '(' exp ')' %prec UNARY
-                       { write_exp_elt_opcode (UNOP_CAST);
+                       { if (current_type)
+                           {
+                             /* Allow automatic dereference of classes.  */
+                             if ((TYPE_CODE (current_type) == TYPE_CODE_PTR)
+                                 && (TYPE_CODE (TYPE_TARGET_TYPE (current_type)) == TYPE_CODE_CLASS)
+                                 && (TYPE_CODE ($1) == TYPE_CODE_CLASS))
+                               write_exp_elt_opcode (UNOP_IND);
+                           }
+                         write_exp_elt_opcode (UNOP_CAST);
                          write_exp_elt_type ($1);
                          write_exp_elt_opcode (UNOP_CAST); 
                          current_type = $1; }
@@ -500,8 +512,28 @@ exp        :       STRING
 
 /* Object pascal  */
 exp    :       THIS
-                       { write_exp_elt_opcode (OP_THIS);
-                         write_exp_elt_opcode (OP_THIS); }
+                       { 
+                         struct value * this_val;
+                         struct type * this_type;
+                         write_exp_elt_opcode (OP_THIS);
+                         write_exp_elt_opcode (OP_THIS); 
+                         /* we need type of this */
+                         this_val = value_of_this (0); 
+                         if (this_val)
+                           this_type = this_val->type;
+                         else
+                           this_type = NULL;
+                         if (this_type)
+                           {
+                             if (TYPE_CODE (this_type) == TYPE_CODE_PTR)
+                               {
+                                 this_type = TYPE_TARGET_TYPE (this_type);
+                                 write_exp_elt_opcode (UNOP_IND);
+                               }
+                           }
+               
+                         current_type = this_type;
+                       }
        ;
 
 /* end of object pascal.  */
@@ -645,7 +677,7 @@ variable:   name_not_typename
                              if (this_type)
                                current_type = lookup_struct_elt_type (
                                  this_type,
-                                 $1.stoken.ptr, false);
+                                 copy_name($1.stoken), false);
                              else
                                current_type = NULL; 
                            }
@@ -689,7 +721,9 @@ type        :       ptype
        ;
 
 typebase  /* Implements (approximately): (type-qualifier)* type-specifier */
-       :       TYPENAME
+       :       '^' typebase
+                       { $$ = lookup_pointer_type ($2); }
+       |       TYPENAME
                        { $$ = $1.type; }
        |       STRUCT name
                        { $$ = lookup_struct (copy_name ($2),
This page took 0.026583 seconds and 4 git commands to generate.