1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-02 13:00:26 +02:00
Commit graph

4452 commits

Author SHA1 Message Date
Andy Wingo
12922f0dd1 psyntax builds case-lambda expressions
* module/ice-9/psyntax.scm (build-case-lambda, build-lambda-case):
  Actually build case-lambda expressions, knowing that the memoizer will
  do the right thing.

* module/ice-9/psyntax-pp.scm: Regenerated.
2010-05-14 00:28:39 +02:00
Andy Wingo
7572ee5261 evaluator support for case-lambda
* libguile/memoize.c (patch_case_lambda, scm_m_case_lambda)
  (scm_m_case_lambda_star): Add memoizers for case-lambda and
  case-lambda*.
  (unmemoize): Unmemoize lambdas with multiple arities.

* libguile/eval.c (prepare_boot_closure_env_for_apply):
  (prepare_boot_closure_env_for_eval): Adapt to return both body and
  env, so that case-lambda clauses can be selected appropriately.
  (eval, boot_closure_apply): Adapt callers.

* module/ice-9/eval.scm (make-general-closure): Support multiple
  arities.
2010-05-14 00:28:39 +02:00
Andy Wingo
d8a071fc4e primitive support for lambda*
* libguile/memoize.c (scm_m_lambda_star): Define lambda* in the
  pre-psyntax env, and make it memoize lambda* expressions.

* libguile/eval.c (BOOT_CLOSURE_PARSE_FULL): New helper.
  (error_invalid_keyword, error_unrecognized_keyword): New helpers.
  (prepare_boot_closure_env_for_apply): Flesh out application of boot
  closures with "full" arity.
  (prepare_boot_closure_env_for_eval): Punt to
  prepare_boot_closure_env_for_eval for the full-arity case.

* module/ice-9/eval.scm (make-fixed-closure): Rename from `closure', and
  just handle fixed arities, where there is no rest argument..
  (make-general-closure): New helper, a procedure, that returns a
  closure that can take rest, optional, and keyword arguments.
  (eval): Adapt to call make-fixed-closure or make-general-closure as
  appropriate.

* test-suite/tests/optargs.test ("lambda* inits"): Test the memoizer as
  well.
2010-05-14 00:28:32 +02:00
Andy Wingo
8f9c5b589d change to format of memoization lambda expressions
* libguile/memoize.c (scm_m_lambda, memoize_named_let)
  (scm_memoize_lambda, unmemoize)
* libguile/eval.c (eval, prepare_boot_closure_env_for_apply)
  (prepare_boot_closure_env_for_eval, boot_closure_apply):
* module/ice-9/eval.scm (primitive-eval): Change the format for memoized
  lambda expressions, so as to allow, in the future, case-lambda* to be
  supported by the evaluator.
2010-05-13 23:37:15 +02:00
Ludovic Courtès
df3f1090e8 Have sxml->xml' handle *TOP*' nodes (bug #29260).
* module/sxml/simple.scm (universal-sxslt-rules): Add handler for
  `*TOP*'.  Suggested by Stefan Israelsson Tampe at
  <https://savannah.gnu.org/bugs/index.php?29260>.

* test-suite/Makefile.am (SCM_TESTS): Add `sxml.simple.test'.

* test-suite/tests/sxml.simple.test: New file.

* THANKS: Add Stefan.
2010-05-11 23:46:05 +02:00
Andy Wingo
4f692ace90 macro expanders return memoized expressions
* libguile/eval.c (scm_c_primitive_eval):
* module/ice-9/eval.scm (primitive-eval): Rely on the expander to
  produce a memoized expression. If the expression is already memoized,
  just pass it through (the equivalent of the old "noexpand" hack).

* libguile/memoize.c (scm_init_memoize): Initialize `memoize-expression'
  as the initial binding of `macroexpand'.

* libguile/modules.c (scm_module_transformer): Before modules are
  booted, look for `macroexpand', not `%pre-modules-transformer'.

* module/ice-9/boot-9.scm: No more %pre-modules-transformer. Loading
  psyntax extends `macroexpand'.
  (make-module): `macroexpand' is the default transformer.

