summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <matthias@benkard.de>2008-06-28 22:22:04 +0200
committerMatthias Andreas Benkard <matthias@benkard.de>2008-06-28 22:22:04 +0200
commitee2d7b7d9bb5ab87dc7986407ee44acd6bcad429 (patch)
tree3c6729e1d9edace9963def362d05d23f7b0e4a74
parent05fc2a9fd9326bd059681b7684a74e1ad1de1ec6 (diff)
Add support for compiler macros to lexical contexts.
-rw-r--r--MLKInterpretedClosure.m1
-rw-r--r--MLKInterpreter.m3
-rw-r--r--MLKLexicalContext.h8
-rw-r--r--MLKLexicalContext.m25
4 files changed, 35 insertions, 2 deletions
diff --git a/MLKInterpretedClosure.m b/MLKInterpretedClosure.m
index edf7e17..4557c7b 100644
--- a/MLKInterpretedClosure.m
+++ b/MLKInterpretedClosure.m
@@ -66,6 +66,7 @@ static MLKSymbol *PROGN;
functions:nil
goTags:nil
macros:nil
+ compilerMacros:nil
symbolMacros:nil
declarations:nil];
diff --git a/MLKInterpreter.m b/MLKInterpreter.m
index f56e750..e276982 100644
--- a/MLKInterpreter.m
+++ b/MLKInterpreter.m
@@ -234,6 +234,7 @@ static MLKSymbol *_LAMBDA;
functions:nil
goTags:nil
macros:nil
+ compilerMacros:nil
symbolMacros:nil
declarations:declarations]);
@@ -373,7 +374,7 @@ static MLKSymbol *_LAMBDA;
[NSArray arrayWithObjects:
program, context, nil]]
objectAtIndex:0]);
-;
+
return [self eval:expansion
inLexicalContext:context
withEnvironment:lexenv];
diff --git a/MLKLexicalContext.h b/MLKLexicalContext.h
index d7335e6..949bcff 100644
--- a/MLKLexicalContext.h
+++ b/MLKLexicalContext.h
@@ -29,8 +29,10 @@
@interface MLKLexicalContext : MLKLispValue
{
NSMutableSet *_knownMacros;
+ NSMutableSet *_knownCompilerMacros;
NSMutableSet *_knownSymbolMacros;
MLKEnvironment *_macros;
+ MLKEnvironment *_compilerMacros;
MLKEnvironment *_symbolMacros;
MLKEnvironment *_goTags;
NSMutableSet *_functions;
@@ -46,6 +48,7 @@
functions:(NSSet *)functions
goTags:(NSDictionary *)goTags
macros:(NSDictionary *)macros
+ compilerMacros:(NSDictionary *)compilerMacros
symbolMacros:(NSDictionary *)symbolMacros
declarations:(id)declarations;
@@ -54,6 +57,7 @@
functions:(NSSet *)functions
goTags:(NSDictionary *)goTags
macros:(NSDictionary *)macros
+ compilerMacros:(NSDictionary *)compilerMacros
symbolMacros:(NSDictionary *)symbolMacros
declarations:(id)declarations;
@@ -67,6 +71,10 @@
-(void) setMacro:(id <MLKFuncallable>)function forSymbol:(MLKSymbol *)symbol;
-(void) addMacro:(id <MLKFuncallable>)value forSymbol:(MLKSymbol *)symbol;
+-(id <MLKFuncallable>) compilerMacroForSymbol:(MLKSymbol *)symbol;
+-(void) setCompilerMacro:(id <MLKFuncallable>)value forSymbol:(MLKSymbol *)symbol;
+-(void) addCompilerMacro:(id <MLKFuncallable>)value forSymbol:(MLKSymbol *)symbol;
+
-(id <MLKFuncallable>) symbolMacroForSymbol:(MLKSymbol *)symbol;
-(void) setSymbolMacro:(id <MLKFuncallable>)function forSymbol:(MLKSymbol *)symbol;
-(void) addSymbolMacro:(id <MLKFuncallable>)value forSymbol:(MLKSymbol *)symbol;
diff --git a/MLKLexicalContext.m b/MLKLexicalContext.m
index 7f7e395..f41b05c 100644
--- a/MLKLexicalContext.m
+++ b/MLKLexicalContext.m
@@ -70,6 +70,7 @@ static MLKSymbol *LEXICAL;
functions:[globalenv functions]
goTags:nil
macros:nil
+ compilerMacros:nil
symbolMacros:nil
declarations:nil];
@@ -82,6 +83,7 @@ static MLKSymbol *LEXICAL;
functions:(NSSet *)functions
goTags:(NSDictionary *)goTags
macros:(NSDictionary *)macros
+ compilerMacros:(NSDictionary *)compilerMacros
symbolMacros:(NSDictionary *)symbolMacros
declarations:(id)declarations
{
@@ -94,6 +96,7 @@ static MLKSymbol *LEXICAL;
_goTags = MAKE_ENVIRONMENT (goTags, _parent, _parent->_goTags);
_macros = MAKE_ENVIRONMENT (macros, _parent, _parent->_macros);
+ _compilerMacros = MAKE_ENVIRONMENT (compilerMacros, _parent, _parent->_compilerMacros);
_symbolMacros = MAKE_ENVIRONMENT (symbolMacros, _parent, _parent->_symbolMacros);
ASSIGN (_knownMacros, [NSMutableSet setWithArray:[macros allKeys]]);
@@ -108,6 +111,7 @@ static MLKSymbol *LEXICAL;
functions:(NSSet *)functions
goTags:(NSDictionary *)goTags
macros:(NSDictionary *)macros
+ compilerMacros:(NSDictionary *)compilerMacros
symbolMacros:(NSDictionary *)symbolMacros
declarations:(id)declarations
{
@@ -117,6 +121,7 @@ static MLKSymbol *LEXICAL;
functions:functions
goTags:goTags
macros:macros
+ compilerMacros:compilerMacros
symbolMacros:symbolMacros
declarations:declarations]);
}
@@ -142,6 +147,22 @@ static MLKSymbol *LEXICAL;
[_macros setValue:value forSymbol:symbol];
}
+-(id <MLKFuncallable>) compilerMacroForSymbol:(MLKSymbol *)symbol
+{
+ return [_compilerMacros valueForSymbol:symbol];
+}
+
+-(void) addCompilerMacro:(id <MLKFuncallable>)value forSymbol:(MLKSymbol *)symbol
+{
+ [_knownCompilerMacros addObject:symbol];
+ [_compilerMacros addValue:value forSymbol:symbol];
+}
+
+-(void) setCompilerMacro:(id <MLKFuncallable>)value forSymbol:(MLKSymbol *)symbol
+{
+ [_compilerMacros setValue:value forSymbol:symbol];
+}
+
-(id <MLKFuncallable>) symbolMacroForSymbol:(MLKSymbol *)symbol
{
return [_symbolMacros valueForSymbol:symbol];
@@ -247,9 +268,11 @@ static MLKSymbol *LEXICAL;
-(void) dealloc
{
RELEASE (_macros);
+ RELEASE (_compilerMacros);
+ RELEASE (_symbolMacros);
RELEASE (_knownMacros);
+ RELEASE (_knownCompilerMacros);
RELEASE (_knownSymbolMacros);
- RELEASE (_symbolMacros);
RELEASE (_goTags);
RELEASE (_functions);
RELEASE (_variables);