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

33 commits

Author SHA1 Message Date
Andy Wingo
b2b33168b1 more care regarding SCM_PACK and SCM_UNPACK
* libguile/control.c (reify_partial_continuation):
* libguile/eval.c (RETURN_BOOT_CLOSURE):
* libguile/frames.c (scm_frame_num_locals, scm_frame_local_ref)
  (scm_frame_local_set_x)
* libguile/frames.h (SCM_FRAME_SET_RETURN_ADDRESS):
  (SCM_FRAME_SET_MV_RETURN_ADDRESS, SCM_FRAME_SET_DYNAMIC_LINK):
* libguile/goops.c (scm_class_of, scm_primitive_generic_generic)
  (scm_c_extend_primitive_generic, compute_getters_n_setters)
  (scm_sys_initialize_object):
* libguile/guardians.c (finalize_guarded):
* libguile/list.c (SCM_I_CONS):
* libguile/macros.c (scm_i_make_primitive_macro)
  (scm_make_syntax_transformer):
* libguile/memoize.c (MAKMEMO, SCM_MAKE_MEMOIZER)
  (SCM_MAKE_REST_MEMOIZER):
* libguile/modules.c (scm_module_reverse_lookup)
* libguile/print.c (iprin1):
* libguile/promises.c (scm_make_promise)
* libguile/srcprop.c (scm_make_srcprops):
* libguile/vectors.c (scm_c_vector_ref):
* libguile/vm-engine.c (vm_engine)
* libguile/vm-i-scheme.c (REL, add1, sub1):
* libguile/vm-i-system.c (new_frame, call_cc)
* libguile/weaks.h (SCM_WEAK_PAIR_WORD_DELETED_P): Be more careful about
  SCM_PACK / SCM_UNPACK.
2011-05-13 15:28:08 +02:00
Andy Wingo
4a655e50a3 use scm_from_latin1_symboln for string literals and load-symbol
* libguile/bytevectors.c:
* libguile/eval.c:
* libguile/goops.c:
* libguile/i18n.c:
* libguile/load.c:
* libguile/memoize.c:
* libguile/modules.c:
* libguile/ports.c:
* libguile/print.c:
* libguile/procs.c:
* libguile/programs.c:
* libguile/read.c:
* libguile/script.c:
* libguile/srfi-14.c:
* libguile/stacks.c:
* libguile/strings.c:
* libguile/throw.c:
* libguile/vm.c: Use scm_from_latin1_symboln to make symbols from string
  literals, because they aren't in the user's locale -- they are in
  ASCII, and we can optimize this case.

* libguile/vm-i-loader.c: Also use scm_from_latin1_symboln when loading
  narrow symbols.
2011-01-07 09:18:41 -08:00
Andy Wingo
efa360afc3 @apply for multiple args in the boot memoizer
* libguile/memoize.c (m_apply): Fix for multiple arguments, as in
  (@apply proc foo bar baz).
2010-08-16 21:36:14 -07:00
Andy Wingo
826373a25d 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.
2010-06-17 13:43:26 +02:00
Andy Wingo
f238862e9e fix bug in memoize
* libguile/memoize.c (memoize): Fix a bug where LETREC was being
  accessed as LET, and it just happened to coincide.
2010-06-17 13:43:25 +02:00
Andy Wingo
632ddbf02b 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.
2010-05-20 12:53:21 +02:00
Andy Wingo
a310a1d12e 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.
2010-05-20 12:25:52 +02:00
Andy Wingo
e1ca91007a fix a couple expander naming bugs
* libguile/expand.h:
* libguile/memoize.c: Fix a couple bugs: it's application-args, not
  application-exps, and public?, not public.
2010-05-19 23:25:50 +02:00
Andy Wingo
dc3e203e07 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.
2010-05-19 22:51:31 +02:00
Andy Wingo
667361f6ce remove the new scm_memoize_begin, etc
* libguile/memoize.h:
* libguile/memoize.c: Remove the recently-added scm_memoize_begin,
  scm_memoize_lambda, et al. We'll take a different tack.
