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

4577 commits

Author SHA1 Message Date
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
64e5d08d3e leap of faith: (ice-9 syncase) in psyntax-pp.scm -> (guile)
* module/ice-9/psyntax-pp.scm: Manually switch psyntax-pp over to (guile)
  from (ice-9 syncase). Heh heh.
2009-04-24 14:21:06 +02:00
Andy Wingo
131826039c syncase early in boot-9, defmacros in terms of syntax-case -- halfway working
* module/ice-9/boot-9.scm
  (eval-when): Remove, as syncase is going to handle this one for us.
  (sc-expand, sc-expand3, sc-chi, install-global-transformer)
  (syntax-dispatch, syntax-error, annotation?, bound-identifier=?)
  (datum->syntax-object, free-identifier=?, generate-temporaries)
  (identifier?, syntax-object->datum, void, andmap): Oh, ugly of uglies:
  add these exciting definitions to the main environment. Hopefully we
  can pull them back out soon.
  (make-module-ref, resolve-module): Stub these out, as a replacement for
  expand-support.
  (%pre-modules-transformer): Define to sc-expand, so that we are using
  syncase from the very start.
  (defmacro, define-macro): Define in terms of syntax-case.
  (macroexpand, macroexpand-1): Remove, there should be a different way
  to get at this -- though perhaps with the same name.
  (make-module): Make sc-expand the default module-transformer.
  (process-define-module): Issue a deprecation warning when using ice-9
  syncase.
  (primitive-macro?): Remove, no meaning...
  (use-syntax): Deprecate.
  (define-private, define-public, defmacro-public): Rework in terms of
  syntax-rules.

* module/ice-9/syncase.scm: Gut, as syncase is provided by core now.
2009-04-24 14:20:30 +02:00
Andy Wingo
a26934a850 module-name returns '(guile) during boot; psyntax tweak
* module/ice-9/boot-9.scm (module-name): Return '(guile) before the
  module system is booted, for syncase's benefit. Defer redefinition
  until the module system is booted.

* module/ice-9/psyntax.scm (put-global-definition-hook): Only set a
  variable if it's unbound.

* module/ice-9/psyntax.scm: Regenerated.
2009-04-24 14:20:22 +02:00
Andy Wingo
757937c290 more steps on the way to boot-time syncase
* module/ice-9/boot-9.scm: Define a version of module-add! for psyntax,
  before modules are booted.

* module/ice-9/psyntax.scm: Remove a warning, and rename a variable.
  Initialize a new variable to 'sc-macro, though it will have no effect.

* module/ice-9/psyntax-pp.scm: Regenerated.
2009-04-24 13:42:25 +02:00
Andy Wingo
819cf0e8b8 I ain't broke, but brother I'm badly bent
* module/ice-9/expand-support.scm (strip-expansion-structures): If, when
  producing @/@@ forms, we find that an @@ variable is not bound in its
  module, just serialize the symbol. This bends hygiene, in that it can
  introduce a global (but not lexical) reference in the expanded module,
  but it seems necessary to not produce (@@ (foo) else) in forms like
  ((@@ (foo) cond) ((test then) ((@@ (foo) else) bar))).
2009-04-23 11:25:22 +02:00
Andy Wingo
8239263f86 fix erroneous #:use-syntax clausen
* module/system/repl/command.scm:
* module/system/repl/common.scm:
* module/system/repl/repl.scm:
* module/system/vm/debug.scm:
* module/system/vm/trace.scm: Change #:use-syntax to #:use-module, as
  that's really what we want to do.
2009-04-22 22:27:50 +02:00
Andy Wingo
eb5d1f8826 move pk, peek, and warn to the beginning of boot-9
* module/ice-9/boot-9.scm (peek, pk, warn): Move these helpers up to the
  top. I like them!
  (load-compiled): Don't define within an if, syncase doesn't like that.
