Commit 4c521bad by Neil Booth Committed by Neil Booth

c-common.h (RID_FIRST_PQ): New.

	* c-common.h (RID_FIRST_PQ): New.
	* c-parse.in (objc_pq_context): New.
	(objc parser): Set objc_pq_context rather than calling
	remember_protocol_qualifiers and forget_protocol_qualifiers.
	Don't call save_and_forget_protocol_qualifiers.
	(yylexname): Handle objc protocol qualifiers here.
	* stringpool.c (struct str_header): Replace with sp_hashnode.
	(SP_EMPTY, SP_LEN, SP_TREE, SP_STR, SP_VALID): New.
	(alloc_string): Rename alloc_ident.  Use the SP_ accessors.
	Allocate an IDENTIFIER_NODE for each identifier.
	(FORALL_STRINGS, set_identifier): Delete.
	(FORALL_IDS, expand_string_table, stringpool_statistics): Update.
	(ggc_alloc_string): Use an obstack.
	(get_identifier, maybe_get_identifier, mark_string_hash): Update.
	* tree.h: Update comments.
	(set_identifier): Delete.
	* objc/objc-act.c (N_PQ, saved_pq, saved_not_pq,
	save_and_forget_protocol_qualifiers, forget_protocol_qualifiers,
	remember_protocol_qualifiers): Delete.

