1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00
Commit graph

11164 commits

Author SHA1 Message Date
Andy Wingo
6fd367e742 tweaks to autocompile code
* libguile/load.c (compiled_is_newer): Tweak diagnostic output.
  (do_try_autocompile, autocompile_catch_handler, scm_try_autocompile):
  Rework to compute the name of the compiled file in advance. If the
  computed name is different from the found .go file and is fresh, use it
  directly.

  Fixes the case where /usr/lib/.../foo.go is out of date but the user
  doesn't have permissions to recompile, so we use the user's local
  compile cache instead if it's fresh.

  (scm_primitive_load): Pass the found .go file as well to
  scm_try_autocompile.
2009-06-03 23:20:44 +02:00
Andy Wingo
ee00175026 implement autocompilation
* am/guilec (.scm.go): Set GUILE_AUTO_COMPILE=0 when compiling individual
  files, and remove the mkdir -p as compile-file takes care of that now.

* libguile/load.c (do_try_autocompile, autocompile_catch_handler)
  (scm_try_autocompile, scm_init_load): Implement autocompilation.

* libguile/script.c (scm_shell_usage, scm_compile_shell_switches): Add
  --autocompile / --no-autocompile command-line options, and support for
  the GUILE_AUTO_COMPILE environment variable, defaulting to
  autocompilation enabled.
2009-06-03 22:20:55 +02:00
Andy Wingo
0fb81f95b0 add exception_on_error optional arg to primitive-load-path
* libguile/init.c (scm_load_startup_files): Use
  scm_c_primitive_load_path.

* libguile/load.c (scm_primitive_load_path): Add an optional arg,
  exception_on_error, which if #f will cause primitive-load-path to just
  return #f if no file is found. This is to help out the semantics of
  try-module-autoload. We can't just catch misc-error, because loading
  the file could raise any exception.
  (scm_c_primitive_load_path): Add the extra arg to
  scm_primitive_load_path.

* libguile/load.h: Adapt scm_primitive_load_path prototype.

* module/ice-9/boot-9.scm (try-module-autoload): Refactor slightly to be
  clearer.
2009-06-03 22:20:55 +02:00
Andy Wingo
1d022387c8 refactors to load.c to support auto-compilation
* libguile/load.c (compiled_is_newer): Factored out of
  scm_primitive_load_path.
  (scm_try_autocompile): New stub, for autocompiling. Currently just
  returns false.
  (scm_primitive_load_path): Refactor, and call out to
  scm_try_autocompile if the .go is missing or not fresh.
2009-06-03 22:20:55 +02:00
Andy Wingo
f3130a2ecf compiled-file-name tries to put the .go in the %load-compiled-path
* module/system/base/compile.scm (ensure-writable-dir): Rename from
  ensure-directory.
  (dsu-sort): Helper, does a decorate / sort / undecorate.
  (compiled-file-name): Refactor to only return a writable filename. The
  readable case is handled by load.c now, and the other case was silly.
  Hopefully it will do the right thing.
  (load-ensuring-compiled): Remove, load.c will call out to compile-file
  if necessary.
  (ensure-fallback-path): Remove, load.c will add the ~/.guile-ccache dir
  to the load-compiled path, which will prompt its creation if necessary.
2009-06-03 22:20:55 +02:00
Andy Wingo
4c9c9b9b98 install .go files under $libdir, not $datadir
* am/guilec: Install .go files to
  $(pkglibdir)/$GUILE_EFFECTIVE_VERSION/ccache.
2009-06-03 22:20:55 +02:00
Andy Wingo
727c259ac5 file-exists? doesn't cause a throw, simpler try-module-autoload
* module/ice-9/boot-9.scm (file-exists?): Change to use the stat
  interface that doesn't throw exceptions.
  (try-module-autoload): Simplify to take advantage of the fact that
  primitive-load-path does the right thing with regards to loading
  compiled files if they are available.
