@Override
	public Descriptor compile(SymbolTable symbolTable){
		
		SymbolTable lokal = new SymbolTable(symbolTable);
		int label = getNextLabelNumber();
		
		if(fparams != null){
			fparams.compile(lokal);
		}
		
		if(declarations != null){
			declarations.compile(lokal);
		}
		
		ProcDescriptor descr = new ProcDescriptor(label,lokal);
		symbolTable.declare(ident.getIdentName(),descr);
		
		
		int allocatedMemory = linkage + lokal.size();
		write("LABEL, " + label);
		
		//entry Code starts here
		write("INIT, " + allocatedMemory);
		write("PUSHREG, RK");
		write("PUSHREG, FP");
		//SL Register retten
		write("PUSHI, " + lokal.currentLvl());
		write("PUSHREG, SL");
		//FP := SP
		write("GETSP");
		write("SETFP");
		//SL := FP
		write("GETFP");
		write("PUSHI, " + lokal.currentLvl());
		write("SETSL");
		//SP := SP + lokale variablen
		write("GETSP");
		write("PUSHI, " + lokal.size());
		write("ADD");
		write("SETSP");
		//end of entryCode
		
		
		if(statseq != null){
			statseq.compile(lokal);
		}else{
			error("Kein StatementSequenzNode");
		}
		
		//exitCode starts here
		//SP := FP
		write("GETFP");
		write("SETSP");
		//Restore SL
		write("PUSHI, " + lokal.currentLvl());
		write("POPREG, SL");
		write("POPREG, FP");
		write("POPREG, RK");
		//SP := SP - Parameter
		write("GETSP");
		write("PUSHI, "+ fparams.size() );
		write("SUB");
		write("SETSP");
		
		int reduceVal = allocatedMemory + fparams.size();
		write("REDUCE, " + reduceVal);
		write("RET");
		
		return descr; 
		
		
	}