//
//  EXPExpression.m
//  Expression
//
//  Created by Ashley on 06/03/2006.
//  Copyright 2006 __MyCompanyName__. All rights reserved.
//

#import "EXPExpression.h"
#import "EXPConstant.h"
#import "EXPUnaryOp.h"
#import "EXPBinOp.h"
#import "EXPTernOp.h" 
#import "EXPSymbolTable.h"
#import "EXPSymbolReference.h"
#import "EXPDimensionElement.h"
#import "EXPDimensionItemElement.h"
#import "EXPIndexElement.h"
#import "EXPVirtualMachine.h"
#import "EXPParser.h"
#import "EXPError.h"
//#import "EXPAssemblerConstants.h"

static int _numEXPExpressionsInited = 0;
static int _numEXPExpressionsDealloced = 0;

@implementation EXPExpression

+ (int) numEXPExpressionsInited
{
	return _numEXPExpressionsInited;
}

+ (int) numEXPExpressionsDealloced
{
	return _numEXPExpressionsDealloced;
}

+ (void) reportElementCount
{
	printf("Expressions inited =    %d\n", _numEXPExpressionsInited);
	printf("Expressions dealloced = %d\n", _numEXPExpressionsDealloced);
}

- (id) init
{
	if ((self=[super init])!=nil) {
		_expressionId = _numEXPExpressionsInited++;
		_indices = [[NSMutableArray alloc] init];
/*	printf("Initialising EXPExpression %d\n", _expressionId);
	if (_expressionId==2) {
		printf("Ooooh...\n");
	} */
	}
	return self;
}

- (void) setIndices:(id)indices
{
	[indices retain];
	[_indices release];
	_indices = indices;
}

- (id) indices
{
	return _indices;
}

- (void) storeIndices
{
}

- (BOOL) isSimple
{
	return NO;
}

- (BOOL) isConstant
{
	return NO;
}

- (NSString *)elementType
{
	return @"none";
}

- (void) setExpressionType:(EXPExpressionType) expressionType
{
	_expressionType = expressionType;
}

- (EXPExpressionType) expressionType
{
	return _expressionType;
}

- (BOOL) isTypeCompatible
{
	return NO;
}

- (BOOL) compile:(EXPVirtualMachine *)machine error:(EXPError *)err opcode:(unsigned int)opcode
{
	return NO;
} 

- (void) setValue:(double) value
{
}

- (double) result
{
	return 0.0;
}

- (NSString *)description
{
	return @"Expression";
} 

- (void) dump
{
	printf("EXPExpression %s %d\n", [[[self class] description] UTF8String], [self retainCount]);
}

- (void) dealloc
{
//	printf("EXPExpression - (void) dealloc. id = %d\n", _expressionId);
	_numEXPExpressionsDealloced++;
	[_indices release];
	[super dealloc];
}

@end