2010-05-18 22:30:58 +02:00
Andy Wingo
311fbeb7c3 scm_memoize_lambda update
* libguile/memoize.h:
* libguile/memoize.c (scm_memoize_lambda): Update to memoize
  "full-arity" lambdas.
2010-05-16 12:24:08 +02:00
Andy Wingo
7572ee5261 evaluator support for case-lambda
* libguile/memoize.c (patch_case_lambda, scm_m_case_lambda)
  (scm_m_case_lambda_star): Add memoizers for case-lambda and
  case-lambda*.
  (unmemoize): Unmemoize lambdas with multiple arities.

* libguile/eval.c (prepare_boot_closure_env_for_apply):
  (prepare_boot_closure_env_for_eval): Adapt to return both body and
  env, so that case-lambda clauses can be selected appropriately.
  (eval, boot_closure_apply): Adapt callers.

* module/ice-9/eval.scm (make-general-closure): Support multiple
  arities.
2010-05-14 00:28:39 +02:00
Andy Wingo
d8a071fc4e primitive support for lambda*
* libguile/memoize.c (scm_m_lambda_star): Define lambda* in the
  pre-psyntax env, and make it memoize lambda* expressions.

* libguile/eval.c (BOOT_CLOSURE_PARSE_FULL): New helper.
  (error_invalid_keyword, error_unrecognized_keyword): New helpers.
  (prepare_boot_closure_env_for_apply): Flesh out application of boot
  closures with "full" arity.
  (prepare_boot_closure_env_for_eval): Punt to
  prepare_boot_closure_env_for_eval for the full-arity case.

* module/ice-9/eval.scm (make-fixed-closure): Rename from `closure', and
  just handle fixed arities, where there is no rest argument..
  (make-general-closure): New helper, a procedure, that returns a
  closure that can take rest, optional, and keyword arguments.
  (eval): Adapt to call make-fixed-closure or make-general-closure as
  appropriate.

* test-suite/tests/optargs.test ("lambda* inits"): Test the memoizer as
  well.
2010-05-14 00:28:32 +02:00
Andy Wingo
9658182d5f tweak to lambda* memoization format
* libguile/memoize.c (FULL_ARITY): Change the form to more closely
  approximate <lambda-case>.
  (unmemoize): Unmemoize lambda* expressions.
2010-05-13 23:37:15 +02:00
Andy Wingo
8f9c5b589d change to format of memoization lambda expressions
* libguile/memoize.c (scm_m_lambda, memoize_named_let)
  (scm_memoize_lambda, unmemoize)
* libguile/eval.c (eval, prepare_boot_closure_env_for_apply)
  (prepare_boot_closure_env_for_eval, boot_closure_apply):
* module/ice-9/eval.scm (primitive-eval): Change the format for memoized
  lambda expressions, so as to allow, in the future, case-lambda* to be
  supported by the evaluator.
2010-05-13 23:37:15 +02:00
Andy Wingo
384012a197 add memoize-begin, memoize-let, etc functions
* libguile/memoize.h:
* libguile/memoize.c (scm_memoize_begin, scm_memoize_if,
  scm_memoize_lambda, scm_memoize_let, scm_memoize_quote,
  scm_memoize_define, scm_memoize_with_fluids, scm_memoize_call,
  scm_memoize_lexical_ref, scm_memoize_lexical_set,
  scm_memoize_toplevel_ref, scm_memoize_toplevel_set,
  scm_memoize_module_ref, scm_memoize_module_set): New functions, public
  to Scheme but private to C. For use by psyntax, in the future.
2010-05-07 23:14:00 +02:00
Andy Wingo
2cd72a849f add "memoizer" data type
* libguile/memoize.h:
* libguile/memoize.c (MAKMEMO_APPLY): Take the proc and args separately.
  (scm_tc16_memoizer, SCM_MEMOIZER_P, SCM_MEMOIZER): New smob type, for
  "syntax" like @apply that have normal evaluation order.
  (memoize_env_ref_macro, memoize): Refactor to handle "memoizers"
  generically.

  Reorganize the list of SCM_SYNTAX forms.

  Move @apply, @dynamic-wind, @call-with-current-continuation,
  @call-with-values, @prompt handling down to be generic "memoizer" data
  types.

  (scm_memoizer_p, scm_memoizer): New functions, exposed to Scheme. Will
  be used by psyntax.
2010-05-07 23:13:41 +02:00
Andy Wingo
4f692ace90 macro expanders return memoized expressions
* libguile/eval.c (scm_c_primitive_eval):
* module/ice-9/eval.scm (primitive-eval): Rely on the expander to
  produce a memoized expression. If the expression is already memoized,
  just pass it through (the equivalent of the old "noexpand" hack).

* libguile/memoize.c (scm_init_memoize): Initialize `memoize-expression'
  as the initial binding of `macroexpand'.

* libguile/modules.c (scm_module_transformer): Before modules are
  booted, look for `macroexpand', not `%pre-modules-transformer'.

