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

16114 commits

Author SHA1 Message Date
Ian Price
ddda4d53e5 Doc: mention vectors are self-quoting
Reported by Dmitry Bogatov <KAction@gnu.org>.

* doc/ref/api-compound.texi (Vector Syntax, Vector Creation): Mention
  that vectors are self-quoting. Remove examples with quote signs.
2013-10-09 22:48:16 +01:00
Ian Price
84a410dbd2 Fix code generated for `while'.
* module/language/lua/compile-tree-il.scm (while-loop->tree-il):
  Generate `letrec' instead of `let'.
  Generate valid `lambda' expression.
2013-09-09 17:03:52 +01:00
Ian Price
b3a7711ba0 Add missing `make-sequence' procedure.
* module/language/lua/compile-tree-il.scm (make-sequence): New procedure.
2013-09-09 17:03:52 +01:00
Ian Price
ced883f7df Use make-application' instead of removed make-call'.
* module/language/lua/compile-tree-il.scm: Rename.
2013-09-09 17:03:52 +01:00
Ian Price
ddb685ee52 Compile Lua's ... form.
* module/language/lua/compile-tree-il.scm (compile): Add clause for
  ast-variable-arguments.
* module/language/lua/parser.scm (define-ast, make-parser): Add
  vararg-gensym field to functions, gensym field to variable-arguments.
  Propagate *vararg-gensym* from functions to variable-arguments.
* test-suite/tests/lua-eval-2.test ("lua-eval"): Check for #nil
2013-09-09 17:01:24 +01:00
Ian Price
f5302e62a7 Fix typo in lua lexer test.
* test-suite/tests/lua-lexer.test ("lua-lexer"): #:vararg -> #:varargs
2013-09-09 17:01:24 +01:00
Phil
f4c44a3ba7 Add some documentation. Function calls now properly handle multiple
values resulting from a function call as the last argument.

doc/ref/api-languages.texi: Add a small blurb about Lua.

module/language/lua/compile-tree-il.scm: Function calls now properly
handle multiple values resulting from a function call as the last
argument.
2013-09-09 17:01:24 +01:00
Phil
faa16f9989 module/language/lua/parser.scm: Rename #:dots to #:varargs 2013-09-09 17:01:24 +01:00
Phil
becaec9a4e Fix and/or double evaluation. Add math.modf, math.fmod.
* module/language/lua/compile-tree-il.scm: Fix and/or double evaluation.

* module/language/lua/notes.org: Add file describing known issues.

* module/language/lua/parser.scm: (token-type): Recognize and/or.

* module/language/lua/standard/math.scm: Add modf, fmod implementations.

* test-suite/tests/lua-eval-3.test: Add another test file for basic
  language features.
2013-09-09 17:01:24 +01:00
Andy Wingo
8c91ae59f9 lua code returning via normal path
* module/language/lua/compile-tree-il.scm (compile): Get more lua code
  returning via the normal path.
2013-09-09 17:01:24 +01:00
Andy Wingo
3043dc0ef7 lua/runtime tweaks
* module/language/lua/runtime.scm: Various indentation and idiom
  tweaks.
2013-09-09 17:01:24 +01:00
Andy Wingo
04175c7dda lua/lexer tweaks
* module/language/lua/lexer.scm: Some tweaks and reindentations. Remove
  the define/init lexer interface; I don't like separating declaration
  and initialization.

* module/language/lua/parser.scm:
* test-suite/tests/lua-lexer.test: Adapt to lexer interface change.
2013-09-09 17:01:24 +01:00
Andy Wingo
d87639dfe4 lua/compile-tree-il tweaks
* module/language/lua/compile-tree-il.scm: Reflow a bit, and a number of
  small rewrites. Added some FIXMEs.
2013-09-09 17:01:23 +01:00
Andy Wingo
ae037892f0 remove true? and false?; lua's truthiness and falsehood is guile's.
* module/language/lua/runtime.scm (true?, false?): Remove, now that #nil
  is false.

