From 82d94f911150e1c9df1d5a44aa52d85637227afa Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Sat, 16 Aug 2008 18:44:46 +0200 Subject: %FSET, %FSETQ: Set global function bindings in a way that compiled code can understand. --- MLKLexicalContext.m | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'MLKLexicalContext.m') diff --git a/MLKLexicalContext.m b/MLKLexicalContext.m index d051b2a..1eaa51c 100644 --- a/MLKLexicalContext.m +++ b/MLKLexicalContext.m @@ -22,6 +22,7 @@ #import #import #import +#import #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); -- cgit v1.2.3