package fr.lifl.stc.stan.implicitFlow; import java.util.HashMap; import java.util.Iterator; import org.apache.bcel.classfile.Method; import org.apache.bcel.generic.InstructionHandle; import org.apache.bcel.generic.InstructionList; import fr.lifl.stc.stan.implicitFlow.data.BooleanExpression; import fr.lifl.stc.stan.implicitFlow.data.BooleanVariable; /** * associates to each bytecode of a method the BooleanExpression on which its execution depends * * @author dorina * */ public class ImplicitDependences { Method method; BooleanVariable[] conditions; /** * bytecode line => BooleanExpression */ HashMap dependences; public ImplicitDependences(Method m, BooleanVariable[] b){ this.method = m; this.conditions = b; dependences = new HashMap(); InstructionList i_list; i_list = new InstructionList(m.getCode().getCode()); Iterator it = i_list.iterator(); while(it.hasNext()) { InstructionHandle ih = it.next(); dependences.put(new Integer(ih.getPosition()), new BooleanExpression()); } } public BooleanExpression getBooleanExpression(int line) { return dependences.get(new Integer(line)); } public void set(int line, BooleanExpression tmp){ this.dependences.put(new Integer(line), tmp); } public String toString() { String s = ""; Iterator it = this.dependences.keySet().iterator(); while(it.hasNext()) { Integer pos = it.next(); BooleanExpression b = this.dependences.get(pos); s += pos + " => " +b+"\n"; } return s; } }