This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC 7/8] Objective-C language


Hello,

This is the patch for the Objective-C language.

Thanks,

Sergio.

diff --git a/gdb/objc-exp.y b/gdb/objc-exp.y
index b43ba66..8ed73dc 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
@@ -107,14 +107,17 @@
 #define	YYDEBUG	0		/* Default to no yydebug support.  */
 #endif
 
-int yyparse (void);
+int yyparse (struct parser_state *);
 
-static int yylex (void);
+static int yylex (struct parser_state *);
 
-void yyerror (char *);
+void yyerror (struct parser_state *, char *);
 
 %}
 
+%parse-param {struct parser_state *ps}
+%lex-param {struct parser_state *ps}
+
 /* Although the yacc "value" of an expression is not used,
    since the result is stored in the structure being created,
    other node types do have values.  */
@@ -147,7 +150,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
@@ -229,79 +232,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 (ps, OP_TYPE);
+			  write_exp_elt_type (ps, $1);
+			  write_exp_elt_opcode (ps, OP_TYPE);}
 	;
 
 /* Expressions, including the comma operator.  */
 exp1	:	exp
 	|	exp1 ',' exp
-			{ write_exp_elt_opcode (BINOP_COMMA); }
+			{ write_exp_elt_opcode (ps, BINOP_COMMA); }
 	;
 
 /* Expressions, not including the comma operator.  */
 exp	:	'*' exp    %prec UNARY
-			{ write_exp_elt_opcode (UNOP_IND); }
+			{ write_exp_elt_opcode (ps, UNOP_IND); }
 	;
 
 exp	:	'&' exp    %prec UNARY
-			{ write_exp_elt_opcode (UNOP_ADDR); }
+			{ write_exp_elt_opcode (ps, UNOP_ADDR); }
 	;
 
 exp	:	'-' exp    %prec UNARY
-			{ write_exp_elt_opcode (UNOP_NEG); }
+			{ write_exp_elt_opcode (ps, UNOP_NEG); }
 	;
 
 exp	:	'!' exp    %prec UNARY
-			{ write_exp_elt_opcode (UNOP_LOGICAL_NOT); }
+			{ write_exp_elt_opcode (ps, UNOP_LOGICAL_NOT); }
 	;
 
 exp	:	'~' exp    %prec UNARY
-			{ write_exp_elt_opcode (UNOP_COMPLEMENT); }
+			{ write_exp_elt_opcode (ps, UNOP_COMPLEMENT); }
 	;
 
 exp	:	INCREMENT exp    %prec UNARY
-			{ write_exp_elt_opcode (UNOP_PREINCREMENT); }
+			{ write_exp_elt_opcode (ps, UNOP_PREINCREMENT); }
 	;
 
 exp	:	DECREMENT exp    %prec UNARY
-			{ write_exp_elt_opcode (UNOP_PREDECREMENT); }
+			{ write_exp_elt_opcode (ps, UNOP_PREDECREMENT); }
 	;
 
 exp	:	exp INCREMENT    %prec UNARY
-			{ write_exp_elt_opcode (UNOP_POSTINCREMENT); }
+			{ write_exp_elt_opcode (ps, UNOP_POSTINCREMENT); }
 	;
 
 exp	:	exp DECREMENT    %prec UNARY
-			{ write_exp_elt_opcode (UNOP_POSTDECREMENT); }
+			{ write_exp_elt_opcode (ps, UNOP_POSTDECREMENT); }
 	;
 
 exp	:	SIZEOF exp       %prec UNARY
