From e97d47a664131b5c80f35265f33e82eefb04f1d0 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Tue, 1 Jul 2008 17:40:34 +0200 Subject: Implement a raw version of LOAD. --- MLKInterpreter.m | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'MLKInterpreter.m') diff --git a/MLKInterpreter.m b/MLKInterpreter.m index 2f9aba3..cf12d6d 100644 --- a/MLKInterpreter.m +++ b/MLKInterpreter.m @@ -25,6 +25,7 @@ #import "MLKLexicalContext.h" #import "MLKLexicalEnvironment.h" #import "MLKPackage.h" +#import "MLKReader.h" #import "MLKRoot.h" #import "MLKSymbol.h" #import "runtime-compatibility.h" @@ -423,4 +424,41 @@ static MLKSymbol *_LAMBDA; } } } + + ++(BOOL) load:(MLKStream *)stream verbose:(BOOL)verbose print:(BOOL)print +{ + id eofValue = [[NSObject alloc] init]; + + while (YES) + { + id result; + id code = [MLKReader readFromStream:stream + eofError:NO + eofValue:eofValue + recursive:NO + preserveWhitespace:NO]; + + //NSLog (@"%@", code); + //NSLog (@"%@", stream); + //NSLog (@"..."); + + if (code == eofValue) + break; + + NSLog (@"; LOAD: Evaluating a top-level form."); + result = [MLKInterpreter + eval:code + inLexicalContext:[MLKLexicalContext globalContext] + withEnvironment:[MLKLexicalEnvironment globalEnvironment]]; + + if (print) + { + //FIXME + NSLog (@"; LOAD: Fnord. Primary value: %@", result); + } + } + + return YES; +} @end -- cgit v1.2.3