* module/ice-9/boot-9.scm: No more %pre-modules-transformer. Loading
  psyntax extends `macroexpand'.
  (make-module): `macroexpand' is the default transformer.

* module/ice-9/psyntax.scm: No more `noexpand'.
  (top-level-eval-hook, local-eval-hook): Instead of annotating with
  noexpand, memoize the expression before handing it to primitive-eval.
  (macroexpand): No more noexpand hack -- in its place we have another
  hack, to memoize the result when running in eval mode.
* module/ice-9/psyntax-pp.scm: Regenerated.
2010-05-07 22:22:19 +02:00
Ludovic Courtès
b7ecadca7b Slightly optimize the memoizer, bootstrap evaluator, and `(ice-9 eval)'.
* libguile/eval.c (CAR, CDR, CAAR, CADR, CDAR, CDDR, CADDR, CDDDR): Use
  the macro variants, not the functions.
  (eval)[SCM_M_CALL]: When invoking a VM program, accumulate its
  arguments on the stack rather than on the heap.

* libguile/memoize.c (CAR, CDR, CAAR, CADR, CDAR, CDDR, CADDR, CDDDR,
  CADDR): Use the macro variants, not the functions.
  (scm_memoized_expression_typecode): Use `SCM_I_MAKINUM' instead of
  `scm_from_uint16'.
2010-03-05 00:36:47 +01:00
Andy Wingo
747022e4cb prompt as part of guile's primitive language
* libguile/control.h:
* libguile/control.c: Remove scm_atcontrol and scm_atprompt.
  (scm_c_make_prompt): Remove handler arg, as the handler is inline.
  (scm_abort): New primitive, exported to Scheme as `abort'. The
  compiler will also recognize calls to `abort', but this is the base
  case.
  (scm_init_control): Remove scm_register_control, just have this
  function, which adds `abort' to the `(guile)' module.

* libguile/eval.c (eval): Add SCM_M_PROMPT case.

* libguile/init.c (scm_i_init_guile): Change scm_register_control call
  into a nice orderly scm_init_control call.

* libguile/memoize.h: (scm_sym_at_prompt, SCM_M_PROMPT):
* libguile/memoize.c (MAKMEMO_PROMPT, scm_m_at_prompt, unmemoize): Add
  prompt support to the memoizer.

* libguile/vm-i-system.c (prompt): Fix to not expect a handler on the
  stack.

* module/ice-9/boot-9.scm (prompt): Add definition in terms of @prompt.

* module/ice-9/control.scm: Simplify, and don't play with the compiler
  here, now that prompt and abort are primitive.

* module/ice-9/eval.scm (primitive-eval): Add a prompt case.

* module/language/tree-il/primitives.scm
  (*interesting-primitive-names*): Add @prompt and prompt.