-			{ write_exp_elt_opcode (UNOP_SIZEOF); }
+			{ write_exp_elt_opcode (ps, 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 (ps, STRUCTOP_PTR);
+			  write_exp_string (ps, $3);
+			  write_exp_elt_opcode (ps, 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 (ps, UNOP_ADDR);
+			  write_exp_elt_opcode (ps, STRUCTOP_MPTR); }
 	;
 exp	:	exp ARROW '*' exp
-			{ write_exp_elt_opcode (STRUCTOP_MPTR); }
+			{ write_exp_elt_opcode (ps, 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 (ps, STRUCTOP_STRUCT);
+			  write_exp_string (ps, $3);
+			  write_exp_elt_opcode (ps, STRUCTOP_STRUCT); }
 	;
 
 
@@ -309,16 +312,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 (ps, UNOP_ADDR);
+			  write_exp_elt_opcode (ps, STRUCTOP_MEMBER); }
 	;
 
 exp	:	exp '.' '*' exp
-			{ write_exp_elt_opcode (STRUCTOP_MEMBER); }
+			{ write_exp_elt_opcode (ps, STRUCTOP_MEMBER); }
 	;
 
 exp	:	exp '[' exp1 ']'
-			{ write_exp_elt_opcode (BINOP_SUBSCRIPT); }
+			{ write_exp_elt_opcode (ps, BINOP_SUBSCRIPT); }
 	;
 /*
  * The rules below parse ObjC message calls of the form:
@@ -329,50 +332,50 @@ exp	: 	'[' TYPENAME
 			{
 			  CORE_ADDR class;
 
-			  class = lookup_objc_class (parse_gdbarch,
+			  class = lookup_objc_class (parse_gdbarch (ps),
 						     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 (ps, OP_LONG);
+			  write_exp_elt_type (ps, parse_type (ps)->builtin_int);
+			  write_exp_elt_longcst (ps, (LONGEST) class);
+			  write_exp_elt_opcode (ps, 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 (ps, OP_OBJC_MSGCALL);
+			  end_msglist (ps);
+			  write_exp_elt_opcode (ps, 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 (ps, OP_LONG);
+			  write_exp_elt_type (ps, parse_type (ps)->builtin_int);
+			  write_exp_elt_longcst (ps, (LONGEST) $2.class);
+			  write_exp_elt_opcode (ps, 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 (ps, OP_OBJC_MSGCALL);
+			  end_msglist (ps);
+			  write_exp_elt_opcode (ps, 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 (ps, OP_OBJC_MSGCALL);
+			  end_msglist (ps);
+			  write_exp_elt_opcode (ps, OP_OBJC_MSGCALL); 
 			}
 	;
 
 msglist :	name
-			{ add_msglist(&$1, 0); }
+			{ add_msglist (&$1, 0); }
 	|	msgarglist
 	;
 
@@ -393,9 +396,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 (ps, OP_FUNCALL);
+			  write_exp_elt_longcst (ps, (LONGEST) end_arglist ());
+			  write_exp_elt_opcode (ps, OP_FUNCALL); }
 	;
 
 lcurly	:	'{'
@@ -417,22 +420,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 (ps, OP_ARRAY);
+			  write_exp_elt_longcst (ps, (LONGEST) 0);
+			  write_exp_elt_longcst (ps, (LONGEST) $3);
+			  write_exp_elt_opcode (ps, 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 (ps, UNOP_MEMVAL);
+			  write_exp_elt_type (ps, $2);
+			  write_exp_elt_opcode (ps, 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 (ps, UNOP_CAST);
+			  write_exp_elt_type (ps, $2);
+			  write_exp_elt_opcode (ps, UNOP_CAST); }
 	;
 
 exp	:	'(' exp1 ')'
@@ -442,120 +445,120 @@ exp	:	'(' exp1 ')'
 /* Binary operators in order of decreasing precedence.  */
 
 exp	:	exp '@' exp
-			{ write_exp_elt_opcode (BINOP_REPEAT); }
+			{ write_exp_elt_opcode (ps, BINOP_REPEAT); }
 	;
 
 exp	:	exp '*' exp
-			{ write_exp_elt_opcode (BINOP_MUL); }
+			{ write_exp_elt_opcode (ps, BINOP_MUL); }
 	;
 
 exp	:	exp '/' exp
-			{ write_exp_elt_opcode (BINOP_DIV); }
+			{ write_exp_elt_opcode (ps, BINOP_DIV); }
 	;
 
 exp	:	exp '%' exp
-			{ write_exp_elt_opcode (BINOP_REM); }
+			{ write_exp_elt_opcode (ps, BINOP_REM); }
 	;
 
 exp	:	exp '+' exp
-			{ write_exp_elt_opcode (BINOP_ADD); }
+			{ write_exp_elt_opcode (ps, BINOP_ADD); }
 	;
 
 exp	:	exp '-' exp
-			{ write_exp_elt_opcode (BINOP_SUB); }
+			{ write_exp_elt_opcode (ps, BINOP_SUB); }
 	;
 
 exp	:	exp LSH exp
-			{ write_exp_elt_opcode (BINOP_LSH); }
+			{ write_exp_elt_opcode (ps, BINOP_LSH); }
 	;
 
 exp	:	exp RSH exp
-			{ write_exp_elt_opcode (BINOP_RSH); }
+			{ write_exp_elt_opcode (ps, BINOP_RSH); }
 	;
 
 exp	:	exp EQUAL exp
-			{ write_exp_elt_opcode (BINOP_EQUAL); }
+			{ write_exp_elt_opcode (ps, BINOP_EQUAL); }
 	;
 
 exp	:	exp NOTEQUAL exp
-			{ write_exp_elt_opcode (BINOP_NOTEQUAL); }
+			{ write_exp_elt_opcode (ps, BINOP_NOTEQUAL); }
 	;
 
 exp	:	exp LEQ exp
-			{ write_exp_elt_opcode (BINOP_LEQ); }
+			{ write_exp_elt_opcode (ps, BINOP_LEQ); }
 	;
 
 exp	:	exp GEQ exp
-			{ write_exp_elt_opcode (BINOP_GEQ); }
+			{ write_exp_elt_opcode (ps, BINOP_GEQ); }
 	;
 
 exp	:	exp '<' exp
-			{ write_exp_elt_opcode (BINOP_LESS); }
+			{ write_exp_elt_opcode (ps, BINOP_LESS); }
 	;
 
 exp	:	exp '>' exp
-			{ write_exp_elt_opcode (BINOP_GTR); }
+			{ write_exp_elt_opcode (ps, BINOP_GTR); }
 	;
 
 exp	:	exp '&' exp
-			{ write_exp_elt_opcode (BINOP_BITWISE_AND); }
+			{ write_exp_elt_opcode (ps, BINOP_BITWISE_AND); }
 	;
 
 exp	:	exp '^' exp
-			{ write_exp_elt_opcode (BINOP_BITWISE_XOR); }
+			{ write_exp_elt_opcode (ps, BINOP_BITWISE_XOR); }
 	;
 
 exp	:	exp '|' exp
-			{ write_exp_elt_opcode (BINOP_BITWISE_IOR); }
+			{ write_exp_elt_opcode (ps, BINOP_BITWISE_IOR); }
 	;
 
 exp	:	exp ANDAND exp
-			{ write_exp_elt_opcode (BINOP_LOGICAL_AND); }
+			{ write_exp_elt_opcode (ps, BINOP_LOGICAL_AND); }
 	;
 
 exp	:	exp OROR exp
-			{ write_exp_elt_opcode (BINOP_LOGICAL_OR); }
+			{ write_exp_elt_opcode (ps, BINOP_LOGICAL_OR); }
 	;
 
 exp	:	exp '?' exp ':' exp	%prec '?'
-			{ write_exp_elt_opcode (TERNOP_COND); }
+			{ write_exp_elt_opcode (ps, TERNOP_COND); }
 	;
 			  
 exp	:	exp '=' exp
-			{ write_exp_elt_opcode (BINOP_ASSIGN); }
+			{ write_exp_elt_opcode (ps, 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 (ps, BINOP_ASSIGN_MODIFY);
+			  write_exp_elt_opcode (ps, $2);
+			  write_exp_elt_opcode (ps, 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 (ps, OP_LONG);
+			  write_exp_elt_type (ps, $1.type);
+			  write_exp_elt_longcst (ps, (LONGEST) ($1.val));
+			  write_exp_elt_opcode (ps, OP_LONG); }
 	;
 
 exp	:	NAME_OR_INT
 			{ YYSTYPE val;
-			  parse_number ($1.stoken.ptr,
+			  parse_number (ps, $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 (ps, OP_LONG);
+			  write_exp_elt_type (ps, val.typed_val_int.type);
+			  write_exp_elt_longcst (ps, (LONGEST) 
 						 val.typed_val_int.val);
-			  write_exp_elt_opcode (OP_LONG);
+			  write_exp_elt_opcode (ps, 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 (ps, OP_DOUBLE);
+			  write_exp_elt_type (ps, $1.type);
+			  write_exp_elt_dblcst (ps, $1.dval);
+			  write_exp_elt_opcode (ps, OP_DOUBLE); }
 	;
 
 exp	:	variable
@@ -567,17 +570,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 (ps, OP_OBJC_SELECTOR);
+			  write_exp_string (ps, $1);
+			  write_exp_elt_opcode (ps, 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 (ps, OP_LONG);
+			  write_exp_elt_type (ps, parse_type (ps)->builtin_int);
 			  CHECK_TYPEDEF ($3);
-			  write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
-			  write_exp_elt_opcode (OP_LONG); }
+			  write_exp_elt_longcst (ps, (LONGEST) TYPE_LENGTH ($3));
+			  write_exp_elt_opcode (ps, OP_LONG); }
 	;
 
 exp	:	STRING
@@ -590,27 +593,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 (ps, OP_LONG);
+			      write_exp_elt_type (ps, parse_type (ps)->builtin_char);
+			      write_exp_elt_longcst (ps, (LONGEST) (*sp++));
+			      write_exp_elt_opcode (ps, 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 (ps, OP_LONG);
+			  write_exp_elt_type (ps, parse_type (ps)->builtin_char);
+			  write_exp_elt_longcst (ps, (LONGEST)'\0');
+			  write_exp_elt_opcode (ps, OP_LONG);
+			  write_exp_elt_opcode (ps, OP_ARRAY);
+			  write_exp_elt_longcst (ps, (LONGEST) 0);
+			  write_exp_elt_longcst (ps, (LONGEST) ($1.length));
+			  write_exp_elt_opcode (ps, 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 (ps, OP_OBJC_NSSTRING);
+			  write_exp_string (ps, $1);
+			  write_exp_elt_opcode (ps, OP_OBJC_NSSTRING); }
 	;
 
 block	:	BLOCKNAME
@@ -656,11 +659,11 @@ variable:	block COLONCOLON name
 				innermost_block = block_found;
 			    }
 
-			  write_exp_elt_opcode (OP_VAR_VALUE);
+			  write_exp_elt_opcode (ps, 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 (ps, block_found);
+			  write_exp_elt_sym (ps, sym);
+			  write_exp_elt_opcode (ps, OP_VAR_VALUE); }
 	;
 
 qualified_name:	typebase COLONCOLON name
@@ -671,10 +674,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 (ps, OP_SCOPE);
+			  write_exp_elt_type (ps, type);
+			  write_exp_string (ps, $3);
+			  write_exp_elt_opcode (ps, OP_SCOPE);
 			}
 	|	typebase COLONCOLON '~' name
 			{
@@ -694,10 +697,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 (ps, OP_SCOPE);
+			  write_exp_elt_type (ps, type);
+			  write_exp_string (ps, tmp_token);
+			  write_exp_elt_opcode (ps, OP_SCOPE);
 			}
 	;
 
@@ -713,16 +716,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 (ps, OP_VAR_VALUE);
+			      write_exp_elt_block (ps, NULL);
+			      write_exp_elt_sym (ps, sym);
+			      write_exp_elt_opcode (ps, OP_VAR_VALUE);
 			      break;
 			    }
 
 			  msymbol = lookup_minimal_symbol (name, NULL, NULL);
 			  if (msymbol != NULL)
-			    write_exp_msymbol (msymbol);
+			    write_exp_msymbol (ps, msymbol);
 			  else if (!have_full_symbols ()
 				   && !have_partial_symbols ())
 			    error (_("No symbol table is loaded.  "
@@ -746,13 +749,13 @@ variable:	name_not_typename
 				    innermost_block = block_found;
 				}
 
-			      write_exp_elt_opcode (OP_VAR_VALUE);
+			      write_exp_elt_opcode (ps, 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 (ps, NULL);
+			      write_exp_elt_sym (ps, sym);
+			      write_exp_elt_opcode (ps, OP_VAR_VALUE);
 			    }
 			  else if ($1.is_a_field_of_this)
 			    {
@@ -762,11 +765,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 (ps, OP_THIS);
+			      write_exp_elt_opcode (ps, OP_THIS);
+			      write_exp_elt_opcode (ps, STRUCTOP_PTR);
+			      write_exp_string (ps, $1.stoken);
+			      write_exp_elt_opcode (ps, STRUCTOP_PTR);
 			    }
 			  else
 			    {
@@ -776,7 +779,7 @@ variable:	name_not_typename
 			      msymbol =
 				lookup_minimal_symbol (arg, NULL, NULL);
 			      if (msymbol != NULL)
-				write_exp_msymbol (msymbol);
+				write_exp_msymbol (ps, msymbol);
 			      else if (!have_full_symbols () && 
 				       !have_partial_symbols ())
 				error (_("No symbol table is loaded.  "
@@ -871,31 +874,31 @@ typebase  /* Implements (approximately): (type-qualifier)* type-specifier.  */
 			    $$ = $1.type;
 			}
 	|	INT_KEYWORD
-			{ $$ = parse_type->builtin_int; }
+			{ $$ = parse_type (ps)->builtin_int; }
 	|	LONG
-			{ $$ = parse_type->builtin_long; }
+			{ $$ = parse_type (ps)->builtin_long; }
 	|	SHORT
-			{ $$ = parse_type->builtin_short; }
+			{ $$ = parse_type (ps)->builtin_short; }
 	|	LONG INT_KEYWORD
-			{ $$ = parse_type->builtin_long; }
+			{ $$ = parse_type (ps)->builtin_long; }
 	|	UNSIGNED LONG INT_KEYWORD
-			{ $$ = parse_type->builtin_unsigned_long; }
+			{ $$ = parse_type (ps)->builtin_unsigned_long; }
 	|	LONG LONG
-			{ $$ = parse_type->builtin_long_long; }
+			{ $$ = parse_type (ps)->builtin_long_long; }
 	|	LONG LONG INT_KEYWORD
-			{ $$ = parse_type->builtin_long_long; }
+			{ $$ = parse_type (ps)->builtin_long_long; }
 	|	UNSIGNED LONG LONG
-			{ $$ = parse_type->builtin_unsigned_long_long; }
+			{ $$ = parse_type (ps)->builtin_unsigned_long_long; }
 	|	UNSIGNED LONG LONG INT_KEYWORD
-			{ $$ = parse_type->builtin_unsigned_long_long; }
+			{ $$ = parse_type (ps)->builtin_unsigned_long_long; }
 	|	SHORT INT_KEYWORD
-			{ $$ = parse_type->builtin_short; }
+			{ $$ = parse_type (ps)->builtin_short; }
 	|	UNSIGNED SHORT INT_KEYWORD
-			{ $$ = parse_type->builtin_unsigned_short; }
+			{ $$ = parse_type (ps)->builtin_unsigned_short; }
 	|	DOUBLE_KEYWORD
-			{ $$ = parse_type->builtin_double; }
+			{ $$ = parse_type (ps)->builtin_double; }
 	|	LONG DOUBLE_KEYWORD
-			{ $$ = parse_type->builtin_long_double; }
+			{ $$ = parse_type (ps)->builtin_long_double; }
 	|	STRUCT name
 			{ $$ = lookup_struct (copy_name ($2),
 					      expression_context_block); }
@@ -909,17 +912,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 (ps),
+							 parse_gdbarch (ps),
 							 TYPE_NAME($2.type)); }
 	|	UNSIGNED
-			{ $$ = parse_type->builtin_unsigned_int; }
+			{ $$ = parse_type (ps)->builtin_unsigned_int; }
 	|	SIGNED_KEYWORD typename
-			{ $$ = lookup_signed_typename (parse_language,
-						       parse_gdbarch,
+			{ $$ = lookup_signed_typename (parse_language (ps),
+						       parse_gdbarch (ps),
 						       TYPE_NAME($2.type)); }
 	|	SIGNED_KEYWORD
-			{ $$ = parse_type->builtin_int; }
+			{ $$ = parse_type (ps)->builtin_int; }
 	|	TEMPLATE name '<' type '>'
 			{ $$ = lookup_template_type(copy_name($2), $4,
 						    expression_context_block);
@@ -936,19 +939,19 @@ typename:	TYPENAME
 		{
 		  $$.stoken.ptr = "int";
 		  $$.stoken.length = 3;
-		  $$.type = parse_type->builtin_int;
+		  $$.type = parse_type (ps)->builtin_int;
 		}
 	|	LONG
 		{
 		  $$.stoken.ptr = "long";
 		  $$.stoken.length = 4;
-		  $$.type = parse_type->builtin_long;
+		  $$.type = parse_type (ps)->builtin_long;
 		}
 	|	SHORT
 		{
 		  $$.stoken.ptr = "short";
 		  $$.stoken.length = 5;
-		  $$.type = parse_type->builtin_short;
+		  $$.type = parse_type (ps)->builtin_short;
 		}
 	;
 
@@ -992,11 +995,8 @@ name_not_typename :	NAME
 /*** Needs some error checking for the float case.  ***/
 
 static int
-parse_number (p, len, parsed_float, putithere)
-     char *p;
-     int len;
-     int parsed_float;
-     YYSTYPE *putithere;
+parse_number (struct parser_state *ps, 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
@@ -1022,7 +1022,7 @@ parse_number (p, len, parsed_float, putithere)
 
   if (parsed_float)
     {
-      if (! parse_c_float (parse_gdbarch, p, len,
+      if (! parse_c_float (parse_gdbarch (ps), p, len,
 			   &putithere->typed_val_float.dval,
 			   &putithere->typed_val_float.type))
 	return ERROR;
@@ -1128,10 +1128,10 @@ parse_number (p, len, parsed_float, putithere)
 
   un = (unsigned LONGEST)n >> 2;
   if (long_p == 0
-      && (un >> (gdbarch_int_bit (parse_gdbarch) - 2)) == 0)
+      && (un >> (gdbarch_int_bit (parse_gdbarch (ps)) - 2)) == 0)
     {
       high_bit
-	= ((unsigned LONGEST)1) << (gdbarch_int_bit (parse_gdbarch) - 1);
+	= ((unsigned LONGEST)1) << (gdbarch_int_bit (parse_gdbarch (ps)) - 1);
 
       /* A large decimal (not hex or octal) constant (between INT_MAX
 	 and UINT_MAX) is a long or unsigned long, according to ANSI,
@@ -1139,29 +1139,29 @@ parse_number (p, len, parsed_float, 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 (ps)->builtin_unsigned_int;
+      signed_type = parse_type (ps)->builtin_int;
     }
   else if (long_p <= 1
-	   && (un >> (gdbarch_long_bit (parse_gdbarch) - 2)) == 0)
+	   && (un >> (gdbarch_long_bit (parse_gdbarch (ps)) - 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 (ps)) - 1);
+      unsigned_type = parse_type (ps)->builtin_unsigned_long;
+      signed_type = parse_type (ps)->builtin_long;
     }
   else
     {
       high_bit = (((unsigned LONGEST)1)
-		  << (gdbarch_long_long_bit (parse_gdbarch) - 32 - 1)
+		  << (gdbarch_long_long_bit (parse_gdbarch (ps)) - 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 (ps)->builtin_unsigned_long_long;
+      signed_type = parse_type (ps)->builtin_long_long;
     }
 
    putithere->typed_val_int.val = n;
@@ -1221,7 +1221,7 @@ static const struct token tokentab2[] =
 /* Read one token, getting characters through lexptr.  */
 
 static int
-yylex (void)
+yylex (struct parser_state *ps)
 {
   int c, tokchr;
   int namelen;
@@ -1272,12 +1272,12 @@ yylex (void)
       lexptr++;
       c = *lexptr++;
       if (c == '\\')
-	c = parse_escape (parse_gdbarch, &lexptr);
+	c = parse_escape (parse_gdbarch (ps), &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 (ps)->builtin_char;
 
       c = *lexptr++;
       if (c != '\'')
@@ -1395,7 +1395,7 @@ yylex (void)
 	    else break;
 	  }
 	if (toktype != ERROR)
-	  toktype = parse_number (tokstart, p - tokstart, 
+	  toktype = parse_number (ps, tokstart, p - tokstart, 
 				  got_dot | got_e, &yylval);
         if (toktype == ERROR)
 	  {
@@ -1503,7 +1503,7 @@ yylex (void)
 	    break;
 	  case '\\':
 	    tokptr++;
-	    c = parse_escape (parse_gdbarch, &tokptr);
+	    c = parse_escape (parse_gdbarch (ps), &tokptr);
 	    if (c == -1)
 	      {
 		continue;
@@ -1564,7 +1564,7 @@ yylex (void)
     case 8:
       if (strncmp (tokstart, "unsigned", 8) == 0)
 	return UNSIGNED;
-      if (parse_language->la_language == language_cplus
+      if (parse_language (ps)->la_language == language_cplus
 	  && strncmp (tokstart, "template", 8) == 0)
 	return TEMPLATE;
       if (strncmp (tokstart, "volatile", 8) == 0)
@@ -1581,7 +1581,7 @@ yylex (void)
 	return DOUBLE_KEYWORD;
       break;
     case 5:
-      if ((parse_language->la_language == language_cplus)
+      if ((parse_language (ps)->la_language == language_cplus)
 	  && strncmp (tokstart, "class", 5) == 0)
 	return CLASS;
       if (strncmp (tokstart, "union", 5) == 0)
@@ -1610,7 +1610,7 @@ yylex (void)
 
   if (*tokstart == '$')
     {
-      write_dollar_variable (yylval.sval);
+      write_dollar_variable (ps, yylval.sval);
       return VARIABLE;
     }
 
@@ -1625,8 +1625,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 (ps)->la_language == language_cplus ||
+	parse_language (ps)->la_language == language_objc)
       need_this = &is_a_field_of_this;
     else
       need_this = (int *) NULL;
@@ -1738,15 +1738,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 (ps),
+						parse_gdbarch (ps), 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 (ps), tmp);
 	if (Class)
 	  {
 	    yylval.class.class = Class;
@@ -1766,7 +1766,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 (ps, tokstart, namelen, 0, &newlval);
 	if (hextype == INT)
 	  {
 	    yylval.ssym.sym = sym;
@@ -1783,8 +1783,7 @@ yylex (void)
 }
 
 void
-yyerror (msg)
-     char *msg;
+yyerror (struct parser_state *ps, char *msg)
 {
   if (*lexptr == '\0')
     error(_("A %s near end of expression."),  (msg ? msg : "error"));
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 1c96309..9cb68ce 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -614,7 +614,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;
@@ -624,12 +624,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..d871d67 100644
--- a/gdb/objc-lang.h
+++ b/gdb/objc-lang.h
@@ -26,10 +26,12 @@ 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 (struct parser_state *, char *);	/* Defined
+							   in objc-exp.y */
 
 extern CORE_ADDR lookup_objc_class     (struct gdbarch *gdbarch,
 					char *classname);
@@ -48,7 +50,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);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]