summaryrefslogtreecommitdiff
path: root/MLKLexicalContext.m
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <matthias@benkard.de>2008-08-16 18:44:46 +0200
committerMatthias Andreas Benkard <matthias@benkard.de>2008-08-16 22:01:47 +0200
commit82d94f911150e1c9df1d5a44aa52d85637227afa (patch)
tree1883258227e0f56b1b4710708849cc4971623bda /MLKLexicalContext.m
parent79abb06fbce7ee8f72556ededeee3eb88baf2fc8 (diff)
%FSET, %FSETQ: Set global function bindings in a way that compiled code can understand.
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);