* module/ice-9/psyntax.scm: No more `noexpand'.
  (top-level-eval-hook, local-eval-hook): Instead of annotating with
  noexpand, memoize the expression before handing it to primitive-eval.
  (macroexpand): No more noexpand hack -- in its place we have another
  hack, to memoize the result when running in eval mode.
* module/ice-9/psyntax-pp.scm: Regenerated.
2010-05-07 22:22:19 +02:00
Ludovic Courtès
36b5e39407 Add (system vm coverage).
* module/system/vm/coverage.scm: New file.

* module/Makefile.am (SYSTEM_SOURCES): Add `system/vm/coverage.scm'.

* test-suite/guile-test (main): Use (system vm coverage).  Handle
  `--coverage' and `-c'.

* test-suite/tests/coverage.test: New file.

* test-suite/Makefile.am (SCM_TESTS): Add `tests/coverage.test'.

* doc/ref/Makefile.am (guile_TEXINFOS): Add `api-coverage.texi'.

* doc/ref/api-coverage.texi: New file.

* doc/ref/guile.texi (API Reference): Include it.
2010-05-07 13:47:53 +02:00
Ludovic Courtès
f9a86f72a6 Add program-free-variables' to (system vm program)'.
* module/system/vm/program.scm (program-free-variables): New procedure.