* module/language/lua/compile-tree-il.scm: Don't emit calls to true? or
  false?.
2013-09-09 17:01:23 +01:00
Andy Wingo
48f7c66a40 lua/parser tweaks
* module/language/lua/parser.scm (define-record, define-ast): Simplify
  these macros.
  (make-parser): A number of small idiomatic changes.
2013-09-09 17:01:23 +01:00
Andy Wingo
a0cecd8ff2 lua/common cleanup
* module/language/lua/common.scm: Remove `or-eqv?'. Make a bit more
  idiomatic.

* module/language/lua/compile-tree-il.scm:
* module/language/lua/lexer.scm:
* module/language/lua/parser.scm:
* module/language/lua/runtime.scm: Replace or-eqv? instances with memq
  or memv.
2013-09-09 17:01:23 +01:00
Andy Wingo
32c58e2edd syntax-error throws to syntax-error
* module/language/lua/common.scm (syntax-error): Throw to
  'syntax-error.
2013-09-09 17:01:23 +01:00
No Itisnt
a30c18c22a add lua language implementation
What is missing:

+ Functions: module, getfenv, setfenv, math.modf, table.sort

+ Parser: needs to be more flexible

+ Compiler: needs more extensive work to properly handle all possible
cases of variable arguments, multiple returns, and loops

+ Language: Variable arguments and unpacking of multiple returns. (For
example we need to be able to handle something as complex as
print(unpack({...})), which is easy with Lua's explicit stack but will
require lots of tree-il gymnastics, or perhaps modifications to better
allow different calling conventions. (For instance -- how would we
support Python or Ruby, where keyword arguments are gathered into a
hashtable and passed as a single argument?)

What is there:

A fair shot at supporting Lua 5.1, not quite a drop-in replacement, but
not far from that goal either.
2013-09-09 17:01:23 +01:00
Andy Wingo
6871327742 Micro-optimize char_decimal_value.
* libguile/numbers.c (char_decimal_value): A wee micro-optimization.
2013-08-31 11:15:01 +02:00
Andy Wingo
25752c4d1c Faster scm_from_port_stringn
* libguile/strings.c (scm_from_port_stringn): Always inline to
  scm_from_utf8_string if the byte sequence is valid utf-8.
2013-08-31 10:57:11 +02:00
Andy Wingo
be7ecef05c unread-char: inline conversion from codepoint to bytes
* libguile/ports.c (scm_ungetc_unlocked): Inline the conversion from
  codepoint to bytes for UTF-8 and latin-1 ports.  Speeds up a
  numbers-reading test case by 100% (!).
2013-08-31 10:44:07 +02:00
Andy Wingo
8ac8e2dfeb Add contification pass
* module/Makefile.am:
* module/language/cps/contification.scm: New pass.

* module/language/cps/compile-rtl.scm (optimize): Wire it into the
  compiler.
2013-08-31 09:40:56 +02:00
Andy Wingo
6e8ad82335 Add CPS -> RTL compiler
* module/Makefile.am:
* module/language/cps/compile-rtl.scm:
* module/language/cps/dfg.scm:
* module/language/cps/slot-allocation.scm: New modules.

* module/language/cps/spec.scm: Register the compiler.

* test-suite/Makefile.am:
* test-suite/tests/rtl-compilation.test: Add tests.
2013-08-31 09:40:56 +02:00
Andy Wingo
934e6b9515 Add pass to reify primcalls without corresponding VM ops
* module/Makefile.am:
* module/language/cps/reify-primitives.scm: New pass.
2013-08-31 09:40:56 +02:00
Andy Wingo
026b561154 Add arity-adapting module
* module/Makefile.am:
* module/language/cps/arities.scm: New module.  Adapts call and return
  arities, especially for primcalls.
2013-08-31 09:40:56 +02:00
Andy Wingo
045392f1b2 Add CPS primitives info module
* module/Makefile.am:
* module/language/cps/primitives.scm: New file.
2013-08-31 09:40:56 +02:00
Andy Wingo
43f768f48d RTL language
* module/Makefile.am
 * module/language/rtl.scm:
 * module/language/rtl/spec.scm: Add a stub RTL language.
2013-08-31 09:40:56 +02:00
Andy Wingo
4b8de65e9d Add closure conversion
* module/Makefile.am
* module/language/cps/closure-conversion.scm: New module, implementing a
  closure conversion pass.
2013-08-31 09:40:56 +02:00
Andy Wingo
4fefc3a867 (compile foo #:to 'cps)
* module/language/tree-il/compile-cps.scm: New module implementing CPS
  conversion of Tree-IL.

* module/Makefile.am:
* module/language/tree-il/spec.scm:
* module/language/cps/spec.scm: Integrate CPS in the build and language
  system.
2013-08-31 09:40:56 +02:00
Andy Wingo
80b01fd086 Add CPS language
* module/Makefile.am:
* module/language/cps.scm:
* module/language/cps/verify.scm: Add CPS language.

* .dir-locals.el: Add indentation rules for some CPS forms.
2013-08-31 09:40:56 +02:00
Andy Wingo
93009a7aca ,xx for RTL images
* module/scripts/disassemble.scm (disassemble):
* module/system/vm/disassembler.scm (disassemble-file): Factor
  disassemble-file out.

* module/system/repl/command.scm (disassemble-file): Map ,xx to
  disassemble RTL images.
2013-08-29 20:50:19 +02:00
Andy Wingo
610295ec9d add ability to disassemble ELF images
* module/scripts/disassemble.scm (disassemble): Update to work with
  RTl (and only RTL, as that's the future).

* module/system/vm/debug.scm (for-each-elf-symbol): New public
  interface.
  (debug-context-from-image): New helper.
  (find-debug-context): Use the helper.

* module/system/vm/disassembler.scm (disassemble-image): New public
  interface.
2013-08-29 20:44:55 +02:00
Andy Wingo
c96933fd54 Export the assembler procedures
* module/system/vm/assembler.scm (define-assembler):
  (define-macro-assembler): Export the assemblers.
2013-08-24 15:41:09 +02:00
Andy Wingo
e063995db8 rtl vm: box-set! binds no values
* libguile/vm-engine.c (box-set!): Remove the OP_DST flag.
2013-08-24 15:40:29 +02:00
Andy Wingo
70a2043143 RA == MVRA in disassembler
* module/system/vm/disassembler.scm: Modify call disassembler to assume
  RA == MVRA.
2013-08-24 15:38:27 +02:00
Andy Wingo
8fa7288928 assembler: give proper permissions to .data section
* module/system/vm/assembler.scm (link-data): Give stringbufs the
  "shared" flag already, so we don't attempt to set it at runtime.  Give
  .data sections the SHF_WRITE flag.
2013-08-24 15:28:03 +02:00
Andy Wingo
72bb47ae4c compile-file adds #:to-disk? #t to opts
* module/system/base/compile.scm (compile-file): Pass #:to-disk? as an
  option to indicate that the result will be being loaded from disk.
  Perhaps a linker might want to page-align in that case.

* module/language/elisp/compile-tree-il.scm (process-options!): Accept
  and ignore the #:to-file compiler option.
2013-08-24 15:27:57 +02:00
Mark H Weaver
84cc4127bd RTL: 'return-values' instruction assumes 'reset-frame' has been called.
* libguile/vm-engine.c (return-values): Remove NVALUES operand.
  Don't reset the frame.

* test-suite/tests/rtl.test ("cached-toplevel-set!"): Adapt to the fact
  that 'return-values' has no operand now, and that 'reset-frame' must
  be done first.
2013-08-24 15:27:50 +02:00
Mark H Weaver
adb8d905df RTL VM: Rename 'apply' instruction to 'tail-apply'.
* libguile/vm-engine.c (apply, tail-apply): apply -> tail-apply.
  (RETURN_VALUE_LIST): goto op_apply -> goto op_tail_apply.

* libguile/vm.c (rtl_apply_code): scm_rtl_op_apply ->
  scm_rtl_op_tail_apply.
2013-08-24 15:22:17 +02:00
Mark H Weaver
e79ed6b1d7 RTL VM: fix multiple value returns.
* libguile/vm-engine.c (halt): Fix off-by-one error in retrieving
  multiple values from the frame.
2013-08-24 15:20:56 +02:00
Mark H Weaver
62d3430cb6 Convert branchable primitives into binary operations only.
* module/language/tree-il/primitives.scm (maybe-simplify-to-eq): Wrap
  within another lambda, binding the primitive name.  If there are less
  than two arguments, expand to constant #t.  If there are more than two
  arguments, convert into a conjunction of binary applications.
  (expand-chained-comparisons): New procedure.
  (*primitive-expand-table*): Add entries for (< <= = >= > eq?).
2013-08-24 15:18:32 +02:00
Mark H Weaver
453acfacf4 Merge remote-tracking branch 'origin/stable-2.0' 2013-08-23 22:36:02 -04:00
Mark H Weaver
0ac084bf2b Fix 'define-public' from (ice-9 curried-definitions).
* module/ice-9/curried-definitions.scm (cdefine, cdefine*): Simplify,
  and improve error reporting by making the patterns more strict.
  (define-public): Fix bug in generated 'export' form.
2013-08-23 02:00:08 -04:00
Mark H Weaver
df3acd296e Improve error checking in 'define-public' and 'module-add!'.
* module/ice-9/boot-9.scm (module-add!): Check that the symbol argument
  is actually a symbol.
  (define-public): Expand into 'define' in such a way that curried
  definitions will immediately fail.
2013-08-19 20:02:50 -04:00
Ian Price
1fcf690929 doc: `get-string-all' takes only one argument.
* doc/ref/api-io.texi (R6RS Textual Input): Remove `count' argument.
2013-08-19 22:25:41 +01:00
Ian Price
20d28792b3 `write-request-line' always prints a path component.
* module/web/http.scm (write-request-line): Always write "/" when path
  is empty, regardless of query.