From-SVN: r42132
parent fca790eb
2001-05-16 Neil Booth <neil@cat.daikokuya.demon.co.uk>
* c-common.h (RID_FIRST_PQ): New.
* c-parse.in (objc_pq_context): New.
(objc parser): Set objc_pq_context rather than calling
remember_protocol_qualifiers and forget_protocol_qualifiers.
Don't call save_and_forget_protocol_qualifiers.
(yylexname): Handle objc protocol qualifiers here.
* stringpool.c (struct str_header): Replace with sp_hashnode.
(SP_EMPTY, SP_LEN, SP_TREE, SP_STR, SP_VALID): New.
(alloc_string): Rename alloc_ident. Use the SP_ accessors.
Allocate an IDENTIFIER_NODE for each identifier.
(FORALL_STRINGS, set_identifier): Delete.
(FORALL_IDS, expand_string_table, stringpool_statistics): Update.
(ggc_alloc_string): Use an obstack.
(get_identifier, maybe_get_identifier, mark_string_hash): Update.
* tree.h: Update comments.
(set_identifier): Delete.
* objc/objc-act.c (N_PQ, saved_pq, saved_not_pq,
save_and_forget_protocol_qualifiers, forget_protocol_qualifiers,
remember_protocol_qualifiers): Delete.
Tue May 15 22:14:09 2001 Jeffrey A Law (law@cygnus.com) Tue May 15 22:14:09 2001 Jeffrey A Law (law@cygnus.com)
* flow.c (life_analysis): After life analysis is complete, do * flow.c (life_analysis): After life analysis is complete, do
......
...@@ -61,7 +61,7 @@ enum rid ...@@ -61,7 +61,7 @@ enum rid
RID_FRIEND, RID_VIRTUAL, RID_EXPLICIT, RID_EXPORT, RID_MUTABLE, RID_FRIEND, RID_VIRTUAL, RID_EXPLICIT, RID_EXPORT, RID_MUTABLE,
/* ObjC */ /* ObjC */
RID_IN, RID_OUT, RID_INOUT, RID_BYCOPY, RID_BYREF, RID_ONEWAY, RID_FIRST_PQ, RID_IN = RID_FIRST_PQ, RID_OUT, RID_INOUT, RID_BYCOPY, RID_BYREF, RID_ONEWAY,
/* C */ /* C */
RID_INT, RID_CHAR, RID_FLOAT, RID_DOUBLE, RID_VOID, RID_INT, RID_CHAR, RID_FLOAT, RID_DOUBLE, RID_VOID,
......
...@@ -271,6 +271,7 @@ tree objc_ivar_context; ...@@ -271,6 +271,7 @@ tree objc_ivar_context;
enum tree_code objc_inherit_code; enum tree_code objc_inherit_code;
int objc_receiver_context; int objc_receiver_context;
int objc_public_flag; int objc_public_flag;
int objc_pq_context;
end ifobjc end ifobjc
...@@ -2837,13 +2838,13 @@ classdef: ...@@ -2837,13 +2838,13 @@ classdef:
protocoldef: protocoldef:
PROTOCOL identifier protocolrefs PROTOCOL identifier protocolrefs
{ {
remember_protocol_qualifiers (); objc_pq_context = 1;
objc_interface_context objc_interface_context
= start_protocol(PROTOCOL_INTERFACE_TYPE, $2, $3); = start_protocol(PROTOCOL_INTERFACE_TYPE, $2, $3);
} }
methodprotolist END methodprotolist END
{ {
forget_protocol_qualifiers(); objc_pq_context = 0;
finish_protocol(objc_interface_context); finish_protocol(objc_interface_context);
objc_interface_context = NULL_TREE; objc_interface_context = NULL_TREE;
} }
...@@ -2949,7 +2950,7 @@ ivar_declarator: ...@@ -2949,7 +2950,7 @@ ivar_declarator:
methoddef: methoddef:
'+' '+'
{ {
remember_protocol_qualifiers (); objc_pq_context = 1;
if (objc_implementation_context) if (objc_implementation_context)
objc_inherit_code = CLASS_METHOD_DECL; objc_inherit_code = CLASS_METHOD_DECL;
else else
...@@ -2957,7 +2958,7 @@ methoddef: ...@@ -2957,7 +2958,7 @@ methoddef:
} }
methoddecl methoddecl
{ {
forget_protocol_qualifiers (); objc_pq_context = 0;
add_class_method (objc_implementation_context, $3); add_class_method (objc_implementation_context, $3);
start_method_def ($3); start_method_def ($3);
objc_method_context = $3; objc_method_context = $3;
...@@ -2974,7 +2975,7 @@ methoddef: ...@@ -2974,7 +2975,7 @@ methoddef:
| '-' | '-'
{ {
remember_protocol_qualifiers (); objc_pq_context = 1;
if (objc_implementation_context) if (objc_implementation_context)
objc_inherit_code = INSTANCE_METHOD_DECL; objc_inherit_code = INSTANCE_METHOD_DECL;
else else
...@@ -2982,7 +2983,7 @@ methoddef: ...@@ -2982,7 +2983,7 @@ methoddef:
} }
methoddecl methoddecl
{ {
forget_protocol_qualifiers (); objc_pq_context = 0;
add_instance_method (objc_implementation_context, $3); add_instance_method (objc_implementation_context, $3);
start_method_def ($3); start_method_def ($3);
objc_method_context = $3; objc_method_context = $3;
...@@ -3023,13 +3024,13 @@ methodproto: ...@@ -3023,13 +3024,13 @@ methodproto:
'+' '+'
{ {
/* Remember protocol qualifiers in prototypes. */ /* Remember protocol qualifiers in prototypes. */
remember_protocol_qualifiers (); objc_pq_context = 1;
objc_inherit_code = CLASS_METHOD_DECL; objc_inherit_code = CLASS_METHOD_DECL;
} }
methoddecl methoddecl
{ {
/* Forget protocol qualifiers here. */ /* Forget protocol qualifiers here. */
forget_protocol_qualifiers (); objc_pq_context = 0;
add_class_method (objc_interface_context, $3); add_class_method (objc_interface_context, $3);
} }
semi_or_error semi_or_error
...@@ -3037,13 +3038,13 @@ methodproto: ...@@ -3037,13 +3038,13 @@ methodproto:
| '-' | '-'
{ {
/* Remember protocol qualifiers in prototypes. */ /* Remember protocol qualifiers in prototypes. */
remember_protocol_qualifiers (); objc_pq_context = 1;
objc_inherit_code = INSTANCE_METHOD_DECL; objc_inherit_code = INSTANCE_METHOD_DECL;
} }
methoddecl methoddecl
{ {
/* Forget protocol qualifiers here. */ /* Forget protocol qualifiers here. */
forget_protocol_qualifiers (); objc_pq_context = 0;
add_instance_method (objc_interface_context, $3); add_instance_method (objc_interface_context, $3);
} }
semi_or_error semi_or_error
...@@ -3615,9 +3616,6 @@ ifobjc ...@@ -3615,9 +3616,6 @@ ifobjc
= get_identifier (reswords[i].word + 1); = get_identifier (reswords[i].word + 1);
end ifobjc end ifobjc
} }
ifobjc
save_and_forget_protocol_qualifiers ();
end ifobjc
} }
const char * const char *
...@@ -3683,22 +3681,28 @@ yylexname () ...@@ -3683,22 +3681,28 @@ yylexname ()
if (C_IS_RESERVED_WORD (yylval.ttype)) if (C_IS_RESERVED_WORD (yylval.ttype))
{ {
enum rid rid_code = C_RID_CODE (yylval.ttype); enum rid rid_code = C_RID_CODE (yylval.ttype);
int yycode = rid_to_yy[(int) rid_code];
if (yycode == STRING_FUNC_NAME) ifobjc
{ if (!((unsigned int) rid_code - (unsigned int) RID_FIRST_PQ < 6)
/* __FUNCTION__ and __PRETTY_FUNCTION__ get converted || objc_pq_context)
to string constants. */ end ifobjc
const char *name = fname_string (rid_code); {
int yycode = rid_to_yy[(int) rid_code];
if (yycode == STRING_FUNC_NAME)
{
/* __FUNCTION__ and __PRETTY_FUNCTION__ get converted
to string constants. */
const char *name = fname_string (rid_code);
yylval.ttype = build_string (strlen (name) + 1, name); yylval.ttype = build_string (strlen (name) + 1, name);
last_token = CPP_STRING; /* so yyerror won't choke */ last_token = CPP_STRING; /* so yyerror won't choke */
return STRING; return STRING;
} }
/* Return the canonical spelling for this keyword. */ /* Return the canonical spelling for this keyword. */
yylval.ttype = ridpointers[(int) rid_code]; yylval.ttype = ridpointers[(int) rid_code];
return yycode; return yycode;
}
} }
decl = lookup_name (yylval.ttype); decl = lookup_name (yylval.ttype);
......
...@@ -8661,46 +8661,3 @@ lookup_objc_ivar (id) ...@@ -8661,46 +8661,3 @@ lookup_objc_ivar (id)
else else
return 0; return 0;
} }
/* Parser callbacks.
Some ObjC keywords are reserved only in a particular context:
in out inout bycopy byref oneway.
We have to save and restore the IDENTIFIER_NODEs that describe
them as keywords, when appropriate. */
#define N_PQ 6
static tree saved_pq[N_PQ];
static tree saved_not_pq[N_PQ];
static const char *const pq_strings[N_PQ] = {
"bycopy", "byref", "in", "inout", "oneway", "out"
};
void
save_and_forget_protocol_qualifiers ()
{
int i;
for (i = 0; i < N_PQ; i++)
saved_pq[i] = set_identifier (pq_strings[i], NULL_TREE);
ggc_add_tree_root (saved_pq, N_PQ);
ggc_add_tree_root (saved_not_pq, N_PQ);
}
void
forget_protocol_qualifiers ()
{
int i;
for (i = 0; i < N_PQ; i++)
{
set_identifier (pq_strings[i], saved_not_pq[i]);
saved_not_pq[i] = NULL_TREE;
}
}
void
remember_protocol_qualifiers ()
{
int i;
for (i = 0; i < N_PQ; i++)
saved_not_pq[i] = set_identifier (pq_strings[i], saved_pq[i]);
}
...@@ -188,7 +188,7 @@ struct tree_common ...@@ -188,7 +188,7 @@ struct tree_common
TREE_OVERFLOW in TREE_OVERFLOW in
INTEGER_CST, REAL_CST, COMPLEX_CST INTEGER_CST, REAL_CST, COMPLEX_CST
TREE_PUBLIC in TREE_PUBLIC in
VAR_DECL or FUNCTION_DECL VAR_DECL or FUNCTION_DECL or IDENTIFIER_NODE
TREE_VIA_PUBLIC in TREE_VIA_PUBLIC in
TREE_LIST or TREE_VEC TREE_LIST or TREE_VEC
EXPR_WFL_EMIT_LINE_NOTE in EXPR_WFL_EMIT_LINE_NOTE in
...@@ -261,7 +261,8 @@ struct tree_common ...@@ -261,7 +261,8 @@ struct tree_common
bounded_flag: bounded_flag:
TREE_BOUNDED in TREE_BOUNDED in
expressions, VAR_DECL, PARM_DECL, FIELD_DECL, FUNCTION_DECL expressions, VAR_DECL, PARM_DECL, FIELD_DECL, FUNCTION_DECL,
IDENTIFIER_NODE
TYPE_BOUNDED in TYPE_BOUNDED in
..._TYPE ..._TYPE
*/ */
...@@ -517,7 +518,7 @@ extern void tree_class_check_failed PARAMS ((const tree, int, ...@@ -517,7 +518,7 @@ extern void tree_class_check_failed PARAMS ((const tree, int,
/* In a VAR_DECL or FUNCTION_DECL, /* In a VAR_DECL or FUNCTION_DECL,
nonzero means name is to be accessible from outside this module. nonzero means name is to be accessible from outside this module.
In an identifier node, nonzero means an external declaration In an IDENTIFIER_NODE, nonzero means an external declaration
accessible from outside this module was previously seen accessible from outside this module was previously seen
for this name in an inner scope. */ for this name in an inner scope. */
#define TREE_PUBLIC(NODE) ((NODE)->common.public_flag) #define TREE_PUBLIC(NODE) ((NODE)->common.public_flag)
...@@ -1952,13 +1953,6 @@ extern tree get_identifier PARAMS ((const char *)); ...@@ -1952,13 +1953,6 @@ extern tree get_identifier PARAMS ((const char *));
extern tree maybe_get_identifier PARAMS ((const char *)); extern tree maybe_get_identifier PARAMS ((const char *));
/* Look up an identifier with the name TEXT, replace its identifier
node with NODE, and return the old identifier node. This is used
by languages which need to enable and disable keywords based on
context; e.g. see remember_protocol_qualifiers in objc/objc-act.c. */
extern tree set_identifier PARAMS ((const char *, tree));
/* Construct various types of nodes. */ /* Construct various types of nodes. */
#define build_int_2(LO,HI) \ #define build_int_2(LO,HI) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment