summaryrefslogtreecommitdiff
path: root/libguile/expand.c
Commit message (Expand)AuthorAgeFilesLines
* Remove unused static definitions...* libguile/expand.c: * libguile/vm.c: Remove unused static definitions. Andy Wingo2016-06-111-9/+0
* Simplify variable resolution in the evaluator...* libguile/expand.c (convert_assignment): Handle creation of the default lambda-case body here. * libguile/eval.c (eval): * module/ice-9/eval.scm (primitive-eval): * libguile/memoize.h: * libguile/memoize.c (MAKMEMO_BOX_REF, MAKMEMO_BOX_SET): (MAKMEMO_TOP_BOX, MAKMEMO_MOD_BOX): Refactor all global var resolution to go through "resolve". Add "box-ref" and "box-set!". Rename memoize-variable-access! to %resolve-variable, and don't be destructive. Andy Wingo2014-12-071-1/+15
* Simplify the interpreter for trivial inits and no letrec...* libguile/memoize.c (FULL_ARITY): Serialize "ninits" and the unbound value instead of the init list. (memoize): Adapt to FULL_ARITY changes. Remove LETREC case. (unmemoize): Adapt to memoized code change. * libguile/eval.c (BOOT_CLOSURE_PARSE_FULL): Adapt to parse ninits and unbound instead of inits. (eval): Lexical-ref can no longer raise an error. (prepare_boot_closure_env_for_apply): Adapt to inits change. * module/ice-9/eval.scm (primitive-eval): Adapt to ninits/unbound change. * libguile/expand.c (expand_named_let): Fix lambda-case creation to make lists for opt and inits. Andy Wingo2014-12-051-8/+9
* Assignment conversion in the interpreter...* libguile/expand.c (compute_assigned, convert_assignment) (scm_convert_assignment): New functions. * libguile/expand.h: Declare scm_convert_assignment. * libguile/memoize.c (scm_memoize_expression): Do assignment conversion before memoization. * test-suite/tests/syntax.test ("letrec"): Detection of unbound letrec variables now works. Andy Wingo2014-12-051-2/+397
* Builtins have procedure properties...* libguile/vm-builtins.h (FOR_EACH_VM_BUILTIN): Add arity information. (enum scm_vm_builtins): * libguile/vm.c (scm_vm_builtin_ref): (scm_vm_builtin_name_to_index): (scm_vm_builtin_index_to_name): Adapt to macro interface change. (scm_init_vm_builtin_properties): New helper, sets procedure properties on builtins. (scm_bootstrap_vm): Just define the builtins here. Later in the bootstrap we set their properties. (scm_sym_apply): Move definition here from expand.c. * libguile/procprop.c (scm_init_procprop): Call scm_init_vm_builtin_properties. Andy Wingo2013-11-081-1/+0
* Remove with-fluids; replaced by with-fluid* and inlined push-fluid primops...* 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*. Andy Wingo2013-06-281-29/+0
* dynamic-wind in terms of wind and unwind; remove <dynwind>, @dynamic-wind...* 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. Andy Wingo2013-06-271-1/+0
* remove @call-with-values memoizer...* 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. Andy Wingo2013-06-271-1/+0
* remove @call-with-current-continuation memoizer...* 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. Andy Wingo2013-06-271-1/+0
* remove @apply memoizer...* 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. Andy Wingo2013-06-271-1/+0
* Remove @prompt memoizer...* 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. Andy Wingo2013-06-271-11/+22
* Merge remote-tracking branch 'origin/stable-2.0'...Conflicts: libguile/expand.c libguile/hashtab.c libguile/ports.c libguile/vectors.c libguile/weaks.c module/language/ecmascript/compile-tree-il.scm module/language/tree-il/effects.scm module/language/tree-il/fix-letrec.scm module/language/tree-il/peval.scm test-suite/tests/peval.test Andy Wingo2012-07-061-12/+15
|\
| * fix warnings in mingw in expand.c...* libguile/expand.c (VOID_, CONST_): Add trailing underscores to avoid name conflicts on MinGW. Andy Wingo2012-07-061-12/+15
* | most uses of scm_from_locale_symbol become scm_from_utf8_symbol...* libguile/array-handle.c: * libguile/chars.c: * libguile/expand.c: * libguile/feature.c: * libguile/goops.c: * libguile/gsubr.c: * libguile/instructions.c: * libguile/load.c: * libguile/macros.c: * libguile/memoize.c: * libguile/modules.c: * libguile/options.c: * libguile/print.c: * libguile/smob.c: * libguile/snarf.h: Change most uses of scm_from_locale_symbol to scm_from_utf8_symbol, as the symbols really are not locale-dependent. Andy Wingo2011-10-251-2/+2
* | sequence of expressions -> seq of head and tail...* 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. Andy Wingo2011-06-021-4/+6
* | add <primcall> to tree-il...* 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. Andy Wingo2011-06-021-0/+1
* | rename <application> to <call>...* 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. Andy Wingo2011-06-021-14/+14
|/
* psyntax, primitive expander, and memoizer support for letrec*...* libguile/expand.c (expand_letrec_helper): Factor out common code. (expand_letrec): Use expand_letrec_helper. (expand_letrec_star): New primitive syntax: letrec*. * libguile/memoize.c (memoize): Add memoizer support for in-order letrec (letrec*). * module/ice-9/psyntax.scm (build-letrec): Another arg, `in-order?'. (chi-body): Adapt to build-letrec change. We don't yet use letrec* for internal definitions. (letrec): Adapt to build-letrec change. (letrec*): New expander. * module/ice-9/psyntax-pp.scm: Regenerated. Andy Wingo2010-06-171-2/+15
* beginnings of letrec* support in the expander...* 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*. Andy Wingo2010-06-171-4/+4
* iron out inconsistency between eval and compile expansion...* libguile/expand.c (expand_lambda_star_case): Harmonize with tree-il, expanding keywords to (aok? (kw name gensym) ...), not (aok? (kw . index) ...). * libguile/memoize.c (memoize): Process the (kw name gensym) format into (kw . index). * module/ice-9/psyntax.scm (build-lambda-case): Remove a compile-versus-eval special case. * module/ice-9/psyntax-pp.scm: Regenerate. Andy Wingo2010-05-201-8/+6
* primitive-eval takes expanded, not memoized, source...* module/ice-9/eval.scm (primitive-eval): * libguile/eval.c (scm_c_primitive_eval): Don't expect a memoized expression -- expect either raw source or an *expanded* expression. We handle memoization ourselves. * libguile/expand.c (scm_macroexpand): Settle down into its proper name, "macroexpand", even as we comment that it is but a fleeting boot expander. (scm_macroexpanded_p): New predicate for expanded code. * libguile/expand.h: Add scm_macroexpanded_p. * libguile/memoize.c (scm_memoize_expression): Require that the expression be expanded. (scm_init_memoize): Don't alias memoize-expression to macroexpand. * module/ice-9/psyntax-pp.scm: * module/ice-9/psyntax.scm: Always produce macroexpanded expressions, and hand them to primitive-eval. No more calls to memoize-expression here. * test-suite/tests/optargs.test: Remove some tests, as unfortunately we have no way to invoke the boot expander after boot. Andy Wingo2010-05-201-1/+11
* %expanded-vtables is a vector...* libguile/expand.c (scm_init_expand): %expanded-vtables is a vector. Andy Wingo2010-05-191-1/+1
* separate boot expansion from memoization...* libguile/Makefile.am: * libguile/init.c: * libguile/expand.c: * libguile/expand.h: Add new expander. The idea is that macroexpansion is one thing, and whether to compile or interpret the result of that is another thing. * libguile/memoize.c: Adapt to expand as necessary, and then memoize expanded source without worrying about syntax errors. * module/ice-9/eval.scm (make-general-closure): Allow alt clauses to not possess the full make-general-closure arity. Andy Wingo2010-05-191-0/+1253