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

186 commits

Author SHA1 Message Date
Ludovic Courtès
722a4fb99e Don't say "source file is newer" when either file is inaccessible.
* libguile/load.c (compiled_is_fresh): Don't emit "source file is newer"
  warning when either FULL_FILENAME or COMPILED_FILENAME could not be
  stat'd.  This is consistent with what load/compiled-file-name do.
2010-09-04 16:13:42 +02:00
Ludovic Courtès
abca59fea4 Compare source/compiled file timestamps with nano-second resolution.
* libguile/load.c (compiled_is_fresh): Rename `res' to
  `compiled_is_newer'.  Use `get_stat_mtime' to compare with nano-second
  resolution when available.

* module/ice-9/boot-9.scm (load)[fresh-compiled-file-name]: Likewise,
  using `stat:mtimensec'.
2010-09-04 16:07:58 +02:00
Andy Wingo
bc325e763f %site-dir is specific to the effective version
* libguile/load.h:
* libguile/load.c (scm_sys_global_site_dir): New API, is what %site-dir
  used to be.
  (scm_sys_site_dir): Changed to be a version-specific dir.
  (scm_init_load_path): Search the version-specific sitedir before the
  global one.

* libguile/Makefile.am (libpath.h): Update SCM_SITE_DIR and
  SCM_GLOBAL_SITE_DIR, as appropriate.
2010-08-06 13:15:29 +02:00
Ludovic Courtès
fefd60ba4b Check for go/scm mtime ordering rather than equality.
* am/guilec (install-data-hook): Remove.
  (guile_install_go_files): New variable.
  ($(guile_install_go_files)): New dependency.

* libguile/load.c (compiled_is_fresh): Check for ordering of STAT_SOURCE
  and STAT_COMPILED, not equality.

* module/ice-9/boot-9.scm (load): Ditto.

* module/system/base/compile.scm (call-with-output-file/atomic): Don't
  set the timestamp of TEMPLATE.
2010-07-26 19:38:52 +02:00
Ludovic Courtès
eba5ea7a4f Canonicalize source file names in `primitive-load-path' (fix bug #30170).
* libguile/load.c (scm_primitive_load_path): Canonicalize
  FULL_FILENAME.  Fixes bug #30170 ("Auto-compilation erroneously
  recompiles dependencies").
