1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-20 02:30:23 +02:00

really boot primitive-eval from scheme.

* libguile/eval.c (scm_primitive_eval, scm_c_primitive_eval):
  (scm_init_eval): Rework so that scm_primitive_eval always calls out to
  the primitive-eval variable. The previous definition is the default
  value, which is probably overridden by scm_init_eval_in_scheme.

* libguile/init.c (scm_i_init_guile): Move ports and load-path up, so we
  can debug when initing eval. Call scm_init_eval_in_scheme. Awesome.

* libguile/load.h:
* libguile/load.c (scm_init_eval_in_scheme): New procedure, loads up
  ice-9/eval.scm to replace the primitive-eval definition, if everything
  is there and up-to-date.

* libguile/modules.c (scm_module_transformer): Export to Scheme, so it's
  there for eval.go.

* module/ice-9/boot-9.scm: No need to define module-transformer.

* module/ice-9/eval.scm (capture-env): Only reference the-root-module if
  modules are booted.
  (primitive-eval): Inline a definition for identity. Throw a more
  standard error for "wrong number of arguments".

* module/ice-9/psyntax.scm (chi-install-global): The macro binding for a
  syncase macro is now a pair: the transformer, and the module that was
  current when the transformer was installed. The latter is used for
  hygiene purposes, replacing the use of procedure-module, which didn't
  work with the interpreter's shared-code closures.
  (chi-macro): Adapt for the binding being a pair, and get the hygiene
  from the cdr.
  (eval-local-transformer): Adapt to new form of macro bindings.

* module/ice-9/psyntax-pp.scm: Regenerated.

* .gitignore: Ignore eval.go.stamp.

* module/Makefile.am: Reorder for fastest serial compilation, now that
  there are no ordering constraints. I did a number of experiments here
  and this seems to be the best; but the bulk of the time is compiling
  psyntax-pp.scm with eval.scm. Not so great.

* libguile/vm-engine.c (vm-engine): Throw a more standard error for
  "wrong type to apply".

* test-suite/tests/gc.test ("gc"): Remove a hack that shouldn't affect
  the new evaluator, and throw in another (gc) for good measure.

* test-suite/tests/goops.test ("defining classes"):
* test-suite/tests/hooks.test (proc1): We can't currently check what the
  arity is of a closure made by eval.scm -- or more accurately all
  closures have 0 required args and no rest args. So punt for now.

* test-suite/tests/syntax.test ("letrec"): The scheme evaluator can't
  check that a variable is unbound, currently; perhaps the full "fixing
  letrec" expansion could fix this. But barring that, punt.
This commit is contained in:
Andy Wingo 2009-12-01 23:54:25 +01:00
parent 67e2d80a6a
commit 5f1611640a
16 changed files with 7422 additions and 7126 deletions

View file

