mirror of
https://forge.sourceware.org/marek/gcc.git
synced 2026-02-22 03:47:02 -05:00
a68: remove coalesce_public_symbols shortcut
As planned, this commit removes a crude hack (the coalescing of 'pub' symbols right after bottom-up parsing) that I introduced during the initial implementation of modules. The goal was to get working separated compilation as soon as possible. Now the rest of the parser, and also the lowerer pass, is made to know about these 'pub' symbols. Signed-off-by: Jose E. Marchesi <jemarch@gnu.org> gcc/algol68/ChangeLog * a68-parser-bottom-up.cc (a68_bottom_up_error_check): Do not check for the absence of public-symbols. (a68_bottom_up_coalesce_pub): Removed function. * a68-parser.cc (a68_parser): Do not call a68_bottom_up_coalesce_pub * a68-parser-extract.cc (a68_extract_indicants): Adapt to the presence of public-symbols. * a68-parser-modes.cc (get_mode_from_proc_variables): Likewise. * a68-parser-taxes.cc (tax_variable_dec): Likewise. (tax_proc_variable_dec): Likewise. (tax_op_dec): Likewise (tax_prio_dec): Likewise. * a68-low-decls.cc (a68_lower_mode_declaration): Adapt to the presence of public-symbols. (a68_lower_variable_declaration): Likewise. (a68_lower_identity_declaration): Likewise. (a68_lower_procedure_declaration): Likewise. (a68_lower_procedure_variable_declaration): Likewise. (a68_lower_brief_operator_declaration): Likewise. (a68_lower_operator_declaration): Likewise. gcc/testsuite/ChangeLog * algol68/compile/module-2.a68: Expand test a little.
This commit is contained in:
@@ -48,6 +48,10 @@
|
||||
equals symbol, declarer;
|
||||
mode symbol, defining indicant,
|
||||
equals symbol, void symbol;
|
||||
public symbol, mode symbol, defining indicant,
|
||||
equals symbol, declarer;
|
||||
public symbol, mode symbol, defining indicant,
|
||||
equals symbol, void symbol;
|
||||
mode declaration, comma symbol,
|
||||
defining indicant, equals symbol, declarer;
|
||||
mode declaration, comma symbol,
|
||||
@@ -71,8 +75,16 @@ a68_lower_mode_declaration (NODE_T *p, LOW_CTX_T ctx)
|
||||
}
|
||||
else
|
||||
{
|
||||
gcc_assert (IS (SUB (p), MODE_SYMBOL));
|
||||
defining_indicant = NEXT (SUB (p));
|
||||
if (IS (SUB (p), PUBLIC_SYMBOL))
|
||||
{
|
||||
gcc_assert (IS (NEXT (SUB (p)), MODE_SYMBOL));
|
||||
defining_indicant = NEXT (NEXT (SUB (p)));
|
||||
}
|
||||
else
|
||||
{
|
||||
gcc_assert (IS (SUB (p), MODE_SYMBOL));
|
||||
defining_indicant = NEXT (SUB (p));
|
||||
}
|
||||
}
|
||||
|
||||
/* Create a TYPE_DECL declaration for the defined mode and chain it in the
|
||||
@@ -100,6 +112,12 @@ a68_lower_mode_declaration (NODE_T *p, LOW_CTX_T ctx)
|
||||
qualifier, declarer, defining identifier;
|
||||
declarer, defining identifier, assign symbol, unit;
|
||||
declarer, defining identifier;
|
||||
public symbol, qualifier, declarer, defining identifier,
|
||||
assign symbol, unit;
|
||||
public symbol, qualifier, declarer, defining identiifer;
|
||||
qualifier, declarer, defining identifier;
|
||||
public symbol, declarer, defining identifier, assign symbol, unit;
|
||||
declarer, defining identifier;
|
||||
variable declaration, comma symbol,
|
||||
defining identifier, assign symbol, unit;
|
||||
variable declaration, comma symbol,
|
||||
@@ -135,21 +153,29 @@ a68_lower_variable_declaration (NODE_T *p, LOW_CTX_T ctx)
|
||||
sub_expr = a68_lower_tree (SUB (p), new_ctx);
|
||||
defining_identifier = NEXT (NEXT (SUB (p)));
|
||||
}
|
||||
else if (IS (SUB (p), QUALIFIER))
|
||||
{
|
||||
/* The qualifier determines what kind of generator is used in the
|
||||
variable declaration. This is already annotated in the tax entry for
|
||||
the definining identifier. */
|
||||
declarer = NEXT (SUB (p));
|
||||
defining_identifier = NEXT (NEXT (SUB (p)));
|
||||
}
|
||||
else if (IS (SUB (p), DECLARER))
|
||||
{
|
||||
declarer = SUB (p);
|
||||
defining_identifier = NEXT (SUB (p));
|
||||
}
|
||||
else
|
||||
gcc_unreachable ();
|
||||
{
|
||||
NODE_T *q = SUB (p);
|
||||
|
||||
if (IS (q, PUBLIC_SYMBOL))
|
||||
FORWARD (q);
|
||||
|
||||
if (IS (q, QUALIFIER))
|
||||
{
|
||||
/* The qualifier determines what kind of generator is used in the
|
||||
variable declaration. This is already annotated in the tax entry
|
||||
for the definining identifier. */
|
||||
declarer = NEXT (q);
|
||||
defining_identifier = NEXT (NEXT (q));
|
||||
}
|
||||
else if (IS (q, DECLARER))
|
||||
{
|
||||
declarer = q;
|
||||
defining_identifier = NEXT (q);
|
||||
}
|
||||
else
|
||||
gcc_unreachable ();
|
||||
}
|
||||
|
||||
/* Communicate declarer upward. */
|
||||
if (ctx.declarer != NULL)
|
||||
@@ -281,6 +307,8 @@ a68_lower_variable_declaration (NODE_T *p, LOW_CTX_T ctx)
|
||||
|
||||
identity declaration : declarer, defining identifier,
|
||||
equals symbol, unit;
|
||||
public symbol, declarer, defining identifier,
|
||||
equals symbol, unit;
|
||||
identity declaration, comma symbol,
|
||||
defining identifier, equals symbol, unit;
|
||||
|
||||
@@ -310,6 +338,10 @@ a68_lower_identity_declaration (NODE_T *p, LOW_CTX_T ctx)
|
||||
sub_expr = a68_lower_tree (SUB (p), ctx);
|
||||
defining_identifier = NEXT (NEXT (SUB (p)));
|
||||
}
|
||||
else if (IS (SUB (p), PUBLIC_SYMBOL))
|
||||
{
|
||||
defining_identifier = NEXT (NEXT (SUB (p)));
|
||||
}
|
||||
else if (IS (SUB (p), DECLARER))
|
||||
{
|
||||
defining_identifier = NEXT (SUB (p));
|
||||
@@ -443,6 +475,7 @@ a68_lower_declaration_list (NODE_T *p, LOW_CTX_T ctx)
|
||||
/* Lower a procedure declaration.
|
||||
|
||||
procedure declaration : proc symbol, defining identifier, assign symbol, routine text;
|
||||
public symbol, proc symbol, defining identifier, assign symbol, routine text;
|
||||
procedure declaration, comma symbol,
|
||||
defining identifier, equals symbol, routine text.
|
||||
|
||||
@@ -458,6 +491,10 @@ a68_lower_procedure_declaration (NODE_T *p, LOW_CTX_T ctx)
|
||||
sub_func_decl = a68_lower_tree (SUB (p), ctx);
|
||||
defining_identifier = NEXT (NEXT (SUB (p)));
|
||||
}
|
||||
else if (IS (SUB (p), PUBLIC_SYMBOL))
|
||||
{
|
||||
defining_identifier = NEXT (NEXT (SUB (p)));
|
||||
}
|
||||
else if (IS (SUB (p), PROC_SYMBOL))
|
||||
{
|
||||
defining_identifier = NEXT (SUB (p));
|
||||
@@ -493,6 +530,8 @@ a68_lower_procedure_declaration (NODE_T *p, LOW_CTX_T ctx)
|
||||
procedure variable declaration
|
||||
: proc symbol, defining identifier, assign symbol, routine text;
|
||||
qualifier, proc symbol, defining identifier, assign symbol, routine text;
|
||||
public symbol, proc symbol, defining identifier, assign symbol, routine text;
|
||||
public symbol, qualifier, proc symbol, defining identifier, assign symbol, routine text;
|
||||
procedure variable declaration, comma symbol, defining identiier, assign symbol, routine text.
|
||||
|
||||
This lowers into the declaration of a VAR_DECL which is a pointer to the
|
||||
@@ -508,15 +547,24 @@ a68_lower_procedure_variable_declaration (NODE_T *p, LOW_CTX_T ctx)
|
||||
sub_decl = a68_lower_tree (SUB (p), ctx);
|
||||
defining_identifier = NEXT (NEXT (SUB (p)));
|
||||
}
|
||||
else if (IS (SUB (p), PROC_SYMBOL))
|
||||
defining_identifier = NEXT (SUB (p));
|
||||
else if (IS (SUB (p), QUALIFIER))
|
||||
/* The qualifier determines what kind of generator is used in the variable
|
||||
declaration. This is already annotated in the tax entry for the
|
||||
definining identifier. */
|
||||
defining_identifier = NEXT (NEXT (SUB (p)));
|
||||
else
|
||||
gcc_unreachable ();
|
||||
{
|
||||
NODE_T *q = SUB (p);
|
||||
|
||||
if (IS (q, PUBLIC_SYMBOL))
|
||||
FORWARD (q);
|
||||
|
||||
if (IS (q, PROC_SYMBOL))
|
||||
defining_identifier = NEXT (q);
|
||||
else if (IS (q, QUALIFIER))
|
||||
/* The qualifier determines what kind of generator is used in the
|
||||
variable declaration. This is already annotated in the tax entry
|
||||
for the definining identifier. */
|
||||
defining_identifier = NEXT (NEXT (q));
|
||||
else
|
||||
gcc_unreachable ();
|
||||
}
|
||||
|
||||
NODE_T *routine_text = NEXT (NEXT (defining_identifier));
|
||||
|
||||
/* The routine text lowers into a pointer to function. */
|
||||
@@ -590,6 +638,7 @@ a68_lower_priority_declaration (NODE_T *p ATTRIBUTE_UNUSED,
|
||||
|
||||
brief operator declaration
|
||||
: op symbol, defining operator, equals symbol, routine text;
|
||||
public symbol, op symbol, defining operator, equals symbol, routine text;
|
||||
brief operator declaration, comma symbol, defining operator, equals symbol, routine text.
|
||||
|
||||
The declarations low in a series of FUNCTION_DECLs, one per declared
|
||||
@@ -607,7 +656,15 @@ a68_lower_brief_operator_declaration (NODE_T *p, LOW_CTX_T ctx)
|
||||
defining_operator = NEXT (NEXT (SUB (p)));
|
||||
}
|
||||
else
|
||||
defining_operator = NEXT (SUB (p));
|
||||
{
|
||||
if (IS (SUB (p), PUBLIC_SYMBOL))
|
||||
{
|
||||
gcc_assert (IS (NEXT (SUB (p)), OP_SYMBOL));
|
||||
defining_operator = NEXT (NEXT (SUB (p)));
|
||||
}
|
||||
else
|
||||
defining_operator = NEXT (SUB (p));
|
||||
}
|
||||
NODE_T *routine_text = NEXT (NEXT (defining_operator));
|
||||
|
||||
/* Lower the routine text to get a function decl. */
|
||||
@@ -634,6 +691,7 @@ a68_lower_brief_operator_declaration (NODE_T *p, LOW_CTX_T ctx)
|
||||
/* Lower an operator declaration.
|
||||
|
||||
operator declaration : operator plan, defining operator, equals symbol, unit;
|
||||
public symbol, operator plan, defining operator, equals symbol, unit;
|
||||
operator declaration, comma symbol, defining operator, equals symbol, unit.
|
||||
|
||||
Each operator declaration lowers into a declaration. */
|
||||
@@ -650,7 +708,12 @@ a68_lower_operator_declaration (NODE_T *p, LOW_CTX_T ctx)
|
||||
defining_operator = NEXT (NEXT (SUB (p)));
|
||||
}
|
||||
else
|
||||
defining_operator = NEXT (SUB (p));
|
||||
{
|
||||
if (IS (SUB (p), PUBLIC_SYMBOL))
|
||||
defining_operator = NEXT (NEXT (SUB (p)));
|
||||
else
|
||||
defining_operator = NEXT (SUB (p));
|
||||
}
|
||||
NODE_T *unit = NEXT (NEXT (defining_operator));
|
||||
|
||||
tree op_decl = TAX_TREE_DECL (TAX (defining_operator));
|
||||
|
||||
@@ -2900,13 +2900,6 @@ a68_bottom_up_error_check (NODE_T *p)
|
||||
a68_error (p, "incorrect number of pictures for A",
|
||||
ATTRIBUTE (p));
|
||||
}
|
||||
else if (IS (p, PUBLIC_SYMBOL))
|
||||
{
|
||||
/* These should have been removed by a68_bottom_up_coalesce_pub and
|
||||
by a68_extract_indicants. */
|
||||
/* XXX get rid of this. */
|
||||
gcc_unreachable ();
|
||||
}
|
||||
else if (a68_is_one_of (p, DEFINING_INDICANT, DEFINING_IDENTIFIER, DEFINING_OPERATOR, STOP))
|
||||
{
|
||||
if (PUBLICIZED (p) && !PUBLIC_RANGE (TABLE (p)))
|
||||
@@ -3004,31 +2997,3 @@ a68_rearrange_goto_less_jumps (NODE_T *p)
|
||||
a68_rearrange_goto_less_jumps (SUB (p));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove PUBLIC_SYMBOLs resulting from reductions from the tree. Note that
|
||||
* the defining indicants, identifiers and operators have been already marked
|
||||
* as publicized or not publicized by the extract routines.
|
||||
*/
|
||||
|
||||
void
|
||||
a68_bottom_up_coalesce_pub (NODE_T *p)
|
||||
{
|
||||
for (; p != NO_NODE; FORWARD (p))
|
||||
{
|
||||
if (a68_is_one_of (p,
|
||||
MODE_DECLARATION, PROCEDURE_DECLARATION, PRIORITY_DECLARATION,
|
||||
PROCEDURE_VARIABLE_DECLARATION, BRIEF_OPERATOR_DECLARATION,
|
||||
OPERATOR_DECLARATION, IDENTITY_DECLARATION,
|
||||
VARIABLE_DECLARATION, STOP))
|
||||
{
|
||||
if (SUB (p) != NO_NODE && IS (SUB (p), PUBLIC_SYMBOL))
|
||||
{
|
||||
NODE_T *public_symbol = SUB (p);
|
||||
SUB (p) = NEXT (public_symbol);
|
||||
PREVIOUS (NEXT (public_symbol)) = NO_NODE;
|
||||
}
|
||||
}
|
||||
a68_bottom_up_coalesce_pub (SUB (p));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ a68_elaborate_bold_tags (NODE_T *p)
|
||||
static NODE_T *
|
||||
skip_pack_declarer (NODE_T *p)
|
||||
{
|
||||
/* Skip () REF [] REF FLEX [] [] ... */
|
||||
/* Skip PUB () REF [] REF FLEX [] [] ... */
|
||||
while (p != NO_NODE
|
||||
&& (a68_is_one_of (p, SUB_SYMBOL, OPEN_SYMBOL, REF_SYMBOL,
|
||||
FLEX_SYMBOL, SHORT_SYMBOL, LONG_SYMBOL, STOP)))
|
||||
@@ -354,10 +354,7 @@ a68_extract_indicants (NODE_T *p)
|
||||
{
|
||||
NODE_T *pub_node = q;
|
||||
extract_revelation (NEXT (pub_node), true /* is_public */);
|
||||
/* XXX get rid of this crap. */
|
||||
PREVIOUS (NEXT (pub_node)) = PREVIOUS (pub_node);
|
||||
if (PREVIOUS (pub_node) != NO_NODE)
|
||||
NEXT (PREVIOUS (pub_node)) = NEXT (pub_node);
|
||||
FORWARD (q);
|
||||
FORWARD (q);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -766,7 +766,7 @@ get_mode_from_proc_variables (NODE_T *p)
|
||||
get_mode_from_proc_variables (SUB (p));
|
||||
get_mode_from_proc_variables (NEXT (p));
|
||||
}
|
||||
else if (IS (p, QUALIFIER) || IS (p, PROC_SYMBOL) || IS (p, COMMA_SYMBOL))
|
||||
else if (IS (p, PUBLIC_SYMBOL) || IS (p, QUALIFIER) || IS (p, PROC_SYMBOL) || IS (p, COMMA_SYMBOL))
|
||||
{
|
||||
get_mode_from_proc_variables (NEXT (p));
|
||||
}
|
||||
|
||||
@@ -890,6 +890,10 @@ tax_identity_dec (NODE_T *p, MOID_T **m)
|
||||
tax_identity_dec (SUB (p), m);
|
||||
tax_identity_dec (NEXT (p), m);
|
||||
}
|
||||
else if (IS (p, PUBLIC_SYMBOL))
|
||||
{
|
||||
tax_identity_dec (NEXT (p), m);
|
||||
}
|
||||
else if (IS (p, DECLARER))
|
||||
{
|
||||
tax_tags (SUB (p));
|
||||
@@ -939,6 +943,10 @@ tax_variable_dec (NODE_T *p, int *q, MOID_T **m, bool e)
|
||||
tax_variable_dec (SUB (p), q, m, e);
|
||||
tax_variable_dec (NEXT (p), q, m, e);
|
||||
}
|
||||
else if (IS (p, PUBLIC_SYMBOL))
|
||||
{
|
||||
tax_variable_dec (NEXT (p), q, m, e);
|
||||
}
|
||||
else if (IS (p, DECLARER))
|
||||
{
|
||||
tax_tags (SUB (p));
|
||||
@@ -1009,7 +1017,7 @@ tax_proc_variable_dec (NODE_T *p, int *q, bool e)
|
||||
*q = ATTRIBUTE (SUB (p));
|
||||
tax_proc_variable_dec (NEXT (p), q, true);
|
||||
}
|
||||
else if (a68_is_one_of (p, PROC_SYMBOL, COMMA_SYMBOL, STOP))
|
||||
else if (a68_is_one_of (p, PUBLIC_SYMBOL, PROC_SYMBOL, COMMA_SYMBOL, STOP))
|
||||
{
|
||||
tax_proc_variable_dec (NEXT (p), q, e);
|
||||
}
|
||||
@@ -1059,7 +1067,7 @@ tax_proc_dec (NODE_T *p)
|
||||
tax_proc_dec (SUB (p));
|
||||
tax_proc_dec (NEXT (p));
|
||||
}
|
||||
else if (a68_is_one_of (p, PROC_SYMBOL, COMMA_SYMBOL, STOP))
|
||||
else if (a68_is_one_of (p, PUBLIC_SYMBOL, PROC_SYMBOL, COMMA_SYMBOL, STOP))
|
||||
{
|
||||
tax_proc_dec (NEXT (p));
|
||||
}
|
||||
@@ -1136,7 +1144,7 @@ tax_op_dec (NODE_T *p, MOID_T **m)
|
||||
{
|
||||
tax_op_dec (NEXT (p), m);
|
||||
}
|
||||
else if (IS (p, COMMA_SYMBOL))
|
||||
else if (a68_is_one_of (p, PUBLIC_SYMBOL, COMMA_SYMBOL, STOP))
|
||||
{
|
||||
tax_op_dec (NEXT (p), m);
|
||||
}
|
||||
@@ -1211,7 +1219,7 @@ tax_brief_op_dec (NODE_T *p)
|
||||
tax_brief_op_dec (SUB (p));
|
||||
tax_brief_op_dec (NEXT (p));
|
||||
}
|
||||
else if (a68_is_one_of (p, OP_SYMBOL, COMMA_SYMBOL, STOP))
|
||||
else if (a68_is_one_of (p, PUBLIC_SYMBOL, OP_SYMBOL, COMMA_SYMBOL, STOP))
|
||||
{
|
||||
tax_brief_op_dec (NEXT (p));
|
||||
}
|
||||
@@ -1247,7 +1255,7 @@ static void tax_prio_dec (NODE_T *p)
|
||||
tax_prio_dec (SUB (p));
|
||||
tax_prio_dec (NEXT (p));
|
||||
}
|
||||
else if (a68_is_one_of (p, PRIO_SYMBOL, COMMA_SYMBOL, STOP))
|
||||
else if (a68_is_one_of (p, PUBLIC_SYMBOL, PRIO_SYMBOL, COMMA_SYMBOL, STOP))
|
||||
{
|
||||
tax_prio_dec (NEXT (p));
|
||||
}
|
||||
|
||||
@@ -522,7 +522,6 @@ a68_parser (const char *filename)
|
||||
// printf ("AFTER PRELIMINARY SYMBOL TABLE SETUP\n");
|
||||
// a68_dump_parse_tree (TOP_NODE (&A68_JOB), true);
|
||||
a68_bottom_up_parser (TOP_NODE (&A68_JOB));
|
||||
a68_bottom_up_coalesce_pub (TOP_NODE (&A68_JOB));
|
||||
renum = 0;
|
||||
renumber_nodes (TOP_NODE (&A68_JOB), &renum);
|
||||
}
|
||||
|
||||
@@ -4,5 +4,6 @@ module Foo = def pub int idpublic = 10;
|
||||
real varprivate := 3.14;
|
||||
pub proc lala = (int a, b) int: a + b;
|
||||
pub proc lele := (int a, b) int: a - b;
|
||||
pub proc(int,int)int lili := (int a, b) int: a * b;
|
||||
skip
|
||||
fed
|
||||
|
||||
Reference in New Issue
Block a user