mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 03:40:34 +02:00
* ice-9/boot-9.scm (compile-time-environment): Remove definition from boot-9 -- instead, autoload it and `compile' from (system base compile). * libguile/objcodes.h: * libguile/objcodes.c (scm_objcode_to_program): Add an optional argument, `external', the external list to set on the returned program. * libguile/vm-i-system.c (externals): New instruction, returns the external list. Only used by (compile-time-environment). * libguile/vm.c (scm_load_compiled_with_vm): Adapt to scm_objcode_to_program change. * module/language/scheme/translate.scm (translate): Actually pay attention to the environment passed as an argument. (custom-transformer-table): Expand out (compile-time-environment) to something that can be passed to `compile'. * module/system/base/compile.scm (*current-language*): Instead of hard-coding `scheme' in various places, use a current language fluid, initialized to `scheme'. (compile-file, load-source-file): Adapt to *current-language*. (load-source-file): Ada (scheme-eval): Removed, no one used this. (compiled-file-name): Don't hard-code "scm" and "go"; instead use the %load-extensions and %load-compiled-extensions. (cenv-module, cenv-ghil-env, cenv-externals): Some accessors for compile-time environments. (compile-time-environment): Here we define (compile-time-environment) to something that will return #f; the compiler however produces different code as noted above. (compile): New function, compiles an expression into a thunk, then runs the thunk to get the value. Useful for procedures. The optional second argument can be either a module or a compile-time-environment; in the latter case, we can recompile even with lexical bindings. (compile-in): If the env specifies a module, set that module for the duration of the compilation. * module/system/base/syntax.scm (%compute-initargs): Fix a bug where the default value for a field would always replace a user-supplied value. Whoops. * module/system/il/ghil.scm (ghil-env-dereify): New function, takes the result of ghil-env-reify and turns it back into a GHIL environment. * scripts/compile (compile): Remove some of the tricky error handling, as the library procedures handle this for us. * test-suite/tests/compiler.test: Add a test for the dynamic compilation bits.
76 lines
2.7 KiB
Scheme
Executable file
76 lines
2.7 KiB
Scheme
Executable file
#!/bin/sh
|
|
# -*- scheme -*-
|
|
exec ${GUILE-guile} -e '(@ (scripts compile) compile)' -s $0 "$@"
|
|
!#
|
|
;;; Compile --- Command-line Guile Scheme compiler
|
|
|
|
;; Copyright 2005,2008 Free Software Foundation, Inc.
|
|
;;
|
|
;; This program is free software; you can redistribute it and/or
|
|
;; modify it under the terms of the GNU General Public License as
|
|
;; published by the Free Software Foundation; either version 2, or
|
|
;; (at your option) any later version.
|
|
;;
|
|
;; This program is distributed in the hope that it will be useful,
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
;; General Public License for more details.
|
|
;;
|
|
;; You should have received a copy of the GNU General Public License
|
|
;; along with this software; see the file COPYING. If not, write to
|
|
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
;; Boston, MA 02110-1301 USA
|
|
|
|
;;; Author: Ludovic Courtès <ludovic.courtes@laas.fr>
|
|
;;; Author: Andy Wingo <wingo@pobox.com>
|
|
|
|
;;; Commentary:
|
|
|
|
;; Usage: compile [ARGS]
|
|
;;
|
|
;; PROGRAM does something.
|
|
;;
|
|
;; TODO: Write it!
|
|
|
|
;;; Code:
|
|
|
|
(define-module (scripts compile)
|
|
#:use-module (system base compile)
|
|
#:use-module (ice-9 getopt-long)
|
|
#:export (compile))
|
|
|
|
(define %options
|
|
'((help (single-char #\h) (value #f))
|
|
(optimize (single-char #\O) (value #f))
|
|
(expand-only (single-char #\e) (value #f))
|
|
(translate-only (single-char #\t) (value #f))
|
|
(compile-only (single-char #\c) (value #f))))
|
|
|
|
(define (compile args)
|
|
(let* ((options (getopt-long args %options))
|
|
(help? (option-ref options 'help #f))
|
|
(optimize? (option-ref options 'optimize #f))
|
|
(expand-only? (option-ref options 'expand-only #f))
|
|
(translate-only? (option-ref options 'translate-only #f))
|
|
(compile-only? (option-ref options 'compile-only #f)))
|
|
(if help?
|
|
(begin
|
|
(format #t "Usage: compile [OPTION] FILE...
|
|
Compile each Guile Scheme source file FILE into a Guile object.
|
|
|
|
-h, --help print this help message
|
|
-O, --optimize turn on optimizations
|
|
-e, --expand-only only go through the code expansion stage
|
|
-t, --translate-only stop after the translation to GHIL
|
|
-c, --compile-only stop after the compilation to GLIL
|
|
|
|
Report bugs to <guile-user@gnu.org>.~%")
|
|
(exit 0)))
|
|
|
|
(let ((compile-opts (append (if optimize? '(#:O) '())
|
|
(if expand-only? '(#:e) '())
|
|
(if translate-only? '(#:t) '())
|
|
(if compile-only? '(#:c) '()))))
|
|
(for-each (lambda (file)
|
|
(apply compile-file file compile-opts))
|
|
(option-ref options '() '())))))
|