2010-06-20 16:57:06 +02:00
Andy Wingo
cd038da546 remove libguile/lang.h, deprecate %nil (in favor of #nil)
* libguile/Makefile.am:
* libguile/init.c:
* libguile/lang.c:
* libguile/lang.h: Remove lang.c and lang.h.

* libguile/pairs.h (SCM_NIL_P, SCM_NULL_OR_NIL_P): Moved here.

* module/ice-9/deprecated.scm (%nil): %nil definition moved here.

* libguile/alist.c:
* libguile/async.c:
* libguile/backtrace.c:
* libguile/boolean.c:
* libguile/dynl.c:
* libguile/eval.c:
* libguile/filesys.c:
* libguile/fluids.c:
* libguile/list.c:
* libguile/load.c:
* libguile/options.c:
* libguile/posix.c:
* libguile/print.c:
* libguile/promises.c:
* libguile/sort.c:
* libguile/throw.c:
* libguile/trees.c:
* libguile/vectors.c:
* libguile/vm.c:
* libguile/weaks.c:
* srfi/srfi-1.c: <libguile/lang.h> references removed.
2010-04-09 14:26:31 +02:00
Andy Wingo
6128f34c4b correctly handle --no-autocompile (fixed broken previous patch)
* libguile/load.c (scm_init_load): Initialize %load-should-autocompile
  to false.

* libguile/init.c (scm_i_init_guile):
* libguile/load.h:
* libguile/load.c (scm_init_load_should_autocompile): At the end of
  init, check GUILE_AUTO_COMPILE.

* libguile/script.c (scm_compile_shell_switches): Instead of making
  --autocompile / --no-autocompile render into the s-expression, just
  handle them immediately, so that --no-autocompile takes effect for the
  expander.
2010-03-30 10:53:05 +02:00
Andy Wingo
655aadf4b0 going through scm_shell not necessary to get autocompilation
* libguile/load.c (scm_init_load): Initialize %load-should-autocompile
  from the environment variable here, so that apps that don't go through
  scm_shell get autocompilation.

* libguile/script.c (scm_compile_shell_switches): Explicitly enable or
  disable autocompilation here, if told to do so.
2010-03-30 10:28:51 +02:00
Andy Wingo
a6029b97ea properly integrate vm bootstrapping into init.c
* libguile/Makefile.am (modinclude_HEADERS):
* libguile/vm-bootstrap.h: Remove vm-bootstrap.h.

* libguile/frames.c: No more vm-bootstrap.h.

* libguile/instructions.c (scm_init_instructions):
* libguile/objcodes.c (scm_init_objcodes):
* libguile/programs.c (scm_init_programs): No need to call
  scm_bootstrap_vm, init.c does that for us.

* libguile/vm.c (scm_bootstrap_vm): No need call e.g.
  scm_bootstrap_frames, init.c does that. Remove a twice-calling guard,
  should be unnecessary. Don't define the load-compiled subr here.

* libguile/load.c (scm_init_load): Define the load-compiled subr here.

* libguile/vm.h: Declare scm_bootstrap_vm here.

* libguile/init.c (scm_i_init_guile): Properly integrate VM
  bootstrapping into this file.
2010-01-07 23:42:41 +01:00
Ludovic Courtès
e29dcaf3b7 Fix 1.8-compatibility of `scm_search_path ()'.
* libguile/load.c (scm_search_path): Handle the 1.8-compatibility case
  where REST is `SCM_UNDEFINED'.  Reported by Dale P. Smith.
2010-01-07 11:10:36 +01:00
Andy Wingo
3c98a49cbd in the load path, look in library-dir before site-dir
* libguile/load.c (scm_init_load_path): Search first in Guile's
  version-specific path (the library path), *then* in the site dir. This
  should allow us to import some of Guile-lib's modules into Guile,
  perhaps customizing them with Guile-version-specific foo, without
  accidentally falling back to system-installed guile-lib in the
  sitedir. Also should reduce the number of stats by half, in the common
  case.
2009-12-20 15:34:19 +01:00
Andy Wingo
ed1bf2c85c if we have no eval.go, load no .go
* libguile/load.c (scm_init_eval_in_scheme): If we have no eval.go, null
  out the load-compiled path so that we load no compiled code. Prevents
  partially compiled Guile from turning tail-calls into stack-munching
  calls.
2009-12-10 20:26:13 +01:00
Andy Wingo
f39448c5a3 remove a bunch of needless scm_permanent_object calls
* libguile/array-handle.c:
* libguile/bytevectors.c:
* libguile/deprecated.c:
* libguile/eval.c:
* libguile/feature.c:
* libguile/filesys.c:
* libguile/gc.c:
* libguile/gdbint.c:
* libguile/goops.c:
* libguile/instructions.c:
* libguile/load.c:
* libguile/modules.c:
* libguile/numbers.c:
* libguile/options.c:
* libguile/ports.c:
* libguile/scmsigs.c:
* libguile/srcprop.c:
* libguile/srfi-4.c:
* libguile/stacks.c:
* libguile/threads.c:
* libguile/vm.c: Remove calls to scm_permanent_object, as they are no
  longer needed with the BDW GC.
2009-12-05 11:32:50 +01:00
Andy Wingo
5f1611640a really boot primitive-eval from scheme.
* libguile/eval.c (scm_primitive_eval, scm_c_primitive_eval):
  (scm_init_eval): Rework so that scm_primitive_eval always calls out to
  the primitive-eval variable. The previous definition is the default
  value, which is probably overridden by scm_init_eval_in_scheme.

* libguile/init.c (scm_i_init_guile): Move ports and load-path up, so we
  can debug when initing eval. Call scm_init_eval_in_scheme. Awesome.

* libguile/load.h:
* libguile/load.c (scm_init_eval_in_scheme): New procedure, loads up
  ice-9/eval.scm to replace the primitive-eval definition, if everything
  is there and up-to-date.

* libguile/modules.c (scm_module_transformer): Export to Scheme, so it's
  there for eval.go.

* module/ice-9/boot-9.scm: No need to define module-transformer.

* module/ice-9/eval.scm (capture-env): Only reference the-root-module if
  modules are booted.
  (primitive-eval): Inline a definition for identity. Throw a more
  standard error for "wrong number of arguments".

* module/ice-9/psyntax.scm (chi-install-global): The macro binding for a
  syncase macro is now a pair: the transformer, and the module that was
  current when the transformer was installed. The latter is used for
  hygiene purposes, replacing the use of procedure-module, which didn't
  work with the interpreter's shared-code closures.
  (chi-macro): Adapt for the binding being a pair, and get the hygiene
  from the cdr.
  (eval-local-transformer): Adapt to new form of macro bindings.

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

* .gitignore: Ignore eval.go.stamp.

* module/Makefile.am: Reorder for fastest serial compilation, now that
  there are no ordering constraints. I did a number of experiments here
  and this seems to be the best; but the bulk of the time is compiling
  psyntax-pp.scm with eval.scm. Not so great.

* libguile/vm-engine.c (vm-engine): Throw a more standard error for
  "wrong type to apply".

* test-suite/tests/gc.test ("gc"): Remove a hack that shouldn't affect
  the new evaluator, and throw in another (gc) for good measure.

* test-suite/tests/goops.test ("defining classes"):
* test-suite/tests/hooks.test (proc1): We can't currently check what the
  arity is of a closure made by eval.scm -- or more accurately all
  closures have 0 required args and no rest args. So punt for now.

* test-suite/tests/syntax.test ("letrec"): The scheme evaluator can't
  check that a variable is unbound, currently; perhaps the full "fixing
  letrec" expansion could fix this. But barring that, punt.
2009-12-03 00:00:38 +01:00
Ludovic Courtès
f8a1c9a859 Have `scm_scan_for_encoding ()' use GC-managed memory.
* libguile/read.c (scm_scan_for_encoding): Rename to ...
  (scm_i_scan_for_encoding): ... this; update callers.  Use
  `scm_gc_strndup ()' instead of `scm_malloc ()'.

* libguile/read.h: Update accordingly.

* libguile/load.c (scm_primitive_load): Don't call free(3) on the value
  returned by `scm_i_scan_for_encoding ()'.
2009-11-14 16:59:25 +01:00
Ludovic Courtès
88cbb42189 Restore signature of `scm_search_path ()' as found in 1.8.
The incompatibly was introduced by
22f4ee4882 ("make primitive-load-path load
compiled files if available").

* doc/ref/api-options.texi (Build Config): Update `search-path'
  documentation.

* libguile/load.c (scm_search_path): Change C prototype to expect only 3
  arguments.  Parse the rest argument accordingly.  Update callers.

* libguile/load.h (scm_search_path): Update accordingly.
2009-11-01 23:29:36 +01:00
Ludovic Courtès
31ab99de56 Restore signature of `scm_primitive_load_path ()' as found in 1.8.
The incompatibility was introduced by
0fb81f95b0 ("add exception_on_error
optional arg to primitive-load-path").

* libguile/load.c (scm_primitive_load_path): Change to take 1 rest
  argument.  Interpret the argument as either a file name (C-level
  backward compatibility with 1.8) or an actual argument list.
  (scm_c_primitive_load_path): Update caller.

* libguile/load.h (scm_primitive_load_path): Update accordingly.

* doc/ref/api-evaluation.texi (Loading): Update documentation of
  `primitive-load-path' and `scm_primitive_load_path ()'.
2009-10-15 01:05:32 +02:00
Ludovic Courtès
87c595c757 Compile in a fresh module by default.
* module/system/base/compile.scm (make-compilation-module,
  language-default-environment): New procedures.
  (read-and-compile, compile): Have ENV default to
  `(language-default-environment from)'.
  (compile-and-load): Compile in `(current-module)'.

* module/system/repl/common.scm (repl-compile): Explicitly compile in
  the current module so that macro definitions are visible.

* libguile/load.c (kw_env): New variable.
  (do_try_autocompile): Call `compile-file' with `#:env (current-module)'.

* test-suite/tests/compiler.test ("psyntax")["compile uses a fresh module by
  default", "compile-time definitions are isolated"]: New tests.
  ["compile in current module"]: Specify `#:env (current-module)'.
  ["redefinition"]: Adjust.

* test-suite/tests/bytevectors.test (c&e): Explicitly compile in the
  current module so that its imports are visible.
2009-09-20 21:54:41 +02:00
Ludovic Courtès
d7a2207326 Add the `%host-type' global variable.
* configure.ac: Define `HOST_TYPE'.

* libguile/load.c (sys_host_type): New variable.

* doc/ref/api-options.texi (Build Config): Document `%host-type'.
2009-09-18 11:40:03 +02:00
Ludovic Courtès
6dc797eee9 Merge branch 'master' into boehm-demers-weiser-gc
Conflicts:
	libguile/gc_os_dep.c
2009-09-09 22:39:49 +02:00
Ludovic Courtès
7af531508c Merge branch 'master' into boehm-demers-weiser-gc
Conflicts:
	libguile/Makefile.am
	libguile/bytevectors.c
	libguile/gc-card.c
	libguile/gc-mark.c
	libguile/programs.c
	libguile/srcprop.c
	libguile/srfi-14.c
	libguile/symbols.c
	libguile/threads.c
	libguile/unif.c
	libguile/vm.c
2009-08-28 19:16:46 +02:00
Andy Wingo
5950cc3fcc fix case in which compiled path had stale .go, but fallback had fresh .go
* libguile/load.c (scm_primitive_load_path): If the compiled path was
  out of date, but the fallback path was current, we correctly detected
  that case, but loaded the wrong file. So here fix the typo.
2009-08-28 17:13:09 +02:00
Ludovic Courtès
1505848425 Add missing `FUNC_NAME' definition.
* libguile/load.c (scm_sys_warn_autocompilation_enabled): Define
  `FUNC_NAME'.
2009-08-28 01:16:49 +02:00
Michael Gran
889975e51a Add full Unicode capability to ports and the default reader
Ports are given two additional properties: a character encoding and
a conversion failure strategy.  These properties have getters and setters.
The new properties are used to convert any locale text to/from the
internal representation of strings.

If unspecified, ports use a default value. The default value of these
properties is held in a fluid.  The default character encoding can be
modified by calling setlocale.

ISO-8859-1 is treated specially.  Since it is a native encoding of
strings, it can be processed more quickly.  Source code is assumed to be
ISO-8859-1 unless otherwise specified.  The encoding of a source code
file can be given as 'coding: XXXXX' in a magic comment at the top of a
file.

The C functions that deal with encoding often use a null pointer
as shorthand for the native Latin-1 encoding, for efficiency's sake.

* test-suite/tests/encoding-iso88591.test: new tests
* test-suite/tests/encoding-iso88597.test: new tests
* test-suite/tests/encoding-utf8.test: new tests
* test-suite/tests/encoding-escapes.test: new tests
* test-suite/tests/numbers.test: declare 'binary' encoding
* test-suite/tests/ports.test: declare 'binary' encoding
* test-suite/tests/r6rs-ports.test: declare 'binary' encoding

* module/system/base/compile.scm (compile-file): use source-code
  file's self-declared encoding when compiling files

* libguile/strports.c: store string ports in locale encoding
  (scm_strport_to_locale_u8vector, scm_call_with_output_locale_u8vector)
  (scm_open_input_locale_u8vector, scm_get_output_locale_u8vector):
  new functions

* libguile/strings.h: new declaration for scm_i_string_contains_char

* libguile/strings.c (scm_i_string_contains_char): new function
  (scm_from_stringn, scm_to_stringn):  use NULL for Latin-1
  (scm_from_locale_stringn, scm_to_locale_stringn): respect character
  encoding of input and output ports

* libguile/read.h: declaration for scm_scan_for_encoding

* libguile/read.c:
  (read_token): now takes scheme string instead of C string/length
  (read_complete_token): new function
  (scm_read_sexp, scm_read_number, scm_read_mixed_case_symbol)
  (scm_read_number_and_radix, scm_read_quote, scm_read_semicolon_comment)
  (scm_read_srfi4_vector, scm_read_bytevector, scm_read_guile_bit_vector)
  (scm_read_scsh_block_comment, scm_read_commented_expression)
  (scm_read_extended_symbol, scm_read_sharp_extension, scm_read_shart)
  (scm_read_expression): use scm_t_wchar for char type, use read_complete_token
  (scm_scan_for_encoding): new function to find a file's character encoding
  (scm_file_encoding): new function to find a port's character encoding

* libguile/rdelim.c: don't unpack strings

* libguile/print.h: declaration for modified function
  scm_i_charprint

* libguile/print.c: use locale when printing characters and
  strings
  (scm_i_charprint): input parameter is now scm_t_wchar
  (scm_simple_format): don't unpack strings

* libguile/posix.h: new declaration for scm_setbinary.

* libguile/posix.c (scm_setlocale): set default and stdio port
  encodings based on the locale's character encoding
  (scm_setbinary): new function

* libguile/ports.h (scm_t_port): add encoding and failed
  conversion handler to port type.  Declarations for new or modified
  functions scm_getc, scm_unget_byte, scm_ungetc,
  scm_i_get_port_encoding, scm_i_set_port_encoding_x,
  scm_port_encoding, scm_set_port_encoding_x,
  scm_i_get_conversion_strategy, scm_i_set_conversion_strategy_x,
  scm_port_conversion_strategy, scm_set_port_conversion_strategy_x.

* libguile/ports.c: assign the current ports to zero on startup so
  we can see if they've been set.
  (scm_current_input_port, scm_current_output_port,
  scm_current_error_port): return #f if the port is not yet
  initialized
  (scm_new_port_table_entry): set up a new port's encoding and
  illegal sequence handler based on the thread's current defaults
  (scm_i_remove_port): free port encoding name when port is removed
  (scm_i_mode_bits_n): now takes a scheme string instead of a c
  string and length.  All callers changed.
  (SCM_MBCHAR_BUF_SIZE): new const
  (scm_getc): new function, since the scm_getc in inline.h is now
  scm_get_byte_or_eof.  This pulls one codepoint from a port.
  (scm_lfwrite_substr, scm_lfwrite_str): now uses port's encoding
  (scm_unget_byte): new function, incorportaing the low-level functionality
  of scm_ungetc
  (scm_ungetc): uses scm_unget_byte

* libguile/numbers.h (scm_t_wchar): compilation order problem with
  scm_t_wchar being use in functions in multiple headers.  Forward
  declare scm_t_wchar.

* libguile/load.c (scm_primitive_load): scan for file encoding at
  top of file and use it to set the load port's encoding

* libguile/inline.h (scm_get_byte_or_eof): new function
  incorporating most of the functionality of scm_getc.

* libguile/fports.c (fport_fill_input): now returns scm_t_wchar

* libguile/chars.h (scm_t_wchar): avoid compilation order problem
  with declaration of scm_t_wchar
2009-08-25 07:54:37 -07:00
Andy Wingo
48a0fe4d6b autocompiled files before installation go to a cache dir in the builddir
* libguile/load.c (scm_init_load_path): Append a slash after
  XDG_CACHE_HOME.

* meta/gdb-uninstalled-guile.in:
* meta/guile.in (XDG_CACHE_HOME): Export this var so we write to a cache
  within the build directory. Probably we should have a GUILE_CACHE_DIR
  to be more specific, though.

* Makefile.am (clean-local): Clear the cache when making clean.
2009-08-20 18:52:38 +02:00
Andy Wingo
9591a2b016 `load' autocompiles
* libguile/load.h:
* libguile/load.c (scm_sys_warn_autocompilation_enabled): New primitive,
  not exported. Since `load' autocompiles now, it should warn in the
  same way that the bits hardcoded into C warn.
  (scm_try_autocompile): Use scm_sys_warn_autocompilation_enabled.

* module/ice-9/boot-9.scm (autocompiled-file-name): New helper.
  (load): Try autocompiling the argument, if appropriate. Will
  autocompile files passed on Guile's command line. `primitive-load' is
  unaffected.
2009-08-18 11:06:04 +02:00
Ludovic Courtès
fbb857a472 Merge branch 'master' into boehm-demers-weiser-gc
Conflicts:
	lib/Makefile.am
	libguile/Makefile.am
	libguile/frames.c
	libguile/gc-card.c
	libguile/gc-freelist.c
	libguile/gc-mark.c
	libguile/gc-segment.c
	libguile/gc_os_dep.c
	libguile/load.c
	libguile/macros.c
	libguile/objcodes.c
	libguile/programs.c
	libguile/strings.c
	libguile/vm.c
	m4/gnulib-cache.m4
	m4/gnulib-comp.m4
	m4/inline.m4
2009-08-18 00:06:45 +02:00
Andy Wingo
6e5c02b8a3 make the fallback path look less like line noise
* libguile/_scm.h:
* libguile/load.c: Rework to only include the relevant pieces in the
  fallback path.
2009-08-11 21:16:05 +02:00
Andy Wingo
86cfb42d56 include objcode cookie in the fallback path
* libguile/_scm.h (SCM_OBJCODE_COOKIE): Move the objcode cookie define
  here, so that load.c can use it. This is a private header.

* libguile/load.c (FALLBACK_DIR): Include the objcode cookie in the
  fallback path. Should fix problems when objcode changes incompatibly
  during the 1.9 series.

* libguile/objcodes.c: Adapt to SCM_OBJCODE_COOKIE move.

This should fix http://article.gmane.org/gmane.lisp.guile.devel/9059.
2009-08-11 20:25:44 +02:00
Andy Wingo
179fe33632 put autocompiled files into ~/.cache or $XDG_CACHE_HOME
* module/system/base/compile.scm (compiled-file-name): Remove unneeded
  path separator.

* libguile/load.c (scm_init_load_path): Change so the default cache path
  is ~/.cache/guile/ccache/1.9, and respect $XDG_CACHE_HOME.
2009-06-20 14:26:54 +02:00
Neil Jerram
53befeb700 Change Guile license to LGPLv3+
(Not quite finished, the following will be done tomorrow.
   module/srfi/*.scm
   module/rnrs/*.scm
   module/scripts/*.scm
   testsuite/*.scm
   guile-readline/*
)
2009-06-17 00:22:09 +01:00
Andy Wingo
535fb833b3 stamp .go with timestamp of .scm; a fresh go has same mtime of .scm
* libguile/load.c (compiled_is_fresh): Rename from compiled_is_newer.
  Check that the mtines of the .go and .scm match exactly, so we don't
  get fooled by rsync-like modifications of the filesystem.

* module/system/base/compile.scm (call-with-output-file/atomic): Add
  optional arg, a reference file. If present we utime the output file to
  match the source file, before the rename.
  (compile-file): Stamp the .go file with the timestamp of the .scm.
2009-06-05 10:51:21 +02:00
Andy Wingo
628132c5ac final (?) tweaks to the autocompile code
* libguile/load.c (do_try_autocompile): Use module_variable, not
  module_lookup, when resolving compile-file, so we get #f instead of an
  exception if the compiler is in the process of being loaded.
  (scm_primitive_load_path): In what I hope is the last patch to this
  code, recheck the fallback path if we found a stale installed .go file.
2009-06-05 10:24:35 +02:00
Andy Wingo
3c997c4ba9 simplify autocompilation some more
* libguile/load.c (scm_init_load_path): Set the fallback path even if
  GUILE_SYSTEM_COMPILED_PATH is set. Now that we store full paths in the
  autocompiled files, and the path contains the effective Guile version,
  there's no danger of accidental collisions.
  (do_try_autocompile, autocompile_catch_handler, scm_try_autocompile):
  Simplify again -- since there's only one place we put autocompiled
  files, and compile-file finds it itself, there's no need to pass along
  the compiled file path.
  (scm_primitive_load_path): Don't call out to compiled-file-name to get
  the fallback path, as we might not be autocompiling, and besides that
  we need to check if the file exists at all.

* module/system/base/compile.scm (compiled-file-name): Simplify again.
  The auto-compiled path is just fallback path + full source path + .go.
2009-06-05 10:06:39 +02:00
Andy Wingo
5ea401bffe further autocompilation tweaks
* module/system/base/compile.scm (compiled-file-name):
* libguile/load.c (scm_init_load_path, scm_try_autocompile)
  (scm_primitive_load_path): Rework so that we search for .go files in
  the load-compiled path and in the fallback path, but we only
  autocompile to the fallback path. Should produce a more desirable experience.
2009-06-05 01:20:19 +02:00
Andy Wingo
c2521a2124 fix error autocompiling parts of the compiler; make check works
* libguile/load.c (scm_try_autocompile): Punt if compiled-file-name does
  not resolve, which would indicate that the file in question is part of
  the compiler itself.

* test-suite/tests/elisp.test: Today I was an evil one -- disable
  autocompilation for the elisp tests, as they are meant only for the
  memoizer's eyes. Hopefully Daniel will fix this :-)
2009-06-03 23:59:58 +02:00
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
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
Ludovic Courtès
d9e59f894e Merge branch 'master' into boehm-demers-weiser-gc
Conflicts:
	libguile/continuations.c
	libguile/gc-freelist.c
	libguile/gc-mark.c
	libguile/symbols.c
	libguile/threads.c
	module/ice-9/boot-9.scm
2009-03-22 15:28:35 +01:00
Andy Wingo
999f1b26e7 Merge commit 'origin/master' into vm
Conflicts:

	doc/Makefile.am
	ice-9/Makefile.am
	libguile/gc.c
2008-09-30 21:12:16 +02:00
Andy Wingo
02b84691b2 don't poke installed scm, go, etc files when running pre-inst-guile
* libguile/load.c (scm_init_load_path): If GUILE_SYSTEM_PATH is set, use
  that instead of the compiled-in suffix to the load path. And, as a
  special case, GUILE_SYSTEM_PATH= is interpreted as '(). A bit nasty.

* pre-inst-guile-env.in (top_builddir): Set GUILE_SYSTEM_PATH to the
  empty string, if it is not set.
2008-09-18 23:04:58 +02:00
Ludovic Courtès
8b039053b8 Remove GC-related code from fluids.
* libguile/fluids.c (all_dynamic_states, all_fluids): Remove.  Together,
  they prevented dynamic states and fluids to be collected.  Callers no
  longer use them.
  (resize_all_states): Remove.
  (grow_dynamic_state): New function.
  (next_fluid_num): Don't call `resize_all_states ()'.
  (scm_i_fluid_num, scm_i_fast_fluid_ref, scm_i_fast_fluid_set_x): Remove,
  as they broke encapsulation and would have needed duplication of the lazy
  dynamic state growing code.
  (scm_fluid_ref, scm_fluid_set_x): Lazily grow the dynamic state's fluid
  vector.
  (scm_fluids_prehistory): Don't set an `scm_after_sweep_c_hook'.

* libguile/fluids.h (SCM_FLUID_NUM, SCM_FAST_FLUID_REF, SCM_FAST_FLUID_SET_X,
  scm_i_fluid_num, scm_i_fast_fluid_set_x, scm_i_fast_fluid_ref): Remove.

* libguile/load.c (the_reader_fluid_num): Remove.
  (scm_primitive_load): Use `scm_fluid_ref ()' instead of
  `SCM_FAST_FLUID_REF ()'.
  (scm_init_load): Likewise.
2008-09-17 00:25:03 +02:00
Ludovic Courtès
dbb605f575 Include <config.h> in all C files; use #ifdef HAVE_CONFIG_H' rather than #if'. 2008-09-13 15:35:27 +02:00
Andy Wingo
22f4ee4882 make primitive-load-path load compiled files if available
* libguile/load.h: Update scm_search_path prototype.

* libguile/load.c: Include vm.h for load-compiled/vm. Not sure if this is
  bad wrt modularity.
  (scm_c_string_has_an_ext): New private helper.
  (scm_search_path): Add an extra optional arg, `require_exts'; if true,
  require that the returned file name have one of the given extensions.
  Changes the C API, but not the scheme API.
  (scm_sys_search_load_path): Adapt to scm_search_path API change.
  (primitive-load-path): Here is the craziness: load a compiled file if
  found and newer than the corresponding (or not) source file.
  (scm_init_load): Define %load-compiled-extensions as the list of
  extensions denoting compiled files; defaults to '(".go").
2008-09-02 11:00:32 -07:00
Kevin Ryde
2b829bbb3d merge from 1.8 branch 2006-04-17 00:05:42 +00:00
Marius Vollmer
661ae7ab6b Renamed the "frames" that are related to dynamic-wind to "dynamic
contexts.  Renamed all functions from scm_frame_ to scm_dynwind_.
Updated documentation.
2006-01-29 00:23:28 +00:00
Neil Jerram
ec3a8ace63 * api-evaluation.texi (Loading): Document custom reader.
* boot-9.scm (load-module): Support an optional custom reader arg,
implemented by passing on to r4rs's load.

* r4rs.scm (load): Support an optional custom reader arg,
implemented by passing on to primitive-load.

* load.c (the_reader, the_reader_fluid_num): New.
(scm_primitive_load): Support custom reader.
(scm_init_load): Init the_reader and the_reader_fluid_num; export
the_reader as `current-reader'.
2005-12-14 00:21:11 +00:00