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

23 commits

Author SHA1 Message Date
Andy Wingo
a755136ba8 fix (oop goops) compilation for (language tree-il primitives)
* module/oop/goops.scm (compile): Whoop-dee, fix up (oop goops) for
  (language tree-il primitives) change.
2009-05-22 21:14:48 +02:00
Andy Wingo
d63927150a just parse method arguments once.
* module/oop/goops.scm (method): Tweak to just run through the arguments
  once. Thanks to Eli Barzilay for the tip.
2009-05-21 15:34:29 +02:00
Andy Wingo
47c8983f08 rewrite `method' as a hygienic macro to re-allow lexical specializers
* module/oop/goops.scm (method): Reimplement as a hygienic macro. This
  seriously took me like 6 hours to figure out. Allows for lexical
  specializers: (let ((<x> ...)) (define-method (foo (arg <x>)) ...)).

* module/oop/goops/compile.scm (next-method?, compile-make-procedure):
  Remove these, as `method' does it all now, hygienically.
2009-05-21 13:49:00 +02:00
Andy Wingo
ad9b8c451b fix @slot-ref / @slot-set! compilation
* module/language/tree-il/compile-glil.scm: Add primcall compilers for
  @slot-ref and @slot-set.

* module/language/tree-il/optimize.scm (add-interesting-primitive!): New
  export. Creates an association between a variable in the current module
  and a primitive name.

* module/oop/goops.scm: Rework compiler hooks to work with tree-il and
  not ghil.
2009-05-20 13:59:42 +02:00
Andy Wingo
22225fc113 syntax-object->datum => syntax->datum, likewise datum->syntax
* module/ice-9/boot-9.scm (datum->syntax, syntax->datum): Rename from
  datum->syntax-object and syntax-object->datum, following r6rs. Change
  all callers. Reorder some of the other exports from psyntax.

* module/ice-9/psyntax.scm: Change datum->syntax and syntax->datum
  definitions and callers.

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

* module/oop/goops.scm (define-class-pre-definition): Update for changes.
2009-04-26 20:56:24 +02:00
Andy Wingo
b3501b8043 all of guile compiles now, expanded with syncase
* libguile/eval.c (scm_m_eval_when): Whoops, eval-when has an implicit
  begin. Fix.

* module/oop/goops.scm: Syncase doesn't like definitions in expression
  context, and grudgingly I have decided to go along with that. But that
  doesn't mean we can't keep the old semantics, via accessing the module
  system directly. So do so. I took the opportunity to rewrite some
  macros with syntax-rules and syntax-case -- the former is nicer than
  the latter, of course.

* module/oop/goops/save.scm: Don't define within an expression.

* module/oop/goops/simple.scm (define-class): Use define-syntax.

* module/oop/goops/stklos.scm (define-class): Use define-syntax.
2009-04-25 14:10:08 +02:00
Andy Wingo
2ce560b944 fix bad syntax in define-macro, (ice-9 match), and (oop goops)
* module/ice-9/boot-9.scm (define-macro): Use syntax-case to destructure
  macro arguments, so we get good errors.

* module/ice-9/match.scm (defstruct, define-const-structure): Don't
  unquote in the `defstruct' macro as a value in expansions.

* module/oop/goops.scm (standard-define-class): Can't define a macro with
  `define', use `define-syntax' instead.
  (define-accessor): Use syntax-rules. Doesn't give us much in this case.
  (toplevel-define!): New helper, to let us keep GOOPS' behavior with the
  new expander. Some solution that works lexically and at the toplevel
  would be nice, though.
  (define-method): Reimplement with syntax-rules -- soooo much nicer.

* module/oop/goops/dispatch.scm (lookup-create-cmethod): Don't define
  within an expression.
2009-04-25 12:50:53 +02:00
Andy Wingo
58df2e4393 merge ice-9, srfi, oop makfiles into module makefile
* configure.in: No longer output the Makefile.ins.