2010-02-19 22:44:24 +01:00
Andy Wingo
bb0229b51d add with-fluids objects and primitive syntax
* libguile/tags.h (scm_tc7_with_fluids): Allocate a tc7 for
  "with-fluids" objects, which will only live on the dynamic stack (wind
  list), not in normal scheme-land.

* libguile/fluids.h (SCM_WITH_FLUIDS_P, SCM_WITH_FLUIDS_LEN)
  (SCM_WITH_FLUIDS_NTH_FLUID, SCM_WITH_FLUIDS_NTH_VAL)
  (SCM_WITH_FLUIDS_SET_NTH_VAL): Add some accessors.
* libguile/fluids.c (scm_i_make_with_fluids, scm_i_swap_with_fluids):
  New internal functions.
  (scm_c_with_fluids, scm_c_with_fluid): Push with-fluids objects on the
  dynwind list, not winders.

* libguile/dynwind.c (scm_i_dowinds): Add cases for winding and
  unwinding with-fluids objects.

* libguile/memoize.h (scm_sym_with_fluids, SCM_M_BEGIN): New public
  data.
* libguile/memoize.c (scm_m_with_fluids): Define with-fluids as a
  primitive syntax.
  (unmemoize): Add with-fluids case.

* libguile/eval.c (eval):
* module/ice-9/eval.scm (primitive-eval): Add with-fluids cases.

* test-suite/tests/fluids.test
  ("fluids not modified if nonfluid passed to with-fluids"): Enable a
  now-passing test.
2010-02-18 22:15:43 +01:00
Andy Wingo
c08899ff24 fix unmemoization bug
* libguile/memoize.c (unmemoize): Fix unmemoization of memoized
  toplevel-ref and module-ref forms.
2010-02-18 22:15:43 +01:00
Andy Wingo
b5e9f3f97e memoize (begin foo) to foo
* libguile/memoize.c (memoize_sequence): Don't make a `begin' if there's
  only one form.
2010-02-18 22:15:43 +01:00
Andy Wingo
d69531e213 dynwind is now a part of guile's primitive language
* 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-02-18 22:12:55 +01:00
Andy Wingo
e809758a7e clean up macros.[ch]
There are some incompatible changes here, but only to interfaces that
were introduced earlier in 1.9, or interfaces which have been broken
since early in 1.9.

* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump, as the macro
  changes affect the interface that is called by psyntax-generated macro
  definitions.

* libguile/inline.h (scm_words): New function, allocates a variable
  number of contiguous scm_t_bits locations, with a given value in the
  0th word, and 0 in the rest of the words.

* libguile/macros.h: Rework interface to correspond more closely, and
  minimally, to the needs of memoize.c and psyntax.
  (SCM_ASSYNT, SCM_MACRO_TYPE_BITS, SCM_MACRO_TYPE_MASK)
  (SCM_F_MACRO_EXTENDED, SCM_MACROP, SCM_MACRO_TYPE)
  (SCM_MACRO_IS_EXTENDED, SCM_BUILTIN_MACRO_P, SCM_SYNCASE_MACRO_P)
  (SCM_MACRO_CODE, scm_tc16_macro): Remove CPP macros related to the
  representation of Scheme macros.
  (scm_i_make_primitive_macro): Renamed from scm_i_makbimacro.
  (scm_i_macro_primitive): New accessor so that memoize.c can get to the
  primitive syntax transformer.
  (scm_make_syncase_macro, scm_make_extended_syncase_macro)
  (scm_syncase_macro_type, scm_syncase_macro_binding): Removed these
  functions, replaced by make-syntax-transformer and its accessors.
  (scm_macro_binding): New accessor, the same as what
  scm_syncase_macro_binding was.

