132 |
|
|
133 |
SCM_REC_MUTEX (source_mutex); |
SCM_REC_MUTEX (source_mutex); |
134 |
|
|
135 |
|
|
136 |
|
/* Lookup a given local variable in an environment. The local variable is |
137 |
|
* given as an iloc, that is a triple <frame, binding, last?>, where frame |
138 |
|
* indicates the relative number of the environment frame (counting upwards |
139 |
|
* from the innermost environment frame), binding indicates the number of the |
140 |
|
* binding within the frame, and last? (which is extracted from the iloc using |
141 |
|
* the macro SCM_ICDRP) indicates whether the binding forms the binding at the |
142 |
|
* very end of the improper list of bindings. */ |
143 |
SCM * |
SCM * |
144 |
scm_ilookup (SCM iloc, SCM env) |
scm_ilookup (SCM iloc, SCM env) |
145 |
{ |
{ |
146 |
register long ir = SCM_IFRAME (iloc); |
unsigned int frame_nr = SCM_IFRAME (iloc); |
147 |
register SCM er = env; |
unsigned int binding_nr = SCM_IDIST (iloc); |
148 |
for (; 0 != ir; --ir) |
SCM frames = env; |
149 |
er = SCM_CDR (er); |
SCM bindings; |
150 |
er = SCM_CAR (er); |
|
151 |
for (ir = SCM_IDIST (iloc); 0 != ir; --ir) |
for (; 0 != frame_nr; --frame_nr) |
152 |
er = SCM_CDR (er); |
frames = SCM_CDR (frames); |
153 |
|
|
154 |
|
bindings = SCM_CAR (frames); |
155 |
|
for (; 0 != binding_nr; --binding_nr) |
156 |
|
bindings = SCM_CDR (bindings); |
157 |
|
|
158 |
if (SCM_ICDRP (iloc)) |
if (SCM_ICDRP (iloc)) |
159 |
return SCM_CDRLOC (er); |
return SCM_CDRLOC (bindings); |
160 |
return SCM_CARLOC (SCM_CDR (er)); |
return SCM_CARLOC (SCM_CDR (bindings)); |
161 |
} |
} |
162 |
|
|
163 |
|
|
164 |
/* The Lookup Car Race |
/* The Lookup Car Race |
165 |
- by Eva Luator |
- by Eva Luator |
166 |
|
|