From 1560780b5fad554f12ce3964854bd474da1048f8 Mon Sep 17 00:00:00 2001 From: Matthias Benkard Date: Sun, 24 Aug 2008 11:51:35 +0200 Subject: MLKLexicalContext: Add -functionIsInline:. --- MLKLexicalContext.m | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'MLKLexicalContext.m') diff --git a/MLKLexicalContext.m b/MLKLexicalContext.m index 3f820a8..a1bb8e8 100644 --- a/MLKLexicalContext.m +++ b/MLKLexicalContext.m @@ -35,6 +35,7 @@ #import "MLKSymbol.h" #import "MLKInteger.h" #import "runtime-compatibility.h" +#import "special-symbols.h" #import "util.h" #include @@ -51,18 +52,10 @@ static MLKLexicalContext *global_context; -static MLKPackage *cl; -static MLKPackage *sys; -static MLKSymbol *SPECIAL; -static MLKSymbol *LEXICAL; - - @implementation MLKLexicalContext +(void) initialize { MLKLexicalEnvironment *globalenv = [MLKLexicalEnvironment globalEnvironment]; - cl = [MLKPackage findPackage:@"COMMON-LISP"]; - sys = [MLKPackage findPackage:@"TOILET-SYSTEM"]; global_context = [[self alloc] initWithParent:nil variables:[globalenv variables] @@ -72,9 +65,8 @@ static MLKSymbol *LEXICAL; compilerMacros:nil symbolMacros:nil declarations:nil]; - - SPECIAL = [cl intern:@"SPECIAL"]; - LEXICAL = [sys intern:@"LEXICAL"]; + + ensure_symbols (); } -(MLKLexicalContext *) initWithParent:(MLKLexicalContext *)aContext @@ -299,6 +291,27 @@ static MLKSymbol *LEXICAL; else return (_parent && [_parent variableIsLexical:symbol]); } +-(BOOL) functionIsInline:(MLKSymbol *)symbol +{ + if ([_functions containsObject:symbol]) + { + id rest = _declarations; + while (rest) + { + id item = [rest car]; + if ([item isKindOfClass:[MLKCons class]] && [[item cdr] car] == symbol) + { + if ([item car] == INLINE) + return YES; + else if ([item car] == NOTINLINE) + return NO; + } + rest = [rest cdr]; + } + } + else return (_parent && [_parent functionIsInline:symbol]); +} + -(void) addVariable:(MLKSymbol *)symbol { symbol = symbol ? (id)symbol : (id)[NSNull null]; -- cgit v1.2.3 From 0be08d02045b70bdb3eb8ab7f01051f4372a2d04 Mon Sep 17 00:00:00 2001 From: Matthias Benkard Date: Sun, 24 Aug 2008 14:34:19 +0200 Subject: MLKLexicalContext: Support NIL as a variable and function name. --- MLKLexicalContext.m | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'MLKLexicalContext.m') diff --git a/MLKLexicalContext.m b/MLKLexicalContext.m index a1bb8e8..d5c6add 100644 --- a/MLKLexicalContext.m +++ b/MLKLexicalContext.m @@ -326,12 +326,12 @@ static MLKLexicalContext *global_context; -(id) deepPropertyForVariable:(id)name key:(id)key { - NSDictionary *props = [_variableInfo objectForKey:name]; + NSDictionary *props = [_variableInfo objectForKey:nullify(name)]; id property; if (props && (property = [props objectForKey:key])) return property; - else if (!_parent || [_variables containsObject:name]) + else if (!_parent || [_variables containsObject:nullify(name)]) return nil; else return [_parent deepPropertyForVariable:name key:key]; @@ -345,13 +345,13 @@ static MLKLexicalContext *global_context; // lexically apparent binding, the property is set in the global // context. This does not make it pervasive, however. - if (!_parent || [_variables containsObject:name]) + if (!_parent || [_variables containsObject:nullify(name)]) { - NSMutableDictionary *props = [_variableInfo objectForKey:name]; + NSMutableDictionary *props = [_variableInfo objectForKey:nullify(name)]; if (!props) { props = [NSMutableDictionary dictionary]; - [_variableInfo setObject:props forKey:name]; + [_variableInfo setObject:props forKey:nullify(name)]; } [props setObject:object forKey:key]; } @@ -363,12 +363,12 @@ static MLKLexicalContext *global_context; -(id) deepPropertyForFunction:(id)name key:(id)key { - NSDictionary *props = [_functionInfo objectForKey:name]; + NSDictionary *props = [_functionInfo objectForKey:nullify(name)]; id property; if (props && (property = [props objectForKey:key])) return property; - else if (!_parent || [_functions containsObject:name]) + else if (!_parent || [_functions containsObject:nullify(name)]) return nil; else return [_parent deepPropertyForFunction:name key:key]; @@ -378,13 +378,13 @@ static MLKLexicalContext *global_context; forFunction:(id)name key:(id)key { - if (!_parent || [_functions containsObject:name]) + if (!_parent || [_functions containsObject:nullify(name)]) { - NSMutableDictionary *props = [_functionInfo objectForKey:name]; + NSMutableDictionary *props = [_functionInfo objectForKey:nullify(name)]; if (!props) { props = [NSMutableDictionary dictionary]; - [_functionInfo setObject:props forKey:name]; + [_functionInfo setObject:props forKey:nullify(name)]; } [props setObject:object forKey:key]; } -- cgit v1.2.3