>From 1a2be190dfcd0512fba59de6c8a569e384e6fbc1 Mon Sep 17 00:00:00 2001 From: Peter Bex Date: Sun, 10 Aug 2014 15:00:13 +0200 Subject: [PATCH 02/19] compiler-modules: Convert batch-driver to a module For now, we use "batch-driver" as the module name, to make things simple. Originally, it looks like the idea was that you can have other kinds of drivers, like an interactive one or a staged one, or one used through the interpreter. We can try to do this through the use of functors, perhaps. This makes things simpler for us: Now we can just append .import.scm to the filename in the build system. The unit now also has the same name as the module, which may be undone when we add a functor and an implementation selection mechanism. Add a few missing names to compiler-namespace which would otherwise be undefined within batch-driver. The apply-test was using "printf" in a macro, which happened to be available when running inside the compiler due to namespace leakage, which is now fixed through proper module usage. It now cleanly imports extras, which provides the printf procedure. --- batch-driver.scm | 20 ++++++++++++++++++-- chicken.scm | 6 ++++-- compiler-namespace.scm | 6 ++++++ rules.make | 7 ++++++- tests/apply-test.scm | 2 +- 5 files changed, 35 insertions(+), 6 deletions(-) diff --git a/batch-driver.scm b/batch-driver.scm index 9ae5f68..015ef8e 100644 --- a/batch-driver.scm +++ b/batch-driver.scm @@ -24,11 +24,26 @@ ; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ; POSSIBILITY OF SUCH DAMAGE. - +;; TODO: Rename batch-driver back to "driver" and turn it into a +;; functor? This may require the creation of an additional file. +;; Same goes for "backend" and "platform". (declare - (unit driver)) + (unit batch-driver) + (uses extras data-structures files srfi-1) ) +;; TODO: Remove these once everything's converted to modules +(include "private-namespace") (include "compiler-namespace") + +(module batch-driver + (compile-source-file + + user-options-pass user-read-pass user-preprocessor-pass user-pass + user-post-analysis-pass) + +(import (except chicken put! get quit syntax-error) scheme + extras data-structures files srfi-1) + (include "tweaks") (define-constant funny-message-timeout 60000) @@ -680,3 +695,4 @@ (##sys#display-times (##sys#stop-timer))) (compiler-cleanup-hook) (dribble "compilation finished.") ) ) ) ) ) ) ) ) ) ) ) ) +) \ No newline at end of file diff --git a/chicken.scm b/chicken.scm index 3e0343a..372adaa 100644 --- a/chicken.scm +++ b/chicken.scm @@ -28,13 +28,15 @@ (declare (uses chicken-syntax chicken-ffi-syntax srfi-1 srfi-4 utils files extras data-structures support - compiler optimizer lfa2 compiler-syntax scrutinizer driver platform backend + compiler optimizer lfa2 compiler-syntax scrutinizer + ;; TODO: These three need to be made configurable somehow + batch-driver platform backend srfi-69)) (include "compiler-namespace") (include "tweaks") - +(import batch-driver) ;;; Prefix argument list with default options: diff --git a/compiler-namespace.scm b/compiler-namespace.scm index 7af9593..f39ee3e 100644 --- a/compiler-namespace.scm +++ b/compiler-namespace.scm @@ -131,6 +131,7 @@ export-dump-hook export-variable expression-has-side-effects? + extended-bindings external-protos-first external-to-pointer external-variables @@ -211,12 +212,15 @@ enable-module-registration no-procedure-checks node->sexpr + node-subexpressions non-foldable-bindings nonwinding-call/cc optimization-iterations + optimize-leaf-routines original-program-size output parameter-limit + parenthesis-synonyms pending-canonicalizations perform-closure-conversion perform-cps-conversion @@ -273,6 +277,7 @@ source-info->line specialize-node! standalone-executable + standard-bindings strict-variable-types string->c-identifier string->expr @@ -292,6 +297,7 @@ unit-name units-used-by-default unlikely-variables + unsafe update-line-number-database update-line-number-database! used-units diff --git a/rules.make b/rules.make index 4269980..ee3c74e 100644 --- a/rules.make +++ b/rules.make @@ -492,6 +492,11 @@ endef $(foreach lib, $(SETUP_API_OBJECTS_1),\ $(eval $(call declare-emitted-import-lib-dependency,$(lib)))) +$(foreach lib, $(filter batch-driver,$(COMPILER_OBJECTS_1)),\ + $(eval $(call declare-emitted-import-lib-dependency,$(lib)))) + +chicken.scm: batch-driver.import.scm batch-driver.scm + define profile-flags $(if $(filter $(basename $(1)),$(PROFILE_OBJECTS)),-profile) endef @@ -568,7 +573,7 @@ $(foreach obj, $(IMPORT_LIBRARIES),\ define declare-bootstrap-compiler-object $(1).c: $$(SRCDIR)$(1).scm $$(SRCDIR)compiler-namespace.scm \ $$(SRCDIR)private-namespace.scm $$(SRCDIR)tweaks.scm - $$(CHICKEN) $$< $$(CHICKEN_COMPILER_OPTIONS) -output-file $$@ + $$(CHICKEN) $$< $$(CHICKEN_COMPILER_OPTIONS) -emit-import-library $(1) -output-file $$@ endef $(foreach obj, $(COMPILER_OBJECTS_1),\ diff --git a/tests/apply-test.scm b/tests/apply-test.scm index 81697a5..155aa70 100644 --- a/tests/apply-test.scm +++ b/tests/apply-test.scm @@ -1,4 +1,4 @@ -(require-extension srfi-1) +(require-extension srfi-1 extras) (define max-argcount ##sys#apply-argument-limit) -- 1.7.10.4