2009-04-22 22:23:43 +02:00
Andy Wingo
efa6f9d944 module-name before syncase is booted
* module/ice-9/boot-9.scm (module-name): Give psyntax a module-name
  definition, even before psyntax is booted (in a future commit).
2009-04-22 00:17:22 +02:00
Andy Wingo
b1e93821a3 fix begin-deprecated
* module/ice-9/boot-9.scm (begin-deprecated): Fix to output source code,
  doh.
2009-04-21 23:03:00 +02:00
Andy Wingo
928258fbf2 tweaks to boot-9
* module/ice-9/boot-9.scm: Move the r4rs init up to the top.
  (try-module-autoload): Don't use with-fluids before it's defined.
2009-04-21 23:02:53 +02:00
Andy Wingo
ae6bba7f9c commit some tweaks to expand.scm, likely obviated by syncase though
* module/language/scheme/expand.scm (re-annotate, expand): A couple of
  speculative cases for dealing with syncase better -- but all of this
  code is likely to go.
2009-04-21 23:02:38 +02:00
Andy Wingo
dec62b5ef8 make syncase aware of (set! (@ (foo) bar) baz)
* module/ice-9/psyntax.scm (set!): Handle (set! (@ (foo ..) bar) val)
  inside syncase. Heh heh heh.

* module/ice-9/psyntax-pp.scm: Regenerated.
2009-04-21 22:56:51 +02:00
Andy Wingo
265e61273d syncase knows about @ / @@
* module/ice-9/psyntax.scm (syntax-type): Handle a new type, module-ref.
  Like external-macro, it also has a procedure as a binding.
  (chi-expr): module-ref forms -- that is to say, (@ (foo ...) bar) -- as
  expressions they are global references, but with respect to a specific
  module.
  (@, @@): Define module-ref syntax handlers.

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

* module/ice-9/syncase.scm: Mark as primitive syntax so we don't clobber
  their definitions.

The reason I'm doing things like this is so as to support (set! (@@ ...)
...) sensibly, which will be the next patch.
2009-04-21 22:26:27 +02:00
Andy Wingo
71d903c881 Merge branch 'syncase' 2009-04-20 22:26:02 +02:00
Andy Wingo
fb3807793f scripts take rest args
* meta/guile-tools: Instead of fixing scripts I should have been fixing
  the script runner.

* module/scripts/compile.scm:
* module/scripts/snarf-guile-m4-docs.scm: Fix to take rest args.
2009-04-20 18:20:01 +02:00
Andy Wingo
2b4b555b8f fix build errors on fresh checkout
* meta/guile-tools: We can't use srfi-1, because on a fresh checkout
  the srfi-1 shlib isn't built yet. Bummer.

* meta/uninstalled-env.in: Fix up the DYLD lines for BSDen.

* module/scripts/snart-guile-m4-docs.scm: Fix expected arguments.
2009-04-20 17:23:40 +02:00
Andy Wingo
69dd78d7c8 no positions when reading psyntax-pp, validation in @/@@, cleanups
* module/ice-9/syncase.scm (old-debug): Re-disable position recording
  when reading psyntax-pp.

* libguile/eval.c (scm_m_at, scm_m_atat): More input validation.

* libguile/debug.c (scm_procedure_module): Use scm_env_module. Remove
  extraneous docstring.
2009-04-17 15:20:19 +02:00
Andy Wingo
c5cc65ac0c fix hygiene + modules + local macros
* module/ice-9/psyntax-pp.scm: Regenerate.

* module/ice-9/psyntax.scm (syntax-type): Look up the type of the car of
  a form relative to its module, if it is a syntax object. Fixes hygiene
  wrt modules and private macros.

* module/ice-9/syncase.scm (sc-macro): Add a comment.

* module/system/base/pmatch.scm: The big test case: just export pmatch,
  not ppat too.
