/**
 * 
 */
package dspl.backend.test;

import java.io.FileNotFoundException;

import dspl.backend.AssemblyfileGenerator;
import dspl.backend.InstructionProcessor;
import dspl.frontend.SymbolicException;
import dspl.intermediate.instructions.Instruction;

/**
 * TestsCompiler is used to compile IntermediateTestCases
 * @author David
 */
public class TestsCompiler {

	/**
	 * @param args *does not use arguments*
	 */
	public static void main(String[] args) throws SymbolicException {
		IntermediateTestCase tc = new HelloWorldv1(); 
		AssemblyfileGenerator afg;
		try {
			afg = new AssemblyfileGenerator(tc.getTestCaseName() + ".s", true);
			
		} catch (FileNotFoundException e) {
			e.printStackTrace();
			return; 
		} 

		afg.writeSkeletonASM(tc.getSymbolTable().getAllVariables()); 
		InstructionProcessor ip = new InstructionProcessor(tc.getSymbolTable(), afg);
		Instruction firstInst = tc.getFirstInstr();
		ip.processInstruction(firstInst); 
		
		afg.writeAsmInstr("call", "_exit"); 
		
		afg.closeFile(); 
	}

}