* module/Makefile.am: Include the contents of ice-9/, srfi/, and oop/.

* module/ice-9/Makefile.am:
* module/ice-9/debugger/Makefile.am:
* module/ice-9/debugging/Makefile.am:
* module/oop/Makefile.am:
* module/oop/goops/Makefile.am:
* module/srfi/Makefile.am: Removed.
2009-04-24 19:40:55 +02: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
b15dea6857 Replace eval-case with eval-when
* module/ice-9/boot-9.scm (eval-when): Replace eval-case with eval-when.
  Eval-when is *much* simpler, and more expressive to boot. Perhaps in
  the future we'll get 'visit and 'revisit too.

* module/ice-9/deprecated.scm (eval-case): Provide mostly-working
  deprecated version of eval-case.

* module/ice-9/boot-9.scm (defmacro, define-macro): Relax condition: we
  can make defmacros that are not at the toplevel now. But in the future
  we should replace this implementation of defmacros with one written in
  syntax-case.
  (define-module, use-modules, use-syntax): Allow at non-toplevel.
  (define-public, defmacro-public, export, re-export): Don't evaluate at
  compile-time, I can't see how that helps things. Allow `export' and
  `re-export' at non-toplevel.

* module/ice-9/getopt-long.scm:
* module/ice-9/i18n.scm:
* module/oop/goops.scm:
* module/oop/goops/compile.scm:
* module/oop/goops/dispatch.scm: Switch to use eval-when, not
  eval-case.

* module/language/scheme/compile-ghil.scm (eval-when): Replace eval-case
  transformer with eval-when transformer. Sooooo much simpler, and it
  will get better once we separate expansion from compilation.

* module/language/scheme/expand.scm (quasiquote): Hm, expand quasiquote
  properly. Not hygienic. Syncase needed.
  (lambda): Handle internal defines with docstrings propertly.
2009-03-06 13:29:13 +01:00
Andy Wingo
81600208f4 a slight add-method speedup
* module/oop/goops.scm (add-method-in-classes!): Use memq instead of
  memv.
2009-02-14 00:47:56 +01:00
Andy Wingo
abd6af11cd generate the fixed-offset accessors at compile-time
* module/language/scheme/compile-ghil.scm (define-scheme-translator):
  Only add an else clause if the transformer didn't have one.

* module/oop/goops.scm (min-fixnum, max-fixnum): Define at compile-time
  as well.
  (@slot-ref, @slot-set!): Only define transformers for these at
  compile-time. Avoids loading up the compiler unnecessarily. Also, allow
  for the `n' to be determined lexically, in which case we dispatch to
  the primitive.
  (num-standard-pre-cache, define-standard-accessor-method)
  (bound-check-get, standard-get, standard-set): Rework the fixed-offset
  getters and setters so that they can be computed at compile-time.
  Accessors to fields with n > num-standard-pre-cache will be dispatched
  to the primitive instead of within the VM.
2009-02-14 00:24:32 +01:00
Andy Wingo
e177058bc4 don't re-enter the compiler during method dispatch
* libguile/goops.c (scm_make): In the pre-inst `make', default
  `procedure' to #f, and read a `make-procedure' instead of
  `compile-env'.

* libguile/goops.h (scm_si_make_procedure): This instead of
  scm_si_compile_env.

* module/oop/goops.scm (make-method): Remove this unused function. Users
  should use (make <method> ...) directly.
  (method): Capture `make-procedure' instead of `procedure' in the case
  that the body calls a next-method. Allows for the kind of
  "recompilation" that we were using before, but with closures instead of
  re-entering the compiler. Type-specific compilation is still
  interesting, but probably should be implemented in another way.
  (initialize): Default #:procedure to #f, and
  s/compile-env/make-procedure/.

