package ch.ntb.inf.deep.ssa;

import ch.ntb.inf.deep.cfg.CFG;


/**
 * @author  millischer
 */

public class SSA {
	public CFG cfg;
	int nofLoopheaders;
	SSANode loopHeaders[];
	
	
	public SSA(CFG cfg) {
		this.cfg = cfg;
		loopHeaders= new SSANode[cfg.getNumberOfNodes()];
		nofLoopheaders = 0;
		
		
		determineStateArray();
	}
	

	public void determineStateArray(){
		SSANode node = (SSANode)this.cfg.rootNode;
		while (node != null) {
			//mark loopheaders for traverse a second time 
			if(node.isLoopHeader()){
				loopHeaders[nofLoopheaders]= node;
				nofLoopheaders++;
			}
			node.mergeAndDetermineStateArray(this);
			node = (SSANode)node.next;
		}
		
		for(int i = 0;i < nofLoopheaders;i++){
			loopHeaders[i].mergeAndDetermineStateArray(this);
		}		
	}
	public void print(int level, int SSANr){
		int count = 0;
		SSANode node = (SSANode)this.cfg.rootNode;
		
		for (int i = 0; i < level; i++)System.out.print("\t");
		System.out.println("SSA"+ SSANr +":");
		
		while(node != null){
			node.print(level+1, count);
			System.out.println("");
			node = (SSANode)node.next;
			count++;
		}
		
		
	}
}

@@ -800,16 +800,611 @@
 %09%09%0D%0A%09%7D%0D%0A
+%09%0D%0A%09/**%0D%0A%09 * Prints out the SSA readable.%3Cp%3E%0D%0A%09 * %3Cb%3EExample:%3C/b%3E%3Cp%3E%0D%0A%09 * %3Cpre%3ESSA 4:%0D%0A    SSANode0:%0D%0A      EntrySet %7B%5B , %5D, %5B ,  %5D%7D%0D%0A         NoOpnd%5BsCloadConst%5D%0D%0A         Dyadic%5BsCadd%5D ( Integer, Integer )%0D%0A         Dyadic%5BsCadd%5D ( Integer, Integer )%0D%0A         Dyadic%5BsCadd%5D ( Integer, Integer )%0D%0A         Monadic%5BsCloadVar%5D ( Void )%0D%0A         NoOpnd%5BsCloadConst%5D%0D%0A         Dyadic%5BsCadd%5D ( Integer, Integer )%0D%0A      ExitSet %7B%5B , %5D, %5B Integer (null), Integer (null) %5D%7D%0D%0A%09 * %3C/pre%3E%0D%0A%09 *  %0D%0A%09 * @param level defines how much to indent%0D%0A%09 * @param SSANr the Number of the SSA in this class%0D%0A%09 */%0D%0A
 %09public 
@@ -1589,16 +1589,17 @@
 tln(%22SSA
+ 
 %22+ SSANr

add javaDoc for print method