2009-04-17 15:20:19 +02:00
Andy Wingo
249bab1c53 @ and @@ as primitive macros
* libguile/eval.h:
* libguile/eval.c (error_unbound_variable, error_defined_variable):
  Move these prototypes up earlier.
  (scm_m_at, scm_m_atat): New functions, provide the @ and @@
  functionality. Moved here from defmacros because they are
  "special", inasmuch as syncase doesn't really understand them in
  interpreted code.

* module/ice-9/boot-9.scm (@, @@): Don't define as defmacros, as
  defmacros have to actually return source now.
2009-04-17 15:20:18 +02:00
Andy Wingo
900761bc8d hygienic compilation
* module/language/scheme/compile-ghil.scm (lookup-transformer): Recognize
  macros as initial (@ ...) or (@@ ...) forms, enabling hygienic
  compilation.
2009-04-17 15:20:18 +02:00
Andy Wingo
d2b61fe0ff houston, we have hygiene
* module/ice-9/expand-support.scm (strip-expansion-structures): Enable
  @/@@ substitution.

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

* module/ice-9/psyntax.scm: Since syntax objects are quotable, make the
  module field the module name, not the module itself. Scope the operand
  of global calls appropriately. Thread modules through syntax-dispatch
  destructuring. Houston, we have hygiene.

* module/ice-9/syncase.scm: Adapt to module / module-name changes.
2009-04-17 15:20:17 +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
4e237f1460 thread the module through syntax-case's expansion
* libguile/debug.h:
* libguile/debug.c (scm_procedure_module): New procedure, returns the
  module that was current when the given procedure was defined. Used by
  syncase to scope free identifiers.

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

* module/ice-9/psyntax.scm: Thread the module through the syntax
  expansion. This is harder than it would appear because in many places
  the different components of syntax objects are destructured.

* module/ice-9/syncase.scm (guile-macro): Adapt to new signature for
  syntax transformer functions.
2009-04-17 15:20:16 +02:00
Andy Wingo
e02e84deed finish bootstrap to syntax-objects with modules
* module/ice-9/psyntax.scm: Now that we have gone through the
  intermediate step (in which both representations of syntax-object had
  to coexist), change all callers to make-syntax-object to pass the third
  argument, and restore the define-structure definition of syntax
  objects.

* module/ice-9/psyntax-pp.scm: Recompile.
2009-04-17 15:20:16 +02:00
Andy Wingo
1641568c33 add modules to syntax objects (part 1, intermediate step)
* module/ice-9/psyntax.scm (make-syntax-object): As an intermediate step
  to adding modules to syntax objects, replace the definition of
  syntax-object as a structure with an expanded-out definition that has
  (1) a constructor that takes 2 or 3 arguments, and (2) a predicate that
  works with vectors of length 3 or 4. I couldn't just redefine
  make-syntax-object, for example, because these are internal
  definitions, and we can't have duplicate bindings in a letrec.
2009-04-17 15:20:16 +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
6d66647d5b guile-tools is a scheme script that loads scheme modules
* meta/guile-tools: Changed to be a scheme script. Instead of looking for
  executables in a "scripts dir", we just look for modules in (scripts),
  and load the modules directly.

* module/Makefile.am:
* module/scripts/: Move the scripts into module/ so they can be compiled.
  Rename scripts from `foo' to `foo.scm'.

* libguile/Makefile.am: Invoke the snarf->texi code via guile-tools.

* configure.in:
* .gitignore: Update for changes.
2009-04-17 11:19:42 +02:00
Andy Wingo
b8076ec6cc support expression-by-expression compilation
* module/language/ghil.scm (unparse-ghil): Fix unparsing of quasiquoted
  expressions.

* module/language/ghil/spec.scm (join): Define a joiner for GHIL.

* module/language/scheme/compile-ghil.scm (cenv-ghil-env): Expand the
  definition of a CENV so it can have an actual ghil-env, if available.
  (compile-ghil): Return the actual ghil env in the cenv.

