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

4577 commits

Author SHA1 Message Date
Andy Wingo
be4efc52d2 pull in srfi-9, implement record-case
* module/system/base/syntax.scm: Pull in srfi-9. Define a record-case
  macro that will replace (match foo (($ <type> slot ...) body...)).
2008-05-03 13:46:56 +02:00
Andy Wingo
063fd30bbe clean up some syntax imports and exports
* module/system/base/syntax.scm (system): Don't re-export receive or
  and-let*; modules should explicitly import these if they want to. Don't
  export an empty stack-catch definition!

* module/system/repl/command.scm (system): Pull in and-let*.

* module/system/vm/disasm.scm (system): Don't import and-let*.
2008-05-02 18:59:04 +02:00
Andy Wingo
0a8a9780b8 remove module.scm
* module/system/base/module.scm: Removed module.scm, as it was unused
  (see 9419ff9ae9).
2008-05-02 17:51:34 +02:00
Andy Wingo
6649bc0436 cleanups in syntax.scm
* benchmark/lib.scm (fibo): Make fibo actually a fibonacci sequence.

* module/system/base/syntax.scm (system): Forward-declare all exports.
  (expand-symbol, slot): Rewrite expand-symbol to expand to a
  non-recursive invocation of `slot', so that in the future when we get
  rid of this syntax, the replacement will be more palatable to the eyes.
2008-05-02 17:35:25 +02:00
Ludovic Courtes
b89fc2153e Slowly improving support for macro compilation.
* module/language/scheme/translate.scm (&current-macros): Removed.
  (&current-macro-module): Removed.
  (&compile-time-module): New.
  (eval-at-compile-time): New.
  (translate): Initialize `&compile-time-module'.
  (expand-macro)[use-syntax]: New case.
  [begin let...]: Don't expand these built-in macros.
  [else]: Rewrote the macro detection and invocation logic.  Invoke macro
  transformers in the current compile-time module.
  (trans): Let `expand-macro' raise an exception if needed.
  (trans-pair)[defmacro define-macro]: Evaluate the macro definition in
  the compile-time module.

* testsuite/t-match.scm: Use `use-syntax' instead of `use-modules' for
  `(ice-9 match)' and `(srfi srfi-9)'.

* testsuite/t-records.scm: Likewise.

git-archimport-id: lcourtes@laas.fr--2005-mobile/guile-vm--mobile--0.6--patch-15
2008-04-25 19:15:50 +02:00
Ludovic Courtes
9dbbe4bb83 Improved macro handling; started documenting the issue.
* doc/guile-vm.texi (Compiling Scheme Code): New node.

* module/language/scheme/translate.scm (&current-macro-module): New.
  (translate): Evaluate macros in `&current-macro-module'.
  (trans-pair): Likewise.

git-archimport-id: lcourtes@laas.fr--2005-mobile/guile-vm--mobile--0.6--patch-13
2008-04-25 19:09:30 +02:00
Ludovic Courtes
23b587b0a1 Encode the length of constant lists/vectors on 2 octets instead of 1.
* module/system/vm/assemble.scm (dump-object!): New sub-procedure
  `too-long'.  For `list' and `vector', encode the length on 2 octets
  instead of 1 and report an error if a list/vector is longer than 65535.

* module/system/vm/disasm.scm (original-value): New sub-procedure
  `list-or-vector?'; when true, return the number of elements for that
  list/vector.

* src/vm_system.c (list): Fetch the length as a two-octet integer.
  (vector): Likewise.

* testsuite/t-basic-contructs.scm: New.

* testsuite/Makefile.am (vm_test_files): Added the above file.

* module/system/vm/core.scm (load-compiled): Added a bit of
  documentation.

git-archimport-id: lcourtes@laas.fr--2005-mobile/guile-vm--mobile--0.6--patch-11
2008-04-25 19:09:30 +02:00
Ludovic Courtes
a55572bf3d Renamed the library from libguilevm' to libguile-vm'.
* src/Makefile.am (lib_LTLIBRARIES): Renamed to `libguilevm.la' to
  `libguile-vm.la'.

