summaryrefslogtreecommitdiff
path: root/module/language
AgeCommit message (Collapse)AuthorFilesLines
2013-09-09Fix code generated for `while'.Ian Price1-2/+2
* module/language/lua/compile-tree-il.scm (while-loop->tree-il): Generate `letrec' instead of `let'. Generate valid `lambda' expression.
2013-09-09Add missing `make-sequence' procedure.Ian Price1-0/+5
* module/language/lua/compile-tree-il.scm (make-sequence): New procedure.
2013-09-09Use `make-application' instead of removed `make-call'.Ian Price1-51/+51
* module/language/lua/compile-tree-il.scm: Rename.
2013-09-09Compile Lua's ... form.Ian Price2-7/+19
* 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-09Add some documentation. Function calls now properly handle multiplePhil4-31/+87
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-09module/language/lua/parser.scm: Rename #:dots to #:varargsPhil3-7/+7
2013-09-09Fix and/or double evaluation. Add math.modf, math.fmod.Phil4-43/+74
* 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-09lua code returning via normal pathAndy Wingo1-2/+2
* module/language/lua/compile-tree-il.scm (compile): Get more lua code returning via the normal path.
2013-09-09lua/runtime tweaksAndy Wingo1-113/+140
* module/language/lua/runtime.scm: Various indentation and idiom tweaks.
2013-09-09lua/lexer tweaksAndy Wingo2-74/+68
* 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-09lua/compile-tree-il tweaksAndy Wingo1-121/+156
* module/language/lua/compile-tree-il.scm: Reflow a bit, and a number of small rewrites. Added some FIXMEs.
2013-09-09remove true? and false?; lua's truthiness and falsehood is guile's.Andy Wingo2-26/+8
* 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-09lua/parser tweaksAndy Wingo1-472/+436
* module/language/lua/parser.scm (define-record, define-ast): Simplify these macros. (make-parser): A number of small idiomatic changes.
2013-09-09lua/common cleanupAndy Wingo5-19/+8
* 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-09syntax-error throws to syntax-errorAndy Wingo1-15/+5
* module/language/lua/common.scm (syntax-error): Throw to 'syntax-error.
2013-09-09add lua language implementationNo Itisnt10-0/+2846
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-08-31Add contification passAndy Wingo2-3/+240
* module/Makefile.am: * module/language/cps/contification.scm: New pass. * module/language/cps/compile-rtl.scm (optimize): Wire it into the compiler.
2013-08-31Add CPS -> RTL compilerAndy Wingo4-1/+1224
* 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-31Add pass to reify primcalls without corresponding VM opsAndy Wingo1-0/+117
* module/Makefile.am: * module/language/cps/reify-primitives.scm: New pass.
2013-08-31Add arity-adapting moduleAndy Wingo1-0/+152
* module/Makefile.am: * module/language/cps/arities.scm: New module. Adapts call and return arities, especially for primcalls.
2013-08-31Add CPS primitives info moduleAndy Wingo1-0/+96
* module/Makefile.am: * module/language/cps/primitives.scm: New file.
2013-08-31RTL languageAndy Wingo2-0/+123
* module/Makefile.am * module/language/rtl.scm: * module/language/rtl/spec.scm: Add a stub RTL language.
2013-08-31Add closure conversionAndy Wingo1-0/+273
* module/Makefile.am * module/language/cps/closure-conversion.scm: New module, implementing a closure conversion pass.
2013-08-31(compile foo #:to 'cps)Andy Wingo3-1/+633
* 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-31Add CPS languageAndy Wingo2-0/+634
* 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-24compile-file adds #:to-disk? #t to optsAndy Wingo1-1/+1
* 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-24Convert branchable primitives into binary operations only.Mark H Weaver1-3/+25
* 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-12Merge remote-tracking branch 'origin/stable-2.0'Mark H Weaver1-25/+20
2013-08-12Common numeric operations are left-to-right associative.Mark H Weaver1-23/+19
* module/language/tree-il/primitives.scm (define-primitive-expander): Use 'match-lambda*' instead of 'case-lambda' for pattern matching. (*primitive-expand-table*): In primitive expanders for '+', '*', '-', '/', 'logior', and 'logand', assume conventional left-to-right associativity.
2013-08-12Numerical comparisons are not negatable.Mark H Weaver1-2/+1
* module/language/tree-il/primitives.scm (*negatable-primitives*): Remove (< <= > >=) from the list of negatable primitives.
2013-08-11Merge remote-tracking branch 'origin/stable-2.0'Mark H Weaver1-1/+1
2013-08-11Adapt ecmascript compiler to tree-il prompt changes, again.Mark H Weaver1-4/+1
* module/language/ecmascript/compile-tree-il.scm (with-return-prompt): The body of an escape-only prompt is no longer a thunk. Adapt.
2013-08-11Inline escape-only prompt bodies in the Tree-ILAndy Wingo6-75/+44
* module/language/scheme/decompile-tree-il.scm (do-decompile): * module/language/tree-il/analyze.scm (analyze-lexicals): * module/language/tree-il/canonicalize.scm (canonicalize): * module/language/tree-il/compile-glil.scm (flatten-lambda-case): * module/language/tree-il/cse.scm (cse): * module/language/tree-il/peval.scm (peval): * test-suite/tests/peval.test ("partial evaluation"): Partially revert 178a40928, so that escape-only prompts explicitly inline their bodies.
2013-08-11remove peval abort-in-tail-position optimizationAndy Wingo1-35/+0
* module/language/tree-il/peval.scm (peval): Remove abort optimization; the CPS compiler will do much better here, and it is complicating things in the meantime.
2013-08-07Decompiler: fix handling of empty 'case-lambda' expressions.Mark H Weaver1-1/+1
* module/language/scheme/decompile-tree-il.scm (choose-output-names): A <lambda> with no <lambda-case> decompiles into a 'case-lambda' primitive. Ensure that 'case-lambda' is not shadowed by a lexical.
2013-08-07Adapt ecmascript compiler to recent tree-il changes for prompts.Mark H Weaver1-5/+10
* module/language/ecmascript/compile-tree-il.scm (with-return-prompt): Adapt to the changes in 178a40928ab5221f6ce57c5af1067abe30a342b3. Prompt tree-il nodes now contain an explicit 'escape-only?' flag, and the body and handler are now both lambdas.
2013-07-06<prompt> body and handler are lambdas; add escape-only? fieldAndy Wingo10-96/+146
* module/language/tree-il.scm (<prompt>): Change to have the body and handler be lambdas, and add an "escape-only?" field. This will make generic prompts work better in CPS or ANF with the RTL VM, as it doesn't make sense in that context to capture only part of a frame. Escape-only prompts can still be fully inlined. (parse-tree-il, unparse-tree-il): Add escape-only? to the serialization. (make-tree-il-folder, pre-post-order): Deal with escape-only?. * module/language/tree-il/analyze.scm (analyze-lexicals): Handle escape-only?, and the new expectations for the body and handler. * module/language/tree-il/canonicalize.scm (canonicalize): Ensure that the body of an escape-only continuation is a thunk, and that the handler is always a lambda. * module/language/tree-il/debug.scm (verify-tree-il): Assert that escape-only? is a boolean. * module/language/tree-il/cse.scm (cse): * module/language/tree-il/effects.scm (make-effects-analyzer): * module/language/tree-il/peval.scm (peval): * module/language/tree-il/primitives.scm (*primitive-expand-table*): * test-suite/tests/peval.test ("partial evaluation"): * module/language/tree-il/compile-glil.scm (flatten-lambda-case): Adapt to <prompt> change.
2013-06-28Remove with-fluids; replaced by with-fluid* and inlined push-fluid primopsAndy Wingo11-156/+86
* libguile/vm-i-system.c (push-fluid, pop-fluid): * doc/ref/vm.texi (Dynamic Environment Instructions): Rename wind-fluids to push-fluid, and unwind-fluids to pop-fluid. They now only work on one fluid binding at a time. * module/ice-9/boot-9.scm (with-fluid*): Implement in Scheme in terms of primcalls to push-fluid and pop-fluid. (custom-throw-handler, catch, with-throw-handler): Use with-fluid* instead of with-fluids, as with-fluids is no longer available before psyntax is loaded. (with-fluids): Define in Scheme in terms of with-fluid*. * libguile/fluids.c (scm_with_fluid): Rename from scm_with_fluids, and don't expose to Scheme. * libguile/eval.c (eval): Remove SCM_M_WITH_FLUIDS case. * libguile/expand.c (expand_with_fluids): Remove with-fluids syntax. (DYNLET): Remove, no longer defining dynlet in the %expanded-vtables. * libguile/expand.h: Remove dynlet definitions. * module/ice-9/eval.scm (primitive-eval): Remove with-fluids case. * libguile/memoize.c (do_push_fluid, do_pop_fluid): New primitive helpers, like wind and unwind. (memoize): Memoize wind and unwind primcalls. Don't memoize dynlet to with-fluids. (scm_init_memoize): Initialize push_fluid and pop_fluid here. * libguile/memoize.h (SCM_M_WITH_FLUIDS): Remove definition. * module/ice-9/psyntax.scm (build-dynlet): Remove; this just supported with-fluids, which is now defined in boot-9. * module/ice-9/psyntax-pp.scm: Regenerate. * doc/ref/compiler.texi (Tree-IL): * module/language/tree-il.scm: * module/language/tree-il/analyze.scm: * module/language/tree-il/canonicalize.scm: * module/language/tree-il/compile-glil.scm: * module/language/tree-il/cse.scm: * module/language/tree-il/debug.scm: * module/language/tree-il/effects.scm: Remove <dynlet>. Add cases for primcalls to push-fluid and pop-fluid in compile-glil.scm and effects.scm. * module/language/tree-il/peval.scm (peval): Factor out with-temporaries; probably a bad idea, but works for now. Factor out make-begin0 (a better idea). Inline primcalls to with-fluid*, and remove dynlet cases. * module/language/tree-il/primitives.scm (*interesting-primitive-names*): Add with-fluid*.
2013-06-27replace <dynset> with primcalls to fluid-set!Andy Wingo9-58/+10
* doc/ref/compiler.texi (Tree-IL): Remove mention of <dynset>. * module/language/scheme/decompile-tree-il.scm (do-decompile): (choose-output-names): Remove dynset. * module/language/tree-il.scm (<tree-il>, parse-tree-il): (unparse-tree-il, make-tree-il-folder, pre-post-order): Remove <dynset>. * module/language/tree-il/analyze.scm (analyze-lexicals): * module/language/tree-il/compile-glil.scm (*primcall-ops*): Add fluid-set!. (flatten-lambda-case): Remove <dynset> case. * module/language/tree-il/cse.scm (cse): * module/language/tree-il/debug.scm (verify-tree-il): Remove <dynset> cases. * module/language/tree-il/effects.scm (make-effects-analyzer): Remove <dynset> case. Add a primcall fluid-set! case. * module/language/tree-il/peval.scm (peval): Remove dynset cases. * module/language/tree-il/primitives.scm (*primitive-expand-table*): Remove fluid-set! -> dynset transformation.
2013-06-27replace <dynref> with primcalls to fluid-refAndy Wingo9-51/+4
* doc/ref/compiler.texi (Tree-IL): Remove mention of <dynref>. * module/language/scheme/decompile-tree-il.scm (do-decompile): (choose-output-names): Remove dynref. * module/language/tree-il.scm (<tree-il>, parse-tree-il): (unparse-tree-il, make-tree-il-folder, pre-post-order): Remove <dynref>. * module/language/tree-il/analyze.scm (analyze-lexicals): * module/language/tree-il/compile-glil.scm (*primcall-ops*): Add fluid-ref. (flatten-lambda-case): Remove <dynref> case. * module/language/tree-il/cse.scm (cse): * module/language/tree-il/debug.scm (verify-tree-il): Remove <dynref> cases. * module/language/tree-il/effects.scm (make-effects-analyzer): Remove <dynref> case. Add a primcall fluid-ref case. * module/language/tree-il/peval.scm (peval): Remove dynref cases. * module/language/tree-il/primitives.scm (*primitive-expand-table*): Remove fluid-ref -> dynref transformation.
2013-06-27dynamic-wind in terms of wind and unwind; remove <dynwind>, @dynamic-windAndy Wingo9-169/+38
* doc/ref/compiler.texi: Remove mention of <dynwind>. * libguile/eval.c (eval): Remove SCM_M_DYNWIND case. * libguile/expand.c: Remove scm_sym_at_dynamic_wind. * libguile/memoize.c (do_wind, do_unwind): A couple of hacky subrs. If we see a wind or unwind primcall, we expand to a call of a quoted subr value. It works and removes a kind of memoized value from the interpreter. For the compiler,primcalls to wind and unwind are handled specially. (MAKMEMO_DYNWIND): Remove. (scm_tc16_memoizer): Remove. Yay! (memoize): Remove speculative lookup for toplevels to see if they are memoizers: there are no more memoizers. Memoize calls to the wind and unwind primitives. (m_dynamic_wind): Remove. (unmemoize): Remove dynwind case. (scm_init_memoize): Add wind and unwind local definitions. * module/ice-9/boot-9.scm (dynamic-wind): Reimplement in terms of "wind" and "unwind" primitives. These primitives are not exposed to other modules. * module/ice-9/eval.scm (primitive-eval): Remove dynwind case. * module/language/scheme/decompile-tree-il.scm (do-decompile): (choose-output-names): Remove dynwind cases. * module/language/tree-il.scm: Remove <dynwind>. Yaaay! * module/language/tree-il/analyze.scm (analyze-lexicals): Remove dynwind cases. * module/language/tree-il/compile-glil.scm (*primcall-ops*): Add wind and unwind. (flatten-lambda-case): Remove dynwind case. Yay! * module/language/tree-il/cse.scm (cse): * module/language/tree-il/debug.scm (verify-tree-il): * module/language/tree-il/effects.scm (make-effects-analyzer): * module/language/tree-il/peval.scm (singly-valued-expression?, peval): Remove <dywind> cases. Inline primcalls to dynamic-wind. Add constant folding for thunk?. * module/language/tree-il/primitives.scm (*interesting-primitive-names*): Remove @dynamic-wind, and add procedure? and thunk?. (*effect+exception-free-primitives*): Add procedure? and thunk?. (*multiply-valued-primitives*): Remove @dynamic-wind. Remove @dynamic-wind expander. * test-suite/tests/peval.test ("partial evaluation"): Update tests for dynwind desugaring.
2013-06-27remove @call-with-values memoizerAndy Wingo3-8/+6
* libguile/memoize.h: * libguile/expand.c (scm_sym_at_call_with_values): Remove. * libguile/memoize.c (memoize, m_call_values, unmemoize): Adapt to memoize call-with-values primcalls. * module/ice-9/boot-9.scm (call-with-values): Expand to a call-with-values primcall. * module/language/tree-il/compile-glil.scm (flatten-lambda-case): Expect call-with-values primcall, without the @, and fall back to a normal call. * module/language/tree-il/peval.scm (peval): Match bare call-with-values. * module/language/tree-il/primitives.scm (*interesting-primitive-names*): (*multiply-valued-primitives*): Remove @call-with-values.
2013-06-27remove @call-with-current-continuation memoizerAndy Wingo2-9/+10
* module/ice-9/boot-9.scm (call-with-current-continuation): Change to primcall call-with-current-continuation. * libguile/memoize.h: * libguile/expand.c (scm_sym_atcall_cc): Remove. * libguile/memoize.c (memoize): Memoize call/cc primcalls to SCM_M_CONT. (m_call_cc): Remove. (unmemoize): Unmemoize to call-with-current-continuation. * module/language/tree-il/compile-glil.scm (flatten-lambda-case): Update to call-with-current-continuation without @ prefix, and fix fallback case. * module/language/tree-il/primitives.scm (*multiply-valued-primitives*): (*interesting-primitive-names*): Remove @call-with-current-continuation. (call/cc): Expand to call-with-current-continuation. * test-suite/tests/tree-il.test ("call/cc"): Update to use and expect call-with-current-continuation primcalls / toplevel refs.
2013-06-27remove @apply memoizerAndy Wingo3-12/+10
* libguile/memoize.c (memoize): Recognize a primcall to 'apply as SCM_M_APPLY. (@apply): Remove @apply memoizer. (unmemoize): Unmemoize using "apply", not "@apply". * libguile/memoize.h: * libguile/expand.c (scm_sym_atapply): Remove. * module/ice-9/boot-9.scm (apply): Re-implement using apply primcall. Use case-lambda, so as to give an appropriate minimum arity. * module/language/tree-il/compile-glil.scm (flatten-lambda-case): Compile a primcall of "apply" specially, not "@apply". * module/language/tree-il/peval.scm (peval): Match primcalls to "apply", not "@apply". Residualize "apply" primcalls. * module/language/tree-il/primitives.scm (*interesting-primitive-names*): (*multiply-valued-primitives*): Remove @apply, and apply primitive expander. * test-suite/tests/peval.test: * test-suite/tests/tree-il.test: Update tests to expect residualized "apply". * test-suite/tests/procprop.test ("procedure-arity"): Update test for better apply arity. * test-suite/tests/strings.test ("string"): Update expected error.
2013-06-27Remove @prompt memoizerAndy Wingo1-19/+2
* libguile/memoize.h: * libguile/memoize.c (MAKMEMO_CALL_WITH_PROMPT, memoize, unmemoize): Remove the @prompt memoizer in favor of recognizing call-with-prompt primcalls. Rename SCM_M_PROMPT to SCM_M_CALL_WITH_PROMPT, and pass a thunk instead of an expression so that it has normal applicative order. * libguile/expand.c (PRIMITIVE_REF, PRIMCALL, expand): Produce primcalls from forms whose car is a primitive. (expand_atat): Recognize (@@ primitive FOO) as being a primitive-ref. * module/ice-9/boot-9.scm (call-with-prompt): Instead of dispatching to the wonky @prompt memoizer, residualize a primcall to call-with-prompt. The memoizer will DTRT to allow call-with-prompt to be interpreted correctly without needing an additional binding. * module/ice-9/eval.scm (primitive-eval): Change the 'prompt clause to a call to call-with-prompt. * module/language/tree-il/primitives.scm: No more need to recognize @prompt. * libguile/eval.c (eval): Adapt to SCM_M_PROMPT renaming to SCM_M_CALL_WITH_PROMPT, and apply the thunk. * libguile/throw.c (pre_init_throw): Adapt to scm_abort_to_prompt_star rename.
2013-06-25abort-to-prompt* instead of @abortAndy Wingo1-3/+5
* libguile/control.h: * libguile/control.c (scm_abort_to_prompt_star): Rename from scm_at_abort. * module/ice-9/boot-9.scm (abort-to-prompt): Use abort-to-prompt*. * module/language/tree-il/primitives.scm: Handle abort-to-prompt* instead of @abort.
2013-06-16<dynwind> no longer has "pre" or "post" fieldsAndy Wingo8-119/+116
* module/language/tree-il.scm (<tree-il>): Remove pre and post fields from <dynwind>. A dynwind now assumes that in normal entry and exit, that the code runs the winders and unwinders using <seq> and <let-values> and such things. (parse-tree-il, unparse-tree-il, make-tree-il-folder, pre-post-order): Adapt <dynwind> users. * module/language/tree-il/analyze.scm (analyze-lexicals): * module/language/tree-il/compile-glil.scm (flatten-lambda-case): * module/language/tree-il/cse.scm (cse): * module/language/tree-il/debug.scm (verify-tree-il): * module/language/tree-il/effects.scm (make-effects-analyzer): Adapt. * module/language/tree-il/peval.scm (peval): * module/language/tree-il/primitives.scm (*primitive-expand-table*): Produce tree-il that calls the winder and unwinder. Recognize singly-valued dynamic-wind expressions. * test-suite/tests/peval.test ("partial evaluation"): Add tests.
2013-06-16Reduce call-with-values to let for singly-valued producersAndy Wingo1-4/+20
* module/language/tree-il/peval.scm (singly-valued-expression?): Add support for conditionals. In the future we should add more expressions here. (peval): Don't inline values into the body of a dynwind, as that could cause the consumer to run in the wrong dynamic context. If the producer is singly-valued and the consumer just has a rest arg, reduce to "let" and cons up a list in the consumer. This may reduce further. * test-suite/tests/peval.test ("partial evaluation"): Add a test.
2013-06-10Rewrite make-tree-il-folder to use the Wright matcher.Andy Wingo1-22/+23
* module/language/tree-il.scm (make-tree-il-folder): Rewrite to use the Wright matcher instead of record-case.
2013-06-10Rewrite unparse-tree-il to use the Wright matcher.Andy Wingo1-29/+33
* module/language/tree-il.scm (unparse-tree-il): Rewrite to use the Wright matcher.