@ -848,11 +848,8 @@ scm_closure (SCM code, SCM env)
}
SCM_DEFINE (scm_primitive_eval, "primitive-eval", 1, 0, 0,
(SCM exp),
"Evaluate @var{exp} in the top-level environment specified by\n"
"the current module.")
#define FUNC_NAME s_scm_primitive_eval
static SCM
scm_c_primitive_eval (SCM exp)
{
SCM transformer = scm_current_module_transformer ();
if (scm_is_true (transformer))
@ -860,7 +857,14 @@ SCM_DEFINE (scm_primitive_eval, "primitive-eval", 1, 0, 0,
exp = scm_memoize_expression (exp);
return eval (exp, SCM_EOL);
}
#undef FUNC_NAME
static SCM var_primitive_eval;
SCM
scm_primitive_eval (SCM exp)
{
return scm_c_vm_run (scm_the_vm (), scm_variable_ref (var_primitive_eval),
&exp, 1);
}
/* Eval does not take the second arg optionally. This is intentional
@ -928,6 +932,8 @@ scm_apply (SCM proc, SCM arg1, SCM args)
void
scm_init_eval ()
{
SCM primitive_eval;
scm_init_opts (scm_evaluator_traps,
scm_evaluator_trap_table);
scm_init_opts (scm_eval_options_interface,
@ -938,6 +944,11 @@ scm_init_eval ()
f_apply = scm_c_define_subr ("apply", scm_tc7_lsubr_2, scm_apply);
scm_permanent_object (f_apply);
primitive_eval = scm_c_make_gsubr ("primitive-eval", 1, 0, 0,
scm_c_primitive_eval);
var_primitive_eval = scm_define (SCM_SUBR_NAME (primitive_eval),
primitive_eval);
#include "libguile/eval.x"
}

View file

@ -551,15 +551,16 @@ scm_i_init_guile (SCM_STACKITEM *base)
scm_init_weaks ();
scm_init_guardians ();
scm_init_vports ();
scm_init_standard_ports (); /* Requires fports */
scm_bootstrap_vm ();
scm_init_memoize ();
scm_init_eval ();
scm_init_load_path ();
scm_init_eval_in_scheme ();
scm_init_evalext ();
scm_init_debug (); /* Requires macro smobs */
scm_init_random ();
scm_init_simpos ();
scm_init_load_path ();
scm_init_standard_ports (); /* Requires fports */
scm_init_dynamic_linking ();
scm_bootstrap_i18n ();
#if SCM_ENABLE_ELISP

View file

@ -837,6 +837,22 @@ scm_c_primitive_load_path (const char *filename)
return scm_primitive_load_path (scm_from_locale_string (filename));
}
void
scm_init_eval_in_scheme (void)
{
SCM eval_scm, eval_go;
eval_scm = scm_search_path (*scm_loc_load_path,
scm_from_locale_string ("ice-9/eval.scm"),
SCM_EOL);
eval_go = scm_search_path (*scm_loc_load_compiled_path,
scm_from_locale_string ("ice-9/eval.go"),
SCM_EOL);
if (scm_is_true (eval_scm) && scm_is_true (eval_go)
&& compiled_is_fresh (eval_scm, eval_go))
scm_load_compiled_with_vm (eval_go);
}
/* Information about the build environment. */

View file

@ -39,6 +39,7 @@ SCM_API SCM scm_c_primitive_load_path (const char *filename);
SCM_INTERNAL SCM scm_sys_warn_autocompilation_enabled (void);
SCM_INTERNAL void scm_init_load_path (void);
SCM_INTERNAL void scm_init_load (void);
SCM_INTERNAL void scm_init_eval_in_scheme (void);
#endif /* SCM_LOAD_H */

View file

@ -561,8 +561,10 @@ scm_current_module_lookup_closure ()
SCM_SYMBOL (sym_sys_pre_modules_transformer, "%pre-modules-transformer");
SCM
scm_module_transformer (SCM module)
SCM_DEFINE (scm_module_transformer, "module-transformer", 1, 0, 0,
(SCM module),
"Returns the syntax expander for the given module.")
#define FUNC_NAME s_scm_module_transformer
{
if (SCM_UNLIKELY (scm_is_false (module)))
{ SCM v = scm_hashq_ref (scm_pre_modules_obarray,
@ -574,8 +576,12 @@ scm_module_transformer (SCM module)
return SCM_VARIABLE_REF (v);
}
else
return SCM_MODULE_TRANSFORMER (module);
{
SCM_VALIDATE_MODULE (SCM_ARG1, module);
return SCM_MODULE_TRANSFORMER (module);
}
}
#undef FUNC_NAME
SCM
scm_current_module_transformer ()

View file

@ -199,8 +199,8 @@ VM_NAME (struct scm_vm *vp, SCM program, SCM *argv, int nargs)
vm_error_wrong_type_apply:
SYNC_ALL ();
scm_error (scm_misc_error_key, FUNC_NAME, "Wrong type to apply: ~S",
scm_list_1 (program), SCM_BOOL_F);
scm_error (scm_arg_type_key, FUNC_NAME, "Wrong type to apply: ~S",
scm_list_1 (program), scm_list_1 (program));
goto vm_error;
vm_error_stack_overflow: