Skip to content
This repository
tree: 29073d7b4e
Fetching contributors…

Cannot retrieve contributors at this time

file 61 lines (47 sloc) 1.386 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
//
// _DDNumberExpression.m
// DDMathParser
//
// Created by Dave DeLong on 11/18/10.
// Copyright 2010 Home. All rights reserved.
//

#import "DDMathParser.h"
#import "_DDNumberExpression.h"


@implementation _DDNumberExpression

- (id) initWithNumber:(NSNumber *)n {
self = [super init];
if (self) {
number = DD_RETAIN(n);
}
return self;
}

- (id)initWithCoder:(NSCoder *)aDecoder {
    return [self initWithNumber:[aDecoder decodeObjectForKey:@"number"]];
}

- (void)encodeWithCoder:(NSCoder *)aCoder {
    [aCoder encodeObject:[self number] forKey:@"number"];
}

#if !DD_HAS_ARC
- (void) dealloc {
[number release];
[super dealloc];
}
#endif

- (DDExpressionType) expressionType { return DDExpressionTypeNumber; }

- (DDExpression *)simplifiedExpressionWithEvaluator:(DDMathEvaluator *)evaluator error:(NSError **)error {
#pragma unused(evaluator, error)
return self;
}

- (NSNumber *) evaluateWithSubstitutions:(NSDictionary *)substitutions evaluator:(DDMathEvaluator *)evaluator error:(NSError **)error {
#pragma unused(substitutions, evaluator, error)
return [self number];
}

- (NSNumber *) number { return number; }

- (NSExpression *) expressionValueForEvaluator:(DDMathEvaluator *)evaluator {
#pragma unused(evaluator)
return [NSExpression expressionForConstantValue:[self number]];
}

- (NSString *) description {
return [[self number] description];
}

@end
Something went wrong with that request. Please try again.