* module/system/vm/core.scm: Dynamic-link "libguile-vm" instead of
  "libguilevm.so".

git-archimport-id: lcourtes@laas.fr--2005-mobile/guile-vm--mobile--0.6--patch-10
2008-04-25 19:09:30 +02:00
Ludovic Courtes
2335fb97dc Added support for defmacro' and define-macro' in the compiler.
* module/language/scheme/translate.scm: Use `(srfi srfi-39)'.
  (&current-macros): New top-level.
  (expand-macro): New.
  (scheme-primitives): Renamed `%scheme-primitives'.
  (%forbidden-primitives): New.
  (trans): Use `expand-macro' instead of `macroexpand'.
  (trans-pair): Handle `define-macro' and `defmacro'.

* module/system/base/compile.scm (call-with-compile-error-catch): Handle
  non-pair LOC.

* testsuite/t-macros2.scm: New test case.

* testsuite/Makefile.am (vm_test_files): Updated.

* testsuite/t-macros.scm: Test `read-options'.

git-archimport-id: lcourtes@laas.fr--2005-mobile/guile-vm--mobile--0.6--patch-9
2008-04-25 19:09:30 +02:00
Ludovic Courtes
d0100f476d Fixed an "unbound variable" in `(system vm conv)'.
* module/system/vm/conv.scm: Autoload `(system vm core)' also when
  `opcode->instruction' is hit.  This fixes an "unbound variable" problem.

git-archimport-id: lcourtes@laas.fr--2005-mobile/guile-vm--mobile--0.6--patch-8
2008-04-25 19:09:30 +02:00
Ludovic Courtes
48302624d9 Fixed error handling; detect and report macro expansion errors.
* module/language/scheme/translate.scm (trans): Catch exceptions thrown
  by `macroexpand' and throw a syntax error.
  (trans-pair): Catch calls to `procedure->memoizing-macro' and raise a
  syntax error.

