summaryrefslogtreecommitdiff
path: root/MLKRoot.m
diff options
context:
space:
mode:
authorMatthias Benkard <mulk@minimulk.mst-plus>2008-08-18 16:13:54 +0200
committerMatthias Benkard <mulk@minimulk.mst-plus>2008-08-18 16:13:54 +0200
commiteec88254d7e37ecb07b0503a9e87abfb81ce2460 (patch)
treed96aa76e24b4b090383623134b35eaf6a10f3431 /MLKRoot.m
parent5cd4de577c08637cb5d78d1c3376b1ff80e74065 (diff)
parent054dc70426505f72a1e9856c9e48c0ae3349d68d (diff)
Merge branch 'master' of http://matthias.benkard.de/code/mulklisp
Diffstat (limited to 'MLKRoot.m')
-rw-r--r--MLKRoot.m64
1 files changed, 61 insertions, 3 deletions
diff --git a/MLKRoot.m b/MLKRoot.m
index b051dd3..0db7483 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);
@@ -707,12 +711,66 @@ as provided by method %@ of object %@",
#ifdef USE_LLVM
+(NSArray *) compile:(NSArray *)args
{
- NSLog (@"Compiling lambda form.");
+ //NSLog (@"Compiling lambda form.");
id thing = [MLKLLVMCompiler compile:denullify([args objectAtIndex:0])
inContext:[MLKLexicalContext globalContext]];
- NSLog (@"Compilation done.");
- NSLog (@"Compiled: %@", thing);
+ //NSLog (@"Compilation done.");
+ //NSLog (@"Compiled: %@", thing);
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);
+}
+
++(NSArray *) macroset:(NSArray *)args
+{
+ id symbol = denullify ([args objectAtIndex:0]);
+ id value = denullify ([args objectAtIndex:1]);
+
+ [[MLKLexicalContext globalContext] addMacro:value
+ forSymbol:symbol];
+
+ RETURN_VALUE (value);
+}
+
++(NSArray *) apply:(NSArray *)args
+{
+ id function = denullify ([args objectAtIndex:0]);
+ id arglist = denullify ([args objectAtIndex:1]);
+
+ if (!function || [function isKindOfClass:[MLKSymbol class]])
+ {
+ function = [[MLKLexicalEnvironment globalEnvironment]
+ functionForSymbol:function];
+ }
+
+ return [function applyToArray:(arglist
+ ? (id)[arglist array]
+ : (id)[NSArray array])];
+}
@end