]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
a68: distinguish between NO_LOWERER and LOWERER_UNIMPL
authorJose E. Marchesi <jemarch@gnu.org>
Thu, 19 Feb 2026 02:46:57 +0000 (03:46 +0100)
committerJose E. Marchesi <jemarch@gnu.org>
Sat, 21 Feb 2026 19:07:23 +0000 (20:07 +0100)
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 <jemarch@gnu.org>
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
gcc/algol68/a68-parser-prelude.cc
gcc/algol68/a68-types.h

index b4ce00a24f7844d0f2422f2418b10c14432d3e76..e9660d750dd6f7d1bc60f28aba4fe4868adef56f 100644 (file)
 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
index 1184da333de89bcb5cc496301885a0473bb1f55f..2916b2199ba9b2826d0ab866c8ee78fc84caf1fb 100644 (file)
@@ -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))),
index eaf8e1900f620ff8f683c5e504fc728f1ed2c13a..ad6b2a92260985fabc1a5097f99caa97d4925e7c 100644 (file)
@@ -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
 {