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

15 commits

Author SHA1 Message Date
Andy Wingo
60d852248f <lambda-case> must have list of optargs
Before, the optional args in a lambda-case could be #f or a list of
symbols.  However the list of symbols is entirely sufficient; no
optional args means a null list.  Change everywhere that produces
lambda-case, matches on lambda-case, and reads deserialized lambda-case.
2024-08-29 09:53:37 +02:00
Mark H Weaver
1160e2d94e Merge remote-tracking branch 'origin/stable-2.0' 2013-08-11 22:46:22 -04:00
Andy Wingo
99983d544a Inline escape-only prompt bodies in the Tree-IL
* module/language/scheme/decompile-tree-il.scm (do-decompile):
* module/language/tree-il/analyze.scm (analyze-lexicals):
* module/language/tree-il/canonicalize.scm (canonicalize):
* module/language/tree-il/compile-glil.scm (flatten-lambda-case):
* module/language/tree-il/cse.scm (cse):
* module/language/tree-il/peval.scm (peval):
* test-suite/tests/peval.test ("partial evaluation"):  Partially revert
  178a40928, so that escape-only prompts explicitly inline their bodies.
2013-08-11 16:45:31 +02:00
Mark H Weaver
d9b312af56 Decompiler: fix handling of empty 'case-lambda' expressions.
* module/language/scheme/decompile-tree-il.scm (choose-output-names):
  A <lambda> with no <lambda-case> decompiles into a 'case-lambda'
  primitive.  Ensure that 'case-lambda' is not shadowed by a lexical.
2013-08-07 05:54:15 -04:00
Andy Wingo
178a40928a <prompt> body and handler are lambdas; add escape-only? field
* module/language/tree-il.scm (<prompt>): Change to have the body and
  handler be lambdas, and add an "escape-only?" field.  This will make
  generic prompts work better in CPS or ANF with the RTL VM, as it
  doesn't make sense in that context to capture only part of a frame.
  Escape-only prompts can still be fully inlined.
  (parse-tree-il, unparse-tree-il): Add escape-only? to the
  serialization.
  (make-tree-il-folder, pre-post-order): Deal with escape-only?.

* module/language/tree-il/analyze.scm (analyze-lexicals): Handle
  escape-only?, and the new expectations for the body and handler.

* module/language/tree-il/canonicalize.scm (canonicalize): Ensure that
  the body of an escape-only continuation is a thunk, and that the
  handler is always a lambda.
* module/language/tree-il/debug.scm (verify-tree-il): Assert that
  escape-only? is a boolean.

* module/language/tree-il/cse.scm (cse):
* module/language/tree-il/effects.scm (make-effects-analyzer):
* module/language/tree-il/peval.scm (peval):
* module/language/tree-il/primitives.scm (*primitive-expand-table*):
* test-suite/tests/peval.test ("partial evaluation"):
* module/language/tree-il/compile-glil.scm (flatten-lambda-case): Adapt
  to <prompt> change.
2013-07-06 20:27:21 +09:00
Andy Wingo
c32b7c4cef Remove with-fluids; replaced by with-fluid* and inlined push-fluid primops
* libguile/vm-i-system.c (push-fluid, pop-fluid):
* doc/ref/vm.texi (Dynamic Environment Instructions): Rename wind-fluids
  to push-fluid, and unwind-fluids to pop-fluid.  They now only work on
  one fluid binding at a time.

* module/ice-9/boot-9.scm (with-fluid*): Implement in Scheme in terms of
  primcalls to push-fluid and pop-fluid.
  (custom-throw-handler, catch, with-throw-handler): Use with-fluid*
  instead of with-fluids, as with-fluids is no longer available before
  psyntax is loaded.
  (with-fluids): Define in Scheme in terms of with-fluid*.

* libguile/fluids.c (scm_with_fluid): Rename from scm_with_fluids, and
  don't expose to Scheme.

* libguile/eval.c (eval): Remove SCM_M_WITH_FLUIDS case.
* libguile/expand.c (expand_with_fluids): Remove with-fluids syntax.
  (DYNLET): Remove, no longer defining dynlet in the %expanded-vtables.
* libguile/expand.h: Remove dynlet definitions.
* module/ice-9/eval.scm (primitive-eval): Remove with-fluids case.
* libguile/memoize.c (do_push_fluid, do_pop_fluid): New primitive
  helpers, like wind and unwind.
  (memoize): Memoize wind and unwind primcalls.  Don't memoize dynlet to
  with-fluids.
  (scm_init_memoize): Initialize push_fluid and pop_fluid here.
* libguile/memoize.h (SCM_M_WITH_FLUIDS): Remove definition.

* module/ice-9/psyntax.scm (build-dynlet): Remove; this just supported
  with-fluids, which is now defined in boot-9.
* module/ice-9/psyntax-pp.scm: Regenerate.

