summaryrefslogtreecommitdiff
path: root/MLKRoot.m
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <matthias@benkard.de>2008-08-17 22:04:27 +0200
committerMatthias Andreas Benkard <matthias@benkard.de>2008-08-17 22:05:18 +0200
commit96870ab2cd94ba6e36585837b69048c544e6d6b6 (patch)
tree5550abe681f2e23dacc0f4ae39e74a1f552608c1 /MLKRoot.m
parent0c789f22fae8c0d318a189e8b8b73f5e5ef81976 (diff)
Promote special operators SET and %FSET to intrinsics.
Diffstat (limited to 'MLKRoot.m')
-rw-r--r--MLKRoot.m31
1 files changed, 31 insertions, 0 deletions
diff --git a/MLKRoot.m b/MLKRoot.m
index b051dd3..0c59c23 100644
--- a/MLKRoot.m
+++ b/MLKRoot.m
@@ -99,6 +99,10 @@ static id truify (BOOL value)
withString:@"_"
options:NSLiteralSearch
range:NSMakeRange(0, [methodName length])];
+ [methodName replaceOccurrencesOfString:@"%"
+ withString:@""
+ options:NSLiteralSearch
+ range:NSMakeRange(0, [methodName length])];
[methodName appendString:@":"];
selector = NSSelectorFromString (methodName);
@@ -715,4 +719,31 @@ as provided by method %@ of object %@",
RETURN_VALUE (thing);
}
#endif
+
++(NSArray *) fset:(NSArray *)args
+{
+ id symbol = denullify ([args objectAtIndex:0]);
+ id value = denullify ([args objectAtIndex:1]);
+
+ [[MLKLexicalContext globalContext] addFunction:symbol];
+ [[MLKLexicalEnvironment globalEnvironment] addFunction:value
+ forSymbol:symbol];
+
+ RETURN_VALUE (value);
+}
+
++(NSArray *) set:(NSArray *)args
+{
+ id symbol = denullify ([args objectAtIndex:0]);
+ id value = denullify ([args objectAtIndex:1]);
+ MLKDynamicContext *dynamicContext = [MLKDynamicContext currentContext];
+
+ if ([dynamicContext bindingForSymbol:symbol])
+ [dynamicContext setValue:value forSymbol:symbol];
+ else
+ [[MLKDynamicContext globalContext] addValue:value
+ forSymbol:symbol];
+
+ RETURN_VALUE (value);
+}
@end