apply сада појединачно копира и брише изразе процедуре, уместо целог тела
This commit is contained in:
parent
ff4e73a624
commit
35cd4b13cf
|
@ -172,5 +172,5 @@ int main(int argc, char **argv)
|
|||
;
|
||||
printf("\nДостигнут крај улазног тока.\nЗбогом и дођите нам опет!\n");
|
||||
|
||||
return 0;
|
||||
exitCirilisp(0);
|
||||
}
|
||||
|
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
21
eval.c
21
eval.c
|
@ -172,31 +172,30 @@ object apply(object procedure, object parameters, env currentEnv)
|
|||
--currentRecursionDepth;
|
||||
SIGERR(maxRecursionDepthError);
|
||||
}
|
||||
object args = copyObject(PROC_COMP_ARGS(procedure));
|
||||
object body = copyObject(PROC_COMP_BODY(procedure));
|
||||
|
||||
object args = PROC_COMP_ARGS(procedure);
|
||||
env definitionEnv = PROC_COMP_ENV(procedure);
|
||||
|
||||
env procEnv = createEnvironment(definitionEnv);
|
||||
if (!bindArgs(parameters, args, procEnv))
|
||||
{
|
||||
deleteObject(args);
|
||||
deleteObject(body);
|
||||
removeEnvironment(procEnv);
|
||||
SIGERR(argumentNumberError);
|
||||
}
|
||||
|
||||
object *currentSubProc = &body;
|
||||
while (TYPE(*currentSubProc) != nilObject)
|
||||
object *currentExprPointer = &PROC_COMP_BODY(procedure);
|
||||
while (TYPE(*currentExprPointer) != nilObject)
|
||||
{
|
||||
CAR(*currentSubProc) = Eval(CAR(*currentSubProc), procEnv);
|
||||
if (TYPE(CDR(*currentSubProc)) == nilObject)
|
||||
object currentExpr = copyObject(CAR(*currentExprPointer));
|
||||
currentExpr = Eval(currentExpr, procEnv);
|
||||
if (TYPE(CDR(*currentExprPointer)) == nilObject)
|
||||
{
|
||||
result = copyObject(CAR(*currentSubProc));
|
||||
result = copyObject(currentExpr);
|
||||
}
|
||||
currentSubProc = &CDR(*currentSubProc);
|
||||
currentExprPointer = &CDR(*currentExprPointer);
|
||||
deleteObject(currentExpr);
|
||||
}
|
||||
deleteObject(args);
|
||||
deleteObject(body);
|
||||
removeEnvironment(procEnv);
|
||||
--currentRecursionDepth;
|
||||
|
||||
|
|
Loading…
Reference in a new issue