* doc/ref/compiler.texi (Tree-IL):
* module/language/tree-il.scm:
* module/language/tree-il/analyze.scm:
* module/language/tree-il/canonicalize.scm:
* module/language/tree-il/compile-glil.scm:
* module/language/tree-il/cse.scm:
* module/language/tree-il/debug.scm:
* module/language/tree-il/effects.scm: Remove <dynlet>.  Add cases for
  primcalls to push-fluid and pop-fluid in compile-glil.scm and
  effects.scm.

* module/language/tree-il/peval.scm (peval): Factor out
  with-temporaries; probably a bad idea, but works for now.  Factor out
  make-begin0 (a better idea).  Inline primcalls to with-fluid*, and
  remove dynlet cases.

* module/language/tree-il/primitives.scm (*interesting-primitive-names*):
  Add with-fluid*.
2013-06-28 19:52:09 +02:00
Andy Wingo
5e0253f19e replace <dynset> with primcalls to fluid-set!
* doc/ref/compiler.texi (Tree-IL): Remove mention of <dynset>.
* module/language/scheme/decompile-tree-il.scm (do-decompile):
  (choose-output-names): Remove dynset.
* module/language/tree-il.scm (<tree-il>, parse-tree-il):
  (unparse-tree-il, make-tree-il-folder, pre-post-order): Remove
  <dynset>.

* module/language/tree-il/analyze.scm (analyze-lexicals):

* module/language/tree-il/compile-glil.scm (*primcall-ops*): Add
  fluid-set!.
  (flatten-lambda-case): Remove <dynset> case.

* module/language/tree-il/cse.scm (cse):
* module/language/tree-il/debug.scm (verify-tree-il): Remove <dynset>
  cases.

* module/language/tree-il/effects.scm (make-effects-analyzer): Remove
  <dynset> case.  Add a primcall fluid-set! case.

* module/language/tree-il/peval.scm (peval): Remove dynset cases.

* module/language/tree-il/primitives.scm (*primitive-expand-table*):
  Remove fluid-set! -> dynset transformation.
2013-06-27 22:02:43 +02:00
Andy Wingo
86d0eb31df replace <dynref> with primcalls to fluid-ref
* doc/ref/compiler.texi (Tree-IL): Remove mention of <dynref>.
* module/language/scheme/decompile-tree-il.scm (do-decompile):
  (choose-output-names): Remove dynref.
* module/language/tree-il.scm (<tree-il>, parse-tree-il):
  (unparse-tree-il, make-tree-il-folder, pre-post-order): Remove
  <dynref>.

* module/language/tree-il/analyze.scm (analyze-lexicals):

* module/language/tree-il/compile-glil.scm (*primcall-ops*): Add
  fluid-ref.
  (flatten-lambda-case): Remove <dynref> case.

* module/language/tree-il/cse.scm (cse):
* module/language/tree-il/debug.scm (verify-tree-il): Remove <dynref>
  cases.

* module/language/tree-il/effects.scm (make-effects-analyzer): Remove
  <dynref> case.  Add a primcall fluid-ref case.

* module/language/tree-il/peval.scm (peval): Remove dynref cases.

* module/language/tree-il/primitives.scm (*primitive-expand-table*):
  Remove fluid-ref -> dynref transformation.
2013-06-27 22:02:43 +02:00
Andy Wingo
bb97e4abd4 dynamic-wind in terms of wind and unwind; remove <dynwind>, @dynamic-wind
* doc/ref/compiler.texi: Remove mention of <dynwind>.
* libguile/eval.c (eval): Remove SCM_M_DYNWIND case.
* libguile/expand.c: Remove scm_sym_at_dynamic_wind.
* libguile/memoize.c (do_wind, do_unwind): A couple of hacky subrs.  If
  we see a wind or unwind primcall, we expand to a call of a quoted subr
  value.  It works and removes a kind of memoized value from the
  interpreter.  For the compiler,primcalls to wind and unwind are
  handled specially.
  (MAKMEMO_DYNWIND): Remove.
  (scm_tc16_memoizer): Remove.  Yay!
  (memoize): Remove speculative lookup for toplevels to see if they are
  memoizers: there are no more memoizers.  Memoize calls to the wind and
  unwind primitives.
  (m_dynamic_wind): Remove.
  (unmemoize): Remove dynwind case.
  (scm_init_memoize): Add wind and unwind local definitions.

* module/ice-9/boot-9.scm (dynamic-wind): Reimplement in terms of "wind"
  and "unwind" primitives.  These primitives are not exposed to other
  modules.

* module/ice-9/eval.scm (primitive-eval): Remove dynwind case.
* module/language/scheme/decompile-tree-il.scm (do-decompile):
  (choose-output-names): Remove dynwind cases.

* module/language/tree-il.scm: Remove <dynwind>.  Yaaay!

* module/language/tree-il/analyze.scm (analyze-lexicals): Remove dynwind
  cases.

