Archived
1

Added Lots of Documentation

Added some nice to haves
Improved and Unified General Code Layout
This commit is contained in:
Kim Wittenburg
2015-01-04 02:54:27 +01:00
parent 152b981e24
commit 7438fd1f95
83 changed files with 2282 additions and 416 deletions

View File

@@ -8,13 +8,21 @@
#import "MPEvaluationContext.h"
@interface MPEvaluationContext ()
@property (nonatomic, strong) NSMutableArray *stack;
@end
@implementation MPEvaluationContext
static MPEvaluationContext *sharedContext;
+ (MPEvaluationContext *)sharedContext
{
if (!sharedContext) {
@@ -23,6 +31,7 @@ static MPEvaluationContext *sharedContext;
return sharedContext;
}
- (instancetype)init
{
if (sharedContext) {
@@ -40,16 +49,19 @@ static MPEvaluationContext *sharedContext;
return self;
}
- (void)push
{
[self.stack addObject:[[NSMutableDictionary alloc] init]];
}
- (void)pop
{
[self.stack removeLastObject];
}
- (BOOL)defineVariable:(NSString *)variable
value:(NSDecimalNumber *)value
{
@@ -62,17 +74,20 @@ static MPEvaluationContext *sharedContext;
return YES;
}
- (void)undefineVariable:(NSString *)variable
{
NSMutableDictionary *currentBindings = self.stack.lastObject;
[currentBindings removeObjectForKey:variable];
}
- (BOOL)isVariableDefined:(NSString *)variable
{
return [self valueForVariable:variable] != nil;
}
- (NSDecimalNumber *)valueForVariable:(NSString *)variable
{
NSUInteger currentIndex = self.stack.count;