summaryrefslogtreecommitdiff
path: root/MLKLexicalContext.m
diff options
context:
space:
mode:
authorMatthias Benkard <mulk@minimulk.mst-plus>2008-08-16 22:51:22 +0200
committerMatthias Benkard <mulk@minimulk.mst-plus>2008-08-16 22:51:22 +0200
commit5cd4de577c08637cb5d78d1c3376b1ff80e74065 (patch)
treec9e0e279f0c95b5f7fc5c691821344cb2e5d3ce4 /MLKLexicalContext.m
parentd858e84c0778dc1851b3a0e324caaf0bef05f274 (diff)
parent3f11cb6b3ddd03d3211dd355cbac23884fa5a6e3 (diff)
Merge branch 'master' of http://matthias.benkard.de/code/mulklisp
Diffstat (limited to 'MLKLexicalContext.m')
-rw-r--r--MLKLexicalContext.m57
1 files changed, 57 insertions, 0 deletions
diff --git a/MLKLexicalContext.m b/MLKLexicalContext.m
index d051b2a..1eaa51c 100644
--- a/MLKLexicalContext.m
+++ b/MLKLexicalContext.m
@@ -22,6 +22,7 @@
#import <Foundation/NSNull.h>
#import <Foundation/NSSet.h>
#import <Foundation/NSString.h>
+#import <Foundation/NSValue.h>
#import "MLKCons.h"
#import "MLKDynamicContext.h"
@@ -358,6 +359,62 @@ static MLKSymbol *LEXICAL;
}
}
+-(void *) functionCellForSymbol:(id)name
+{
+ id prop = [self deepPropertyForFunction:name
+ key:@"LEXCTX.function-cell"];
+
+ if (!prop)
+ {
+ void *cell = malloc (sizeof(id (*)()));
+ prop = [NSValue valueWithPointer:cell];
+ [self setDeepProperty:prop
+ forFunction:name
+ key:@"LEXCTX.function-cell"];
+ return cell;
+ }
+ else
+ {
+ return [prop pointerValue];
+ }
+}
+
+-(void *) closureDataPointerForSymbol:(id)name
+{
+ id prop = [self deepPropertyForFunction:name
+ key:@"LEXCTX.closure-data"];
+
+ if (!prop)
+ {
+ void *cell = malloc (sizeof(id (*)()));
+ prop = [NSValue valueWithPointer:cell];
+ [self setDeepProperty:prop
+ forFunction:name
+ key:@"LEXCTX.closure-data"];
+ return cell;
+ }
+ else
+ {
+ return [prop pointerValue];
+ }
+}
+
+-(id) bindingForSymbol:(id)name
+{
+ id prop = [self deepPropertyForVariable:name
+ key:@"LEXCTX.variable-binding"];
+
+ if (!prop)
+ {
+ prop = [MLKBinding binding];
+ [self setDeepProperty:prop
+ forVariable:name
+ key:@"LEXCTX.variable-binding"];
+ }
+
+ return prop;
+}
+
-(void) dealloc
{
LRELEASE (_macros);