From c83bce248c8f70e9970fc46c5d74bdc98db766d3 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Sun, 22 Jun 2008 22:13:06 +0200 Subject: MLKLexicalContext: Add support for symbol macros. --- MLKLexicalContext.h | 2 ++ MLKLexicalContext.m | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/MLKLexicalContext.h b/MLKLexicalContext.h index f869d8d..3bc5078 100644 --- a/MLKLexicalContext.h +++ b/MLKLexicalContext.h @@ -25,6 +25,7 @@ @interface MLKLexicalContext : MLKLispValue { NSArray *_knownMacros; + NSArray *_knownSymbolMacros; MLKEnvironment *_macros; MLKEnvironment *_symbolMacros; MLKEnvironment *_goTags; @@ -45,6 +46,7 @@ -(BOOL) symbolNamesFunction:(MLKSymbol *)symbol; -(BOOL) symbolNamesMacro:(MLKSymbol *)symbol; +-(BOOL) symbolNamesSymbolMacro:(MLKSymbol *)symbol; -(id) macroForSymbol:(MLKSymbol *)symbol; -(void) setMacro:(MLKFuncallable *)function forSymbol:(MLKSymbol *)symbol; diff --git a/MLKLexicalContext.m b/MLKLexicalContext.m index 06d2ebb..2103989 100644 --- a/MLKLexicalContext.m +++ b/MLKLexicalContext.m @@ -95,6 +95,7 @@ static MLKSymbol *LEXICAL; _symbolMacros = MAKE_ENVIRONMENT (macros, _parent, _parent->_symbolMacros); _knownMacros = [macros allKeys]; + _knownSymbolMacros = [symbolMacros allKeys]; ASSIGN (_declarations, declarations); return self; @@ -150,6 +151,16 @@ static MLKSymbol *LEXICAL; return (_parent && [_parent symbolNamesMacro:symbol]); } +-(BOOL) symbolNamesSymbolMacro:(MLKSymbol *)symbol +{ + if ([_variableLocations objectForKey:(symbol ? (id)symbol : (id)[NSNull null])]) + return NO; + else if ([_knownSymbolMacros containsObject:(symbol ? (id)symbol : (id)[NSNull null])]) + return YES; + else + return (_parent && [_parent symbolNamesSymbolMacro:symbol]); +} + -(BOOL) variableIsLexical:(MLKSymbol *)symbol { id rest; @@ -200,6 +211,7 @@ static MLKSymbol *LEXICAL; { RELEASE (_macros); RELEASE (_knownMacros); + RELEASE (_knownSymbolMacros); RELEASE (_symbolMacros); RELEASE (_goTags); RELEASE (_functionLocations); -- cgit v1.2.3