summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MLKEnvironment.h2
-rw-r--r--MLKEnvironment.m15
2 files changed, 13 insertions, 4 deletions
diff --git a/MLKEnvironment.h b/MLKEnvironment.h
index bb35067..0e67c22 100644
--- a/MLKEnvironment.h
+++ b/MLKEnvironment.h
@@ -20,6 +20,7 @@
#import "MLKLispValue.h"
#import "MLKSymbol.h"
+#import <Foundation/NSArray.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSSet.h>
#import <Foundation/NSString.h>
@@ -39,6 +40,7 @@
-(MLKEnvironment *) parent;
+-(NSArray *) bindingArray;
-(NSSet *) bindings;
-(void) addBinding:(MLKBinding *)binding forSymbol:(MLKSymbol *)symbol;
-(void) setBinding:(MLKBinding *)binding forSymbol:(MLKSymbol *)symbol;
diff --git a/MLKEnvironment.m b/MLKEnvironment.m
index 7119bac..c557f79 100644
--- a/MLKEnvironment.m
+++ b/MLKEnvironment.m
@@ -58,12 +58,19 @@
return _parent;
}
+-(NSArray *) bindingArray
+{
+ NSMutableArray *array = [NSMutableArray arrayWithArray:[_bindings allKeys]];
+
+ if (_parent)
+ [array addObjectsFromArray:[_parent bindingArray]];
+
+ return array;
+}
+
-(NSSet *) bindings
{
- NSSet *set = [NSSet setWithArray:[_bindings allKeys]];
- return (_parent
- ? (id)[set setByAddingObjectsFromSet:[_parent bindings]]
- : (id)set);
+ return [NSSet setWithArray:[self bindingArray]];
}
-(void) setValue:(id)value forSymbol:(MLKSymbol *)symbol;