diff options
author | Matthias Andreas Benkard <matthias@benkard.de> | 2008-06-22 22:13:06 +0200 |
---|---|---|
committer | Matthias Andreas Benkard <matthias@benkard.de> | 2008-06-22 22:13:06 +0200 |
commit | c83bce248c8f70e9970fc46c5d74bdc98db766d3 (patch) | |
tree | d7153606b5788ca742109fd46fbf13fc5d7b2d46 | |
parent | bbd50fa93b66cfee268c3c7f038d855b953c7eb1 (diff) |
MLKLexicalContext: Add support for symbol macros.
-rw-r--r-- | MLKLexicalContext.h | 2 | ||||
-rw-r--r-- | MLKLexicalContext.m | 12 |
2 files changed, 14 insertions, 0 deletions
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); |