summaryrefslogtreecommitdiff
path: root/module/language/tree-il.scm
AgeCommit message (Collapse)AuthorFilesLines
2011-11-09inline dynwind guards for normal control flowAndy Wingo1-18/+30
* module/language/tree-il.scm (<tree-il>): Add `pre' and `post' fields to <dynwind>, so that we can inline the guard bodies in the normal control-flow case. It also avoids duplicating code in compile-glil, which probably hides more bugs in 2.0. (parse-tree-il, unparse-tree-il, tree-il->scheme, tree-il-fold) (make-tree-il-folder, post-order!, pre-order!): Update. * module/language/tree-il/analyze.scm (analyze-lexicals): Update. * module/language/tree-il/compile-glil.scm (flatten-lambda-case): Update to use `pre' and `post' instead of compiling code twice. * module/language/tree-il/debug.scm (verify-tree-il): Update. * module/language/tree-il/peval.scm (peval): Update. Instead of doing complicated things in <dynwind>, handle 'dynamic-wind primcalls. * module/language/tree-il/primitives.scm (*primitive-expand-table*): Remove 'dynamic-wind mess. Adapt '@dynamic-wind. * test-suite/tests/tree-il.test ("partial evaluation"): Update tests.
2011-11-09Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-3/+3
Conflicts: module/language/tree-il/peval.scm module/language/tree-il/primitives.scm test-suite/tests/tree-il.test
2011-11-09fix <dynwind> serialization.Andy Wingo1-3/+3
* module/language/tree-il.scm (unparse-tree-il): Fix <dynwind> serialization.
2011-09-29Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-79/+77
This was a pretty big merge involving a fair amount of porting, especially to peval and its tests. I did not update psyntax-pp.scm, that comes in the next commit. Conflicts: module/ice-9/boot-9.scm module/ice-9/psyntax-pp.scm module/language/ecmascript/compile-tree-il.scm module/language/tree-il.scm module/language/tree-il/analyze.scm module/language/tree-il/inline.scm test-suite/tests/tree-il.test
2011-09-28fix unparse-tree-il of <dynset>Andy Wingo1-1/+1
* module/language/tree-il.scm (unparse-tree-il): Fix printing of `dynset'.
2011-09-02more define-syntax-rule usageAndy Wingo1-75/+73
* module/ice-9/boot-9.scm: * module/ice-9/control.scm: * module/ice-9/futures.scm: * module/ice-9/optargs.scm: * module/ice-9/poll.scm: * module/ice-9/receive.scm: * module/ice-9/threads.scm: * module/ice-9/vlist.scm: * module/language/assembly/compile-bytecode.scm: * module/language/ecmascript/compile-tree-il.scm: * module/language/tree-il.scm: * module/oop/goops.scm: * module/oop/goops/simple.scm: * module/oop/goops/stklos.scm: * module/srfi/srfi-1.scm: * module/srfi/srfi-35.scm: * module/srfi/srfi-39.scm: * module/srfi/srfi-45.scm: * module/srfi/srfi-67/compare.scm: * module/sxml/match.scm: * module/system/repl/error-handling.scm: * module/system/repl/repl.scm: * module/system/vm/inspect.scm: * module/texinfo.scm: * module/web/server.scm: Use define-syntax-rule, where it makes sense.
2011-08-31Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-1/+1
Conflicts: libguile/bytevectors.c libguile/bytevectors.h libguile/objcodes.c libguile/r6rs-ports.c libguile/strings.c libguile/vm.c
2011-08-04fix tree-il->scheme testAndy Wingo1-1/+1
* module/language/tree-il.scm (tree-il->scheme): Fix incorporation of `lambda' in a `case-lambda'. * test-suite/tests/tree-il.test ("tree-il->scheme"): Add a test.
2011-06-18fix tree-il->scheme bug for seqAndy Wingo1-1/+2
* module/language/tree-il.scm (tree-il->scheme): Fix bug for `seq'. * module/ice-9/psyntax-pp.scm: Regenerate correctly.
2011-06-02sequence of expressions -> seq of head and tailAndy Wingo1-18/+40
* libguile/expand.h: * module/language/tree-il.scm: Rename "sequence" to "seq", and instead of taking a list of expressions, take a head and a tail. * module/language/tree-il/analyze.scm: * module/language/tree-il/compile-glil.scm: * module/language/tree-il/fix-letrec.scm: * module/language/tree-il/spec.scm: * module/language/elisp/compile-tree-il.scm: * module/ice-9/psyntax.scm: * module/ice-9/psyntax-pp.scm: * module/ice-9/eval.scm: * libguile/memoize.h: * libguile/memoize.c: * libguile/expand.c: * libguile/eval.c: Adapt to the new seq format.
2011-06-02add <primcall> to tree-ilAndy Wingo1-0/+21
* libguile/expand.c: * libguile/expand.h (SCM_EXPANDED_PRIMCALL_TYPE_NAME): (SCM_EXPANDED_PRIMCALL_FIELD_NAMES): (SCM_EXPANDED_PRIMCALL_SRC): (SCM_EXPANDED_PRIMCALL_NAME): (SCM_EXPANDED_PRIMCALL_ARGS): (SCM_MAKE_EXPANDED_PRIMCALL): Add "primcall" Tree-IL type. * doc/ref/compiler.texi (Tree-IL): Update docs. * libguile/memoize.c (memoize): Memoizer for primcalls. * module/ice-9/psyntax.scm: Build primcalls, sometimes. Also change build-primref to just make a primitive-ref. * module/language/tree-il.scm: Add primcall to the exports, parsers, serializers, etc. * module/language/tree-il/analyze.scm: * module/language/tree-il/compile-glil.scm: * module/language/tree-il/fix-letrec.scm: * module/language/tree-il/inline.scm: * module/language/tree-il/primitives.scm: * module/language/elisp/compile-tree-il.scm: Add primcall support. * test-suite/tests/tree-il.test: Use primcalls sometimes.
2011-06-02rename <application> to <call>Andy Wingo1-17/+18
* doc/ref/compiler.texi (The Scheme Compiler): Update docs. * libguile/expand.h: * libguile/expand.c: * module/language/tree-il.scm: Rename <application> to <call>. Change the external representation from (apply proc arg ...) to (call proc arg ...). * libguile/memoize.c: * module/ice-9/psyntax-pp.scm: * module/ice-9/psyntax.scm: * module/language/brainfuck/compile-tree-il.scm: * module/language/ecmascript/compile-tree-il.scm: * module/language/elisp/compile-tree-il.scm: * module/language/tree-il/analyze.scm: * module/language/tree-il/compile-glil.scm: * module/language/tree-il/fix-letrec.scm: * module/language/tree-il/inline.scm: * module/language/tree-il/primitives.scm: * test-suite/tests/tree-il.test: Update all callers.
2011-03-27tree-il->scheme fixAndy Wingo1-3/+4
* module/language/tree-il.scm (tree-il->scheme): Fix <prompt> to Scheme serialization.
2010-10-08Improve pretty-printing of tree-il objects.Ludovic Courtès1-1/+1
* module/language/tree-il.scm (print-tree-il): Print the AST with ~S instead of ~A.
2010-07-09Remove trailing whitespaceNo Itisnt1-62/+62
* module/language/tree-il.scm: Remove trailing whitespace
2010-06-17tree-il->scheme renders fix as letrec*Andy Wingo1-2/+4
* module/language/tree-il.scm (tree-il->scheme): Expand out to letrec*, as it doesn't matter, and this avoids a let when running through the evaluator.
2010-06-17beginnings of letrec* support in the expanderAndy Wingo1-7/+12
* libguile/expand.h (SCM_EXPANDED_LETREC_IN_ORDER_P) (SCM_MAKE_EXPANDED_LETREC): Add a new field to letrec, in-order?. Will be used to support letrec*. * libguile/expand.c (LETREC, expand_named_let, expand_letrec): Adapt code. * module/language/elisp/compile-tree-il.scm (compile-pair): * module/ice-9/psyntax.scm (build-named-let, build-letrec): Pass #f for in-order? to `make-letrec'. * module/ice-9/psyntax-pp.scm: Regenerate. * module/language/tree-il.scm: Add letrec-in-order? accessor. (parse-tree-il, unparse-tree-il): Parse and unparse an in-order? letrec as `letrec*'. (tree-il->scheme): Serialize letrec*.
2010-06-11unparse the tag of a promptAndy Wingo1-1/+1
* module/language/tree-il.scm (unparse-tree-il): Properly unparse the tag of a prompt.
2010-05-20macroexpanded pretty-printerAndy Wingo1-1/+6
* module/language/tree-il.scm (print-tree-il): (borrow-core-vtables, <tree-il>): When tree-il loads, override the printers for macroexpanded structures.
2010-05-20tree-il->scheme for lambda* et alAndy Wingo1-9/+56
* module/language/tree-il.scm (tree-il->scheme): Fix lambda* / case-lambda / case-lambda* transformation.
2010-05-19tree-il on expanded-vtablesAndy Wingo1-18/+60
* module/language/tree-il.scm: In a somewhat daring move, inherit the "core" tree-il constructs from %expanded-vtables.
2010-05-02rename `vars' field in tree-il binding constructs to `gensyms'Andy Wingo1-37/+37
* module/language/tree-il.scm (<tree-il>): Rename `vars' fields of <let>, <letrec>, <fix>, and <lambda-case> to `gensyms'. For clarity, and to match <lexical-ref>. * module/language/tree-il.scm: * module/language/tree-il/analyze.scm: * module/language/tree-il/compile-glil.scm: * module/language/tree-il/fix-letrec.scm: * module/language/tree-il/inline.scm: Update all callers.
2010-02-22abort always dispatches to VM bytecode, to detect same-invocation abortsAndy Wingo1-17/+22
* libguile/control.h: * libguile/control.c (scm_c_make_prompt): Take an extra arg, a cookie. Continuations will be rewindable only if the abort has the same cookie as the prompt. (scm_at_abort): Redefine from scm_abort, and instead of taking rest args, take the abort values as a list directly. Also, don't allow rewinding, because we won't support rewinding the C stack with delimited continuations. * libguile/eval.c (eval): Adapt to scm_c_make_prompt change. * libguile/vm-engine.c (vm_engine): Use vp->cookie to get a unique value corresponding to this VM invocation. * libguile/vm-i-system.c (prompt): Pass the cookie to scm_c_make_prompt. (abort): Take an additional tail arg. * libguile/vm.c (vm_abort): Parse out the abort tail arg. This is for the @abort case, or the (apply abort ...) case. (make_vm): Initialize the cookie to 0. * libguile/vm.h (struct scm_vm): Add cookie. * module/ice-9/boot-9.scm (abort): Define here as a trampoline to @abort. Needed to make sure that a call to abort dispatches to a VM opcode, so the cookie will be the same. * module/language/tree-il.scm (<tree-il>): Add a "tail" field to <abort>, for the (apply abort ...) case, or (@abort tag args). Should be #<const ()> in the normal case. Add support throughout. * module/language/tree-il/analyze.scm (analyze-lexicals): Add abort-tail support here too. * module/language/tree-il/compile-glil.scm (flatten): Compile the tail argument appropriately. * module/language/tree-il/primitives.scm (*primitive-expand-table*): Fix @abort and abort cases to pass the tail arg to make-abort.
2010-02-19add <dynref> and <dynset> to tree-ilAndy Wingo1-0/+45
* module/language/tree-il.scm (<dynref>, <dynset>): New tree-il language elements, corresponding to fluid-ref and fluid-set. * module/language/tree-il/analyze.scm: * module/language/tree-il/compile-glil.scm: Wire them up in the usual manner.
2010-02-19rename <control> to <abort>Andy Wingo1-18/+16
* libguile/vm-i-system.c (abort): Rename instruction from `throw'. * libguile/vm.c (vm_abort): Rename from vm_throw. * module/language/tree-il.scm (<abort>, make-abort, abort-src, abort-tag, abort-args: Rename from <control> & company. * module/language/tree-il/analyze.scm: * module/language/tree-il/compile-glil.scm: * module/language/tree-il/primitives.scm: Fix all callers.
2010-02-19<prompt> has no pre-unwind-handler, it's unnecessaryAndy Wingo1-32/+19
* libguile/control.h: * libguile/control.c (scm_c_make_prompt, SCM_PROMPT_PRE_UNWIND_HANDLER): * libguile/vm-i-system.c (prompt) * module/language/tree-il.scm (<prompt> prompt-pre-unwind-handler): * module/language/tree-il/analyze.scm: * module/language/tree-il/compile-glil.scm: * module/language/tree-il/inline.scm: * module/language/tree-il/primitives.scm: Remove the "pre-unwind" handler from prompt; it turns out not to be necessary. Adapt all references.
2010-02-19fix tree-il->scheme bug for <dynlet>Andy Wingo1-1/+1
* module/language/tree-il.scm (tree-il->scheme): Bugfix for dynlet.
2010-02-18add dynlet to tree-ilAndy Wingo1-0/+33
* module/language/tree-il.scm (<dynlet>, dynlet?, make-dynlet) (dynlet-src, dynlet-fluids, dynlet-vals, dynlet-body): New tree-il construct, mapping to `with-fluids'. (parse-tree-il, unparse-tree-il, tree-il->scheme, tree-il-fold): (make-tree-il-folder, post-order!, pre-order!): Wire it up. * module/language/tree-il/analyze.scm (analyze-lexicals): Add dynlet support.
2010-02-18rename <dynamic-wind> to <dynwind>Andy Wingo1-17/+17
* module/language/tree-il.scm (<dynwind>): Rename from <dynamic-wind>. * module/language/tree-il/analyze.scm: * module/language/tree-il/primitives.scm: * module/language/tree-il/compile-glil.scm: All accessors and callers changed.
2010-02-18dynwind is now a part of guile's primitive languageAndy Wingo1-3/+3
* libguile/memoize.h (scm_sym_at_dynamic_wind, SCM_M_DYNWIND) * libguile/memoize.c (memoized_tags, MAKMEMO_DYNWIND) (scm_m_at_dynamic_wind, unmemoize): Add dynwind as a primitive expression type. * libguile/dynwind.c (scm_dynamic_wind): Downgrade to a normal C function. * libguile/eval.c (eval): * module/ice-9/eval.scm (primitive-eval): Add dynwind support. * module/ice-9/r4rs.scm: More relevant docs. (apply): Define in a more regular way. (dynamic-wind): Add to this file, with docs, dispatching to @dynamic-wind. * module/language/tree-il/primitives.scm: Parse @dynamic-wind into a tree-il dynamic-wind.
2010-01-31new tree-il for prompt, control, and dynamic-windAndy Wingo1-4/+107
* module/language/tree-il.scm: Initial tree-il support for <prompt>, <control>, and <dynamic-wind>.
2009-12-11rename <conditional> then and else to consequent and alternateAndy Wingo1-22/+22
* module/language/tree-il.scm (<tree-il>): Rename the "then" and "else" clauses of <conditional> to "consequent" and "alternate". More verbose, yes, but that way we avoid unexpected behavior with "else". (parse-tree-il, unparse-tree-il, tree-il->scheme, tree-il-fold): (make-tree-il-folder, post-order!, pre-order!) * module/language/tree-il/analyze.scm (analyze-lexicals): * module/language/tree-il/compile-glil.scm (flatten): * module/language/tree-il/fix-letrec.scm (simple-expression?): Update callers.
2009-12-11rename lambda-case-else to lambda-case-alternateAndy Wingo1-20/+20
* module/language/tree-il.scm (<tree-il>): Rename the "else" field of <lambda-case> to "alternate". Conflicts less with the "else" keyword as used by case, cond, record-case, pmatch, etc. (parse-tree-il, unparse-tree-il, tree-il->scheme, tree-il-fold) (make-tree-il-folder, post-order!, pre-order!): Adapt traversal operators for <lambda-case> change. * module/language/tree-il/analyze.scm (analyze-lexicals) (validate-arity): * module/language/tree-il/compile-glil.scm (flatten): * module/language/tree-il/inline.scm (inline!): Adapt for <lambda-case> change.
2009-11-15Revert "implement #:predicate" and remove predicate from <lambda-case>Andy Wingo1-35/+18
Turns out this was not a very useful idea, and semantically tricky to boot. This reverts commit 24bf130fd15afbc8b3a2ccdc50a027f9b6c9e623, and makes the following additional changes: * module/ice-9/optargs.scm (parse-lambda-case, let-optional) (let-optional*, let-keywords, let-keywords*): * module/language/tree-il.scm: (<lambda-case>, parse-tree-il) (unparse-tree-il, tree-il->scheme, tree-il-fold, make-tree-il-folder) (post-order!, pre-order!): * module/language/tree-il/analyze.scm (analyze-lexicals): * module/language/tree-il/compile-glil.scm (compile-glil): * module/language/tree-il/inline.scm (inline!): Remove all traces of #:predicate from tree-il. * module/ice-9/psyntax.scm (build-simple-lambda, build-lambda-case) (chi-lambda-case): Adapt to tree-il change. * module/ice-9/psyntax-pp.scm: Regenerated. * module/language/brainfuck/compile-tree-il.scm (compile-body): * module/language/ecmascript/compile-tree-il.scm (comp, comp-body): * test-suite/tests/tree-il.test: Adapt to tree-il change. * doc/ref/api-procedures.texi (Case-lambda): Remove mention of #:predicate.
2009-10-23separate "inits" field in <lambda-case>; compile fixes for inits, kwargsAndy Wingo1-42/+36
* module/language/tree-il.scm (<lambda-case>): Add "inits" field, so we don't have to parse it out of opt and kw. Adapt the traversal procedures. * module/language/tree-il/analyze.scm (analyze-lexicals): Analyze lexicals in the <lambda-case> init expressions as well. Fix keyword allocation. * module/language/tree-il/compile-glil.scm (compile-glil): Adapt to make-lambda-case change. (flatten): Adapt to "inits" slot, actually init uninitialized args, and fix bugs related to keyword arguments. * module/language/tree-il/inline.scm (inline!): Adapt a little bit -- but with no effect. * module/language/glil/compile-assembly.scm (glil->assembly): Flesh out <glil-kw-prelude> compilation some more. Add a "bound?" op for <glil-lexical>, which will push #t if the local is bound. * module/ice-9/psyntax.scm (build-simple-lambda, build-lambda-case): Update for new signature of make-lambda-case. * module/ice-9/psyntax-pp.scm: Regenerated. * module/language/brainfuck/compile-tree-il.scm (compile-body): * module/language/ecmascript/compile-tree-il.scm (comp): * test-suite/tests/tree-il.test ("lambda"): Update for new lambda-case syntax.
2009-10-23finish support for optional & keyword args; update ecmascript compilerAndy Wingo1-14/+20
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump. * libguile/vm-i-system.c (br-if-nargs-ne, br-if-args-lt) (br-if-nargs-gt): New instructions, for use by different lambda cases. (bind-optionals, bind-optionals/shuffle, bind-kwargs): New instructions, for binding optional and keyword arguments. Renumber other ops. * module/language/ecmascript/compile-tree-il.scm (comp, comp-body): Update for new tree-il. Use the new optional argument mechanism instead of emulating it with rest arguments. * module/language/glil/compile-assembly.scm (glil->assembly): Tweaks for optional and keyword argument compilation. * module/language/tree-il.scm (parse-tree-il, unparse-tree-il): Make the else case optional, in the s-expression serialization of tree-il. * module/language/tree-il/compile-glil.scm (flatten): Handle all of the lambda-case capabilities.
2009-10-23tree-il support for case-lambdaAndy Wingo1-21/+87
* module/language/tree-il.scm (<lambda>, <lambda-case>): Split lambda into the lambda itself, denoting the procedure, and lambda-case, denoting a particular arity case. Lambda-case is fairly featureful, and has not yet been fully tested. (<let-values>): Use a <lambda-case> as the binding expression. Seems to suit the purpose well. Adapt parsers, unparsers, traversal operators, etc. Sometimes in this first version we assume there are no optional args, rest args, or a predicate. * module/language/tree-il/analyze.scm (analyze-lexicals): Adapt for the new case-lambda regime. Fairly well commented. It actually simplifies things. (report-unused-variables): Update for new tree-il. * module/language/tree-il/compile-glil.scm: Adapt for the new tree-il. There are some first stabs here at proper case-lambda compilation, but they are untested as of yet. * module/language/tree-il/inline.scm (inline!): Rework so we can recurse on a single node; though these transformations are strictly reductive, so they should complete in bounded time. Simplify accordingly, and adapt to case-lambda. Oh, and we handle lambda->let in not just the nullary case. * module/ice-9/psyntax.scm (build-simple-lambda, build-case-lambda) (build-lambda-case): New constructors. The idea is that after syntax expansion, we shouldn't have to deal with improper lists any more. Build-simple-lambda is a shortcut for the common case. The others are not fully exercised yet. Adapt callers. (syntax): Add some debugging in the lambda case. I don't fully understand this, but in practice we don't seem to see rest args here. (lambda): Inline chi-lambda-clause, and adapt for build-simple-lambda. * module/ice-9/psyntax-pp.scm: Regenerated. * test-suite/tests/tree-il.test: Update tests for new tree-il lambda format, and to expect post-prelude labels for all glil programs.
2009-09-21Remove unused variables in system/language.Ludovic Courtès1-11/+11
* module/language/assembly.scm (byte-length): Don't match unused record slots. * module/language/tree-il.scm (tree-il->scheme, post-order!, pre-order!): Likewise. * module/language/tree-il/analyze.scm (analyze-lexicals): Likewise. * module/language/tree-il/compile-glil.scm (flatten): Likewise. * module/language/assembly/disassemble.scm (disassemble-load-program): Don't match unused list elements. * module/language/glil/decompile-assembly.scm (decompile-toplevel, decompile-load-program): Likewise. * module/system/xref.scm (program-callee-rev-vars): Likewise. * module/language/assembly/compile-bytecode.scm (write-bytecode)[write-sized-loader]: Remove. * module/language/assembly/decompile-bytecode.scm (decode-load-program): Factorize `pad' variables. * module/language/ecmascript/base.scm (object->value/string, object->value/number)[v]: Remove. * module/language/ecmascript/tokenize.scm (read-slash)[c0]: Remove. * module/language/objcode/spec.scm (decompile-value)[nargs]: Remove. * module/system/repl/command.scm (time)[vms-start, vms-end]: Remove. * module/system/repl/repl.scm (prompting-meta-read): Use `prompt'.
2009-08-06actually implement "fixing letrec"Andy Wingo1-61/+39
* module/Makefile.am (SOURCES): Reorganize so GHIL is compiled last, along with ecmascript. * module/language/scheme/spec.scm: Remove references to GHIL, as it's bitrotten and obsolete.. * module/language/tree-il.scm (make-tree-il-folder): Rework so that we only have down and up procs, and call down and up on each element. * module/language/tree-il/analyze.scm (analyze-lexicals): Fix a thinko handling let-values. * module/language/tree-il/fix-letrec.scm: Actually implement fixing letrec. The resulting code will perform better, but violations of the letrec restriction are not detected. This behavior is allowed by the spec, but it is undesirable. Perhaps that will be fixed later. * module/language/tree-il/inline.scm (inline!): Fix a case in which ((lambda args foo)) would be erroneously inlined to foo. Remove empty let, letrec, and fix statements. * module/language/tree-il/primitives.scm (effect-free-primitive?): New public predicate.
2009-08-05let-values in terms of syntax-case, add make-tree-il-folderAndy Wingo1-2/+76
* module/language/tree-il.scm (tree-il-fold): Fix for let-values case. (make-tree-il-folder): New public macro, makes a multi-valued folder specific to the number of seeds that the user wants. * module/language/tree-il/optimize.scm (optimize!): Reverse the order of inline! and fix-letrec!, as the latter might expose opportunities for the former. * module/srfi/srfi-11.scm (let-values): Reimplement in terms of syntax-case, so that its expressions may reference hygienically bound variables. See the NEWS for the rationale. (let*-values): An empty let*-values still introduces a local `let' binding contour. * module/system/base/syntax.scm (record-case): Yukkkk. Reimplement in terms of syntax-case. Ug-ly, but see the NEWS again: "Lexical bindings introduced by hygienic macros may not be referenced by nonhygienic macros."
2009-08-05add <fix> tree-il construct, and compile itAndy Wingo1-0/+24
* libguile/vm-i-system.c (fix-closure): New instruction, for wiring together fixpoint procedures. * module/Makefile.am (TREE_IL_LANG_SOURCES): Add fix-letrec.scm. * module/language/glil/compile-assembly.scm (glil->assembly): Reindent the <glil-lexical> case, and handle 'fix for locally-bound vars. * module/language/tree-il.scm (<fix>): Add the <fix> tree-il type and accessors, for fixed-point bindings. This IL construct is taken from the Waddell paper. (parse-tree-il, unparse-tree-il, tree-il->scheme, tree-il-fold) (pre-order!, post-order!): Update for <fix>. * module/language/tree-il/analyze.scm (analyze-lexicals): Update for <fix>. The difference here is that the bindings may not be assigned, and are not marked as such. They are not boxed. (report-unused-variables): Update for <fix>. * module/language/tree-il/compile-glil.scm (flatten): Compile <fix> to GLIL. * module/language/tree-il/fix-letrec.scm: A stub implementation of fixing letrec -- will flesh out in a separate commit. * module/language/tree-il/inline.scm: Fix license, it was mistakenly added with LGPL v2.1+. * module/language/tree-il/optimize.scm (optimize!): Run the fix-letrec! pass.
2009-07-31Add `tree-il-fold', a purely functional iterator on `tree-il'.Ludovic Courtès1-1/+48
* module/language/tree-il.scm (tree-il-fold): New procedure. * test-suite/tests/tree-il.test ("tree-il-fold"): New test prefix.
2009-06-21add brainfuck->tree-il compilerAndy Wingo1-0/+3
* module/Makefile.am (BRAINFUCK_LANG_SOURCES): Compile at the end. Add compile-tree-il.scm. * module/language/brainfuck/compile-tree-il.scm: New compiler, compiles to tree-il instead of scheme. I thought it would be more illustrative, though there are some uncommented bits. * module/language/brainfuck/parse.scm: Modify not to put a header on the scheme representation. After all, we don't put <scheme> before scheme code, do we? :) * module/language/brainfuck/spec.scm: Add tree-il compiler. * module/language/tree-il.scm: Understand (set! (lexical foo) ...). * module/system/base/language.scm: Update license. Actually, updates licenses on all these.
2009-06-17Change Guile license to LGPLv3+Neil Jerram1-1/+1
(Not quite finished, the following will be done tomorrow. module/srfi/*.scm module/rnrs/*.scm module/scripts/*.scm testsuite/*.scm guile-readline/* )
2009-06-08call-with-values can make fewer closuresAndy Wingo1-126/+115
* module/language/tree-il.scm: Rename let-exp and letrec-exp to let-body and letrec-body. Add <let-values>, a one-expression let-values that should avoid the needless creation of two closures in many common multiple-value cases. We'll need to add an optimization pass to the compiler to produce this form, though, as well as rewriting lambdas into lets, etc. I added this form instead of adding more special cases to the call-with-values compile code because it's a useful intermediate form -- it will allow the optimizer to perform constant folding across more code. * module/language/tree-il.scm (parse-tree-il, unparse-tree-il) (tree-il->scheme, post-order!, pre-order!): Adapt to let/letrec body renaming, and let-values. * module/language/tree-il/analyze.scm (analyze-lexicals): Adapt for renaming, and add cases for let-values. * module/language/tree-il/compile-glil.scm (flatten): Add a new context, `vals', used by let-values code for the values producer. Code that produces multiple values can then jump to the let-values MV return address directly, instead of trampolining into a procedure. Add code to compile let-values.
2009-05-24update docs, clean up VM vestiges, macro docs, fix (/ a b c)Andy Wingo1-22/+9
* doc/ref/api-procedures.texi (Compiled Procedures): Fix for API changes. * doc/ref/compiler.texi (Compiling to the Virtual Machine): Replace GHIL docs with Tree-IL docs. Update the bits about the Scheme compiler to talk about Tree-IL and the expander instead of GHIL. Remove <glil-argument>. Add placeholder sections for assembly and bytecode. * doc/ref/vm.texi: Update examples with what currently happens. Reword some things. Fix a couple errors. * libguile/vm-i-system.c (externals): Remove this instruction, it's not used. * module/ice-9/documentation.scm (object-documentation): If the object is a macro, try to return documentation on the macro transformer. * module/language/assembly/disassemble.scm (disassemble-load-program): Fix problem in which we skipped the first element of the object vector, because of changes to procedure layouts a few months ago. * module/language/scheme/spec.scm (read-file): Remove read-file definition. * module/language/tree-il.scm: Reorder exports. Remove <lexical>, it was a compat shim to something that was never released. Fix `location'. * module/language/tree-il/primitives.scm (/): Fix expander for more than two args to /. * module/system/base/compile.scm (read-file-in): Remove unused definition. * module/system/base/language.scm (system): Remove language-read-file. * module/language/ecmascript/spec.scm (ecmascript): Remove read-file definition.
2009-05-21some work on syntax.testAndy Wingo1-1/+3
* module/language/tree-il.scm (tree-il->scheme): * module/ice-9/psyntax.scm (build-conditional): Attempt to not generate (if #f #f) as the second arm of an if, but it doesn't seem to be successful. * module/ice-9/psyntax-pp.scm (syntax-rules): Regenerate. * test-suite/tests/syntax.test (exception:unexpected-syntax): Change capitalization. ("unquote-splicing"): Update test. ("begin"): Add in second arms on these ifs, to avoid the strange though harmless expansion of `if'. (matches?): New helper macro. ("lambda"): Match on lexically bound symbols, as they will be alpha-renamed.
2009-05-18add tree-il->glil compilation test suiteAndy Wingo1-10/+10
* module/language/tree-il.scm (parse-tree-il): Fix a number of bugs. (unparse-tree-il): Apply takes rest args now. * module/language/tree-il/analyze.scm (analyze-lexicals) (analyze-lexicals): Heap vars shouldn't increment the number of locals. * module/language/tree-il/optimize.scm (resolve-primitives!): Don't resolve public refs to primitives, not at the moment anyway. * test-suite/Makefile.am (SCM_TESTS): Add tree-il test. * test-suite/lib.scm (pass-if, expect-fail, pass-if-exception) (expect-fail-exception): Rewrite as syntax-rules macros. In a very amusing turn of events, it turns out that bindings introduced by hygienic macros are not visible inside expansions produced by defmacros. This seems to be expected, so go ahead and work around the problem. * test-suite/tests/srfi-31.test ("rec special form"): Expand in eval. * test-suite/tests/syntax.test ("begin"): Do some more expanding in eval, though all is not yet well. * test-suite/tests/tree-il.test: New test suite, for tree-il->glil compilation.
2009-05-17actually pass original ids on to tree-il data typesAndy Wingo1-20/+20
* module/ice-9/psyntax.scm (build-lambda, build-let, build-named-let) (build-letrec): Actually pass along the original ids to tree-il constructors. * module/ice-9/psyntax-pp.scm: Regenerated. * module/language/tree-il.scm: Add fields in <lambda>, <let>, and <letrec> for the original variable names. * module/language/tree-il/compile-glil.scm (compile-glil): Adapt for new make-lambda arg.
2009-05-15tree-il -> glil compiler works now, at least in initial testsAndy Wingo1-0/+14
* module/language/tree-il/analyze.scm: Break analyzer out into its own file. * module/language/tree-il/compile-glil.scm: Port the GHIL->GLIL compiler over to work on tree-il. Works, but still misses a number of important optimizations. * module/language/tree-il.scm: Add <void>. Not used quite yet. * module/language/glil.scm: Remove <glil-argument>, as it is the same as <glil-local> (minus an offset). * module/language/glil/compile-assembly.scm: * module/language/glil/decompile-assembly.scm: * module/language/ghil/compile-glil.scm: Adapt for <glil-argument> * removal. * module/Makefile.am (TREE_IL_LANG_SOURCES): Reorder, and add analyze.scm.