# Path: krakatau-lib/src/main/resources/Lib/Krakatau/ssa/ssa_types.py
# SSA_INT = 'int', 32
# SSA_LONG = 'int', 64
# SSA_FLOAT = 'float', fu.FLOAT_SIZE
# SSA_DOUBLE = 'float', fu.DOUBLE_SIZE
# SSA_OBJECT = 'obj',
# SSA_MONAD = 'monad',
# def verifierToSSAType(vtype):
#     def __init__(self, key):
#     def getSuccessors(self):
#     def filterVarConstraints(self, keepvars):
#     def removePredPair(self, pair):
#     def replacePredPair(self, oldp, newp):
#     def __str__(self):
# class BasicBlock(object):


import collections, itertools
from ..ssa import ssa_types
    innodes = [x for x in innodes if not x in temp and not temp.add(x)]

    for n in innodes:
        n.replaceSuccessors(dupmap)

    S = set(innodes)
    for old, new in dups:
        for p in old.predecessors[:]:
            if p in S:
                old.predecessors.remove(p)
                new.predecessors.append(p)
        new.replaceSuccessors(dupmap)
        for c in new.successors:
            c.predecessors.append(new)

    return zip(*dups)[1]

def createGraphProxy(ssagraph):
    assert(not ssagraph.procs) #should have already been inlined

    nodes = [BlockProxy(b.key, itertools.count(), block=b) for b in ssagraph.blocks]
    allnodes = nodes[:] #will also contain indirected nodes

    entryNode = None
    intypes = ddict(set)
    for n in nodes:
        invars = [phi.rval for phi in n.block.phis]
        for b, t in n.block.jump.getSuccessorPairs():
            intypes[b.key].add(t)


# Path: krakatau-lib/src/main/resources/Lib/Krakatau/ssa/ssa_types.py
# SSA_INT = 'int', 32
# SSA_LONG = 'int', 64
# SSA_FLOAT = 'float', fu.FLOAT_SIZE
# SSA_DOUBLE = 'float', fu.DOUBLE_SIZE
# SSA_OBJECT = 'obj',
# SSA_MONAD = 'monad',
# def verifierToSSAType(vtype):
#     def __init__(self, key):
#     def getSuccessors(self):
#     def filterVarConstraints(self, keepvars):
#     def removePredPair(self, pair):
#     def replacePredPair(self, oldp, newp):
#     def __str__(self):
# class BasicBlock(object):


# Path: krakatau-lib/src/main/resources/Lib/Krakatau/java/graphproxy.py
import collections, itertools
from ..ssa import ssa_types

    innodes = [x for x in innodes if not x in temp and not temp.add(x)]

    for n in innodes:
        n.replaceSuccessors(dupmap)

    S = set(innodes)
    for old, new in dups:
        for p in old.predecessors[:]:
            if p in S:
                old.predecessors.remove(p)
                new.predecessors.append(p)
        new.replaceSuccessors(dupmap)
        for c in new.successors:
            c.predecessors.append(new)

    return zip(*dups)[1]

def createGraphProxy(ssagraph):
    assert(not ssagraph.procs) #should have already been inlined

    nodes = [BlockProxy(b.key, itertools.count(), block=b) for b in ssagraph.blocks]
    allnodes = nodes[:] #will also contain indirected nodes

    entryNode = None
    intypes = ddict(set)
    for n in nodes:
        invars = [phi.rval for phi in n.block.phis]
        for b, t in n.block.jump.getSuccessorPairs():
            intypes[b.key].add(t)


        if n.bkey == ssagraph.entryKey: