From 08e462e7a12530c2c7bb8036be05d79d1dfe9456 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Fri, 27 Jun 2008 16:13:38 +0200 Subject: Add class MLKRoot. --- MLKInterpreter.m | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'MLKInterpreter.m') diff --git a/MLKInterpreter.m b/MLKInterpreter.m index 49db342..35ea2ad 100644 --- a/MLKInterpreter.m +++ b/MLKInterpreter.m @@ -25,6 +25,7 @@ #import "MLKLexicalContext.h" #import "MLKLexicalEnvironment.h" #import "MLKPackage.h" +#import "MLKRoot.h" #import "MLKSymbol.h" #import "runtime-compatibility.h" @@ -376,10 +377,33 @@ static MLKSymbol *_LAMBDA; } else { - [NSException raise:@"MLKNoSuchOperatorException" - format:@"%@ does not name a known operator.", - [car descriptionForLisp]]; - return nil; + NSMutableArray *args = [NSMutableArray array]; + MLKCons *rest = [program cdr]; + NSArray *results; + + while (rest) + { + id result = [[self eval:[rest car] + inLexicalContext:context + withEnvironment:lexenv] + objectAtIndex:0]; + [args addObject:result]; + rest = [rest cdr]; + } + + results = [MLKRoot dispatch:car withArguments:args]; + + if (results) + { + return results; + } + else + { + [NSException raise:@"MLKNoSuchOperatorException" + format:@"%@ does not name a known operator.", + [car descriptionForLisp]]; + return nil; + } } } } -- cgit v1.2.3