diff options
author | Matthias Andreas Benkard <matthias@benkard.de> | 2008-06-27 14:42:33 +0200 |
---|---|---|
committer | Matthias Andreas Benkard <matthias@benkard.de> | 2008-06-27 14:42:33 +0200 |
commit | 189d02b12aa33fc18eaff9558675d9fa9d6ba668 (patch) | |
tree | bbaa136bcb5961452e89f103fa907cff65a9863e | |
parent | cb23a76bbd3b7b1ccf4a5ec8894437e449a9047d (diff) |
MLKInterpreter: Fix APPLY and %LAMBDA.
-rw-r--r-- | MLKInterpretedClosure.h | 8 | ||||
-rw-r--r-- | MLKInterpretedClosure.m | 21 | ||||
-rw-r--r-- | MLKInterpreter.m | 14 |
3 files changed, 29 insertions, 14 deletions
diff --git a/MLKInterpretedClosure.h b/MLKInterpretedClosure.h index 5d1ac25..942a9b8 100644 --- a/MLKInterpretedClosure.h +++ b/MLKInterpretedClosure.h @@ -33,10 +33,10 @@ MLKLexicalEnvironment *environment; } --(id) initWithBodyForm:(id)form - lambdaListName:(MLKSymbol *)symbol - context:(MLKLexicalContext *)lexctx - environment:(MLKLexicalEnvironment *)lexenv; +-(id) initWithBodyForms:(id)forms + lambdaListName:(MLKSymbol *)symbol + context:(MLKLexicalContext *)lexctx + environment:(MLKLexicalEnvironment *)lexenv; -(NSArray *) applyToArray:(NSArray *)arguments; diff --git a/MLKInterpretedClosure.m b/MLKInterpretedClosure.m index 48f1805..edf7e17 100644 --- a/MLKInterpretedClosure.m +++ b/MLKInterpretedClosure.m @@ -19,20 +19,31 @@ #import "MLKCons.h" #import "MLKInterpretedClosure.h" #import "MLKInterpreter.h" +#import "MLKPackage.h" #import "runtime-compatibility.h" #import <Foundation/NSDictionary.h> #import <Foundation/NSSet.h> +static MLKSymbol *PROGN; + + @implementation MLKInterpretedClosure --(id) initWithBodyForm:(id)form - lambdaListName:(MLKSymbol *)symbol - context:(MLKLexicalContext *)lexctx - environment:(MLKLexicalEnvironment *)lexenv ++(void) initialize +{ + MLKPackage *cl; + cl = [MLKPackage findPackage:@"COMMON-LISP"]; + PROGN = [cl intern:@"PROGN"]; +} + +-(id) initWithBodyForms:(id)forms + lambdaListName:(MLKSymbol *)symbol + context:(MLKLexicalContext *)lexctx + environment:(MLKLexicalEnvironment *)lexenv { self = [super init]; - ASSIGN (bodyForm, form); + ASSIGN (bodyForm, [MLKCons cons:PROGN with:forms]); ASSIGN (context, lexctx); ASSIGN (environment, lexenv); ASSIGN (lambdaListName, symbol); diff --git a/MLKInterpreter.m b/MLKInterpreter.m index 01a915f..7fc14d7 100644 --- a/MLKInterpreter.m +++ b/MLKInterpreter.m @@ -127,9 +127,13 @@ static MLKSymbol *_LAMBDA; inLexicalContext:context withEnvironment:lexenv]; - return [[[program cdr] car] applyToArray:(rest - ? (id)[rest array] - : (id)[NSArray array])]; + id <MLKFuncallable> function = [self eval:[[program cdr] car] + inLexicalContext:context + withEnvironment:lexenv]; + + return [function applyToArray:(rest + ? (id)[rest array] + : (id)[NSArray array])]; } else if (car == _DEFMACRO) { @@ -163,11 +167,11 @@ static MLKSymbol *_LAMBDA; // would be a lambda list in a real LAMBDA form must be a // symbol here. id lambdaList = [[program cdr] car]; - id body = [[[program cdr] cdr] cdr]; + id body = [[program cdr] cdr]; MLKInterpretedClosure *closure; closure = AUTORELEASE ([[MLKInterpretedClosure alloc] - initWithBodyForm:body + initWithBodyForms:body lambdaListName:lambdaList context:context environment:lexenv]); |