* test-suite/tests/web-http.test ("write-request-line"): Add test.
2013-08-19 10:43:02 +01:00
Mark H Weaver
c099201da1 In bytevector->uint-list et al, check that SIZE divides the bv length.
Fixes <http://bugs.gnu.org/15100>.
Reported by Göran Weinholt <goran@weinholt.se>.

* libguile/bytevectors.c (INTEGERS_TO_LIST): Enforce the R6RS
  requirement that SIZE divides the bytevector length.

* test-suite/tests/bytevectors.test: Add test.  Remove tests that
  assumes that this "divides" check is not enforced.
2013-08-16 23:13:54 -04:00
Mark H Weaver
88cff2ef1b Merge remote-tracking branch 'origin/stable-2.0' 2013-08-16 23:05:34 -04:00
Mark H Weaver
088cfb7d76 Improved error checking in bytevector->uint-list and bytevector->sint-list.
Partially fixes <http://bugs.gnu.org/15100>.
Reported by Göran Weinholt <goran@weinholt.se>.

* libguile/bytevectors.c (INTEGERS_TO_LIST): Make sure SIZE isn't 0.
  Allow SIZE to be greater than the bytevector length, for consistency
  with allowing extra bytes at the end when the bytevector length is
  non-zero.  Use scm_from_size_t instead of scm_from_uint.

* test-suite/tests/bytevectors.test: Add tests.  Remove a test that
  checks for an exception when SIZE is greater than the bytevector
  length.
2013-08-16 22:54:39 -04:00
Mark H Weaver
521c542199 Merge remote-tracking branch 'origin/stable-2.0' 2013-08-15 04:09:04 -04:00