package accrue.jl5.ext;

import java.util.Map;

import polyglot.ext.jl5.ast.EnumConstant;
import polyglot.util.InternalCompilerError;
import polyglot.visit.DataFlow;
import polyglot.visit.FlowGraph;
import polyglot.visit.FlowGraph.EdgeKey;
import polyglot.visit.FlowGraph.Peer;
import accrue.analysis.ext.ExtField;
import accrue.analysis.interprocanalysis.DataFlowDispatch;
import accrue.jl5.JL5DataFlowDispatch;

public class ExtEnumConstant extends ExtField {
    @Override
    public <DFItem extends DataFlow.Item> Map<EdgeKey, DFItem> flowDispatch(
            DataFlowDispatch<DFItem> d, DFItem dfIn, FlowGraph<DFItem> graph,
            Peer<DFItem> peer) {
        EnumConstant n = (EnumConstant) this.node();
        if (d instanceof JL5DataFlowDispatch) {
            JL5DataFlowDispatch<DFItem> jl5d = (JL5DataFlowDispatch<DFItem>) d;
            return jl5d.flowEnumConstant(n, dfIn, graph, peer);
        }
        throw new InternalCompilerError("DataFlowDispatch "
                + d.getClass()
                + " does not support JL5 AST nodes. It should implemetn JL5DataFlowDispatch.");
    }

}