* module/language/objcode/spec.scm (program-free-variables): Remove.
2010-05-07 13:47:52 +02:00
Andy Wingo
d9b1c71ac6 fix macros that expand into (begin (define-module ...) ...)
* module/ice-9/boot-9.scm (define-module): Add `expand' to the
  situations, so that we ensure the current module changes at expand
  time.

* module/ice-9/r6rs-libraries.scm (library): Expand the body within @@
  expressions.
2010-05-06 22:42:44 +02:00
Andy Wingo
f2d126801c psyntax no longer attempts to track (current-module)
* module/ice-9/psyntax.scm: Revert tracking of the current module while
  expanding toplevel sequences. Better to preserve lexical scoping
  (relative to the module of the original expression) and allow for @@
  to override it.

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

* test-suite/tests/syncase.test: Test module-changing with @@.
2010-05-06 22:42:44 +02:00
Andy Wingo
27cbec84da @@ generalized to arbitrary expressions.
* module/ice-9/psyntax.scm (@@): The RHS of an @@ is no longer
  restricted to be an identifier, it can be an arbitrary expression.

* module/ice-9/psyntax-pp.scm: Regenerated.
2010-05-06 22:42:44 +02:00
Andy Wingo
9365d8ad3a change form of @ and @@ psyntax handlers
* module/ice-9/psyntax.scm (@, @@): Take r and w args, and also return
  r, w, and s. Adapt callers.
2010-05-06 22:42:44 +02:00
Andy Wingo
807f7ab0ac add `expand' eval-when situation
* module/ice-9/psyntax.scm (chi-when-list, chi-top): Add an undocumented
  `expand' situation to eval-when, which will trigger at expand-time for
  toplevel expressions. Useful when you are expanding for eval, but need
  to do some side effect to affect the expander -- like defining a
  module.

* module/ice-9/psyntax-pp.scm: Regenerate.
2010-05-06 22:42:44 +02:00
Andy Wingo
9a74920905 add explanatory comment to chi-macro
* module/ice-9/psyntax.scm (chi-macro): Add comment.
2010-05-04 23:48:10 +02:00
Julian Graham
b1e4c7cc28 add support for r6rs libraries
* module/ice-9/boot-9.scm: Include ice-9/r6rs-libraries.scm.
* module/ice-9/r6rs-libraries.scm: New file.
* module/Makefile.am (NOCOMP_SOURCES): Add r6rs-libraries.scm.
2010-05-03 22:11:15 +02:00
Andy Wingo
fe58ead4a3 only ensure local vars for definitions during expansion when compiling
* module/ice-9/psyntax.scm (chi-top): Only modify the compile-time
  environment to indicate that there is a local binding if we are
  running in compile mode. Otherwise some eval-when things might not
  have gotten executed, and our current-module could be wrong.

* module/ice-9/psyntax-pp.scm: Regenerate.
2010-05-03 22:11:15 +02:00
Andy Wingo
d61517239d export, re-export etc as syntax-rules macros
* module/ice-9/boot-9.scm (export, re-export, export-syntax)
  (re-export-syntax): Rewrite as syntax-rules macros.
2010-05-03 17:02:50 +02:00
Andy Wingo
4e3328ce69 rewrite use-modules and use-syntax using syntax-case
* module/ice-9/boot-9.scm (use-modules): Rewrite as a syntax-case macro.
  (use-syntax): Likewise.
  (compile-interface-spec): Remove unused function
2010-05-03 17:02:45 +02:00
Andy Wingo
074e036ee2 rewrite define-module as a syntax-case macro
* module/ice-9/boot-9.scm (define-module): Rewrite as a syntax-case
  macro, so that the expansion has proper module hygiene. Otherwise
  process-define-module isn't properly resolved against the root module
  -- a bytecode file that starts with a define-module would just try to
  look up process-define-module from the current module.
  (compile-define-module-args): Remove. Internal, and no one else used
  it.
2010-05-03 17:02:45 +02:00
Andy Wingo
a40e1c9078 remove duplicate quasisyntax.scm EXTRA_DIST
* module/Makefile.am (EXTRA_DIST): Remove quasisyntax.scm, as the
  NOCOMP_SOURCES handles that case.
2010-05-03 17:02:45 +02:00
Andy Wingo
de45d8eef9 add assert-nargs-ee/locals instruction
* libguile/vm-i-system.c (assert-nargs-ee/locals): New instruction, a
  combination of assert-nargs-ee and reserve-locals in the case in which
  nreq and nlocs can both be represented in 8 bits.

* module/language/glil/compile-assembly.scm (glil->assembly): Add
  compiler case.

* doc/ref/vm.texi (Function Prologue Instructions): Update docs.
2010-05-02 13:41:31 +02:00
Andy Wingo
93f63467e6 rename vars' field in tree-il binding constructs to gensyms'
* module/language/tree-il.scm (<tree-il>): Rename `vars' fields of
  <let>, <letrec>, <fix>, and <lambda-case> to `gensyms'. For clarity,
  and to match <lexical-ref>.

* module/language/tree-il.scm:
* module/language/tree-il/analyze.scm:
* module/language/tree-il/compile-glil.scm:
* module/language/tree-il/fix-letrec.scm:
* module/language/tree-il/inline.scm: Update all callers.
2010-05-02 11:22:23 +02:00
Andy Wingo
915aca30ba fix a comment about environments and the scheme compiler
* module/language/scheme/compile-tree-il.scm: Fix a comment about the
  format of environments.
2010-05-02 11:19:46 +02:00
Andy Wingo
246ea9e16a remove `version' field from <language>
* module/system/base/language.scm (<language>): Remove the `version'
  field from languages. It just wasn't useful.

* module/language/assembly/spec.scm:
* module/language/brainfuck/spec.scm:
* module/language/bytecode/spec.scm:
* module/language/ecmascript/spec.scm:
* module/language/elisp/spec.scm:
* module/language/glil/spec.scm:
* module/language/objcode/spec.scm:
* module/language/scheme/spec.scm:
* module/language/tree-il/spec.scm:
* module/language/value/spec.scm: Remove #:version from all language
  definitions. Shorten some language names (e.g. "Guile Scheme" ->
  "Scheme").
2010-05-02 11:19:13 +02:00
Andy Wingo
9a974fd384 optimize and bugfix make-struct VM opcode
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump for make-struct
  change.

* libguile/struct.c (scm_i_alloc_struct): Use scm_words instead of
  scm_gc_malloc to simplify the code and inline the call to GC_MALLOC.

* module/language/tree-il/compile-glil.scm (*primcall-ops*): Compile
  make-struct/no-tail to make-struct.

* module/language/tree-il/primitives.scm (define-primitive-expander):
  Allow a conditional branch of #f to aboirt inlining.
  (make-struct): Expand into make-struct/no-tail in the case that
  tail-size is 0.

* libguile/vm-i-scheme.c (make-struct): Adapt to always assume tail-size
  is 0. Inline allocation if possible. Don't decrement the SP past live
  objects on the stack, which could cause GC to miss references. Use the
  NULLSTACK macro.
2010-05-01 00:31:18 +02:00
Andy Wingo
52272fc764 fix bug in compile-glil.scm for return opcode-hack
* module/language/tree-il/compile-glil.scm (*primcall-ops*): Fix entry
  for `return'. Thanks to Jon Herron for the report.
2010-04-27 23:04:39 +02:00
Andy Wingo
d2b7b761e5 add module-export-all!
* module/ice-9/boot-9.scm (module-export-all!): New function, exports
  all current and future local variables from a module.