2009-06-03 22:20:55 +02:00
Andy Wingo
d1e47c6e6c update uninstalled-env.in for load-compiled path separation
* meta/uninstalled-env.in: Update to set GUILE_LOAD_COMPILED_PATH and
  GUILE_SYSTEM_COMPILED_PATH.
2009-06-03 22:20:55 +02:00
Andy Wingo
fcb6f5ff33 add exception-on-error optional arg to `stat' in scheme
* libguile/filesys.h:
* libguile/filesys.c (scm_stat): Add optional arg, exception-on-error,
  which if #f (not the default) will just return #f instead of raising an
  exception if the stat fails.
2009-06-03 22:20:55 +02:00
Andy Wingo
5b197db838 separate the load-compiled path from the load path
* libguile/Makefile.am (libpath.h): Add definitions for SCM_CCACHE_DIR
  and SCM_EFFECTIVE_VERSION. These are private, the header is not
  installed. Add ccachedir to build-info. Rework some other build-info
  definitions.

* libguile/load.c (scm_loc_load_compiled_path): New global, corresponding
  to the new environment variable, GUILE_LOAD_COMPILED_PATH. Compiled
  files will now be searched for in this path, and only in this path.
  (scm_init_load_path): Init the load-compiled path too. We initialize it
  with $pkglibdir/guile/$effective_version/ccache, and also with
  $HOME/.guile-ccache/$effective_version/. This will respect the
  libdir/datadir difference, and it is a preparation for automatic
  compilation support.
  (scm_primitive_load_path): Search only the GUILE_LOAD_COMPILED_PATH for
  compiled files.
  (scm_init_load): Cache scm_loc_load_compiled_path.
2009-06-03 22:20:54 +02:00
Julian Graham
2f9ae9b104 Merge branch 'master' of git://git.savannah.gnu.org/guile 2009-06-02 09:35:02 -04:00
Julian Graham
922d417bf4 Implementation of SRFI-98 (An interface to access environment variables).
* NEWS: Add SRFI-98 to 1.8.7 features.

* doc/ref/srfi-modules.text (SRFI-98): Documentation for SRFI-98.

* module/srfi/srfi-98.scm: New file.  SRFI-98 implementation.

* test-suite/tests/srfi-98.test: New file.  SRFI-98 unit tests.
2009-05-30 21:19:59 -04:00
Andy Wingo
938d46a35d Merge branch 'syncase-in-boot-9'
Conflicts:
	module/Makefile.am
2009-05-29 16:01:43 +02:00
Ludovic Courtès
1ee2c72eaf Import R6RS bytevectors and I/O ports from Guile-R6RS-Libs 0.2.
* README: Document dependency on GNU libunistring.

* benchmark-suite/Makefile.am (SCM_BENCHMARKS): Add
  `benchmark/bytevectors.bm'.

* configure.in: Make sure we have libunistring; update $LIBS.

* libguile.h: Include "bytevectors.h" and "r6rs-ports.h".

* libguile/Makefile.am (libguile_la_SOURCES): Add `bytevectors.c' and
  `r6rs-ports.c'
  (DOT_X_FILES): Add `bytevectors.x' and `r6rs-ports.x'.
  (DOT_DOC_FILES): Add `bytevectors.doc' and `r6rs-ports.doc'.
  (noinst_HEADERS): Add `ieee-754.h'.
  (modinclude_HEADERS): Add `bytevectors.h' and `r6rs-ports.h'

* libguile/validate.h (SCM_VALIDATE_BYTEVECTOR): New macro.

* module/Makefile.am (SOURCES): Add $(RNRS_SOURCES).
  (RNRS_SOURCES): New variable.

* test-suite/Makefile.am (SCM_TESTS): Add `bytevectors.test' and
  `r6rs-ports.test'.
2009-05-28 23:12:01 +02:00
Ludovic Courtès
24d56127bb Use GNU libunistring and Gnulib modules needed by R6RS bytevectors and ports.
* m4/gnulib-cache.m4 (gl_MODULES): Add `byteswap', `iconv_open-utf',
  `libunistring', `striconveh', and `string'.
