1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-01 04:10:18 +02:00

* eval.c (SCM_CEVAL): Cleaned up the handling of 'if', 'let',

'letrec' and 'set*': Removed some uses of t.arg1, t.lloc and proc
as temporary variables.  Removed side-effecting operations from
conditions and macro calls.  Introduced temporary variables with
hopefully descriptive names for clarification.  Replaced SCM_N?IMP
by a more explicit predicate in some places.  Removed code that
was conditionally compiled if SICP was defined - which it never
is.
This commit is contained in:
Dirk Herrmann 2002-03-02 12:47:45 +00:00
parent e5cb71a0a9
commit 38ace99eb3
2 changed files with 68 additions and 50 deletions

View file

@ -1,3 +1,14 @@
2002-03-02 Dirk Herrmann <D.Herrmann@tu-bs.de>
* eval.c (SCM_CEVAL): Cleaned up the handling of 'if', 'let',
'letrec' and 'set*': Removed some uses of t.arg1, t.lloc and proc
as temporary variables. Removed side-effecting operations from
conditions and macro calls. Introduced temporary variables with
hopefully descriptive names for clarification. Replaced SCM_N?IMP
by a more explicit predicate in some places. Removed code that
was conditionally compiled if SICP was defined - which it never
is.
2002-03-02 Dirk Herrmann <D.Herrmann@tu-bs.de>
* eval.c (SCM_CEVAL): Cleaned up the handling of 'cons' and 'do':

View file

@ -2003,8 +2003,8 @@ dispatch:
x = SCM_CDR (x);
while (!SCM_NULLP (SCM_CDR (x)))
{
SCM condition = EVALCAR (x, env);
if (SCM_FALSEP (condition) || SCM_NILP (condition))
SCM test_result = EVALCAR (x, env);
if (SCM_FALSEP (test_result) || SCM_NILP (test_result))
RETURN (SCM_BOOL_F);
else
x = SCM_CDR (x);
@ -2231,24 +2231,34 @@ dispatch:
case SCM_BIT8 (SCM_IM_IF):
x = SCM_CDR (x);
if (!SCM_FALSEP (t.arg1 = EVALCAR (x, env)) && !SCM_NILP (t.arg1))
{
SCM test_result = EVALCAR (x, env);
if (!SCM_FALSEP (test_result) && !SCM_NILP (test_result))
x = SCM_CDR (x);
else if (SCM_IMP (x = SCM_CDDR (x)))
else
{
x = SCM_CDDR (x);
if (SCM_NULLP (x))
RETURN (SCM_UNSPECIFIED);
}
}
PREP_APPLY (SCM_UNDEFINED, SCM_EOL);
goto carloop;
case SCM_BIT8 (SCM_IM_LET):
x = SCM_CDR (x);
proc = SCM_CADR (x);
t.arg1 = SCM_EOL;
{
SCM init_forms = SCM_CADR (x);
SCM init_values = SCM_EOL;
do
{
t.arg1 = scm_cons (EVALCAR (proc, env), t.arg1);
init_values = scm_cons (EVALCAR (init_forms, env), init_values);
init_forms = SCM_CDR (init_forms);
}
while (!SCM_NULLP (init_forms));
env = EXTEND_ENV (SCM_CAR (x), init_values, env);
}
while (SCM_NIMP (proc = SCM_CDR (proc)));
env = EXTEND_ENV (SCM_CAR (x), t.arg1, env);
x = SCM_CDR (x);
goto nontoplevel_cdrxnoap;
@ -2257,14 +2267,17 @@ dispatch:
x = SCM_CDR (x);
env = EXTEND_ENV (SCM_CAR (x), scm_undefineds, env);
x = SCM_CDR (x);
proc = SCM_CAR (x);
t.arg1 = SCM_EOL;
{
SCM init_forms = SCM_CAR (x);
SCM init_values = SCM_EOL;
do
{
t.arg1 = scm_cons (EVALCAR (proc, env), t.arg1);
init_values = scm_cons (EVALCAR (init_forms, env), init_values);
init_forms = SCM_CDR (init_forms);
}
while (!SCM_NULLP (init_forms));
SCM_SETCDR (SCM_CAR (env), init_values);
}
while (SCM_NIMP (proc = SCM_CDR (proc)));
SCM_SETCDR (SCM_CAR (env), t.arg1);
goto nontoplevel_cdrxnoap;
@ -2313,33 +2326,27 @@ dispatch:
case SCM_BIT8 (SCM_IM_SET_X):
x = SCM_CDR (x);
proc = SCM_CAR (x);
switch (SCM_ITAG3 (proc))
{
case scm_tc3_cons:
if (SCM_VARIABLEP (proc))
t.lloc = SCM_VARIABLE_LOC (proc);
else
t.lloc = scm_lookupcar (x, env, 1);
break;
SCM *location;
SCM variable = SCM_CAR (x);
if (SCM_VARIABLEP (variable))
location = SCM_VARIABLE_LOC (variable);
#ifdef MEMOIZE_LOCALS
case scm_tc3_imm24:
t.lloc = scm_ilookup (proc, env);
break;
else if (SCM_ILOCP (variable))
location = scm_ilookup (variable, env);
#endif
}
else /* (SCM_SYMBOLP (variable)) is known to be true */
location = scm_lookupcar (x, env, 1);
x = SCM_CDR (x);
*t.lloc = EVALCAR (x, env);
#ifdef SICP
RETURN (*t.lloc);
#else
*location = EVALCAR (x, env);
}
RETURN (SCM_UNSPECIFIED);
#endif
case SCM_BIT8(SCM_IM_DEFINE): /* only for internal defines */
scm_misc_error (NULL, "Bad define placement", SCM_EOL);
/* new syntactic forms go here. */
case SCM_BIT8(SCM_MAKISYM (0)):
proc = SCM_CAR (x);