* module/oop/goops/compile.scm (code-table-lookup): Just return the
  cmethod, not the entry -- since the entry is now just (append types
  cmethod).
  (compile-make-procedure): New procedure, returns a form that, when
  evaluated/compiled, will yield a procedure of one argument, the
  next-method. When called with a next-method, the procedure returns an
  actual method implementation. compile-make-procedure returns #f if the
  body doesn't call next-method.
  (compile-method): Unify to always return procedures. Much cleaner and
  *much* faster in the compiled case. In the interpreted case, there
  might be a slight slowdown, but if there is one it should be slight.

* module/oop/goops/dispatch.scm (method-cache-install!): Adapt to removal
  of compute-entry-with-cmethod.
2009-02-13 23:30:20 +01:00
Andy Wingo
af35fc20a6 use append-map in goops
* module/oop/goops.scm (ensure-metaclass, make-extended-generic): Some
  minor optimizations to use append-map.
2009-02-05 00:31:38 +01:00
Andy Wingo
ef7e18683c inline dispatch to program cmethods, tick in return, remove old goops methods
* libguile/objects.c (scm_apply_generic): Inline the case when the
  generic is a program.

* libguile/vm-i-system.c (return): Tick when functions return.

* module/oop/goops.scm (object-eqv?, object-equal?): Remove these
  historical methods.
2009-02-03 21:13:01 +01:00
Andy Wingo
ca445ba5ec rename translate.scm to compile-ghil.scm, and more work on compiler.texi
* doc/ref/api-evaluation.texi: Fix some typos and xrefs.

* doc/ref/compiler.texi (The Scheme Compiler): Document the scheme
  compiler, and start documenting the GHIL language.

* doc/ref/guile.texi (Guile Implementation): Whoops, put autoconf after
  the implementation foo. Unless we want it before?

* doc/ref/history.texi (The Emacs Thesis): Fix typo.

* doc/ref/vm.texi (Environment Control Instructions): Rename offset to
  index.

* module/language/ghil.scm (parse-ghil): Fix what I think was a bug --
  the consumer in a mv-call shouldn't be a rest arg.

* module/language/scheme/Makefile.am (SOURCES):
* module/language/scheme/compile-ghil.scm: Rename this file from
  translate.scm.

* module/oop/goops.scm:
* module/language/scheme/spec.scm: Deal with renaming.
2009-01-09 17:49:09 +01:00
Andy Wingo
9ff56d9e65 (language ghil def) becomes (language ghil)
* module/language/Makefile.am:
* module/language/ghil/Makefile.am:
* module/language/ghil.scm:
* module/language/ghil/compile-glil.scm:
* module/language/ghil/spec.scm:
* module/language/glil/Makefile.am:
* module/language/glil.scm:
* module/language/glil/compile-objcode.scm:
* module/language/glil/spec.scm:
* module/language/scheme/inline.scm:
* module/language/scheme/translate.scm:
* module/oop/goops.scm: Rename (language ghil def) and (language glil
  def) to not have the "def". They're nicer names.
2009-01-08 19:25:38 +01:00
Andy Wingo
d9042285ba move lang-specific modules, e.g. (system il compile) to (language ghil compile-glil)
* configure.in: Remove module/system/il directory.

* module/language/ghil/Makefile.am (SOURCES):
* module/language/ghil/compile-glil.scm (system):
* module/language/ghil/def.scm (language):
* module/language/ghil/spec.scm (language, ghil):
* module/language/glil/Makefile.am (SOURCES):
* module/language/glil/compile-objcode.scm (language):
* module/language/glil/def.scm (language):
* module/language/glil/spec.scm (language, compile):
* module/language/scheme/Makefile.am (SOURCES):
* module/language/scheme/inline.scm (system, define-inline):
* module/language/scheme/translate.scm (language): Move files, renaming
  the modules.

* module/oop/goops.scm (load-toplevel): Unfortunately the GHIL name
  leaked here. Patch it up.