* module/system/base/compile.scm (compile-file): Rewrite. `output-file'
  is now a keyword argument, along with the new kwargs `env' and `from'.
  We now allow exceptions to propagate up, and instead of printing the
  output file to the console, we return a string corresponding to its
  location.
  (compile-and-load): Use read-and-compile.
  (compile-fold): Thread around the cenv as well. Return all three
  values.
  (find-language-joint, read-and-compile): New exciting helpers. The idea
  is that compiling a file should be semantically equivalent to compiling
  each expression in it, one by one. Compilation can have side effects,
  e.g. affecting the current language or the current reader. So what we
  do is find a point in the compilation path at which different
  expressions of a given language can be joined into one. Expressions
  from the source language are compiled to the joint language, then
  joined and compiled to the target.
  (compile): Just return the first value from compile-fold.

* module/system/base/language.scm (language-joiner): New optional field.

* scripts/compile: Rework for changes to compile-file.
2009-04-16 17:49:59 +02:00
Andy Wingo
b41b92c9d1 compilation passes return third value: the continuation environment
* module/system/base/compile.scm: Expect compile passes to produce three
  values, not two. The third is the "continuation environment", the
  environment that can be used to compile a subsequent expression from
  the same source language. For example, expansion-time side effects can
  set the current module, which would be reflected appropriately in the
  continuation environment.

* module/language/assembly/compile-bytecode.scm:
* module/language/bytecode/spec.scm:
* module/language/ecmascript/compile-ghil.scm:
* module/language/ghil/compile-glil.scm:
* module/language/glil/spec.scm:
* module/language/objcode/spec.scm:
* module/language/scheme/compile-ghil.scm:
* module/system/base/compile.scm: Update compile passes to return a
  continuation environment.
