/**
 * 
 */
package dspl.backend;

import dspl.SymbolTable;
import dspl.intermediate.instructions.ArithmaticInstruction;

/**
 * Abstract class for ArithmaticInstructorProcessor. <br>
 * For each targetted ISA, an implementation of ArithamticInstructionProcessor is required<Br>
 * @author David
 */
public abstract class ArithmaticInstructionProcessor {
	/**
	 * Dummy constructor. 
	 *
	 */
	public ArithmaticInstructionProcessor() { 
		
	}
	
	/**
	 * Process an Arithmatic Instruction
	 * @param instr
	 * @param st
	 * @param afg
	 */
	public void processArithmaticInstructor(ArithmaticInstruction instr, SymbolTable st, AssemblyfileGenerator afg) { 
		switch (instr.getArithmaticOperationType()) { 
		case ArithmaticInstruction.OPERATION_ADDITION:
			processAddition(instr, st, afg); 
			break;
		case ArithmaticInstruction.OPERATION_ASSIGNMENT:
			processAssignment(instr, st, afg); 
			break;
		case ArithmaticInstruction.OPERATION_CONVERSION:
			processConversion(instr, st, afg); 
			break;
		case ArithmaticInstruction.OPERATION_CONVOLUTION:
			processConvolution(instr, st, afg); 
			break;
		case ArithmaticInstruction.OPERATION_DIVISION:
			processDivision(instr, st, afg); 
			break;
		case ArithmaticInstruction.OPERATION_MULTIPLICATION:
			processMultiplication(instr, st, afg); 
			break;
		case ArithmaticInstruction.OPERATION_SUBTRACTION:
			processSubtraction(instr, st, afg); 
			break;
		default:
			throw new Error("Unidentified operation type returned by Arithmatic Instruction"); 
		}
	}
	
	/**
	 * Process an Addition Arithmatic Operation
	 * @param instr
	 */
	public abstract void processAddition(ArithmaticInstruction instr, SymbolTable st, AssemblyfileGenerator afg);
	
	/**
	 * Process an Assignment Operation
	 * @param instr
	 */
	public abstract void processAssignment(ArithmaticInstruction instr, SymbolTable st, AssemblyfileGenerator afg);
	
	/**
	 * Process a Conversion Operation
	 * @param instr
	 */
	public abstract void processConversion(ArithmaticInstruction instr, SymbolTable st, AssemblyfileGenerator afg);
	
	/**
	 * Process a Convolution Operation
	 * @param instr
	 */
	public abstract void processConvolution(ArithmaticInstruction instr, SymbolTable st, AssemblyfileGenerator afg);
	
	/**
	 * Process a Divison Operation
	 * @param instr
	 */
	public abstract void processDivision(ArithmaticInstruction instr, SymbolTable st, AssemblyfileGenerator afg);
	
	/**
	 * Process a Multiplication Operation
	 * @param instr
	 */
	public abstract void processMultiplication(ArithmaticInstruction instr, SymbolTable st, AssemblyfileGenerator afg);
	
	/**
	 * Process a Subtraction Operation
	 * @param instr
	 */
	public abstract void processSubtraction(ArithmaticInstruction instr, SymbolTable st, AssemblyfileGenerator afg);
}