* module/system/vm/Makefile.am (SOURCES): Remove assemble.scm.
2009-01-08 12:18:34 +01:00
Andy Wingo
b0b180d522 nifty generic compiler infrastructure -- no more hardcoded passes
* module/system/base/language.scm (<language>): Rework so that instead of
  hardcoding passes in the language, we define compilers that translate
  from one language to another. Add `parser' to the language fields, a
  bit of a hack but useful for languages with s-expression external
  representations but with record internal representations.
  (define-language, *compilation-cache*, invalidate-compilation-cache!)
  (compute-compilation-order, lookup-compilation-order): Add an algorithm
  that does a depth-first search for a translation path from a source
  language to a target language, caching the result in a lookup table.

* module/language/scheme/spec.scm:
* module/language/ghil/spec.scm: Update to the new language format.

* module/language/glil/spec.scm: Add a language specification for GLIL,
  with a compiler to objcode. Also there are parsers and printers, for
  repl usage, but for some reason this doesn't work yet.

* module/language/objcode/spec.scm: Define a language specification for
  object code. There is some sleight of hand here, in the "compiler" to
  values; but there is method behind the madness, because this way we
  higher levels can pass environments (a module + externals pair) to
  objcode->program.

* module/language/value/spec.scm: Define a language specification for
  values. There is something intellectually dishonest about this, but it
  does serve its purpose as a foundation for the language hierarchy.

* configure.in:
* module/language/Makefile.am
* module/language/ghil/Makefile.am
* module/language/glil/Makefile.am
* module/language/objcode/Makefile.am
* module/language/value/Makefile.am:
  Autotomfoolery for the ghil, glil, objcode, and value languages.

* module/language/scheme/translate.scm (translate): Import the bits that
  understand `compile-time-environment' here, and pass on the relevant
  portions of the environment to the next compiler pass.

* module/system/base/compile.scm (current-language): New procedure, refs
  the current language fluid, or lazily sets it to scheme.
  (call-once, call-with-output-file/atomic): Refactor these bits to use
  with-throw-handler. No functional change.
  (compile-file, compile-and-load, compile-passes, compile-fold)
  (compile): Refactor the public interface of the compiler to be generic
  and simple. Uses `lookup-compilation-order' to find a path from the
  source language to the target language.

* module/system/base/syntax.scm (define-type): Adapt to changes in
  define-record.
  (define-record): Instead of expecting all slots in the first form,
  expect them in the body, and let the first form hold the options.

* module/system/il/compile.scm (compile): Adapt to the compilation pass
  API (three in and two out).

* module/system/il/ghil.scm (<ghil-var>, <ghil-env>)
  (<ghil-toplevel-env>): Adapt to define-record changes.

* module/system/il/glil.scm (<glil-vars>): Adapt to define-record
  changes.
  (<glil>, print-glil): Add a GLIL record printer that uses unparse.
  (parse-glil, unparse-glil): Update unparse (formerly known as pprint),
  and write a parse function.

* module/system/repl/common.scm (<repl>): Adapt to define-record changes.
  (repl-parse): New function, parses the read form using the current
  language. Something of a hack.
  (repl-compile): Adapt to changes in `compile'.
  (repl-eval): Fix up the does-the-language-have-a-compiler check for
  changes in <language>.

* module/system/repl/repl.scm (start-repl): Parse the form before eval.

* module/system/repl/command.scm (describe): Parse.
  (compile): Be more generic.
  (compile-file): Adapt to changes in compile-file.
  (disassemble, time, profile, trace): Parse.

* module/system/vm/debug.scm:
* module/system/vm/assemble.scm: Adapt to define-record changes.

* module/language/scheme/translate.scm (receive): Fix an important bug
  that gave `receive' letrec semantics instead of let semantics. Whoops!
2008-11-14 22:42:31 +01:00
Andy Wingo
3f0bce1e14 move guilec.mk to am/guilec
* am/Makefile.am:
* am/guilec: guilec moved here from /guilec.mk.

All includers of guilec adapted.
2008-11-01 13:05:10 +01: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