2010-04-27 22:57:54 +02:00
Andy Wingo
4e48b4950e module-public-interface is a field in the module record
* module/ice-9/boot-9.scm (module-public-interface)
  (set-module-public-interface!): Instead of using
  '%module-public-interface, use a field in the module instead.
  (make-module, make-autoload-interface): Adapt.

* module/ice-9/deprecated.scm (module-public-interface):
  (set-module-public-interface!): Add shims so that manually munging
  %module-public-interface should continue to work.
2010-04-24 17:43:59 +02:00
Andy Wingo
69928c8a32 fix some uses of %module-public-interface
* module/ice-9/r5rs.scm:
* module/ice-9/safe-r5rs.scm:
* module/oop/goops/save.scm:
* module/oop/goops/simple.scm:
* module/oop/goops/stklos.scm: Fix some uses of
  %module-public-interface.
2010-04-24 17:43:52 +02:00
Andy Wingo
993dae8623 module-public-interface in Scheme
* libguile/modules.c: Consolidate all variables to the top of the file.
  (scm_module_public_interface): Dispatch to Scheme.
  (scm_post_boot_init_modules): Resolve module-public-interface.

* module/ice-9/boot-9.scm (module-public-interface): Implement in
  Scheme.
2010-04-24 17:42:01 +02:00
Andy Wingo
81fc66cfb6 add submodule binders
* module/ice-9/boot-9.scm (module-submodule-binder)
  (set-module-submodule-binder!): New field on modules.
  (make-module, make-autoload-interface): Adapt.
  (module-ref-submodule): If we miss the submodules table, call the
  submodules binder, if any.

* module/ice-9/deprecated.scm (module-ref-submodule): Check the
  submodule binder before the deprecated look into the obarray.
2010-04-24 17:42:01 +02:00
Andy Wingo
f6a5308b03 module-{ref,define}-submodule use the submodules table
* module/ice-9/boot-9.scm (module-ref-submodule)
  (module-define-submodule!): Implement in terms of the
  module-submodules table, instead of looking for bindings in the value
  namespace.

* module/ice-9/deprecated.scm (module-ref-submodule):
  (module-define-submodule!): Define deprecated versions of these that
  duplicate the submodules table in the normal values namespace, for
  back compatibility.
2010-04-24 17:42:01 +02:00
Andy Wingo
f905381d31 add submodules field to modules
* module/ice-9/boot-9.scm (module-type, module-constructor): Add a field
  to modules, a table that will hold submodules.
  (make-module, make-autoload-interface): Adapt.
2010-04-24 17:42:00 +02:00
Andy Wingo
9b023f3c63 use nested-ref-module in (system xref)
* module/system/xref.scm (program-callee-rev-vars): Use
  nested-ref-module instead of nested-ref.
2010-04-24 17:42:00 +02:00
Andy Wingo
28b8c785e7 nested module fixen to (ice-9 ls)
* module/ice-9/ls.scm (local-definitions-in, definitions-in): Use nested
  module procedures, as appropriate.
  (recursive-local-define): Fix attempt to treat null as false. Whoops..
2010-04-24 17:42:00 +02:00
Andy Wingo
635a8b36b1 deprecated %app shims use module-define-submodule!
* module/ice-9/deprecated.scm (%app, app, modules): Don't use the module
  interface to provide %app shims, use module-define-submodule! directly
  to side-effect the root module.
2010-04-24 17:42:00 +02:00
Andy Wingo
d58ccc669c resolve-module uses -module variants
* module/ice-9/boot-9.scm (resolve-module): Use module-define-submodule!
  when binding the root, and nested-ref-module for the hot lookup, which
  is guaranteed to return a module or #f.
2010-04-24 17:42:00 +02:00
Andy Wingo
9e0bfdbaa3 use the define-module variants in module-name and make-modules-in
* module/ice-9/boot-9.scm (module-name): Use module-define-submodule!
  instead of nested-define!.
  (make-modules-in): Rewrite in terms of nested-define-module!.
2010-04-24 17:42:00 +02:00
Andy Wingo
b910c4ac4e nested-ref et al use module-ref-submodule; add -module nested variants
* module/ice-9/boot-9.scm: Update comments above nested-ref to include
  ref-module and define-module!.
  (nested-ref, nested-set!, nested-define!, nested-remove!): Use
  module-ref-submodule to traverse the module hierarchy.
  (nested-ref-module, nested-define-module!): New functions, like
  nested-ref and nested-define!, but operate on namespaces instead of
  values.
  (local-ref-module, local-define-module): New analogs of local-ref and
  local-define, but for namespaces.
