//
//  EXPAuxiliaryElement.m
//  XMLTest
//
//  Created by Ashley on 12/04/2007.
//  Copyright 2007 __MyCompanyName__. All rights reserved.
//

#import "EXPAuxiliaryElement.h"
#import "EXPAssemblerConstants.h"

@implementation EXPAuxiliaryElement

- (BOOL) isAuxiliary
{
	return YES;
}

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

- (BOOL) compile:(EXPStackMachine *)machine error:(NSError **)err opcode:(unsigned int)opcode
{
	BOOL success = [super compile:machine error:err opcode:(opcode + XMODE)];
	return success;
}

- (BOOL) compile:(EXPStackMachine *)machine error:(NSError **)err withArguments:(NSArray *)arguments
{
	BOOL success = [self compile:machine error:err opcode:LDAP];
	return success;
}

- (BOOL) compileAuxilaryAssignment:(EXPStackMachine *)machine error:(NSError **)err
{
	if ([self expression]==nil) {
		return YES;
	}
	
	BOOL success = [super compile:machine error:err withArguments:nil];
	
	if (success) {
		[machine putUInt:STRX];
		[machine putUInt:[self address]];
	}
	return success;
}

- (NSString *)description
{
	return [NSString stringWithFormat:@"EXPAuxiliaryElement '%@'", [self name]];
}

@end