2009-05-28 23:12:00 +02:00
Andy Wingo
e3c5df5396 add tests for #' etc
* test-suite/tests/reader.test ("#'"): Add tests for the hash-syntax
  reader macros.
2009-05-28 15:01:30 +02:00
Andy Wingo
6ed0c41a2d add reader tests for #;
* test-suite/tests/reader.test ("#;"): Add reader tests for #;.
2009-05-28 14:59:47 +02:00
Andy Wingo
34f3d47df9 add reader support for #; #` #' #, and #,@. fix bug in compile-and-load.
* libguile/read.c (flush_ws, scm_read_commented_expression)
  (scm_read_sharp): Add support for commenting out expressions with #;.
  (scm_read_syntax, scm_read_sharp): Add support for #', #`, #, and #,@.

* module/ice-9/boot-9.scm: Remove #' read-hash extension, which actually
  didn't do anything at all. It's been there since 1997, but no Guile
  code I've ever seen uses it, and it conflicts with #'x => (syntax x)
  from modern Scheme.

* module/system/base/compile.scm (compile-and-load): Whoops, fix a number
  of bugs here.
2009-05-28 14:49:33 +02:00
Neil Jerram
21346c4f5e Remove possible deadlock in scm_join_thread_timed
* libguile/threads.c (scm_join_thread_timed): Recheck t->exited before
  looping round to call block_self again, in case thread t has now
  exited.

