import java.io.Writer;
import java.io.PrintWriter;

public class SimpleIA32Generator extends AssemblyGenerator {
	public int getSystemIntSize() {
		return 4;
	}

	public int getPointerSize() {
		return 4;
	}

	public int getFunctionSize() {
		return 4;
	}

	PrintWriter out;

	public void generateAssembly(Writer out,
	StaticVariable[] staticVariableDefinitionList,
	Function[] functionDefinitionList) {
		this.out = new PrintWriter(out);

		// プログラムを出力する
		this.out.println(".section .text");
		for (int i = 0; i < functionDefinitionList.length; i++) {
			generateFunction(functionDefinitionList[i]);
		}

		// データの領域を出力する
		this.out.println(".section .bss");
		for (int i = 0; i < staticVariableDefinitionList.length; i++) {
			StaticVariable sv = staticVariableDefinitionList[i];
			this.out.println(".comm " + sv.getName() + ", " + sv.getDataType().getWidth());
		}

		this.out.flush();
	}

	private void generateFunction(Function func) {
		out.println(".globl " + func.getName());
		out.println(func.getName() + ":");
	}
}

@@ -936,16 +936,27 @@
 func) %7B%0A
+%09%09// %E9%96%A2%E6%95%B0%E3%81%AE%E9%96%8B%E5%A7%8B%0A
 %09%09out.pr
@@ -1027,13 +1027,1171 @@
 + %22:%22);%0A
+%09%09// %E9%96%A2%E6%95%B0%E5%86%85%E3%81%AE%E5%91%BD%E4%BB%A4%E3%82%92%E3%81%9D%E3%82%8C%E3%81%9E%E3%82%8C%E5%87%BA%E5%8A%9B%E3%81%99%E3%82%8B%0A%09%09int instNum = func.getInstructionNumber();%0A%09%09for (int i = 0; i %3C instNum; i++) %7B%0A%09%09%09generateInstruction(func.getInstruction(i));%0A%09%09%7D%0A%09%09// %E9%96%A2%E6%95%B0%E3%81%AE%E7%B5%82%E3%82%8F%E3%82%8A%0A%09%09out.println(%22stoa.funcend.%22 + func.getName() + %22:%22);%0A%09%09out.println(%22%5Ctret%22);%0A%09%7D%0A%0A%09private void generateInstruction(Instruction inst) %7B%0A%09%09if (inst instanceof NormalExpression) %7B%0A%09%09%09throw new SystemLimitException(%22NormalExpression not implemented yet%22);%0A%09%09%7D else if (inst instanceof ReturnInstruction) %7B%0A%09%09%09throw new SystemLimitException(%22ReturnInstruction not implemented yet%22);%0A%09%09%7D else if (inst instanceof ConditionalBranch) %7B%0A%09%09%09throw new SystemLimitException(%22ConditionalBranch not implemented yet%22);%0A%09%09%7D else if (inst instanceof InfiniteLoop) %7B%0A%09%09%09throw new SystemLimitException(%22InfiniteLoop not implemented yet%22);%0A%09%09%7D else if (inst instanceof WhileLoop) %7B%0A%09%09%09throw new SystemLimitException(%22WhileLoop not implemented yet%22);%0A%09%09%7D else if (inst instanceof BreakInstruction) %7B%0A%09%09%09throw new SystemLimitException(%22BreakInstruction not implemented yet%22);%0A%09%09%7D else if (inst instanceof ContinueInstruction) %7B%0A%09%09%09throw new SystemLimitException(%22ContinueInstruction not implemented yet%22);%0A%09%09%7D%0A
 %09%7D%0A%7D%0A

add instruction generation for function