This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 08/10] Objective-C language
- From: Sergio Durigan Junior <sergiodj at redhat dot com>
- To: GDB Patches <gdb-patches at sourceware dot org>
- Cc: Tom Tromey <tromey at redhat dot com>, Sergio Durigan Junior <sergiodj at redhat dot com>
- Date: Sat, 2 Jun 2012 16:32:06 -0300
- Subject: [PATCH 08/10] Objective-C language
- References: <1338665528-5932-1-git-send-email-sergiodj@redhat.com>
Patch for the Objective-C language. Similar to the C language one.
---
gdb/objc-exp.y | 412 ++++++++++++++++++++++++++++--------------------------
gdb/objc-lang.c | 8 +-
gdb/objc-lang.h | 7 +-
3 files changed, 222 insertions(+), 205 deletions(-)
diff --git a/gdb/objc-exp.y b/gdb/objc-exp.y
index 6f51edf..5157596 100644
--- a/gdb/objc-exp.y
+++ b/gdb/objc-exp.y
@@ -52,7 +52,7 @@
#include "completer.h" /* For skip_quoted(). */
#include "block.h"
-#define parse_type builtin_type (parse_gdbarch)
+#define parse_type(ps) builtin_type (parse_gdbarch (ps))
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror,
etc), as well as gratuitiously global symbol names, so we can have
@@ -63,7 +63,7 @@
adding those names to this list. */
#define yymaxdepth objc_maxdepth
-#define yyparse objc_parse
+#define yyparse _objc_parse
#define yylex objc_lex
#define yyerror objc_error
#define yylval objc_lval
@@ -113,6 +113,11 @@
#define YYDEBUG 0 /* Default to no yydebug support. */
#endif
+/* The state of the parser, used internally when we are parsing the
+ expression. */
+
+static struct parser_state *pstate = NULL;
+
int yyparse (void);
static int yylex (void);
@@ -153,7 +158,7 @@ void yyerror (char *);
%{
/* YYSTYPE gets defined by %union. */
-static int parse_number (char *, int, int, YYSTYPE *);
+static int parse_number (struct parser_state *, char *, int, int, YYSTYPE *);
%}
%type <voidval> exp exp1 type_exp start variable qualified_name lcurly
@@ -235,79 +240,79 @@ start : exp1
;
type_exp: type
- { write_exp_elt_opcode(OP_TYPE);
- write_exp_elt_type($1);
- write_exp_elt_opcode(OP_TYPE);}
+ { write_exp_elt_opcode (pstate, OP_TYPE);
+ write_exp_elt_type (pstate, $1);
+ write_exp_elt_opcode (pstate, OP_TYPE);}
;
/* Expressions, including the comma operator. */
exp1 : exp
| exp1 ',' exp
- { write_exp_elt_opcode (BINOP_COMMA); }
+ { write_exp_elt_opcode (pstate, BINOP_COMMA); }
;
/* Expressions, not including the comma operator. */
exp : '*' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_IND); }
+ { write_exp_elt_opcode (pstate, UNOP_IND); }
;
exp : '&' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_ADDR); }
+ { write_exp_elt_opcode (pstate, UNOP_ADDR); }
;
exp : '-' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_NEG); }
+ { write_exp_elt_opcode (pstate, UNOP_NEG); }
;
exp : '!' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_LOGICAL_NOT); }
+ { write_exp_elt_opcode (pstate, UNOP_LOGICAL_NOT); }
;
exp : '~' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_COMPLEMENT); }
+ { write_exp_elt_opcode (pstate, UNOP_COMPLEMENT); }
;
exp : INCREMENT exp %prec UNARY
- { write_exp_elt_opcode (UNOP_PREINCREMENT); }
+ { write_exp_elt_opcode (pstate, UNOP_PREINCREMENT); }
;
exp : DECREMENT exp %prec UNARY
- { write_exp_elt_opcode (UNOP_PREDECREMENT); }
+ { write_exp_elt_opcode (pstate, UNOP_PREDECREMENT); }
;
exp : exp INCREMENT %prec UNARY
- { write_exp_elt_opcode (UNOP_POSTINCREMENT); }
+ { write_exp_elt_opcode (pstate, UNOP_POSTINCREMENT); }
;
exp : exp DECREMENT %prec UNARY
- { write_exp_elt_opcode (UNOP_POSTDECREMENT); }
+ { write_exp_elt_opcode (pstate, UNOP_POSTDECREMENT); }
;
exp : SIZEOF exp %prec UNARY
- { write_exp_elt_opcode (UNOP_SIZEOF); }
+ { write_exp_elt_opcode (pstate, UNOP_SIZEOF); }
;
exp : exp ARROW name
- { write_exp_elt_opcode (STRUCTOP_PTR);
- write_exp_string ($3);
- write_exp_elt_opcode (STRUCTOP_PTR); }
+ { write_exp_elt_opcode (pstate, STRUCTOP_PTR);
+ write_exp_string (pstate, $3);
+ write_exp_elt_opcode (pstate, STRUCTOP_PTR); }
;
exp : exp ARROW qualified_name
{ /* exp->type::name becomes exp->*(&type::name) */
/* Note: this doesn't work if name is a
static member! FIXME */
- write_exp_elt_opcode (UNOP_ADDR);
- write_exp_elt_opcode (STRUCTOP_MPTR); }
+ write_exp_elt_opcode (pstate, UNOP_ADDR);
+ write_exp_elt_opcode (pstate, STRUCTOP_MPTR); }
;
exp : exp ARROW '*' exp
- { write_exp_elt_opcode (STRUCTOP_MPTR); }
+ { write_exp_elt_opcode (pstate, STRUCTOP_MPTR); }
;
exp : exp '.' name
- { write_exp_elt_opcode (STRUCTOP_STRUCT);
- write_exp_string ($3);
- write_exp_elt_opcode (STRUCTOP_STRUCT); }
+ { write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
+ write_exp_string (pstate, $3);
+ write_exp_elt_opcode (pstate, STRUCTOP_STRUCT); }
;
@@ -315,16 +320,16 @@ exp : exp '.' qualified_name
{ /* exp.type::name becomes exp.*(&type::name) */
/* Note: this doesn't work if name is a
static member! FIXME */
- write_exp_elt_opcode (UNOP_ADDR);
- write_exp_elt_opcode (STRUCTOP_MEMBER); }
+ write_exp_elt_opcode (pstate, UNOP_ADDR);
+ write_exp_elt_opcode (pstate, STRUCTOP_MEMBER); }
;
exp : exp '.' '*' exp
- { write_exp_elt_opcode (STRUCTOP_MEMBER); }
+ { write_exp_elt_opcode (pstate, STRUCTOP_MEMBER); }
;
exp : exp '[' exp1 ']'
- { write_exp_elt_opcode (BINOP_SUBSCRIPT); }
+ { write_exp_elt_opcode (pstate, BINOP_SUBSCRIPT); }
;
/*
* The rules below parse ObjC message calls of the form:
@@ -335,50 +340,50 @@ exp : '[' TYPENAME
{
CORE_ADDR class;
- class = lookup_objc_class (parse_gdbarch,
+ class = lookup_objc_class (parse_gdbarch (pstate),
copy_name ($2.stoken));
if (class == 0)
error (_("%s is not an ObjC Class"),
copy_name ($2.stoken));
- write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (parse_type->builtin_int);
- write_exp_elt_longcst ((LONGEST) class);
- write_exp_elt_opcode (OP_LONG);
- start_msglist();
+ write_exp_elt_opcode (pstate, OP_LONG);
+ write_exp_elt_type (pstate, parse_type (pstate)->builtin_int);
+ write_exp_elt_longcst (pstate, (LONGEST) class);
+ write_exp_elt_opcode (pstate, OP_LONG);
+ start_msglist ();
}
msglist ']'
- { write_exp_elt_opcode (OP_OBJC_MSGCALL);
- end_msglist();
- write_exp_elt_opcode (OP_OBJC_MSGCALL);
+ { write_exp_elt_opcode (pstate, OP_OBJC_MSGCALL);
+ end_msglist (pstate);
+ write_exp_elt_opcode (pstate, OP_OBJC_MSGCALL);
}
;
exp : '[' CLASSNAME
{
- write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (parse_type->builtin_int);
- write_exp_elt_longcst ((LONGEST) $2.class);
- write_exp_elt_opcode (OP_LONG);
+ write_exp_elt_opcode (pstate, OP_LONG);
+ write_exp_elt_type (pstate, parse_type (pstate)->builtin_int);
+ write_exp_elt_longcst (pstate, (LONGEST) $2.class);
+ write_exp_elt_opcode (pstate, OP_LONG);
start_msglist();
}
msglist ']'
- { write_exp_elt_opcode (OP_OBJC_MSGCALL);
- end_msglist();
- write_exp_elt_opcode (OP_OBJC_MSGCALL);
+ { write_exp_elt_opcode (pstate, OP_OBJC_MSGCALL);
+ end_msglist (pstate);
+ write_exp_elt_opcode (pstate, OP_OBJC_MSGCALL);
}
;
exp : '[' exp
- { start_msglist(); }
+ { start_msglist (); }
msglist ']'
- { write_exp_elt_opcode (OP_OBJC_MSGCALL);
- end_msglist();
- write_exp_elt_opcode (OP_OBJC_MSGCALL);
+ { write_exp_elt_opcode (pstate, OP_OBJC_MSGCALL);
+ end_msglist (pstate);
+ write_exp_elt_opcode (pstate, OP_OBJC_MSGCALL);
}
;
msglist : name
- { add_msglist(&$1, 0); }
+ { add_msglist (&$1, 0); }
| msgarglist
;
@@ -399,9 +404,9 @@ exp : exp '('
being accumulated by an outer function call. */
{ start_arglist (); }
arglist ')' %prec ARROW
- { write_exp_elt_opcode (OP_FUNCALL);
- write_exp_elt_longcst ((LONGEST) end_arglist ());
- write_exp_elt_opcode (OP_FUNCALL); }
+ { write_exp_elt_opcode (pstate, OP_FUNCALL);
+ write_exp_elt_longcst (pstate, (LONGEST) end_arglist ());
+ write_exp_elt_opcode (pstate, OP_FUNCALL); }
;
lcurly : '{'
@@ -423,22 +428,22 @@ rcurly : '}'
{ $$ = end_arglist () - 1; }
;
exp : lcurly arglist rcurly %prec ARROW
- { write_exp_elt_opcode (OP_ARRAY);
- write_exp_elt_longcst ((LONGEST) 0);
- write_exp_elt_longcst ((LONGEST) $3);
- write_exp_elt_opcode (OP_ARRAY); }
+ { write_exp_elt_opcode (pstate, OP_ARRAY);
+ write_exp_elt_longcst (pstate, (LONGEST) 0);
+ write_exp_elt_longcst (pstate, (LONGEST) $3);
+ write_exp_elt_opcode (pstate, OP_ARRAY); }
;
exp : lcurly type rcurly exp %prec UNARY
- { write_exp_elt_opcode (UNOP_MEMVAL);
- write_exp_elt_type ($2);
- write_exp_elt_opcode (UNOP_MEMVAL); }
+ { write_exp_elt_opcode (pstate, UNOP_MEMVAL);
+ write_exp_elt_type (pstate, $2);
+ write_exp_elt_opcode (pstate, UNOP_MEMVAL); }
;
exp : '(' type ')' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_CAST);
- write_exp_elt_type ($2);
- write_exp_elt_opcode (UNOP_CAST); }
+ { write_exp_elt_opcode (pstate, UNOP_CAST);
+ write_exp_elt_type (pstate, $2);
+ write_exp_elt_opcode (pstate, UNOP_CAST); }
;
exp : '(' exp1 ')'
@@ -448,120 +453,120 @@ exp : '(' exp1 ')'
/* Binary operators in order of decreasing precedence. */
exp : exp '@' exp
- { write_exp_elt_opcode (BINOP_REPEAT); }
+ { write_exp_elt_opcode (pstate, BINOP_REPEAT); }
;
exp : exp '*' exp
- { write_exp_elt_opcode (BINOP_MUL); }
+ { write_exp_elt_opcode (pstate, BINOP_MUL); }
;
exp : exp '/' exp
- { write_exp_elt_opcode (BINOP_DIV); }
+ { write_exp_elt_opcode (pstate, BINOP_DIV); }
;
exp : exp '%' exp
- { write_exp_elt_opcode (BINOP_REM); }
+ { write_exp_elt_opcode (pstate, BINOP_REM); }
;
exp : exp '+' exp
- { write_exp_elt_opcode (BINOP_ADD); }
+ { write_exp_elt_opcode (pstate, BINOP_ADD); }
;
exp : exp '-' exp
- { write_exp_elt_opcode (BINOP_SUB); }
+ { write_exp_elt_opcode (pstate, BINOP_SUB); }
;
exp : exp LSH exp
- { write_exp_elt_opcode (BINOP_LSH); }
+ { write_exp_elt_opcode (pstate, BINOP_LSH); }
;
exp : exp RSH exp
- { write_exp_elt_opcode (BINOP_RSH); }
+ { write_exp_elt_opcode (pstate, BINOP_RSH); }
;
exp : exp EQUAL exp
- { write_exp_elt_opcode (BINOP_EQUAL); }
+ { write_exp_elt_opcode (pstate, BINOP_EQUAL); }
;
exp : exp NOTEQUAL exp
- { write_exp_elt_opcode (BINOP_NOTEQUAL); }
+ { write_exp_elt_opcode (pstate, BINOP_NOTEQUAL); }
;
exp : exp LEQ exp
- { write_exp_elt_opcode (BINOP_LEQ); }
+ { write_exp_elt_opcode (pstate, BINOP_LEQ); }
;
exp : exp GEQ exp
- { write_exp_elt_opcode (BINOP_GEQ); }
+ { write_exp_elt_opcode (pstate, BINOP_GEQ); }
;
exp : exp '<' exp
- { write_exp_elt_opcode (BINOP_LESS); }
+ { write_exp_elt_opcode (pstate, BINOP_LESS); }
;
exp : exp '>' exp
- { write_exp_elt_opcode (BINOP_GTR); }
+ { write_exp_elt_opcode (pstate, BINOP_GTR); }
;
exp : exp '&' exp
- { write_exp_elt_opcode (BINOP_BITWISE_AND); }
+ { write_exp_elt_opcode (pstate, BINOP_BITWISE_AND); }
;
exp : exp '^' exp
- { write_exp_elt_opcode (BINOP_BITWISE_XOR); }
+ { write_exp_elt_opcode (pstate, BINOP_BITWISE_XOR); }
;
exp : exp '|' exp
- { write_exp_elt_opcode (BINOP_BITWISE_IOR); }
+ { write_exp_elt_opcode (pstate, BINOP_BITWISE_IOR); }
;
exp : exp ANDAND exp
- { write_exp_elt_opcode (BINOP_LOGICAL_AND); }
+ { write_exp_elt_opcode (pstate, BINOP_LOGICAL_AND); }
;
exp : exp OROR exp
- { write_exp_elt_opcode (BINOP_LOGICAL_OR); }
+ { write_exp_elt_opcode (pstate, BINOP_LOGICAL_OR); }
;
exp : exp '?' exp ':' exp %prec '?'
- { write_exp_elt_opcode (TERNOP_COND); }
+ { write_exp_elt_opcode (pstate, TERNOP_COND); }
;
exp : exp '=' exp
- { write_exp_elt_opcode (BINOP_ASSIGN); }
+ { write_exp_elt_opcode (pstate, BINOP_ASSIGN); }
;
exp : exp ASSIGN_MODIFY exp
- { write_exp_elt_opcode (BINOP_ASSIGN_MODIFY);
- write_exp_elt_opcode ($2);
- write_exp_elt_opcode (BINOP_ASSIGN_MODIFY); }
+ { write_exp_elt_opcode (pstate, BINOP_ASSIGN_MODIFY);
+ write_exp_elt_opcode (pstate, $2);
+ write_exp_elt_opcode (pstate, BINOP_ASSIGN_MODIFY); }
;
exp : INT
- { write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type ($1.type);
- write_exp_elt_longcst ((LONGEST)($1.val));
- write_exp_elt_opcode (OP_LONG); }
+ { write_exp_elt_opcode (pstate, OP_LONG);
+ write_exp_elt_type (pstate, $1.type);
+ write_exp_elt_longcst (pstate, (LONGEST) ($1.val));
+ write_exp_elt_opcode (pstate, OP_LONG); }
;
exp : NAME_OR_INT
{ YYSTYPE val;
- parse_number ($1.stoken.ptr,
+ parse_number (pstate, $1.stoken.ptr,
$1.stoken.length, 0, &val);
- write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (val.typed_val_int.type);
- write_exp_elt_longcst ((LONGEST)
+ write_exp_elt_opcode (pstate, OP_LONG);
+ write_exp_elt_type (pstate, val.typed_val_int.type);
+ write_exp_elt_longcst (pstate, (LONGEST)
val.typed_val_int.val);
- write_exp_elt_opcode (OP_LONG);
+ write_exp_elt_opcode (pstate, OP_LONG);
}
;
exp : FLOAT
- { write_exp_elt_opcode (OP_DOUBLE);
- write_exp_elt_type ($1.type);
- write_exp_elt_dblcst ($1.dval);
- write_exp_elt_opcode (OP_DOUBLE); }
+ { write_exp_elt_opcode (pstate, OP_DOUBLE);
+ write_exp_elt_type (pstate, $1.type);
+ write_exp_elt_dblcst (pstate, $1.dval);
+ write_exp_elt_opcode (pstate, OP_DOUBLE); }
;
exp : variable
@@ -573,17 +578,17 @@ exp : VARIABLE
exp : SELECTOR
{
- write_exp_elt_opcode (OP_OBJC_SELECTOR);
- write_exp_string ($1);
- write_exp_elt_opcode (OP_OBJC_SELECTOR); }
+ write_exp_elt_opcode (pstate, OP_OBJC_SELECTOR);
+ write_exp_string (pstate, $1);
+ write_exp_elt_opcode (pstate, OP_OBJC_SELECTOR); }
;
exp : SIZEOF '(' type ')' %prec UNARY
- { write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (parse_type->builtin_int);
+ { write_exp_elt_opcode (pstate, OP_LONG);
+ write_exp_elt_type (pstate, parse_type (pstate)->builtin_int);
CHECK_TYPEDEF ($3);
- write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
- write_exp_elt_opcode (OP_LONG); }
+ write_exp_elt_longcst (pstate, (LONGEST) TYPE_LENGTH ($3));
+ write_exp_elt_opcode (pstate, OP_LONG); }
;
exp : STRING
@@ -596,27 +601,27 @@ exp : STRING
char *sp = $1.ptr; int count = $1.length;
while (count-- > 0)
{
- write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (parse_type->builtin_char);
- write_exp_elt_longcst ((LONGEST)(*sp++));
- write_exp_elt_opcode (OP_LONG);
+ write_exp_elt_opcode (pstate, OP_LONG);
+ write_exp_elt_type (pstate, parse_type (pstate)->builtin_char);
+ write_exp_elt_longcst (pstate, (LONGEST) (*sp++));
+ write_exp_elt_opcode (pstate, OP_LONG);
}
- write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (parse_type->builtin_char);
- write_exp_elt_longcst ((LONGEST)'\0');
- write_exp_elt_opcode (OP_LONG);
- write_exp_elt_opcode (OP_ARRAY);
- write_exp_elt_longcst ((LONGEST) 0);
- write_exp_elt_longcst ((LONGEST) ($1.length));
- write_exp_elt_opcode (OP_ARRAY); }
+ write_exp_elt_opcode (pstate, OP_LONG);
+ write_exp_elt_type (pstate, parse_type (pstate)->builtin_char);
+ write_exp_elt_longcst (pstate, (LONGEST)'\0');
+ write_exp_elt_opcode (pstate, OP_LONG);
+ write_exp_elt_opcode (pstate, OP_ARRAY);
+ write_exp_elt_longcst (pstate, (LONGEST) 0);
+ write_exp_elt_longcst (pstate, (LONGEST) ($1.length));
+ write_exp_elt_opcode (pstate, OP_ARRAY); }
;
exp : NSSTRING /* ObjC NextStep NSString constant
* of the form '@' '"' string '"'.
*/
- { write_exp_elt_opcode (OP_OBJC_NSSTRING);
- write_exp_string ($1);
- write_exp_elt_opcode (OP_OBJC_NSSTRING); }
+ { write_exp_elt_opcode (pstate, OP_OBJC_NSSTRING);
+ write_exp_string (pstate, $1);
+ write_exp_elt_opcode (pstate, OP_OBJC_NSSTRING); }
;
block : BLOCKNAME
@@ -662,11 +667,11 @@ variable: block COLONCOLON name
innermost_block = block_found;
}
- write_exp_elt_opcode (OP_VAR_VALUE);
+ write_exp_elt_opcode (pstate, 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); }
+ write_exp_elt_block (pstate, block_found);
+ write_exp_elt_sym (pstate, sym);
+ write_exp_elt_opcode (pstate, OP_VAR_VALUE); }
;
qualified_name: typebase COLONCOLON name
@@ -677,10 +682,10 @@ qualified_name: typebase COLONCOLON name
error (_("`%s' is not defined as an aggregate type."),
TYPE_NAME (type));
- write_exp_elt_opcode (OP_SCOPE);
- write_exp_elt_type (type);
- write_exp_string ($3);
- write_exp_elt_opcode (OP_SCOPE);
+ write_exp_elt_opcode (pstate, OP_SCOPE);
+ write_exp_elt_type (pstate, type);
+ write_exp_string (pstate, $3);
+ write_exp_elt_opcode (pstate, OP_SCOPE);
}
| typebase COLONCOLON '~' name
{
@@ -700,10 +705,10 @@ qualified_name: typebase COLONCOLON name
tmp_token.ptr[0] = '~';
memcpy (tmp_token.ptr+1, $4.ptr, $4.length);
tmp_token.ptr[tmp_token.length] = 0;
- write_exp_elt_opcode (OP_SCOPE);
- write_exp_elt_type (type);
- write_exp_string (tmp_token);
- write_exp_elt_opcode (OP_SCOPE);
+ write_exp_elt_opcode (pstate, OP_SCOPE);
+ write_exp_elt_type (pstate, type);
+ write_exp_string (pstate, tmp_token);
+ write_exp_elt_opcode (pstate, OP_SCOPE);
}
;
@@ -719,16 +724,16 @@ variable: qualified_name
VAR_DOMAIN, (int *) NULL);
if (sym)
{
- write_exp_elt_opcode (OP_VAR_VALUE);
- write_exp_elt_block (NULL);
- write_exp_elt_sym (sym);
- write_exp_elt_opcode (OP_VAR_VALUE);
+ write_exp_elt_opcode (pstate, OP_VAR_VALUE);
+ write_exp_elt_block (pstate, NULL);
+ write_exp_elt_sym (pstate, sym);
+ write_exp_elt_opcode (pstate, OP_VAR_VALUE);
break;
}
msymbol = lookup_minimal_symbol (name, NULL, NULL);
if (msymbol != NULL)
- write_exp_msymbol (msymbol);
+ write_exp_msymbol (pstate, msymbol);
else if (!have_full_symbols ()
&& !have_partial_symbols ())
error (_("No symbol table is loaded. "
@@ -752,13 +757,13 @@ variable: name_not_typename
innermost_block = block_found;
}
- write_exp_elt_opcode (OP_VAR_VALUE);
+ write_exp_elt_opcode (pstate, 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);
+ write_exp_elt_block (pstate, NULL);
+ write_exp_elt_sym (pstate, sym);
+ write_exp_elt_opcode (pstate, OP_VAR_VALUE);
}
else if ($1.is_a_field_of_this)
{
@@ -768,11 +773,11 @@ variable: name_not_typename
if (innermost_block == 0 ||
contained_in (block_found, innermost_block))
innermost_block = block_found;
- write_exp_elt_opcode (OP_THIS);
- write_exp_elt_opcode (OP_THIS);
- write_exp_elt_opcode (STRUCTOP_PTR);
- write_exp_string ($1.stoken);
- write_exp_elt_opcode (STRUCTOP_PTR);
+ write_exp_elt_opcode (pstate, OP_THIS);
+ write_exp_elt_opcode (pstate, OP_THIS);
+ write_exp_elt_opcode (pstate, STRUCTOP_PTR);
+ write_exp_string (pstate, $1.stoken);
+ write_exp_elt_opcode (pstate, STRUCTOP_PTR);
}
else
{
@@ -782,7 +787,7 @@ variable: name_not_typename
msymbol =
lookup_minimal_symbol (arg, NULL, NULL);
if (msymbol != NULL)
- write_exp_msymbol (msymbol);
+ write_exp_msymbol (pstate, msymbol);
else if (!have_full_symbols () &&
!have_partial_symbols ())
error (_("No symbol table is loaded. "
@@ -877,31 +882,31 @@ typebase /* Implements (approximately): (type-qualifier)* type-specifier. */
$$ = $1.type;
}
| INT_KEYWORD
- { $$ = parse_type->builtin_int; }
+ { $$ = parse_type (pstate)->builtin_int; }
| LONG
- { $$ = parse_type->builtin_long; }
+ { $$ = parse_type (pstate)->builtin_long; }
| SHORT
- { $$ = parse_type->builtin_short; }
+ { $$ = parse_type (pstate)->builtin_short; }
| LONG INT_KEYWORD
- { $$ = parse_type->builtin_long; }
+ { $$ = parse_type (pstate)->builtin_long; }
| UNSIGNED LONG INT_KEYWORD
- { $$ = parse_type->builtin_unsigned_long; }
+ { $$ = parse_type (pstate)->builtin_unsigned_long; }
| LONG LONG
- { $$ = parse_type->builtin_long_long; }
+ { $$ = parse_type (pstate)->builtin_long_long; }
| LONG LONG INT_KEYWORD
- { $$ = parse_type->builtin_long_long; }
+ { $$ = parse_type (pstate)->builtin_long_long; }
| UNSIGNED LONG LONG
- { $$ = parse_type->builtin_unsigned_long_long; }
+ { $$ = parse_type (pstate)->builtin_unsigned_long_long; }
| UNSIGNED LONG LONG INT_KEYWORD
- { $$ = parse_type->builtin_unsigned_long_long; }
+ { $$ = parse_type (pstate)->builtin_unsigned_long_long; }
| SHORT INT_KEYWORD
- { $$ = parse_type->builtin_short; }
+ { $$ = parse_type (pstate)->builtin_short; }
| UNSIGNED SHORT INT_KEYWORD
- { $$ = parse_type->builtin_unsigned_short; }
+ { $$ = parse_type (pstate)->builtin_unsigned_short; }
| DOUBLE_KEYWORD
- { $$ = parse_type->builtin_double; }
+ { $$ = parse_type (pstate)->builtin_double; }
| LONG DOUBLE_KEYWORD
- { $$ = parse_type->builtin_long_double; }
+ { $$ = parse_type (pstate)->builtin_long_double; }
| STRUCT name
{ $$ = lookup_struct (copy_name ($2),
expression_context_block); }
@@ -915,17 +920,17 @@ typebase /* Implements (approximately): (type-qualifier)* type-specifier. */
{ $$ = lookup_enum (copy_name ($2),
expression_context_block); }
| UNSIGNED typename
- { $$ = lookup_unsigned_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_unsigned_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
TYPE_NAME($2.type)); }
| UNSIGNED
- { $$ = parse_type->builtin_unsigned_int; }
+ { $$ = parse_type (pstate)->builtin_unsigned_int; }
| SIGNED_KEYWORD typename
- { $$ = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_signed_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
TYPE_NAME($2.type)); }
| SIGNED_KEYWORD
- { $$ = parse_type->builtin_int; }
+ { $$ = parse_type (pstate)->builtin_int; }
| TEMPLATE name '<' type '>'
{ $$ = lookup_template_type(copy_name($2), $4,
expression_context_block);
@@ -942,19 +947,19 @@ typename: TYPENAME
{
$$.stoken.ptr = "int";
$$.stoken.length = 3;
- $$.type = parse_type->builtin_int;
+ $$.type = parse_type (pstate)->builtin_int;
}
| LONG
{
$$.stoken.ptr = "long";
$$.stoken.length = 4;
- $$.type = parse_type->builtin_long;
+ $$.type = parse_type (pstate)->builtin_long;
}
| SHORT
{
$$.stoken.ptr = "short";
$$.stoken.length = 5;
- $$.type = parse_type->builtin_short;
+ $$.type = parse_type (pstate)->builtin_short;
}
;
@@ -998,7 +1003,8 @@ name_not_typename : NAME
/*** Needs some error checking for the float case. ***/
static int
-parse_number (char *p, int len, int parsed_float, YYSTYPE *putithere)
+parse_number (struct parser_state *par_state, char *p, int len,
+ int parsed_float, YYSTYPE *putithere)
{
/* FIXME: Shouldn't these be unsigned? We don't deal with negative
values here, and we do kind of silly things like cast to
@@ -1024,7 +1030,7 @@ parse_number (char *p, int len, int parsed_float, YYSTYPE *putithere)
if (parsed_float)
{
- if (! parse_c_float (parse_gdbarch, p, len,
+ if (! parse_c_float (parse_gdbarch (par_state), p, len,
&putithere->typed_val_float.dval,
&putithere->typed_val_float.type))
return ERROR;
@@ -1130,10 +1136,10 @@ parse_number (char *p, int len, int parsed_float, YYSTYPE *putithere)
un = (unsigned LONGEST)n >> 2;
if (long_p == 0
- && (un >> (gdbarch_int_bit (parse_gdbarch) - 2)) == 0)
+ && (un >> (gdbarch_int_bit (parse_gdbarch (par_state)) - 2)) == 0)
{
high_bit
- = ((unsigned LONGEST)1) << (gdbarch_int_bit (parse_gdbarch) - 1);
+ = ((unsigned LONGEST)1) << (gdbarch_int_bit (parse_gdbarch (par_state)) - 1);
/* A large decimal (not hex or octal) constant (between INT_MAX
and UINT_MAX) is a long or unsigned long, according to ANSI,
@@ -1141,29 +1147,29 @@ parse_number (char *p, int len, int parsed_float, YYSTYPE *putithere)
int. This probably should be fixed. GCC gives a warning on
such constants. */
- unsigned_type = parse_type->builtin_unsigned_int;
- signed_type = parse_type->builtin_int;
+ unsigned_type = parse_type (par_state)->builtin_unsigned_int;
+ signed_type = parse_type (par_state)->builtin_int;
}
else if (long_p <= 1
- && (un >> (gdbarch_long_bit (parse_gdbarch) - 2)) == 0)
+ && (un >> (gdbarch_long_bit (parse_gdbarch (par_state)) - 2)) == 0)
{
high_bit
- = ((unsigned LONGEST)1) << (gdbarch_long_bit (parse_gdbarch) - 1);
- unsigned_type = parse_type->builtin_unsigned_long;
- signed_type = parse_type->builtin_long;
+ = ((unsigned LONGEST)1) << (gdbarch_long_bit (parse_gdbarch (par_state)) - 1);
+ unsigned_type = parse_type (par_state)->builtin_unsigned_long;
+ signed_type = parse_type (par_state)->builtin_long;
}
else
{
high_bit = (((unsigned LONGEST)1)
- << (gdbarch_long_long_bit (parse_gdbarch) - 32 - 1)
+ << (gdbarch_long_long_bit (parse_gdbarch (par_state)) - 32 - 1)
<< 16
<< 16);
if (high_bit == 0)
/* A long long does not fit in a LONGEST. */
high_bit =
(unsigned LONGEST)1 << (sizeof (LONGEST) * HOST_CHAR_BIT - 1);
- unsigned_type = parse_type->builtin_unsigned_long_long;
- signed_type = parse_type->builtin_long_long;
+ unsigned_type = parse_type (par_state)->builtin_unsigned_long_long;
+ signed_type = parse_type (par_state)->builtin_long_long;
}
putithere->typed_val_int.val = n;
@@ -1274,12 +1280,12 @@ yylex (void)
lexptr++;
c = *lexptr++;
if (c == '\\')
- c = parse_escape (parse_gdbarch, &lexptr);
+ c = parse_escape (parse_gdbarch (pstate), &lexptr);
else if (c == '\'')
error (_("Empty character constant."));
yylval.typed_val_int.val = c;
- yylval.typed_val_int.type = parse_type->builtin_char;
+ yylval.typed_val_int.type = parse_type (pstate)->builtin_char;
c = *lexptr++;
if (c != '\'')
@@ -1397,7 +1403,7 @@ yylex (void)
else break;
}
if (toktype != ERROR)
- toktype = parse_number (tokstart, p - tokstart,
+ toktype = parse_number (pstate, tokstart, p - tokstart,
got_dot | got_e, &yylval);
if (toktype == ERROR)
{
@@ -1502,7 +1508,7 @@ yylex (void)
break;
case '\\':
tokptr++;
- c = parse_escape (parse_gdbarch, &tokptr);
+ c = parse_escape (parse_gdbarch (pstate), &tokptr);
if (c == -1)
{
continue;
@@ -1563,7 +1569,7 @@ yylex (void)
case 8:
if (strncmp (tokstart, "unsigned", 8) == 0)
return UNSIGNED;
- if (parse_language->la_language == language_cplus
+ if (parse_language (pstate)->la_language == language_cplus
&& strncmp (tokstart, "template", 8) == 0)
return TEMPLATE;
if (strncmp (tokstart, "volatile", 8) == 0)
@@ -1580,7 +1586,7 @@ yylex (void)
return DOUBLE_KEYWORD;
break;
case 5:
- if ((parse_language->la_language == language_cplus)
+ if ((parse_language (pstate)->la_language == language_cplus)
&& strncmp (tokstart, "class", 5) == 0)
return CLASS;
if (strncmp (tokstart, "union", 5) == 0)
@@ -1609,7 +1615,7 @@ yylex (void)
if (*tokstart == '$')
{
- write_dollar_variable (yylval.sval);
+ write_dollar_variable (pstate, yylval.sval);
return VARIABLE;
}
@@ -1624,8 +1630,8 @@ yylex (void)
int is_a_field_of_this = 0, *need_this;
int hextype;
- if (parse_language->la_language == language_cplus ||
- parse_language->la_language == language_objc)
+ if (parse_language (pstate)->la_language == language_cplus ||
+ parse_language (pstate)->la_language == language_objc)
need_this = &is_a_field_of_this;
else
need_this = (int *) NULL;
@@ -1737,15 +1743,15 @@ yylex (void)
return TYPENAME;
}
yylval.tsym.type
- = language_lookup_primitive_type_by_name (parse_language,
- parse_gdbarch, tmp);
+ = language_lookup_primitive_type_by_name (parse_language (pstate),
+ parse_gdbarch (pstate), tmp);
if (yylval.tsym.type != NULL)
return TYPENAME;
/* See if it's an ObjC classname. */
if (!sym)
{
- CORE_ADDR Class = lookup_objc_class (parse_gdbarch, tmp);
+ CORE_ADDR Class = lookup_objc_class (parse_gdbarch (pstate), tmp);
if (Class)
{
yylval.class.class = Class;
@@ -1765,7 +1771,7 @@ yylex (void)
(tokstart[0] >= 'A' && tokstart[0] < 'A' + input_radix - 10)))
{
YYSTYPE newlval; /* Its value is ignored. */
- hextype = parse_number (tokstart, namelen, 0, &newlval);
+ hextype = parse_number (pstate, tokstart, namelen, 0, &newlval);
if (hextype == INT)
{
yylval.ssym.sym = sym;
@@ -1781,6 +1787,16 @@ yylex (void)
}
}
+int
+objc_parse (struct parser_state *par_state)
+{
+ /* Setting up the parser state. */
+ gdb_assert (par_state != NULL);
+ pstate = par_state;
+
+ return _objc_parse ();
+}
+
void
yyerror (char *msg)
{
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 15bf792..52786cc 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -615,7 +615,7 @@ add_msglist(struct stoken *str, int addcolon)
}
int
-end_msglist(void)
+end_msglist (struct parser_state *ps)
{
int val = msglist_len;
struct selname *sel = selname_chain;
@@ -625,12 +625,12 @@ end_msglist(void)
selname_chain = sel->next;
msglist_len = sel->msglist_len;
msglist_sel = sel->msglist_sel;
- selid = lookup_child_selector (parse_gdbarch, p);
+ selid = lookup_child_selector (parse_gdbarch (ps), p);
if (!selid)
error (_("Can't find selector \"%s\""), p);
- write_exp_elt_longcst (selid);
+ write_exp_elt_longcst (ps, selid);
xfree(p);
- write_exp_elt_longcst (val); /* Number of args */
+ write_exp_elt_longcst (ps, val); /* Number of args */
xfree(sel);
return val;
diff --git a/gdb/objc-lang.h b/gdb/objc-lang.h
index 593ef02..ba656f8 100644
--- a/gdb/objc-lang.h
+++ b/gdb/objc-lang.h
@@ -26,10 +26,11 @@ struct stoken;
struct value;
struct block;
+struct parser_state;
-extern int objc_parse (void); /* Defined in c-exp.y */
+extern int objc_parse (struct parser_state *); /* Defined in objc-exp.y */
-extern void objc_error (char *); /* Defined in c-exp.y */
+extern void objc_error (char *); /* Defined in objc-exp.y */
extern CORE_ADDR lookup_objc_class (struct gdbarch *gdbarch,
char *classname);
@@ -48,7 +49,7 @@ extern struct value *value_nsstring (struct gdbarch *gdbarch,
/* for parsing Objective C */
extern void start_msglist (void);
extern void add_msglist (struct stoken *str, int addcolon);
-extern int end_msglist (void);
+extern int end_msglist (struct parser_state *);
struct symbol *lookup_struct_typedef (char *name, struct block *block,
int noerr);
--
1.7.7.6