2010-04-24 17:41:47 +02:00
Andy Wingo
0f27ab8a9e add module-ref-submodule, module-define-submodule!
* module/ice-9/boot-9.scm (module-ref-submodule):
  (module-define-submodule!): New stubs, will be used to separate
  traversing the module tree from accessing values.
2010-04-23 16:14:31 +02:00
Andy Wingo
51b22dbb48 tweak to resolve-module
* module/ice-9/boot-9.scm (resolve-module): If we found a module but it
  didn't have a public interface and we're not autoloading, just return
  the module directly instead of dispatching to make-modules-in.
2010-04-23 16:14:31 +02:00
Andy Wingo
aa26a6d2b1 fix (app modules) usage in (ice-9 session)
* module/ice-9/session.scm (root-modules): Fix '(app modules) usage.
2010-04-23 16:14:31 +02:00
Andy Wingo
cb67c838f5 deprecate %app
* module/ice-9/boot-9.scm (module-name): Don't rely on (%app modules),
  use other tricks to name anonymous modules.
  (resolve-module): Instead of relying on %app, close over the root of
  the module hierarchy -- the module that was '(%app modules).

* module/ice-9/deprecated.scm (%app): Provide a compatible %app shim.
2010-04-22 15:37:04 +02:00
Andy Wingo
bbd1d13333 refactorings for the module boot process
* module/ice-9/boot-9.scm (%app): Bind %app and (%app modules) within
  the nested hierarchy before making (guile).
  (the-root-module): Define to '(%app modules guile) together with
  the-root-module's definition.
  (resolve-module): Define a "phase 2" resolve-module that only works on the
  root module.
  (try-module-autoload): No need for stub definition, as modules.c does
  not reference this binding.
  (resolve-module): Redefine, after modules have been loaded, to
  actually do its job, without any hacks for the pre-boot phase.

  Move up the boot code before the definition of resolve-module's
  helpers.
2010-04-22 15:36:42 +02:00
Andy Wingo
dbbbc2a1d0 add comments to resolve-module
* module/ice-9/boot-9.scm (resolve-module): Add comments.
2010-04-22 15:31:02 +02:00
Andy Wingo
c9904ab040 formally deprecate `app'
* module/ice-9/deprecated.scm (app): Deprecate.
* module/ice-9/boot-9.scm: Remove app definition.
2010-04-22 15:31:02 +02:00
Andy Wingo
30ce621c5a (app modules) -> (%app modules)
* module/ice-9/debugging/breakpoints.scm (module-if-already-loaded):
  (all-loaded-modules):
* module/oop/goops/stklos.scm: Fix instances of (app modules) to be
  (%app modules).
2010-04-22 15:31:02 +02:00
Andy Wingo
53ab624703 fix comment about "local-define" and "local-remove".
* module/ice-9/boot-9.scm: Fix comment about "local-define!", whereas
  it's "local-define". Same for "local-remove".
2010-04-20 12:43:15 +02:00
Andy Wingo
31ac29b621 module-type defined programmatically
* module/ice-9/boot-9.scm (make-record-type): Add an explanatory
  comment.
  (%print-module): Remove a hacky comment about redefinitions being
  difficult, because now the module-printer is called by name from
  module-type's printer.
  (module-type): Define the module type, its constructor, predicate, and
  accessors programmatically, at expansion time. Should reduce any
  errors in transcription, between adding fields and adding accessors.

* libguile/modules.c (scm_lookup_closure_module): Move an explanatory
  comment here from boot-9.scm.
2010-04-20 12:34:05 +02:00
Andy Wingo
e31f22ebf0 avoid primitive-eval in record-constructor
* module/ice-9/boot-9.scm (record-type-vtable): Add a third field, a
  precomputed constructor. There is an unfortunate circularity here,
  though.
  (make-record-type): If the record has fewer than 20 fields,
  return a constructor pre-generated to suit. Otherwise just check the
  length, and dispatch to `apply' and not `primitive-eval'. FWIW the
  current module record has something like 12 fields.
  (record-constructor): If we're asking for the standard constructor,
  return the precomputed constructor.
2010-04-19 20:19:24 +02:00