package latte;

import latte.lattice.Lattice;

public abstract class FunctionPointer {

	public Lattice execute (Lattice lattice) {
		// test: 'foreach(lattice; @0 += @-1)'
		Lattice newLat = new Lattice(Lattice.SEQ);
		for(int index = 0; index < lattice.length(); index++) {
			newLat.concatenate(execute(lattice.getVector().get(index)));
		}
		return newLat;
	}
	
	public void foreach (Lattice lattice) {
		// test: 'foreach(lattice; @0 += @-1)'
		for(int index = 0; index < lattice.length(); index++) {
			Lattice offset0 = lattice.getElementByOffset(index, 0);
			Lattice offsetM1 = lattice.getElementByOffset(index, 1);
			/*offsetM1 = generatAtString(index, offset);
			if (offsetM1 != null)*/
			offset0.plusEqual(offsetM1);
		}
	}
}
