aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2023-10-30 16:39:59 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2023-11-06 00:46:26 +0100
commit1000dde87131a77f456139bdf19e0a87b0776608 (patch)
tree503937fb0a6d5d6aa47a6e5d3be94c511c739286
parentHAdd sections to introspection documentation. (diff)
downloadcalp-1000dde87131a77f456139bdf19e0a87b0776608.tar.gz
calp-1000dde87131a77f456139bdf19e0a87b0776608.tar.xz
Merge (hnh module-introspection static) into parent module.
It only contained a single binding, and the base module was already utilities.
-rw-r--r--doc/ref/introspection.texi13
-rw-r--r--module/hnh/module-introspection.scm8
-rw-r--r--module/hnh/module-introspection/all-modules.scm1
-rw-r--r--module/hnh/module-introspection/static-util.scm9
-rw-r--r--module/scripts/module-dependants.scm1
-rw-r--r--module/scripts/module-imports.scm6
-rw-r--r--module/scripts/peg-to-graph.scm4
-rwxr-xr-xscripts/get-config.scm2
-rw-r--r--tests/unit/module-introspection/module-introspection.scm9
-rw-r--r--tests/unit/module-introspection/static-util.scm15
10 files changed, 29 insertions, 39 deletions
diff --git a/doc/ref/introspection.texi b/doc/ref/introspection.texi
index e1abcc84..8a51f3ad 100644
--- a/doc/ref/introspection.texi
+++ b/doc/ref/introspection.texi
@@ -26,6 +26,11 @@ Checks if @var{form} starts with @code{'define-module}.
In a list of forms, find the first one which satisfies @code{module-declarations?}.
@end defun
+@defun get-forms port
+Repeatadly call @code{read} on @var{port}, and return a list of the
+read forms in order of occurence in the file.
+@end defun
+
@node Module Uses
@section Module Uses
@@ -68,14 +73,6 @@ Note that if the module was imported multiple times then it will be
present multiple times in the list, possibly with different options.
@end defun
-@node Static Module Introspection Utilities
-@section Static Utilities
-
-@defun get-forms port
-Repeatadly call @code{read} on @var{port}, and return a list of the
-read forms in order of occurence in the file.
-@end defun
-
@node Finding all Modules in Directory
@section Finding all Modules in Directory
diff --git a/module/hnh/module-introspection.scm b/module/hnh/module-introspection.scm
index 83e561f1..254c33c7 100644
--- a/module/hnh/module-introspection.scm
+++ b/module/hnh/module-introspection.scm
@@ -4,6 +4,7 @@
:export (unique-symbols
find-module-declaration
module-declaration?
+ get-forms
))
@@ -20,3 +21,10 @@
(define (find-module-declaration forms)
(and=> (find module-declaration? forms)
cadr))
+
+(define (get-forms port)
+ (let loop ((done '()))
+ (let ((form (read port)))
+ (if (eof-object? form)
+ done
+ (loop (cons form done))))))
diff --git a/module/hnh/module-introspection/all-modules.scm b/module/hnh/module-introspection/all-modules.scm
index 5b4b37d2..3d202839 100644
--- a/module/hnh/module-introspection/all-modules.scm
+++ b/module/hnh/module-introspection/all-modules.scm
@@ -4,7 +4,6 @@
:use-module (ice-9 match)
:use-module (hnh util path)
:use-module (hnh module-introspection)
- :use-module ((hnh module-introspection static-util) :select (get-forms))
:export (all-files-and-modules-under-directory
all-files-under-directory
all-modules-under-directory
diff --git a/module/hnh/module-introspection/static-util.scm b/module/hnh/module-introspection/static-util.scm
deleted file mode 100644
index 7593ce3c..00000000
--- a/module/hnh/module-introspection/static-util.scm
+++ /dev/null
@@ -1,9 +0,0 @@
-(define-module (hnh module-introspection static-util)
- :export (get-forms))
-
-(define (get-forms port)
- (let loop ((done '()))
- (let ((form (read port)))
- (if (eof-object? form)
- done
- (loop (cons form done))))))
diff --git a/module/scripts/module-dependants.scm b/module/scripts/module-dependants.scm
index 6bda1917..f39c548d 100644
--- a/module/scripts/module-dependants.scm
+++ b/module/scripts/module-dependants.scm
@@ -15,7 +15,6 @@
:use-module (ice-9 format)
:use-module (texinfo string-utils)
:use-module (hnh module-introspection)
- :use-module ((hnh module-introspection static-util) :select (get-forms))
:export (main))
(define %summary "Print all modules which depend on module specified in target file.")
diff --git a/module/scripts/module-imports.scm b/module/scripts/module-imports.scm
index 7758c53a..39dc78da 100644
--- a/module/scripts/module-imports.scm
+++ b/module/scripts/module-imports.scm
@@ -13,8 +13,10 @@
(define-module (scripts module-imports)
:use-module ((srfi srfi-1) :select (lset-difference))
:use-module ((rnrs lists) :select (remp filter partition))
- :use-module ((hnh module-introspection) :select (module-declaration? unique-symbols))
- :use-module ((hnh module-introspection static-util) :select (get-forms))
+ :use-module ((hnh module-introspection)
+ :select (module-declaration?
+ unique-symbols
+ get-forms))
:use-module ((hnh module-introspection module-uses) :select (module-uses*))
:export (main)
)
diff --git a/module/scripts/peg-to-graph.scm b/module/scripts/peg-to-graph.scm
index afd7a4c3..82974042 100644
--- a/module/scripts/peg-to-graph.scm
+++ b/module/scripts/peg-to-graph.scm
@@ -1,7 +1,7 @@
(define-module (scripts peg-to-graph)
:use-module ((graphviz) :prefix #{gv:}#)
- :use-module ((hnh module-introspection) :select (unique-symbols))
- :use-module ((hnh module-introspection static-util) :select (get-forms))
+ :use-module ((hnh module-introspection)
+ :select (unique-symbols get-forms))
:use-module (srfi srfi-1)
:use-module (ice-9 match)
:use-module (hnh util options)
diff --git a/scripts/get-config.scm b/scripts/get-config.scm
index 99204941..69fdcea7 100755
--- a/scripts/get-config.scm
+++ b/scripts/get-config.scm
@@ -19,7 +19,7 @@
(hnh module-introspection all-modules)
(hnh module-introspection module-introspection)
- ((hnh module-introspection static-util)
+ ((hnh module-introspection)
:select (get-forms))
((calp translation)
diff --git a/tests/unit/module-introspection/module-introspection.scm b/tests/unit/module-introspection/module-introspection.scm
index 48e1fbac..f51aacde 100644
--- a/tests/unit/module-introspection/module-introspection.scm
+++ b/tests/unit/module-introspection/module-introspection.scm
@@ -16,4 +16,13 @@
:export (nothing))
(define nothing '()))))
+(test-equal "All forms"
+ '((define (f x)
+ (* x 2))
+ (define-module (a)
+ :use-module (srfi srfi-1)
+ :export (f)))
+ (call-with-input-file "tests/test-module-tree/a.scm" get-forms))
+
+
'((hnh module-introspection))
diff --git a/tests/unit/module-introspection/static-util.scm b/tests/unit/module-introspection/static-util.scm
deleted file mode 100644
index f9b7e17e..00000000
--- a/tests/unit/module-introspection/static-util.scm
+++ /dev/null
@@ -1,15 +0,0 @@
-(define-module (test module-introspection static-util)
- :use-module (srfi srfi-64)
- :use-module (srfi srfi-88)
- :use-module (hnh module-introspection static-util))
-
-(test-equal "All forms"
- '((define (f x)
- (* x 2))
- (define-module (a)
- :use-module (srfi srfi-1)
- :export (f)))
- (call-with-input-file "tests/test-module-tree/a.scm" get-forms))
-
-
-'((hnh module-introspection static-util))