Archived
1

Improved Evaluation

This commit is contained in:
Kim Wittenburg
2014-09-28 23:50:18 +02:00
parent 43b6f78afb
commit d67a1949e9
19 changed files with 841 additions and 89 deletions

View File

@@ -45,22 +45,27 @@ static MPEvaluationContext *sharedContext;
[self.stack removeLastObject];
}
- (void)bindValue:(NSDecimalNumber *)value toName:(NSString *)variableName
- (void)defineVariable:(NSString *)variable withValue:(id)value
{
NSMutableDictionary *currentBindings = self.stack.lastObject;
currentBindings[variableName] = value;
currentBindings[variable] = value;
}
- (void)unbindVariableName:(NSString *)variableName
- (void)undefineVariable:(NSString *)variable
{
NSMutableDictionary *currentBindings = self.stack.lastObject;
[currentBindings removeObjectForKey:variableName];
[currentBindings removeObjectForKey:variable];
}
- (NSDecimalNumber *)valueForVariableName:(NSString *)variableName
- (NSDecimalNumber *)valueForVariable:(NSString *)variable
{
NSMutableDictionary *currentBindings = self.stack.lastObject;
return currentBindings[variableName];
return currentBindings[variable];
}
- (BOOL)isVariableDefined:(NSString *)variable
{
return [self valueForVariable:variable] != nil;
}
@end