2009-04-16 15:20:40 +02:00
Jose A. Ortega Ruiz
aa49787b5e Improved handling of callers cache in (system xref).
* We cache callees in each module, and keep a list of modified
    ('tainted') modules, which is used to reconstruct the callers
    database incrementally.
  * `procedure-callers' now returns an a-list, keyed by module name.
2009-04-04 11:55:50 -07:00
Andy Wingo
9c0cd73e61 Merge branch 'wingo' 2009-03-28 22:31:20 -07:00
Andy Wingo
6ecae97fb8 fix duplicates in procedure-callers
* module/system/xref.scm (ensure-callers-db): OK! Since we can see the
  same variable twice, e.g. in different modules, keep a unified hash of
  seen vars and modules. Prevents duplicates in procedure-callers.
2009-03-28 22:21:00 -07:00
Andy Wingo
154a611669 fix spurious duplicates in procedure-callees and callers
* module/system/xref.scm (program-callee-rev-vars): It's possible to get
  duplicates when combining callees of inner procedures, so ignore dups.
  Quadratic, boo.
2009-03-28 21:57:47 -07:00
Andy Wingo
60ae5ca2a3 frame, program, objcode, etc inits use load-extension
* libguile/extensions.h: Define a scm_t_extension_init_func.

* libguile/frames.c:
* libguile/instructions.c:
* libguile/objcodes.c:
* libguile/programs.c:
* libguile/vm.c: Register extension init funcs. Should play nicer with a
  static Guile, in addition to working on Darwin with non-default
  installation prefixes without munging DYLD_LIBRARY_PATH.

* module/system/vm/frame.scm:
* module/system/vm/instruction.scm:
* module/system/vm/objcode.scm:
* module/system/vm/program.scm:
* module/system/vm/vm.scm: Use load-extension.
2009-03-27 18:40:15 -07: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
80540f3914 speed up goops rehashing
* module/oop/goops/dispatch.scm (cache-try-hash!): Speed up goops
  rehashing, in theory. I haven't measured, though.
2009-03-20 16:20:00 +01:00
Andy Wingo
32e49fa355 fix interpreted methods with empty bodies
* module/oop/goops.scm (method): If a method has no body, subst in `(if
  #f #f)' instead of `(begin)', to please the memoizer.
2009-03-20 16:20:00 +01:00
Andy Wingo
4e2f1e9edd add generic method-formals; fixes to method-source
* module/oop/goops.scm (method-source): Don't throw an error if this
  method has no source.
  (method-formals): New generic function, the complement of
  method-specializers for introspection.
2009-03-20 16:20:00 +01:00
Andy Wingo
e0a3ad670b rework procedure-callers to stay correct as callees are redefined
* module/system/xref.scm (procedure-callers): Rework to calculate the
  callers of a *variable*, not of a value. This is because the
  module-observers only get fired when the module changes, not with the
  variables change values. Also accept either a variable, a symbol
  (resolved in the current module), or a modname . symname pair.
2009-03-18 01:49:28 +01:00
Andy Wingo
7eba9c99c2 doubly-weak callers db
* module/system/xref.scm (ensure-callers-db): Store the callers db as a
  doubly-weak hash table.
2009-03-18 00:46:16 +01:00
Andy Wingo
b190790255 implement procedure-callers
* module/system/xref.scm: Implement procedure-callers, as the inverse of
  procedure-callees, with a cache invalidated by changes in modules.

* module/ice-9/boot-9.scm (module-use!): Don't poke module observers when
  module-use! is called for an already-used module.
2009-03-18 00:44:26 +01:00
Andy Wingo
4f96d42b2d add xref stub for interpreted procedures
* module/system/xref.scm (hacky-procedure-callees): Add a
  procedure-callees implementation for procedures with source, that
  currently does nothing. Not sure what to do, going into the future.
2009-03-17 23:16:35 +01:00
Andy Wingo
e04894e1ac add xref.scm
* module/system/xref.scm: New module, will provide callers/callees info.

* module/Makefile.am (SOURCES): Add xref.scm.
2009-03-17 23:11:56 +01:00
Andy Wingo
06dc937dd7 decompile source info into <glil-source> annotations.
* module/language/glil/decompile-assembly.scm (decompile-load-program):
  Decompile source information into <glil-source> annotations.
2009-03-17 16:47:43 +01:00
Andy Wingo
ff33605d6a fix bug serializing filenames in source locations
* module/language/glil/compile-assembly.scm (limn-sources): Fix bug
  whereby filename was serialized as a ("foo") instead of "foo".
2009-03-17 16:47:35 +01:00
Andy Wingo
eb7ea0450a tweaks to asm->glil decompiler, perhaps fix a (program-source p 0) bug
* module/language/ghil/compile-glil.scm (codegen): Push a program's
  source locations before copying external args to heap -- perhaps fixes
  (program-source p 0) for some programs.

* module/language/glil/decompile-assembly.scm (decompile-load-program):
  Take another arg, the object vector. Emit <glil-bind> and <glil-unbind>
  correctly. Properly unparse properties. Just have to deal with source
  locations now.
2009-03-17 16:47:28 +01:00
Andy Wingo
860f569a6a add assembly->glil decompiler
* module/language/glil/decompile-assembly.scm: A first pass at an
  assembly->glil decompiler. Works for a small subset of programs.

* module/Makefile.am (GLIL_LANG_SOURCES):
* module/language/glil/spec.scm (glil): Add the decompiler.
2009-03-17 16:47:24 +01:00
Andy Wingo
a3f0ff0faf update disassembler for changes to decompiler
* module/language/assembly/disassemble.scm (disassemble-load-program)
  (code-annotation): And update the disassembler for changes to
  decompiler.
2009-03-17 16:47:19 +01:00
Andy Wingo
6fe6a2a27d parse jumps as labels when decompiling bytecode->assembly
* module/language/assembly/decompile-bytecode.scm (decode-load-program):
  Parse out jumps as labels.
2009-03-17 16:47:14 +01:00