Fundamental Redesign of Evaluation
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
|
||||
|
||||
|
||||
@class MPFunction, MPExpression, MPRangePath;
|
||||
@class MPFunction, MPExpression, MPRangePath, MPFunctionTerm;
|
||||
@protocol MPExpressionElement;
|
||||
|
||||
|
||||
@@ -241,6 +241,12 @@
|
||||
*/
|
||||
- (void)didChangeChildAtIndex:(NSUInteger)index;
|
||||
|
||||
|
||||
#pragma mark Evaluating Functions
|
||||
|
||||
|
||||
- (BOOL)expectsVariableDefinitionInChildAtIndex:(NSUInteger)index;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -256,6 +262,10 @@
|
||||
*/
|
||||
@interface MPFunction (MPSubclassOverride)
|
||||
|
||||
/* In Addition to the methods listed below MPFunction subclasses should also
|
||||
* override the NSObject methods -description and -hash.
|
||||
*/
|
||||
|
||||
#pragma mark Working With the Expression Tree
|
||||
/*!
|
||||
@methodgroup Working With the Expression Tree
|
||||
@@ -281,40 +291,6 @@
|
||||
@methodgroup Evaluating Functions
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
@method validate:
|
||||
@brief Validates the function and all its children for syntax errors.
|
||||
|
||||
@param error
|
||||
If the validation fails this parameter should be set to an
|
||||
appropriate value.
|
||||
|
||||
@return @c YES if the validation was successful, @c NO otherwise.
|
||||
*/
|
||||
- (BOOL)validate:(NSError *__autoreleasing *)error;
|
||||
|
||||
|
||||
/*!
|
||||
@method evaluate:
|
||||
@brief Evaluates the function.
|
||||
|
||||
@discussion Function evaluation should actually perform math. Also the
|
||||
implementation of this method assumes that the function and all
|
||||
children are valid (as determined by the @c -validate: method).
|
||||
|
||||
@param error
|
||||
If a mathematical error occurs it is reflected in this parameter.
|
||||
Depending on the error this method then either returns @c nil or
|
||||
@c NaN.
|
||||
|
||||
@return The result of the evaluation or @c nil or @c NaN if an evaluation
|
||||
error occured (such as a division by @c 0).
|
||||
*/
|
||||
- (NSDecimalNumber *)evaluate:(NSError *__autoreleasing *)error;
|
||||
|
||||
/* In Addition to the above methods MPFunction subclasses should also override
|
||||
* the NSObject methods -description and -hash.
|
||||
*/
|
||||
- (Class)functionTermClass;
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user