# Path: javadecompiler/Krakatau/ssa/objtypes.py
# def isSubtype(env, x, y):
# def commonSupertype(env, tts):
# def verifierToSynthetic_seq(vtypes):
# def verifierToSynthetic(vtype):
# def declTypeToActual(env, decltype):


from ..ssa.objtypes import IntTT, ShortTT, CharTT, ByteTT, BoolTT, BExpr
from . import ast

    def find(self, x):
        if x not in self.d:
            return x
        path = [x]
        while path[-1] in self.d:
            path.append(self.d[path[-1]])
        root = path.pop()
        for y in path:
            self.d[y] = root
        return root

    def union(self, x, x2):
        if x is None or x2 is None:
            return
        root1, root2 = self.find(x), self.find(x2)
        if root2 in FORCED_ROOTS:
            root1, root2 = root2, root1
        if root1 != root2 and root2 not in FORCED_ROOTS:
            self.d[root2] = root1

##############################################################
def visitStatementTree(scope, callback):
    for item in scope.statements:
        for sub in item.getScopes():
            visitStatementTree(sub, callback=callback)
        if item.expr is not None:
            callback(item, item.expr)

int_tags = frozenset(tt[0] for tt in [IntTT, ShortTT, CharTT, ByteTT, BoolTT])

# Path: javadecompiler/Krakatau/ssa/objtypes.py
# def isSubtype(env, x, y):
# def commonSupertype(env, tts):
# def verifierToSynthetic_seq(vtypes):
# def verifierToSynthetic(vtype):
# def declTypeToActual(env, decltype):


# Path: javadecompiler/Krakatau/java/boolize.py
from ..ssa.objtypes import IntTT, ShortTT, CharTT, ByteTT, BoolTT, BExpr
from . import ast


    def find(self, x):
        if x not in self.d:
            return x
        path = [x]
        while path[-1] in self.d:
            path.append(self.d[path[-1]])
        root = path.pop()
        for y in path:
            self.d[y] = root
        return root

    def union(self, x, x2):
        if x is None or x2 is None:
            return
        root1, root2 = self.find(x), self.find(x2)
        if root2 in FORCED_ROOTS:
            root1, root2 = root2, root1
        if root1 != root2 and root2 not in FORCED_ROOTS:
            self.d[root2] = root1

##############################################################
def visitStatementTree(scope, callback):
    for item in scope.statements:
        for sub in item.getScopes():
            visitStatementTree(sub, callback=callback)
        if item.expr is not None:
            callback(item, item.expr)

int_tags = frozenset(tt[0] for tt in [IntTT, ShortTT, CharTT, ByteTT, BoolTT])

array_tags = frozenset([ByteTT[0], BoolTT[0], BExpr])