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

20 commits

Author SHA1 Message Date
Andy Wingo
c72a0237e3 Fix compile-psyntax.scm -- canonicalize pass not needed
* module/ice-9/compile-psyntax.scm: Remove use of canonicalization pass,
as it's not needed.  Whoopdy!
2021-04-29 21:52:27 +02:00
Andy Wingo
79a40cf717 Add "mod" field to tree-il toplevel ref, set, define
Add "mod" field to <toplevel-ref>, <toplevel-set>, and
<toplevel-define>, indicating the expander's idea of what the current
module is when a toplevel variable is accessed or created.  This will
help in later optimizations.

* libguile/expand.c (TOPLEVEL_REF, TOPLEVEL_SET, TOPLEVEL_DEFINE)
  (expand, expand_define, expand_set_x, convert_assignment):
* libguile/expand.h (SCM_EXPANDED_TOPLEVEL_REF_FIELD_NAMES):
(SCM_MAKE_EXPANDED_TOPLEVEL_REF, SCM_EXPANDED_TOPLEVEL_SET_FIELD_NAMES):
(SCM_MAKE_EXPANDED_TOPLEVEL_SET, SCM_EXPANDED_TOPLEVEL_DEFINE_FIELD_NAMES):
(SCM_MAKE_EXPANDED_TOPLEVEL_DEFINE):
* module/ice-9/compile-psyntax.scm (translate-literal-syntax-objects):
* module/ice-9/psyntax-pp.scm:
* module/ice-9/psyntax.scm:
* module/language/tree-il.scm:
* module/language/tree-il.scm (parse-tree-il, make-tree-il-folder):
(pre-post-order):
* module/language/tree-il/analyze.scm (goops-toplevel-definition):
(macro-use-before-definition-analysis, proc-ref?, format-analysis):
* module/language/tree-il/compile-cps.scm (convert):
* module/language/tree-il/debug.scm (verify-tree-il):
* module/language/tree-il/effects.scm (make-effects-analyzer):
* module/language/tree-il/fix-letrec.scm (free-variables):
* module/language/tree-il/peval.scm (peval):
* test-suite/tests/tree-il.test: Adapt uses.
2019-08-18 22:27:12 +02:00
Andy Wingo
a42bfae65f Psyntax generates new syntax objects
* module/ice-9/psyntax.scm (make-syntax-object): Change to make
  new-style syntax objects.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/ice-9/compile-psyntax.scm (squeeze-syntax-object): Change to be
  functional.
  (squeeze-constant): Likewise.
  (squeeze-tree-il): Likewise.
  (translate-literal-syntax-objects): New pass.  The compiler can embed
  literal syntax objects into compiled objects, but syntax can no longer
  be read/written; otherwise users could forge syntax objects.  So for
  the bootstrap phase, rewrite literal constants to calls to
  make-syntax.
2017-03-28 19:23:13 +02:00
Andy Wingo
403d78f915 Tree-il post-order rewriter no longer destructive
* module/language/tree-il.scm (pre-post-order): New helper, like
  pre-order! and post-order! but not destructive.
  (post-order): Implement in terms of pre-post-order, and rename from
  post-order!.

* module/ice-9/compile-psyntax.scm (squeeze-tree-il):
* module/language/tree-il/canonicalize.scm (canonicalize):
* module/language/tree-il/fix-letrec.scm (fix-letrec):
* module/language/tree-il/primitives.scm (resolve-primitives): Use
  post-order, and rename from the destructive
  variants (squeeze-tree-il!, canonicalize!, etc).  Adapt callers.

* test-suite/tests/tree-il.test (strip-source): Adapt to post-order.

* test-suite/tests/cse.test:
* test-suite/tests/peval.test:
* module/language/tree-il/optimize.scm: Adapt callers.
2013-06-10 22:46:08 +02:00
Mark H Weaver
1af6d2a717 Minimize size of embedded syntax objects in psyntax-pp.scm
* module/ice-9/compile-psyntax.scm: Minimize syntax object literals
  embedded in psyntax-pp.scm.

* module/ice-9/psyntax.scm: Rename a few variables so that syntax
  objects embedded in macros have no lexical bindings, so that their
  minimized syntax objects will have no embedded labels.  These labels
  were the last remaining gensym counters in psyntax-pp.scm.

* module/ice-9/psyntax-pp.scm: Regenerate.  It is now less than one
  quarter of its previous size!  More importantly, this file no longer
  contains any gensym counters, which means that in the future, local
  changes to psyntax.scm will usually result in only local changes to
  psyntax-pp.scm.
2012-03-03 18:06:59 -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
Andy Wingo
f9685f4373 globally unique marks and labels using syntax-session-id
* libguile/macros.c (scm_init_macros): Add definition of new
  syntax-session-id helper.

* module/ice-9/psyntax.scm: Capture a reference to syntax-session-id at
  boot time.  Uniquify marks and labels using the session id.