* module/system/base/compile.scm (call-with-compile-error-catch): Made a
  macro (a procedure doesn't do the job).
  (compile-file): Uncommented call to `call-with-compile-error-catch'.

git-archimport-id: lcourtes@laas.fr--2005-mobile/guile-vm--mobile--0.6--patch-7
2008-04-25 19:09:30 +02:00
Ludovic Courtes
884d46de23 Tried compiling more code; augmented the doc.
* module/language/Makefile.am: New.

* module/language/scheme/Makefile.am: New.

* configure.in: Produce these two new Makefiles.

* doc/guile-vm.texi: Documented `compile-file', `compiled-file-name', and
  `compile-in'.

* module/system/base/compile.scm: Cosmetic changes.

* module/system/base/language.scm: Likewise.

* module/system/il/Makefile.am: Tried (and failed) to compile more
  things.

* module/system/vm/Makefile.am: All source files in here can now be
  compiled without harming further compilation.

* module/system/vm/assemble.scm: Select only specific bindings from
  `(system vm core)'.
  (dump-object!): Show a more meaningful error message.

* module/system/vm/conv.scm: Select only specific bindings from `(system
  vm core)'.

* module/system/vm/debug.scm: Likewise.

* module/system/vm/frame.scm: Changed the header.  Use a renamer for
  `(system vm core)'.

* src/guilec.in: Added options, via `getopt-long'.

git-archimport-id: lcourtes@laas.fr--2005-mobile/guile-vm--mobile--0.6--patch-6
2008-04-25 19:09:30 +02:00
Ludovic Courtes
b6368dbbb9 Fixed a Scheme translation bug; cleaned compilation with GCC 4.
* module/language/scheme/translate.scm (trans-pair): In the `set!' case,
  when a procedure-with-setter is passed, call `trans:pair' with an
  actual pair.  This fixes a long-lasting bug which prevented compilation
  of `set!' statements with procedures-with-setter (this showed up when
  compiling `(system vm assemble)').

* module/system/base/compile.scm: Added `objcode->u8vector' to the
  `#:select' clause.

* module/system/base/syntax.scm: Cosmetic changes.

* module/system/vm/assemble.scm (preprocess): Removed debugging
  statements.

* src/frames.c: Cosmetic changes.

* src/frames.h (SCM_FRAME_SET_DYNAMIC_LINK): New.

* src/objcodes.c: Use `scm_t_uint8' instead of `char' when relevant.

* src/vm.c (vm_heapify_frames_1): Use `SCM_FRAME_SET_DYNAMIC_LINK ()'.

* src/vm_loader.c: Added casts to mute GCC 4 warnings.

* testsuite/run-vm-tests.scm (*scheme*): Renamed to `%scheme'.
  (run-test-from-file): Renamed to `compile/run-test-from-file'.
  (run-vm-tests): Run each test using both the VM and the interpreter;
  compare the results.

* testsuite/t-proc-with-setter.scm: Try out `get/set'.

* doc/Makefile.am (info_TEXINFOS): New.

* doc/guile-vm.texi: Added index entries and indices.

* doc/texinfo.tex: New file.

git-archimport-id: lcourtes@laas.fr--2005-mobile/guile-vm--mobile--0.6--patch-5
2008-04-25 19:09:30 +02:00
Ludovic Court`es
49edef60dc Minor binding name clash tweak.
* module/system/base/compile.scm: Only import `the-vm' and `vm-load' from
  `(system vm core)'.

git-archimport-id: lcourtes@laas.fr--2004-libre/guile-vm--revival--0.6--patch-10
2008-04-25 19:09:30 +02:00
Ludovic Courtes
a52b2d3d55 Started documenting the compiler.
* doc/guile-vm.texi:  Documented the compiler (node `The Compiler').
  Removed a number of things that might have been relevant to Guile-VM 0.0.

* module/system/il/compile.scm (optimize):  Commented out the case
  using `<ghil-inst?>'.

* src/vm_engine.c (vm_run)[objects_handle]:  New variable.
  Before leaving the function, release OBJECTS_HANDLE.

* src/vm_engine.h (CACHE_PROGRAM):  Use `scm_vector_writable_elements'
  instead of `scm_vector_elements';  don't release the handle right away.

* src/vm_loader.c (load-program):  New commented out piece of code
  dealing with simple vectors.

* src/vm_system.c (object-ref):  Added the type of OBJNUM.

git-archimport-id: lcourtes@laas.fr--2005-mobile/guile-vm--mobile--0.6--patch-3
2008-04-25 19:09:30 +02:00
Ludovic Courtes
0b5f0e49a8 * src/objcodes.c (make_objcode_by_mmap): Fixed the error type when the
object file is too small.

* doc/guile-vm.texi:  Documented `make-closure'.  Improved the documentation
  of `load-program'.

* testsuite:  New directory.

* configure.in:  Added `testsuite/Makefile' to `AC_OUTPUT'.

* Makefile.am (SUBDIRS):  Added `testsuite'.

* src/vm_engine.h (VM_CHECK_OBJECT):  New option.
  (CHECK_OBJECT):  New macro.

* src/vm_system.c (object-ref):  Use VM_CHECK_OBJECT.

* module/system/vm/assemble.scm (preprocess):  Commented out the debugging
  code.

* benchmark/lib.scm (do-loop):  New procedure.

git-archimport-id: lcourtes@laas.fr--2005-mobile/guile-vm--mobile--0.6--patch-2
2008-04-25 19:09:30 +02:00
Ludovic Courtes
6208295910 Removed a few more deprecated function calls; documented closures.
* src/Makefile.am (.c.x):  Fixed the rule.

* src/envs.c:  Use `scm_hash_get_handle ()' instead of
  `scm_sym2ovcell_soft ()' and `scm_hash_create_handle_x ()' instead of
  `scm_intern_symbol ()'.

* src/objcodes.c (bytecode->objcode):  Don't use `SCM_VALIDATE_INUM', use
  `SCM_VALIDATE_NUMBER' instead.
  (make_objcode_by_mmap):  Check whether the file is smaller than the
  magic cookies; check whether the magic cookies are there.

* src/frames.c (frame-local-ref):  Likewise, but use `SCM_MAKE_VALIDATE'.
  (frame-local-set!):  Likewise.

* src/instructions.c (opcode->instruction):  Likewise.

* src/programs.c (program-external-set!):  New function.

* src/guile-disasm.in:  New file.

* src/Makefile.am:  Produce `guile-disasm'.

* doc/guile-vm.texi:  Documented `external-ref', `external-set', `local-ref'
  and `local-set'.

* module/system/vm/disasm.scm (disassemble-bytecode):  Fixed the way
  `load-program' is represented.

git-archimport-id: lcourtes@laas.fr--2005-mobile/guile-vm--mobile--0.6--patch-1
2008-04-25 19:09:30 +02:00
Ludovic Court`es
2d80426a3e Improved the VM's efficiency. The VM is as fast as the interpreter. :-(
* benchmark/lib.scm:  New file.
* benchmark/measure.scm:  New file.
* README:  Added useful pointers to various threads.
* doc/guile-vm.texi:  Fixed the description of `load-program' (it now expects
  _immediate_ integers).
* src/*.[ch]:  Use immediate integers whereever possible, as in the original
  code.  For `CONS', use `scm_cell' rather than `scm_cons'.

git-archimport-id: lcourtes@laas.fr--2004-libre/guile-vm--revival--0.6--patch-6
2008-04-25 19:09:30 +02:00
Ludovic Court`es
238e7a11a8 Got the VM up and running! Augmented the documentation.
* src/*.[ch]:  Replaced the remaining `SCM_MAKINUM', and changed `SCM_VELTS'
  into `scm_vector_elements ()'.
* src/vm_loader.c (link):  Fixed so that it pushed a variable object on
  the stack.
* src/vm_system.c (variable-ref):  Fixed so that it uses `scm_variable_ref ()'
  and friends.
* module/system/vm/assemble.scm (dump-object!):  Fixed the string case.
* src/vm_engine.h (CONS):  Use `scm_cons' instead of `SCM_NEWCELL'.
* doc/guile-vm.texi:  Added actual instruction definitions, explanations of
  the program invocation mechanism, programs' object tables, etc., in the
  `Instruction Set' chapter.

git-archimport-id: lcourtes@laas.fr--2004-libre/guile-vm--revival--0.6--patch-5
2008-04-25 19:09:30 +02:00
Ludovic Court`es
fa19602c28 Fixed the compiler, got the disassembler working.
* doc/guile-vm.texi:  Texified and cleaned up.
* src/vm.c:  Use `scm_from_locale_string ()' instead of `scm_makfrom0str ()'.
* src/vm_engine.c:  Likewise.
* src/programs.c (scm_program_bytecode):  Return a u8vector instead of a string.
* module/system/vm/conv.scm (make-byte-decoder):  Fixed a few things wrt. to
  the string to u8vector transition.
* src/objcodes.c (bytecode->objcode):  Fixed a bug where the last 10 bytes of
  the bytecode where ignored.
* module/system/vm/assemble.scm (dump-object!):  Don't convert everything
  to a u8vector, keep strings where it makes sense.
* module/system/vm/conv.scm (code->bytes):  Accordingly, convert strings to
  u8vectors when needed.
  (make-byte-decoder):  Accordingly too, when decoding instructions, return
  variable-length instructions' argument as strings except for `load-program'.
* module/system/vm/disasm.scm:  Export `disassemble-bytecode'.

git-archimport-id: lcourtes@laas.fr--2004-libre/guile-vm--revival--0.6--patch-4
2008-04-25 19:09:30 +02:00
Ludovic Court`es
054599f117 Updated the assembly process so that `u8vectors' are used. Compilation works.
* module/system/vm/conv.scm (encode-length):  Use u8vectors.
  (code->bytes):  Likewise.
* module/system/vm/assemble.scm (codegen):  Use u8vectors instead
  of strings.
* src/objcodes.c (objcode->string):  Removed.
  (objcode->u8vector):  New function.
* module/system/base/compile.scm (compile-file):  Use `objcode->u8vector'
  and `uniform-vector-write'.

git-archimport-id: lcourtes@laas.fr--2004-libre/guile-vm--revival--0.6--patch-3
2008-04-25 19:09:29 +02:00
Ludovic Court`es
d8eeb67c89 Translation from Scheme to GHIL, and compilation to GLIL work.
* src/*.c:  Removed calls to `scm_must_malloc', `SCM_MUST_MALLOC' and
  `scm_must_free'.  Same for `SCM_INUMP', `SCM_INUM', `SCM_STRING_CHARS',
  and the likes.
* module/system/base/syntax.scm:  Do not import `(ice-9 match)' and do
  not re-export `match', do not export `syntax-error' which was not
  defined here.
* module/system/base/compile.scm (call-with-compile-error-catch):  Use
  the `catch' form instead of `try'.
* src/instructions.c:  Use `scm_from_char ()' instead of the deprecated
  macro `SCM_MAKINUM ()'.
* src/instructions.h (scm_instruction):  Made `npop' a signed char.

git-archimport-id: lcourtes@laas.fr--2004-libre/guile-vm--revival--0.6--patch-2
2008-04-25 19:09:29 +02:00
Keisuke Nishida
7a0d0cee1f *** empty log message *** 2001-05-02 15:05:05 +00:00
Keisuke Nishida
abaca96059 *** empty log message *** 2001-04-25 07:42:32 +00:00
Keisuke Nishida
46f215f85b *** empty log message *** 2001-04-25 01:55:45 +00:00
Keisuke Nishida
a6df585ae7 *** empty log message *** 2001-04-23 06:17:52 +00:00
Keisuke Nishida
af988bbf9c *** empty log message *** 2001-04-23 04:28:13 +00:00
Keisuke Nishida
ac99cb0cb1 *** empty log message *** 2001-04-22 02:13:48 +00:00
Keisuke Nishida
061f7faeca *** empty log message *** 2001-04-19 06:28:03 +00:00
Keisuke Nishida
24aa2715f6 *** empty log message *** 2001-04-19 05:59:09 +00:00
Keisuke Nishida
f21dfea659 *** empty log message *** 2001-04-19 03:09:27 +00:00
Keisuke Nishida
8f5cfc810f *** empty log message *** 2001-04-16 03:43:48 +00:00
Keisuke Nishida
78591ef5c3 *** empty log message *** 2001-04-16 00:08:10 +00:00
Keisuke Nishida
cb4cca12e7 *** empty log message *** 2001-04-15 15:02:41 +00:00
Keisuke Nishida
c722838216 *** empty log message *** 2001-04-15 14:54:59 +00:00
Keisuke Nishida
bd5b51c205 SLIB init file for Guile. 2001-04-14 11:26:26 +00:00
Keisuke Nishida
9ddacf866c Import SLIB 2d1. 2001-04-14 11:24:45 +00:00
Keisuke Nishida
92e7e03fae *** empty log message *** 2001-04-12 23:30:38 +00:00
Keisuke Nishida
b0c33ccaa6 *** empty log message *** 2001-04-12 00:15:31 +00:00
Keisuke Nishida
9f59b2c4d0 *** empty log message *** 2001-04-11 23:43:01 +00:00
Keisuke Nishida
712e77f291 *** empty log message *** 2001-04-11 23:27:08 +00:00
Keisuke Nishida
662925356a *** empty log message *** 2001-04-11 23:12:37 +00:00
Keisuke Nishida
75b55db5f8 *** empty log message *** 2001-04-11 21:54:57 +00:00
Keisuke Nishida
41f248a84a *** empty log message *** 2001-04-11 20:57:44 +00:00
Keisuke Nishida
8710eba09b *** empty log message *** 2001-04-10 06:11:26 +00:00
Keisuke Nishida
be2d2946bc *** empty log message *** 2001-04-10 00:32:46 +00:00
Keisuke Nishida
532565b047 *** empty log message *** 2001-04-09 06:36:59 +00:00
Keisuke Nishida
f349065ed9 *** empty log message *** 2001-04-09 04:08:46 +00:00
Keisuke Nishida
880ed584e8 *** empty log message *** 2001-04-09 04:02:01 +00:00
Keisuke Nishida
58995613d9 *** empty log message *** 2001-04-09 01:50:48 +00:00