Until now all the identifiers interned in A68_STANDENV were lowered by
using an explicit lowering routine.  This is because the entirely of
the standard preludes were implemented by having the compiler generate
the corresponding code inline.  We have a check in place to determine
whether a lowerer has been installed for a given standard construct:
NO_LOWERER.  This is a lowerer routine that just prints a message and
ICEs.

We want to write part of the standard preludes in Algol 68.  To make
that possible this patch introduces a distinction between NO_LOWERER,
meaning the definition comes from Algol 68 code in the runtime library
and therefore does not use a lowering routine, and LOWERER_UNIMPL,
which means the definition uses a lowering routine but a proper one
has not been written yet.

Signed-off-by: Jose E. Marchesi <[email protected]>

gcc/algol68/ChangeLog

        * a68-types.h (NO_LOWERER): Redefine as NULL.
        (LOWERER_UNIMPL): Define.
        * a68-parser-prelude.cc (a68_idf): Use LOWERER_UNIMPL instead of
        NO_LOWERER.
        (a68_prio): Likewise.
        (a68_op): Likewise.
        * a68-low-units.cc (a68_lower_identifier): Do not assume
        declarations in A68_STANDENV all have lowerers.
        (a68_lower_formula): Likewise.
        (a68_lower_monadic_formula): Likewise.
---
 gcc/algol68/a68-low-units.cc      | 15 +++++++++------
 gcc/algol68/a68-parser-prelude.cc |  8 ++++----
 gcc/algol68/a68-types.h           |  3 ++-
 3 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/gcc/algol68/a68-low-units.cc b/gcc/algol68/a68-low-units.cc
index b4ce00a24f7..e9660d750dd 100644
--- a/gcc/algol68/a68-low-units.cc
+++ b/gcc/algol68/a68-low-units.cc
@@ -54,11 +54,12 @@
 tree
 a68_lower_identifier (NODE_T *p, LOW_CTX_T ctx)
 {
-  if (TAG_TABLE (TAX (p)) == A68_STANDENV)
+  LOWERER_T lowerer = LOWERER (TAX (p));
+
+  if (lowerer != NO_LOWERER)
     {
       /* This identifier is defined in the standard prelude.  Use its lowering
         handler.  */
-      LOWERER_T lowerer = LOWERER (TAX (p));
       return (*lowerer) (p, ctx);
     }
   else
@@ -959,11 +960,12 @@ a68_lower_formula (NODE_T *p, LOW_CTX_T ctx)
     return a68_lower_tree (SUB (p), ctx);
   else
     {
+      LOWERER_T lowerer = LOWERER (TAX (NEXT (SUB (p))));
+
       /* If the operator is defined in the standard prelude, then use its 
lowering
         code.  */
-      if (TAG_TABLE (TAX (NEXT (SUB (p)))) == A68_STANDENV)
+      if (lowerer != NO_LOWERER)
        {
-         LOWERER_T lowerer = LOWERER (TAX (NEXT (SUB (p))));
          return (*lowerer) (p, ctx);
        }
       else
@@ -991,11 +993,12 @@ a68_lower_formula (NODE_T *p, LOW_CTX_T ctx)
 tree
 a68_lower_monadic_formula (NODE_T *p, LOW_CTX_T ctx)
 {
+  LOWERER_T lowerer = LOWERER (TAX (SUB (p)));
+
   /* If the operator is defined in the standard prelude, then use its lowering
      code.  */
-  if (TAG_TABLE (TAX (SUB (p))) == A68_STANDENV)
+  if (lowerer != NO_LOWERER)
     {
-      LOWERER_T lowerer = LOWERER (TAX (SUB (p)));
       return (*lowerer) (p, ctx);
     }
   else
diff --git a/gcc/algol68/a68-parser-prelude.cc 
b/gcc/algol68/a68-parser-prelude.cc
index 1184da333de..2916b2199ba 100644
--- a/gcc/algol68/a68-parser-prelude.cc
+++ b/gcc/algol68/a68-parser-prelude.cc
@@ -48,7 +48,7 @@
 
 static void
 add_a68_standenv (bool portable, int a, NODE_T* n, char *c, MOID_T *m,
-                 int p, LOWERER_T l = NO_LOWERER)
+                 int p, LOWERER_T l = LOWERER_UNIMPL)
 {
 #define INSERT_TAG(l, n) \
   do {                  \
@@ -119,7 +119,7 @@ a68_proc (MOID_T *m, ...)
 /* Enter an identifier in standenv.  */
 
 static void
-a68_idf (bool portable, const char *n, MOID_T *m, LOWERER_T l = NO_LOWERER)
+a68_idf (bool portable, const char *n, MOID_T *m, LOWERER_T l = LOWERER_UNIMPL)
 {
   add_a68_standenv (portable, IDENTIFIER,
                    a68_some_node (TEXT (a68_add_token (&A68 (top_token), n))),
@@ -144,13 +144,13 @@ a68_prio (const char *p, int b)
 {
   add_a68_standenv (true, PRIO_SYMBOL,
                    a68_some_node (TEXT (a68_add_token (&A68 (top_token), p))),
-                   NO_TEXT, NO_MOID, b, NO_LOWERER);
+                   NO_TEXT, NO_MOID, b, LOWERER_UNIMPL);
 }
 
 /* Enter operator in standenv.  */
 
 static void
-a68_op (bool portable, const char *n, MOID_T *m, LOWERER_T l = NO_LOWERER)
+a68_op (bool portable, const char *n, MOID_T *m, LOWERER_T l = LOWERER_UNIMPL)
 {
   add_a68_standenv (portable, OP_SYMBOL,
                    a68_some_node (TEXT (a68_add_token (&A68 (top_token), n))),
diff --git a/gcc/algol68/a68-types.h b/gcc/algol68/a68-types.h
index eaf8e1900f6..ad6b2a92260 100644
--- a/gcc/algol68/a68-types.h
+++ b/gcc/algol68/a68-types.h
@@ -151,7 +151,8 @@ typedef struct LOW_CTX_T LOW_CTX_T;
 /* Type of the lowerer routines defined in a68-low-prelude.cc.  */
 typedef tree (*LOWERER_T) (struct NODE_T *, struct LOW_CTX_T);
 
-#define NO_LOWERER a68_lower_unimplemented
+#define NO_LOWERER NULL
+#define LOWERER_UNIMPL a68_lower_unimplemented
 
 struct GTY((chain_next ("%h.more"), chain_prev ("%h.less"))) KEYWORD_T
 {
-- 
2.39.5

Reply via email to