* libguile/macros.c: All representation details of syntax transformers
  are private to this file now.
  (macro_print): Print macros as #<syntax-transformer ...>, or
  #<primitive-syntax-transformer ...> if psyntax has not attached a
  transformer of its own.
  (scm_i_make_primitive_macro): Represent macros as 5-word smobs.
  (scm_make_syntax_transformer): New constructor for syntax transformers
  (macros), exported to scheme. Takes a name, and looks it up in the
  current module to determine the previous primitive transformer, if
  any.
  (scm_macro_type): Instead of returning 'builtin-macro!, etc, return
  the type as set by psyntax, or #f if it's a primitive.
  (scm_macro_name): Return the stored macro name.
  (scm_macro_transformer): Return the psyntax-set syntax transformer.
  Hacky, but should help introspection somewhat.

* libguile/memoize.c (memoize_env_ref_transformer): Use the new
  scm_i_macro_primitive, and adapt to other macro API changes.

* module/ice-9/psyntax.scm (put-global-definition-hook)
  (get-global-definition-hook, chi-install-global): Call (and generate
  calls to) the new macro constructors and accessors.

* module/ice-9/psyntax-pp.scm: Doubly regenerated.

* module/ice-9/debugging/traps.scm (trap-here): Comment out this
  definition and export, while it's not working.
2010-01-05 15:33:46 +01:00
Andy Wingo
bab9804661 remove mmacros, SCM_SYNTAX snarf macro
* libguile/snarf.h (SCM_SYNTAX): Remove snarf macro, users can't define
  primitive syntax any more.

* libguile/memoize.c (SCM_SYNTAX): Define locally, and just call
  scm_i_makbimacro as there's no difference between that and
  scm_makmmacro. Alter invocations to suit.

* libguile/macros.h:
* libguile/macros.c (scm_i_makmmacro): Remove; users can't define
  primitive syntax any more. Use define-syntax instead.
  (scm_make_synt): Remove, this was only used by the SCM_SYNTAX snarf
  macro.
  (scm_i_makbimacro): Change prototype of this internal function to make
  the gsubr on behalf of the caller.
  (macro_print, scm_macro_type): Remove cases for mmacros.
2010-01-05 11:47:16 +01:00
Ludovic Courtès
bc4adf1739 Remove unneeded #include <assert.h>.
* libguile/backtrace.c, libguile/eval.c, libguile/gc.c,
  libguile/goops.c, libguile/memoize.c, libguile/threads.c,
  libguile/uniform.c, libguile/vm.c,
  test-suite/standalone/test-conversion.c,
  test-suite/standalone/test-list.c: Don't include <assert.h>.
2009-12-15 20:20:38 +01:00
Andy Wingo
9331f91cc4 primitive-eval passes first N args on stack directly, not via apply
* libguile/memoize.c (MAKMEMO_CALL): Memoize in the number of arguments
  at the call site.
  (memoize, scm_m_cond, memoize_named_let, unmemoize):
* libguile/eval.c (eval): Adapt to changes in call memoization.

* module/ice-9/eval.scm (primitive-eval): For calls, pass the first N
  arguments directly on the stack, and only the rest as a consed
  argument list to apply. Currently N is 4.
2009-12-13 17:19:59 +01:00
Andy Wingo
7230aaf961 fix FUNC_NAME of scm_memoize_variable_access_x
* libguile/memoize.c (scm_memoize_variable_access_x): Fix FUNC_NAME
  definition.
2009-12-09 10:07:04 +01:00
Andy Wingo
66e78727d6 add scm_c_make_struct[v]
* libguile/struct.h (scm_c_make_struct, scm_c_make_structv): New
  functions with which you can make a struct without consing a rest
  list.

* libguile/struct.c (scm_struct_init): Refactor to take an array of init
  values, not a list.
  (scm_make_struct, scm_make_vtable_vtable): Pull the rest arg out into
  a list and pass it down to the new array-taking functions.

* libguile/memoize.c: Remove a neeless #include <alloca>.
2009-12-07 11:21:59 +01:00
Andy Wingo
df338a2264 remove tc7_subr_* and tc7_lsubr_*
* libguile/tags.h: Remove tc7 #defines for subrs, replacing them with
  placeholders. These were public, but hopfully unused. I don't see how
  to usefully deprecate them.

