[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[COMMITTED] pkl: support for re-definition of types
From: |
Jose E. Marchesi |
Subject: |
[COMMITTED] pkl: support for re-definition of types |
Date: |
Sun, 23 Jan 2022 22:38:42 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Now it is also allowed to load the same module more than once.
2022-01-23 Jose E. Marchesi <jemarch@gnu.org>
* libpoke/pkl-env.c (_decl): Allow re-registering types.
* libpoke/pkl-tab.y (load_module): Allow loading the same module
more than once.
* libpoke/pkl.c (pkl_add_module): Do not add module to the list if
it is already loaded.
* testsuite/poke.pkl/load-3.pk: Remove test.
* testsuite/Makefile.am (EXTRA_DIST): Remove test load-3.pk.
---
ChangeLog | 6 ++++++
libpoke/pkl-env.c | 2 --
libpoke/pkl-tab.y | 7 -------
libpoke/pkl.c | 3 +++
testsuite/Makefile.am | 1 -
testsuite/poke.pkl/load-3.pk | 13 -------------
6 files changed, 9 insertions(+), 23 deletions(-)
delete mode 100644 testsuite/poke.pkl/load-3.pk
diff --git a/ChangeLog b/ChangeLog
index 3b558bdd..83ff9767 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,12 @@
2022-01-23 Jose E. Marchesi <jemarch@gnu.org>
* libpoke/pkl-env.c (_decl): Allow re-registering types.
+ * libpoke/pkl-tab.y (load_module): Allow loading the same module
+ more than once.
+ * libpoke/pkl.c (pkl_add_module): Do not add module to the list if
+ it is already loaded.
+ * testsuite/poke.pkl/load-3.pk: Remove test.
+ * testsuite/Makefile.am (EXTRA_DIST): Remove test load-3.pk.
2022-01-23 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
diff --git a/libpoke/pkl-env.c b/libpoke/pkl-env.c
index 65112238..6eabcf6f 100644
--- a/libpoke/pkl-env.c
+++ b/libpoke/pkl-env.c
@@ -139,8 +139,6 @@ register_decl (int top_level_p,
found_decl = get_registered (hash_table, name);
if (found_decl != NULL)
{
- int decl_kind = PKL_AST_DECL_KIND (decl);
-
if (top_level_p)
{
pkl_ast_node decl_name = PKL_AST_DECL_NAME (found_decl);
diff --git a/libpoke/pkl-tab.y b/libpoke/pkl-tab.y
index c89e2b9c..1cc5df36 100644
--- a/libpoke/pkl-tab.y
+++ b/libpoke/pkl-tab.y
@@ -296,13 +296,6 @@ load_module (struct pkl_parser *parser,
/* No file found. */
return 1;
- if (pkl_module_loaded_p (parser->compiler, module_filename))
- {
- /* Module already loaded. */
- *node = NULL;
- return 0;
- }
-
fp = fopen (module_filename, "rb");
if (!fp)
{
diff --git a/libpoke/pkl.c b/libpoke/pkl.c
index c5e68718..e912df99 100644
--- a/libpoke/pkl.c
+++ b/libpoke/pkl.c
@@ -634,6 +634,9 @@ pkl_add_module (pkl_compiler compiler, const char *path)
{
const char *module = last_component (path);
+ if (pkl_module_loaded_p (compiler, path))
+ return;
+
if (compiler->num_modules % PKL_MODULES_STEP == 0)
{
size_t size = ((compiler->num_modules + PKL_MODULES_STEP)
diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am
index aad19c19..66f537de 100644
--- a/testsuite/Makefile.am
+++ b/testsuite/Makefile.am
@@ -1397,7 +1397,6 @@ EXTRA_DIST = \
poke.pkl/lex-3.pk \
poke.pkl/load-1.pk \
poke.pkl/load-2.pk \
- poke.pkl/load-3.pk \
poke.pkl/load-4.pk \
poke.pkl/load-5.pk \
poke.pkl/load-diag-1.pk \
diff --git a/testsuite/poke.pkl/load-3.pk b/testsuite/poke.pkl/load-3.pk
deleted file mode 100644
index b90af67e..00000000
--- a/testsuite/poke.pkl/load-3.pk
+++ /dev/null
@@ -1,13 +0,0 @@
-/* { dg-do run } */
-/* { dg-data {a*} {foo = foo + 1;} foo.pk } */
-
-/* Check that foo.pk is not loaded twice. */
-
-var foo = 0;
-
-/* { dg-command { load foo } } */
-/* { dg-command { foo } } */
-/* { dg-output "1" } */
-/* { dg-command { load foo } } */
-/* { dg-command { foo } } */
-/* { dg-output "\n1" } */
--
2.11.0
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [COMMITTED] pkl: support for re-definition of types,
Jose E. Marchesi <=