* module/ice-9/boot-9.scm: Shunt syntax-session-id off to (system
  syntax) once we finished booting.

* module/ice-9/compile-psyntax.scm: Override syntax-session-id when
  remaking psyntax to avoid spurious diffs.

* module/ice-9/psyntax-pp.scm: Regenerate.
2012-01-26 12:08:58 +01:00
Andy Wingo
014de9e25d generate psyntax-pp in canonical form
* module/ice-9/compile-psyntax.scm (source): Canonicalize after
  optimizing.  The optimizer should be a little more clever, but
  currently fix-letrec outputs some non-canonical forms.

* module/ice-9/psyntax-pp.scm: Regenerate.
2011-09-28 19:42:32 +02:00
Andy Wingo
417ee09802 compile-psyntax "optimizes" psyntax-pp
* module/ice-9/compile-psyntax.scm (source): "Optimize" psyntax-pp
  before writing it out.

* module/ice-9/psyntax-pp.scm: Regenerated.
2010-06-17 13:43:27 +02:00
Ludovic Courtès
adb8f30600 Add copyight/license header in `compile-psyntax.scm'. 2010-05-25 23:31:36 +02:00
Andy Wingo
8a73a6d294 rename sc-expand to macroexpand
* module/ice-9/boot-9.scm (macroexpand): Rename from sc-expand.
  (%pre-modules-transformer): Adapt to name change.
* module/ice-9/compile-psyntax.scm: Adapt to name change.
* module/ice-9/psyntax-pp.scm: Regenerated.
* module/ice-9/psyntax.scm: Rename sc-expand to macroexpand.
* module/language/scheme/compile-tree-il.scm (compile-tree-il): Adapt to
  name change.
2010-03-19 15:22:27 +01:00
Andy Wingo
65dd9e3846 pretty-print psyntax-pp.scm
* module/ice-9/compile-psyntax.scm: Pretty-print psyntax-pp.scm, given
  that we are going to compile it anyway.

* module/ice-9/psyntax-pp.scm: Regenerated.
2009-06-08 22:44:01 +02:00
Andy Wingo
811d10f5a2 new language: tree-il. psyntax generates it when run in compile mode.
* module/Makefile.am: Add tree-il sources.

* module/ice-9/compile-psyntax.scm: Adjust for sc-expand producing
  tree-il in compile mode.

* module/ice-9/psyntax.scm: Switch from expand-support to tree-il for
  generating output in compile mode. Completely generate tree-il -- the
  output wasn't Scheme before, but now it's completely not Scheme.

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

* module/language/scheme/compile-ghil.scm: Strip structures using
  tree-il, not expand-support.

* module/language/tree-il.scm:
* module/language/tree-il/spec.scm
* module/language/tree-il/compile-glil.scm: New language. It will compile
  to GLIL, though it doesn't yet.
2009-05-07 17:32:01 +02:00
Andy Wingo
71f46dbd5e sc-expand in compile mode produces (ice-9 expand-support) structures
* module/ice-9/psyntax.scm (*mode*): New moving part, a fluid.
  (sc-expand): Dynamically bind *mode* to the expansion mode.
  (build-global-reference): Change to be a procedure instead of local
  syntax. Import the logic about when to make a @ or @@ form to here,
  from boot-9.scm. If we are compiling, build output using (ice-9
  expand-support)'s make-module-ref, otherwise just making the familiar
  s-expressions. (This will allow us to correctly expand in modules in
  which @ or @@ are not bound, at least when we are compiling.)
  (build-global-assignment): Use the result of build-global-reference. A
  bit hacky, but hey.
  (top-level-eval-hook, local-eval-hook): Strip expansion structures
  before evalling.

* module/ice-9/boot-9.scm (make-module-ref): Remove, this logic is now
  back in psyntax.scm.

* module/ice-9/compile-psyntax.scm (source): Since we expand in compile
  mode, we need to strip expansion structures.

* module/ice-9/expand-support.scm (strip-expansion-structures): Remove
  the logic about whether and how to strip @/@@ from here, as it's part
  of psyntax now.

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

* module/language/scheme/compile-ghil.scm (compile-ghil): Strip expansion
  structures -- for now. In the future, we might translate directly from
  these structures into GHIL.
2009-05-04 11:57:36 +02:00
Andy Wingo
123f8abb2d replace sc-expand with sc-expand3, removing binding for sc-expand3
* module/ice-9/boot-9.scm (sc-expand3):
* module/ice-9/psyntax.scm (sc-expand3): Replace sc-expand with
  sc-expand3, as expand3 with one argument is the same as sc-expand.

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

* module/ice-9/compile-psyntax.scm:
* module/language/scheme/compile-ghil.scm: Change callers to sc-expand3
  to use sc-expand.
2009-05-04 10:47:31 +02:00
Andy Wingo
9c35c5796c make sure we compile boot code in (guile), not (guile-user)
* libguile/eval.h:
* libguile/eval.c (scm_m_eval_when): Define a cheap eval-when, used
  before syncase has booted.

* module/Makefile.am: Reorder to put (system vm) and (system repl)
  modules after the compiler, as they are not needed at runtime.

* module/ice-9/boot-9.scm: Move the eval-when earlier, to be the first
  thing -- so when we recompile Guile we do so all in the '(guile)
  module, not '(guile-user).

* module/ice-9/compile-psyntax.scm: Rewrite to assume that psyntax.scm
  will eval-when to set its module, etc. Have everything in a let --
  otherwise the `format' call is in (guile), but `target' was defined
  in (guile-user). Also, write in an eval-when to the expanded file.

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

