package accrue.jl5;

import java.util.Map;

import polyglot.ext.jl5.ast.EnumConstant;
import polyglot.ext.jl5.ast.EnumConstantDecl;
import polyglot.ext.jl5.ast.ExtendedFor;
import polyglot.ext.jl5.ast.ParamTypeNode;
import polyglot.visit.DataFlow;
import polyglot.visit.FlowGraph;
import polyglot.visit.FlowGraph.EdgeKey;
import polyglot.visit.FlowGraph.Peer;
import accrue.analysis.interprocanalysis.DataFlowDispatch;

/**
 * Helper interface to assist in dispatch for dataflow implementations that
 * support JL5.
 * 
 * @param <DFItem> dataflow item type
 */
public interface JL5DataFlowDispatch<DFItem extends DataFlow.Item> extends
        DataFlowDispatch<DFItem> {
    /**
     * Compute the dataflow for <code>n</code>
     * 
     * @param n
     *            AST node to compute the dataflow for
     * @param dfIn
     *            input dataflow item
     * @param graph
     *            dataflow graph
     * @param peer
     *            occurrence of the dataflow node in the flowgraph
     * @return A map of exit edge keys to dataflow items
     */
    Map<EdgeKey, DFItem> flowEnumConstantDecl(EnumConstantDecl n, DFItem dfIn,
            FlowGraph<DFItem> graph, Peer<DFItem> peer);

    /**
     * Compute the dataflow for <code>n</code>
     * 
     * @param n
     *            AST node to compute the dataflow for
     * @param dfIn
     *            input dataflow item
     * @param graph
     *            dataflow graph
     * @param peer
     *            occurrence of the dataflow node in the flowgraph
     * @return A map of exit edge keys to dataflow items
     */
    Map<EdgeKey, DFItem> flowEnumConstant(EnumConstant n, DFItem dfIn,
            FlowGraph<DFItem> graph, Peer<DFItem> peer);

    /**
     * Compute the dataflow for <code>n</code>
     * 
     * @param n
     *            AST node to compute the dataflow for
     * @param dfIn
     *            input dataflow item
     * @param graph
     *            dataflow graph
     * @param peer
     *            occurrence of the dataflow node in the flowgraph
     * @return A map of exit edge keys to dataflow items
     */
    Map<EdgeKey, DFItem> flowExtendedFor(ExtendedFor n, DFItem dfIn,
            FlowGraph<DFItem> graph, Peer<DFItem> peer);

    /**
     * Compute the dataflow for <code>n</code>
     * 
     * @param n
     *            AST node to compute the dataflow for
     * @param dfIn
     *            input dataflow item
     * @param graph
     *            dataflow graph
     * @param peer
     *            occurrence of the dataflow node in the flowgraph
     * @return A map of exit edge keys to dataflow items
     */
    Map<EdgeKey, DFItem> flowParamTypeNode(ParamTypeNode n, DFItem dfIn,
            FlowGraph<DFItem> graph, Peer<DFItem> peer);

}