* libguile/array-map.c (scm_array_map_x): Remove special cases for
  certain subr types. This might make things slower for the moment,
  otoh, native compilation should moot that question.

* libguile/eval.i.c:
* libguile/eval.c: Remove subr-handling cases. To regain this speed and
  more won't have to wait for native compilation, though -- this change
  smooths the way for subr dispatch in the VM.

* libguile/gsubr.c (scm_i_gsubr_apply): Fix a bug in which we didn't
  detect too-many-arguments. This would only show up when using ceval,
  as only ceval called this function.

* test-suite/tests/ramap.test ("array-map!"): Change the expected
  exception if passed a procedure of the wrong arity. It now gives
  wrong-num-args.
  more won't have to wait for native compilation, though -- this change
  smooths the way for subr dispatch in the VM.

* libguile/goops.c (scm_class_of): Remove subr cases. No speed
  implication.

* libguile/objects.c (scm_valid_object_procedure_p): Remove this public
  but undocumented, and useless, function. I do not think this will
  affect anyone at all.
  (scm_set_object_procedure_x): Replace a call to
  scm_valid_object_procedure_p with scm_procedure_p, and actually wrap
  with a scm_is_true.

* module/oop/goops.scm (initialize-object-procedure): Don't call
  valid-object-procedure?.
2009-12-03 15:22:07 +01:00
Andy Wingo
3149a5b60d add memoized expression accessors to scheme
* libguile/eval.c: Fix a comment.
  (eval): Abstract out the variable memoization into a function,
  scm_memoize_variable_access_x.

* libguile/memoize.c (memoized_tags): Fix a couple names.
  (scm_memoize_variable_access_x): New internal function. Actually it's
  public to Scheme, but we can't do much about that, because the new
  evaluator will need it.
  (scm_memoized_expression_typecode, scm_memoized_expression_data): New
  accessors for memoized code, for Scheme.
  (scm_memoized_typecode): Looks up the typecode for a symbol.
2009-12-01 21:00:27 +01:00
Andy Wingo
b7742c6b71 new evaluator, y'all
* libguile/eval.c: So, ladies & gents, a new evaluator. It's similar to
  the old one, in that we memoize and then evaluate, but in this
  incarnation, memoization of an expression happens before evaluation,
  not lazily as the expression is evaluated. This makes the evaluation
  itself much cleaner, in addition to being threadsafe. In addition,
  since this C evaluator will in the future just serve to bootstrap the
  Scheme evaluator, we don't have to pay much concern for debugging
  conveniences. So the environment is just a list of values, and the
  memoizer pre-computes where it's going to find each individual value
  in the environment.

  Interface changes are commented below, with eval.h.

  (scm_evaluator_traps): No need to reset the debug mode after rnning te
  traps thing. But really, the whole traps system needs some love.

* libguile/memoize.h:
* libguile/memoize.c: New memoizer, which runs before evaluation,
  checking all syntax before evaluation begins. Significantly, no
  debugging information is left for lexical variables, which is not so
  great for interactive debugging; perhaps we should change this to have
  a var list in the future as per the classic interpreters. But it's
  quite fast, and the resulting code is quite good. Also note that it
  doesn't produce ilocs, memoized code is a smob whose type is in the
  first word of the smob itself.

* libguile/eval.h (scm_sym_and, scm_sym_begin, scm_sym_case)
  (scm_sym_cond, scm_sym_define, scm_sym_do, scm_sym_if, scm_sym_lambda)
  (scm_sym_let, scm_sym_letstar, scm_sym_letrec, scm_sym_quote)
  (scm_sym_quasiquote, scm_sym_unquote, scm_sym_uq_splicing, scm_sym_at)
  (scm_sym_atat, scm_sym_atapply, scm_sym_atcall_cc)
  (scm_sym_at_call_with_values, scm_sym_delay, scm_sym_eval_when)
  (scm_sym_arrow, scm_sym_else, scm_sym_apply, scm_sym_set_x)
  (scm_sym_args): Remove public declaration of these symbols.
  (scm_ilookup, scm_lookupcar, scm_eval_car, scm_eval_body)
  (scm_eval_args, scm_i_eval_x, scm_i_eval): Remove public declaration
  of these functions.
  (scm_ceval, scm_deval, scm_ceval_ptr): Remove declarations of these
  deprecated functions.
  (scm_i_print_iloc, scm_i_print_isym, scm_i_unmemocopy_expr)
  (scm_i_unmemocopy_body): Remove declarations of these internal
  functions.
  (scm_primitive_eval_x, scm_eval_x): Redefine as macros for their less
  destructive siblings.