* test-suite/tests/threads.test ("don't hang when joined thread
  terminates in SCM_TICK"): New test.
2009-05-27 22:43:24 +01:00
Neil Jerram
4201062de5 Fix wait-condition-variable so that it doesn't leave asyncs blocked
* libguile/threads.c (fat_mutex_unlock): Unblock asyncs when breaking
  out of loop.

* test-suite/tests/threads.test (asyncs-still-working?): New function,
  to test if asyncs are working (i.e. unblocked).  Use this throughout
  threads.test, in particular before and after the "timed locking
  succeeds if mutex unlocked within timeout" test.
2009-05-27 22:43:24 +01:00
Andy Wingo
560b9c256d adjust VM copyright notices to LGPL, use SCM_INTERNAL/API properly
* libguile/frames.c:
* libguile/frames.h:
* libguile/instructions.c:
* libguile/instructions.h:
* libguile/objcodes.c:
* libguile/objcodes.h:
* libguile/programs.c:
* libguile/programs.h:
* libguile/vm-bootstrap.h:
* libguile/vm-engine.c:
* libguile/vm-engine.h:
* libguile/vm-expand.h:
* libguile/vm-i-scheme.c:
* libguile/vm.c:
* libguile/vm.h: Update to use SCM_API and SCM_INTERNAL correctly. Adjust
  copyright to be the same as the copyright of Guile itself, which should
  be fine given that the FSF holds the whole thing.
2009-05-26 22:23:44 +02:00
Andy Wingo
1351c2dba5 fix backtraces with compiled boot-9
* module/ice-9/boot-9.scm (default-pre-unwind-handler): Since we were
  tail-called by pre-unwind-handler-dispatch, we can't use
  pre-unwind-handler-dispatch as a narrowing argument. Instead just
  narrow by one frame.
  (pre-unwind-handler-dispatch): Deprecate.
  (error-catching-loop): Remove crack comment and code, and just use
  default-pre-unwind-handler as our pre-unwind handler.

* module/ice-9/stack-catch.scm (stack-catch):
* module/system/repl/repl.scm (call-with-backtrace): Use
  default-pre-unwind-handler directly.
2009-05-26 21:51:42 +02:00
Andy Wingo
b579617b2d gnulib-tool --import environ; rely on gnulib for environ definitions
* libguile/posix.c:
* libguile/stime.c: Remove environ definition, gnulib provides it now.
2009-05-26 18:14:54 +02:00
Andy Wingo
442f3f20dd symbols are now hidden unless explicitly exported by SCM_API
* libguile/__scm.h (SCM_API, SCM_INTERNAL): Take the reverse strategy: symbols will
  be hidden by default, and only exported with SCM_API. In addition to working
  on Mac OS, it has the several nice efficiency benefits on Linux, and unifies
  codepaths with Win32.

* libguile/Makefile.am: Define BUILDING_LIBGUILE when building Guile.
2009-05-26 17:46:03 +02:00
Andy Wingo
d9a9e18205 gnulib-tool --import lib-symbol-visibility 2009-05-26 17:45:48 +02:00
Andy Wingo
9d07bb7276 distcheck fix, fix (ice-9 time)
* lang/Makefile.am (elisp_sources): Add elisp/expand.scm.

* module/ice-9/time.scm (time): Fix for new macro expander. Ew.
2009-05-26 16:03:37 +02:00
Andy Wingo
7364333952 update docs -- sections on assembly and objcode
* doc/ref/api-procedures.texi:
* doc/ref/compiler.texi:
* doc/ref/vm.texi: Update the docs some more.
2009-05-25 22:45:42 +02:00
Andy Wingo
81fd315299 update docs, clean up VM vestiges, macro docs, fix (/ a b c)
* doc/ref/api-procedures.texi (Compiled Procedures): Fix for API changes.

* doc/ref/compiler.texi (Compiling to the Virtual Machine): Replace GHIL
  docs with Tree-IL docs. Update the bits about the Scheme compiler to
  talk about Tree-IL and the expander instead of GHIL. Remove
  <glil-argument>. Add placeholder sections for assembly and bytecode.

* doc/ref/vm.texi: Update examples with what currently happens. Reword
  some things. Fix a couple errors.

* libguile/vm-i-system.c (externals): Remove this instruction, it's not
  used.

* module/ice-9/documentation.scm (object-documentation): If the object is
  a macro, try to return documentation on the macro transformer.

* module/language/assembly/disassemble.scm (disassemble-load-program):
  Fix problem in which we skipped the first element of the object vector,
  because of changes to procedure layouts a few months ago.

* module/language/scheme/spec.scm (read-file): Remove read-file
  definition.

* module/language/tree-il.scm: Reorder exports. Remove <lexical>, it was
  a compat shim to something that was never released. Fix `location'.

* module/language/tree-il/primitives.scm (/): Fix expander for more than
  two args to /.

* module/system/base/compile.scm (read-file-in): Remove unused
  definition.

* module/system/base/language.scm (system): Remove language-read-file.

* module/language/ecmascript/spec.scm (ecmascript): Remove read-file
  definition.
2009-05-24 13:09:01 +02:00
Ludovic Courtès
de784acd87 Rewrite SRFI-35 macros using `syntax-rules'.
* module/srfi/srfi-35.scm: Use `(ice-9 syncase)'.
  (define-condition-type, condition): Rewritten using `syntax-rules'.
  (compound-condition, condition-instantiation): New helper internal
  macros.  Thanks to Andy Wingo for his help!
2009-05-22 23:44:43 +02:00
Andy Wingo
a755136ba8 fix (oop goops) compilation for (language tree-il primitives)
* module/oop/goops.scm (compile): Whoop-dee, fix up (oop goops) for
  (language tree-il primitives) change.
2009-05-22 21:14:48 +02:00
Andy Wingo
0e7b72a8fe source location tracking in psyntax, booya!
* module/ice-9/psyntax.scm (source-annotation): Return #f if
  source-properties returns null.
  (source-wrap): Rework a bit.
  (syntax-type): Don't throw away source info for wrapped expressions.
  Can has source location info, fools!
  (chi-body): Correctly propagate source info for body subforms.
  (syntax): Remove special case for map, it doesn't apply (ahem) for
  Guile.

* module/ice-9/psyntax-pp.scm: Regenerate.
2009-05-22 21:12:42 +02:00
Andy Wingo
b40d023067 remove annotations in psyntax in favor of guile's source properties
* module/ice-9/psyntax.scm: Remove references to annotation objects,
  we're just going to try and use Guile's source properties now. It works
  until `syntax' reconstructs output, at which point it seems we lose it.

* module/ice-9/psyntax-pp.scm: Regenerated.
2009-05-22 19:48:14 +02:00
Andy Wingo
39a2eca2ce fix problem naming internal definitions
* module/ice-9/psyntax.scm (chi-body): Fix a problem introduced in
  dc1eed52f7, that internal syntax definitions were included in the id
  lis along with value definitions. Only showed up on a second bootstrap.
  Psyntax, how I love thee.

* module/ice-9/psyntax-pp.scm
2009-05-22 19:26:58 +02:00
Andy Wingo
55ae815b62 move things to (language tree-il primitives)
* module/language/tree-il/optimize.scm:
* module/language/tree-il/primitives.scm: Move primitive-related things
  to primitive.scm from inline.scm and optimize.scm.

* module/Makefile.am: Update for inventory changes.
2009-05-22 16:07:41 +02:00
Andy Wingo
e0c90f9084 fix tree-il test to work if source info happens to be present
* module/language/tree-il/compile-glil.scm (flatten-lambda): Fix source
  emission.

* test-suite/tests/tree-il.test (strip-source): Strip source info on
  tree-il before compiling, so we don't get extraneous source info in the
  glil. Make check passes!
2009-05-22 13:00:23 +02:00
Andy Wingo
e6b9443179 fix bad call to make-glil-src
* module/language/tree-il/compile-glil.scm (flatten-lambda): Fix bad call
  to make-glil-src, unfortunately not hit during production because
  psyntax doesn't yet understand source locations.
2009-05-22 12:48:45 +02:00
Andy Wingo
7902c54713 fix expansion of (ice-9 threads)
* module/ice-9/threads.scm: Move syntax definitions before the procedures
  that use them, and rewrite as hygienic macros since they are so much
  nicer that way. Fixes the thread tests.
2009-05-22 12:45:49 +02:00
Andy Wingo
9ecac781bf syntax.test is passing, yay
* test-suite/tests/syntax.test ("top-level define"): Remove the test for
  currying, as we don't do that any more by default. It should be easy
  for the user to add in if she wants it, though.
  ("do"): Remove unmemoization tests, as sc-expand fully expands `do'.
  ("while"): Remove while tests in empty environments. They have been
  throwing 'unresolved, and the problem they seek to test is fully
  handled by hygiene anyway.

  And otherwise tweak expected exception strings, and everything passes!
2009-05-22 12:22:39 +02:00
Andy Wingo
dc1eed52f7 residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
  from the SRFI itself. Yuk.
  (%print-module, make-modules-in, %app, (%app modules))
  (module-name): Syncase needs to get at the names of modules, even at
  anonymous modules. So lazily assign gensyms as module names. Name %app
  as (%app), but since (%app modules) is at the top of the module
  hierarchy, name it ().

* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
  definitions and in lets.
  (let, letrec): Give more specific errors in a couple of cases.

* module/ice-9/psyntax-pp.scm: Regenerated.

* test-suite/tests/syntax.test: More work. Many exceptions have different
  messages than they used to, many more generic; we can roll this back to
  be faithful to the original strings, but it doesn't seem necessary to
  me.
2009-05-22 12:08:50 +02:00
Andy Wingo
0260421208 some work on syntax.test
* module/language/tree-il.scm (tree-il->scheme):
* module/ice-9/psyntax.scm (build-conditional): Attempt to not generate
  (if #f #f) as the second arm of an if, but it doesn't seem to be
  successful.

* module/ice-9/psyntax-pp.scm (syntax-rules): Regenerate.

* test-suite/tests/syntax.test (exception:unexpected-syntax): Change
  capitalization.
  ("unquote-splicing"): Update test.
  ("begin"): Add in second arms on these ifs, to avoid the strange though
  harmless expansion of `if'.
  (matches?): New helper macro.
  ("lambda"): Match on lexically bound symbols, as they will be
  alpha-renamed.
2009-05-21 22:43:07 +02:00
Andy Wingo
40b36cfbbe catch syntax errors in unquote and unquote-splicing
* module/ice-9/psyntax.scm (quasiquote): Catch syntax errors in unquote
  and unquote-splicing.

* module/ice-9/psytax-pp.scm: Regenerated.
2009-05-21 22:11:48 +02:00
Andy Wingo
2032f3d1db fix multiple values returning from srfi-18's `with-exception-handler'
* module/srfi/srfi-18.scm (with-exception-handler): Hah! Fixed a
  scurrilous bug in which we assumed that the thunk returned one or more
  values. Hah.
2009-05-21 21:39:37 +02:00
Andy Wingo
0f423f20aa fix apply and call/cc in drop contexts
* module/language/tree-il/compile-glil.scm (flatten): Actually apply only
  needs one arg after the proc. And shit, call/cc and apply in drop
  contexts also need to be able to return arbitrary numbers of values;
  work it by trampolining through their applicative (non-@) definitions.
  Also, simplify the single-valued drop case to avoid the
  truncate-values.

* module/language/tree-il/inline.scm (call/cc):
* module/language/tree-il/optimize.scm (*interesting-primitive-names*):
  Define call/cc as "interesting". Perhaps we should be hashing on value
  and not on variable.

* test-suite/tests/tree-il.test ("application"): Fix up test for new,
  sleeker output. (Actually the GLIL is more verbose, but the assembly is
  better.)
  ("apply", "call/cc"): Add some more tests.
2009-05-21 21:13:24 +02:00
Andy Wingo
30a5e062d0 procedures in "drop" contexts can return unspecified values
* module/language/tree-il/compile-glil.scm (flatten): For applications in
  "drop" context, allow the procedure to return unspecified values
  (including 0 values).

* test-suite/tests/tree-il.test ("application"): Adapt test.

* module/srfi/srfi-18.scm (wrap): Clarify.

* test-suite/tests/srfi-18.test: Fix so that the expression importing
  srfi-18 is expanded before the tests. However the tests are still
  failing, something about 0-valued returns...
2009-05-21 17:22:58 +02:00
Andy Wingo
a48358b38f fix srfi-17.test
* test-suite/tests/srfi-17.test (exception:bad-quote): Change the
  expected exception for (set! (quote foo) ...) errors.
2009-05-21 16:04:14 +02:00
Andy Wingo
d63927150a just parse method arguments once.
* module/oop/goops.scm (method): Tweak to just run through the arguments
  once. Thanks to Eli Barzilay for the tip.
2009-05-21 15:34:29 +02:00
Andy Wingo
47c8983f08 rewrite `method' as a hygienic macro to re-allow lexical specializers
* module/oop/goops.scm (method): Reimplement as a hygienic macro. This
  seriously took me like 6 hours to figure out. Allows for lexical
  specializers: (let ((<x> ...)) (define-method (foo (arg <x>)) ...)).

* module/oop/goops/compile.scm (next-method?, compile-make-procedure):
  Remove these, as `method' does it all now, hygienically.
2009-05-21 13:49:00 +02:00
Ludovic Courtès
837b0ae0b5 Make use of Gnulib's `flock' module.
* libguile/posix.c: Always use <sys/file.h>, which is provided by
  Gnulib.
  (flock)[__MINGW32__]: Remove.
  (scm_flock): Compile unconditionally.  Always use Gnulib's flock(2).
2009-05-21 01:24:01 +02:00
Ludovic Courtès
3731192f30 Make use of Gnulib's `putenv' module.
* libguile/posix.c: Include <stdlib.h> since the putenv(3) declaration
  is there (POSIX and Gnulib).
  (scm_putenv): Rely on Gnulib's `putenv' module.
2009-05-21 01:17:00 +02:00
Ludovic Courtès
f240aacb41 Add Gnulib portability modules; update Gnulib files.
* m4/gnulib-cache.m4 (gl_MODULES): Add `flock' (provides flock(2)
  declaration and implementation), `fpieee' (fixes floating point
  behavior on Alpha and SH), `stdlib' (provides an unsetenv(3)
  declaration, among others), `putenv' (provides a putenv(3) declaration
  and implementation with the semantics we need).
2009-05-21 01:00:41 +02:00