* module/ice-9/networking.scm:
* module/ice-9/psyntax.scm:
* module/ice-9/r4rs.scm: Sprinkles of eval-when, for flavor.
2009-04-24 23:10:31 +02:00
Andy Wingo
85e95b4710 fix load for syncase-in-boot-9; compile-psyntax works again
* module/ice-9/r4rs.scm:
* module/ice-9/boot-9.scm (%load-verbosely, assert-load-verbosity)
  (%load-announce, %load-hook, load): Move these from r4rs.scm to
  boot-9.scm.

* module/ice-9/compile-psyntax.scm: Update to work with
  syncase-in-boot-9.

* module/ice-9/psyntax-pp.scm: Recompiled with syncase-in-boot-9.
2009-04-24 14:22:00 +02:00
Andy Wingo
8e1d0d507a more work on modules and hygiene, not finished yet, alas.
* module/ice-9/compile-psyntax.scm: No more expansion-eval-closure.

* module/ice-9/expand-support.scm (strip-expansion-structures): Only @@
  names whose module is not the current module. Actually @@ serialization
  is disabled for this commit, just to get this one in and keep things
  working.

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

* module/ice-9/psyntax.scm (put-global-definition-hook)
  (get-global-definition-hook): Instead of going through that stupid
  getprop/putprop interface, let's just inline Guile-specific code here.
  (build-global-reference, build-global-assignment): Fix a bug where the
  module and public? were switched, which happily allowed things to
  compile. (We reintroduce a similar bug above in expand-support.)
  (lookup): Add a module argument.
  (global-extend): Adapt for put-global-definition-hook invocation.
  (syntax-type): Lookup with mod. Return mod even for lexicals and
  define-form -- why not.
  (chi-top, fluid-let-syntax, syntax, set!): Lookup with mod. Wrap with
  mod.

* module/ice-9/syncase.scm (expansion-eval-closure)
  (current-eval-closure, env->eval-closure): OK! So the idea is: module
  hygiene is syncase's business, not ours. So lose the eval-closure
  fluid. Also, eval closures are so 1990s.
  (sc-macro): But, we have to take the module from the env, sadly. In the
  future this will be different.
  Remove the rest of the eval-closure bits. Enable source reporting,
  while we're debugging.

* module/language/scheme/compile-ghil.scm (lookup-transformer): Adapt for
  eval closure fluid changes.
2009-04-17 15:20:17 +02:00
Andy Wingo
9d80c15649 serialize module information into syncase's output -- getting ready for hygiene
* module/ice-9/Makefile.am: Replace annotate.scm with expand-support.scm.

* module/ice-9/annotate.scm: Removed; subsumed into expand-support.scm.

* module/ice-9/compile-psyntax.scm: Strip out expansion structures before
  writing to disk.

* module/ice-9/expand-support.scm: New file. Provides annotation support,
  and other compound data types for use by the expander. Currently the
  only one that is used is the toplevel reference, <module-ref>, but we
  will record lexicals this way soon.

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

* module/ice-9/psyntax.scm (build-global-reference)
  (build-global-assignment): Instead of expanding out global references
  as symbols, expand them as <module-ref> structures, with space to
  record the module that they should be scoped against. This is in
  anticipation of us actually threading the module info through the
  syntax transformation, so that we can get hygiene with respect to
  modules.

* module/ice-9/syncase.scm: Replace eval-when. Since sc-expand will give
  us something that isn't Scheme because we put the <module-ref>
  structures in it, strip that info whenever we actually do need scheme.

* module/language/scheme/compile-ghil.scm (lookup-transformer): Strip
  expansion structures here too.

* module/language/scheme/expand.scm (language): Swap annotate for
  expand-support. But this file will die soon, I think.
2009-04-17 15:20:15 +02:00
Andy Wingo
00d0489205 move ice-9/ and oop/ under module/
Moved ice-9/ and oop/ under module/, with the idea being that we have
only scheme under module/. Adjusted configure.in and Makefile.am
appropriately. Put oop/ at the end of the compilation order.
2008-11-01 12:44:21 +01:00
Renamed from ice-9/compile-psyntax.scm (Browse further)