summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <matthias@benkard.de>2008-08-03 19:37:58 +0200
committerMatthias Andreas Benkard <matthias@benkard.de>2008-08-03 19:37:58 +0200
commite47e8f93ea74559384ba77f0bd7da71fee95eb01 (patch)
treee9f5f09596370e19ca5887d3d367d592e4f2a793
parenta12f1024e24ac9962b6eb364d27590f7ab37c18d (diff)
Add PROGV.
-rw-r--r--MLKInterpreter.m64
1 files changed, 64 insertions, 0 deletions
diff --git a/MLKInterpreter.m b/MLKInterpreter.m
index 8b8600a..d22ce09 100644
--- a/MLKInterpreter.m
+++ b/MLKInterpreter.m
@@ -962,6 +962,70 @@ static MLKSymbol *MULTIPLE_VALUE_CALL;
else
return result;
}
+ else if (car == PROGV)
+ {
+ id variables, values, body, result;
+ MLKDynamicContext *dynctx;
+
+ if (expandOnly)
+ {
+ RETURN_VALUE ([MLKCons
+ cons:PROGV
+ with:[denullify([[self eval:[MLKCons
+ cons:PROGN
+ with:[program cdr]]
+ inLexicalContext:context
+ withEnvironment:lexenv
+ mode:mode]
+ objectAtIndex:0]) cdr]]);
+ }
+
+ dynctx = [[MLKDynamicContext alloc]
+ initWithParent:dynamicContext
+ variables:nil
+ handlers:nil
+ restarts:nil
+ catchTags:nil
+ activeHandlerEnvironment:nil];
+
+ body = [[[program cdr] cdr] cdr];
+ variables = denullify ([[self eval:[[program cdr] car]
+ inLexicalContext:context
+ withEnvironment:lexenv]
+ objectAtIndex:0]);
+ values = denullify ([[self eval:[[[program cdr] cdr] car]
+ inLexicalContext:context
+ withEnvironment:lexenv]
+ objectAtIndex:0]);
+
+ for (; variables; (variables = [variables cdr], values = [values cdr]))
+ {
+ id var = [variables car];
+ id value = [values car];
+
+ [dynctx addValue:value forSymbol:var];
+ }
+
+ [dynctx pushContext];
+
+ NS_DURING
+ {
+ result = [self eval:[MLKCons cons:PROGN with:body]
+ inLexicalContext:context
+ withEnvironment:lexenv];
+ }
+ NS_HANDLER
+ {
+ [MLKDynamicContext popContext];
+ [localException raise];
+ }
+ NS_ENDHANDLER;
+
+ [MLKDynamicContext popContext];
+ RELEASE (dynctx);
+
+ return result;
+ }
else if (car == QUOTE)
{
if (expandOnly)