* module/language/tree-il/compile-glil.scm (*primcall-ops*): Add wind
  and unwind.
  (flatten-lambda-case): Remove dynwind case.  Yay!

* module/language/tree-il/cse.scm (cse):
* module/language/tree-il/debug.scm (verify-tree-il):
* module/language/tree-il/effects.scm (make-effects-analyzer):
* module/language/tree-il/peval.scm (singly-valued-expression?, peval):
  Remove <dywind> cases.  Inline primcalls to dynamic-wind.  Add
  constant folding for thunk?.

* module/language/tree-il/primitives.scm (*interesting-primitive-names*):
  Remove @dynamic-wind, and add procedure? and thunk?.
  (*effect+exception-free-primitives*): Add procedure? and thunk?.
  (*multiply-valued-primitives*): Remove @dynamic-wind.
  Remove @dynamic-wind expander.

* test-suite/tests/peval.test ("partial evaluation"): Update tests for
  dynwind desugaring.
2013-06-27 22:02:43 +02:00
Mark H Weaver
26d148066f Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	configure.ac
	libguile/deprecated.c
	libguile/deprecated.h
	libguile/filesys.h
	libguile/fluids.c
	libguile/fports.c
	libguile/gc.c
	libguile/guile.c
	libguile/numbers.c
	libguile/objcodes.c
	libguile/r6rs-ports.c
	libguile/smob.c
	libguile/socket.c
	libguile/threads.h
	module/language/scheme/decompile-tree-il.scm
	module/language/tree-il/peval.scm
	test-suite/tests/syncase.test
2013-03-28 05:09:53 -04:00
Andy Wingo
19113f1ca7 allow case-lambda expressions with no clauses
* module/ice-9/psyntax-pp.scm:
* module/ice-9/psyntax.scm (case-lambda, case-lambda*): Allow 0
  clauses.

* module/language/scheme/decompile-tree-il.scm (do-decompile):
  (choose-output-names):
* module/language/tree-il.scm (unparse-tree-il):
  (tree-il-fold, post-order!, pre-order!):
* module/language/tree-il/effects.scm (make-effects-analyzer):
* module/language/tree-il/cse.scm (cse):
* module/language/tree-il/debug.scm (verify-tree-il):
* module/language/tree-il/peval.scm (peval): Allow for lambda-body to be
  #f.

* libguile/memoize.c (memoize):
* module/language/tree-il/canonicalize.scm (canonicalize!): Give a body
  to empty case-lambda before evaluating it or compiling it,
  respectively.

* test-suite/tests/optargs.test ("case-lambda", "case-lambda*"): Add
  tests.
2013-03-09 11:16:31 +01:00
Mark H Weaver
d019ef9288 Merge branch 'stable-2.0'
Conflicts:
	module/ice-9/psyntax-pp.scm
	module/language/tree-il.scm
2012-03-03 20:20:16 -05:00
Mark H Weaver
72ee0ef71b tree-il->scheme improvements
* module/language/tree-il.scm (tree-il->scheme): New implementation that
  simply calls 'decompile-tree-il'.

* module/language/scheme/decompile-tree-il.scm (choose-output-names,
  do-decompile): New internal procedures.

  (decompile-tree-il): New and improved implementation.  Print source
  identifiers where possible, otherwise add minimal numeric suffixes.
  Previously we printed the gensyms.  Avoid 'begin' in contexts that
  provide an implicit 'begin'.  Produce 'cond', 'case', 'and', 'or',
  'let*', named let, and internal defines where appropriate.  Recognize
  keyword arguments in 'opts' to disable the production of these derived
  syntactic forms, and to optionally strip numeric suffixes from
  variable names.

* module/ice-9/compile-psyntax.scm: Disable partial evaluation, letrec
  fixing, and primitive expansion when producing psyntax-pp.scm, in
  order to produce output as close to the original source as practical.
  Disable production of derived syntactic forms as needed during
  bootstrap.  Strip numeric suffixes from variable names.  Adjust
  pretty-printing parameters.

* module/ice-9/psyntax-pp.scm: Regenerate.  It is now less than half
  of the original size.
2012-03-03 18:05:21 -05: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
b81d329e44 more work on tree-il compilation
* module/language/scheme/amatch.scm: Remove, this approach won't be used.

* module/Makefile.am: Adjust for additions and removals.

* module/language/scheme/compile-ghil.scm: Remove an vestigial debugging
  statement.

* module/language/scheme/spec.scm:
* module/language/scheme/compile-tree-il.scm:
* module/language/scheme/decompile-tree-il.scm: Add tree-il compiler and
  decompiler.

* module/language/tree-il/compile-glil.scm: Add some notes.

* module/language/tree-il/spec.scm: No need to wrap expressions in
  lambdas -- GHIL needs somewhere to put its variables, we don't.
2009-05-08 12:56:18 +02:00