* libguile/Makefile.am: Add memoize.[ch] to the build.

* libguile/debug.h (scm_debug_mode_p, scm_check_entry_p)
  (scm_check_apply_p, scm_check_exit_p, scm_check_memoize_p)
  (scm_debug_eframe_size): Remove these vars that were tied to the old
  evaluator's execution model.
  (SCM_RESET_DEBUG_MODE): Remove, no more need for this.
  (SCM_MEMOIZEDP, SCM_MEMOIZED_EXP, SCM_MEMOIZED_ENV): Remove macros
  referring to old memoized code representation.
  (scm_local_eval, scm_procedure_environment, scm_memoized_environment)
  (scm_make_memoized, scm_memoized_p): Remove functions operating on old
  memoized code representation.
  (scm_memcons, scm_mem_to_proc, scm_proc_to_mem): Remove debug-only
  code for old evaluator.

* libguile/debug.c: Remove code to correspond with debug.h removals.
  (scm_debug_options): No need to set the debug mode or frame limit
  here, as we don't have C stack limits any more. Perhaps this is a bug,
  but as long as we can compile eval.scm, we should be fine.

* libguile/init.c (scm_i_init_guile): Init memoize.c.

* libguile/modules.c (scm_top_level_env, scm_env_top_level)
  (scm_env_module, scm_system_module_env_p): Remove these functions.

* libguile/print.c (iprin1): No more need to handle isyms. Adapt to new
  form of interpreted procedures.

* libguile/procprop.c (scm_i_procedure_arity): Adapt to new form of
  interpreted procedures.

* libguile/procs.c (scm_thunk_p): Adapt to new form of interpreted
  procedures.
* libguile/procs.h (SCM_CLOSURE_FORMALS): Removed, this exists no more.
  (SCM_CLOSURE_NUM_REQUIRED_ARGS, SCM_CLOSURE_HAS_REST_ARGS): New
  accessors.

* libguile/srcprop.c (scm_source_properties, scm_source_property)
  (scm_set_source_property_x): Remove special cases for memoized code.

* libguile/stacks.c (read_frame): Remove a source-property case for
  interpreted code.
  (NEXT_FRAME): Remove a case that I don't fully understand, that seems
  to be designed to skip over apply frames. Will be obsolete in the
  futures.
  (read_frames): Default source value for interpreted frames to #f.
  (narrow_stack): Don't pay attention to the system_module thing.

* libguile/tags.h: Remove isyms and ilocs. Whee!

* libguile/validate.h (SCM_VALIDATE_MEMOIZED): Fix to use the new
  MEMOIZED_P formulation.

* module/ice-9/psyntax-pp.scm (do, quasiquote, case): Adapt for these no
  longer being primitive macros.
* module/ice-9/boot-9.scm: Whitespace change, but just a poke to force a
  rebuild due to and/or/cond/... not being primitives any more.

* module/ice-9/deprecated.scm (unmemoize-expr): Deprecate, it's
  unmemoize-expression now.

* test-suite/tests/eval.test ("define set procedure-name"): XFAIL a
  couple of tests here; I don't know what to do about them. I reckon the
  expander should ensure that defined values are named.

* test-suite/tests/chars.test ("basic char handling"): Fix expected
  exception when trying to apply a char.
2009-12-01 21:00:26 +01:00