mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-21 20:20:24 +02:00
* eval.c (scm_ilookup): Rewritten to improve readability.
This commit is contained in:
parent
6a3f13f070
commit
12841895dc
2 changed files with 27 additions and 9 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
2003-04-27 Dirk Herrmann <D.Herrmann@tu-bs.de>
|
||||||
|
|
||||||
|
* eval.c (scm_ilookup): Rewritten to improve readability.
|
||||||
|
|
||||||
2003-04-27 Dirk Herrmann <D.Herrmann@tu-bs.de>
|
2003-04-27 Dirk Herrmann <D.Herrmann@tu-bs.de>
|
||||||
|
|
||||||
* eval.c (scm_i_call_closure_0, call_closure_1, call_closure_2):
|
* eval.c (scm_i_call_closure_0, call_closure_1, call_closure_2):
|
||||||
|
|
|
@ -132,21 +132,35 @@ char *alloca ();
|
||||||
|
|
||||||
SCM_REC_MUTEX (source_mutex);
|
SCM_REC_MUTEX (source_mutex);
|
||||||
|
|
||||||
|
|
||||||
|
/* Lookup a given local variable in an environment. The local variable is
|
||||||
|
* given as an iloc, that is a triple <frame, binding, last?>, where frame
|
||||||
|
* indicates the relative number of the environment frame (counting upwards
|
||||||
|
* from the innermost environment frame), binding indicates the number of the
|
||||||
|
* binding within the frame, and last? (which is extracted from the iloc using
|
||||||
|
* the macro SCM_ICDRP) indicates whether the binding forms the binding at the
|
||||||
|
* very end of the improper list of bindings. */
|
||||||
SCM *
|
SCM *
|
||||||
scm_ilookup (SCM iloc, SCM env)
|
scm_ilookup (SCM iloc, SCM env)
|
||||||
{
|
{
|
||||||
register long ir = SCM_IFRAME (iloc);
|
unsigned int frame_nr = SCM_IFRAME (iloc);
|
||||||
register SCM er = env;
|
unsigned int binding_nr = SCM_IDIST (iloc);
|
||||||
for (; 0 != ir; --ir)
|
SCM frames = env;
|
||||||
er = SCM_CDR (er);
|
SCM bindings;
|
||||||
er = SCM_CAR (er);
|
|
||||||
for (ir = SCM_IDIST (iloc); 0 != ir; --ir)
|
for (; 0 != frame_nr; --frame_nr)
|
||||||
er = SCM_CDR (er);
|
frames = SCM_CDR (frames);
|
||||||
|
|
||||||
|
bindings = SCM_CAR (frames);
|
||||||
|
for (; 0 != binding_nr; --binding_nr)
|
||||||
|
bindings = SCM_CDR (bindings);
|
||||||
|
|
||||||
if (SCM_ICDRP (iloc))
|
if (SCM_ICDRP (iloc))
|
||||||
return SCM_CDRLOC (er);
|
return SCM_CDRLOC (bindings);
|
||||||
return SCM_CARLOC (SCM_CDR (er));
|
return SCM_CARLOC (SCM_CDR (bindings));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* The Lookup Car Race
|
/* The Lookup Car Race
|
||||||
- by Eva Luator
|
- by Eva Luator
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue