# 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
                # the only "unknown" vars are bexpr[] and ints. All else have fixed types
                if forceExact or (tag != BExpr and tag != IntTT[0]):
                    sets.union(tag == BoolTT[0], expr)
                varlist.append(expr)
                return sets.find(expr)
        elif isinstance(expr, ast.Literal):
            if expr.dtype == IntTT and expr.val not in (0,1):
                return False
            return None #if val is 0 or 1, or the literal is a null, it is freely convertable
        elif isinstance(expr, ast.Assignment) or (isinstance(expr, ast.BinaryInfix) and expr.opstr in ('&','|','^')):
            return subs[0]
        elif isinstance(expr, (ast.ArrayAccess, ast.Parenthesis, ast.UnaryPrefix)):
            return visitExpr(expr.params[0])
        elif expr.dtype is not None and expr.dtype[0] != BExpr:
            return expr.dtype[0] == BoolTT[0]
        return None

    def visitStatement(item, expr):
        root = visitExpr(expr)
        if isinstance(item, ast.ReturnStatement):
            forced_val = (item.tt[0] == BoolTT[0])
            sets.union(forced_val, root)

    for expr in arg_vars:
        visitExpr(expr, forceExact=True)
    visitStatementTree(root, callback=visitStatement)

    #Fix the propagated types
    for var in set(varlist):
        tag, dim = var.dtype

# 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

                # the only "unknown" vars are bexpr[] and ints. All else have fixed types
                if forceExact or (tag != BExpr and tag != IntTT[0]):
                    sets.union(tag == BoolTT[0], expr)
                varlist.append(expr)
                return sets.find(expr)
        elif isinstance(expr, ast.Literal):
            if expr.dtype == IntTT and expr.val not in (0,1):
                return False
            return None #if val is 0 or 1, or the literal is a null, it is freely convertable
        elif isinstance(expr, ast.Assignment) or (isinstance(expr, ast.BinaryInfix) and expr.opstr in ('&','|','^')):
            return subs[0]
        elif isinstance(expr, (ast.ArrayAccess, ast.Parenthesis, ast.UnaryPrefix)):
            return visitExpr(expr.params[0])
        elif expr.dtype is not None and expr.dtype[0] != BExpr:
            return expr.dtype[0] == BoolTT[0]
        return None

    def visitStatement(item, expr):
        root = visitExpr(expr)
        if isinstance(item, ast.ReturnStatement):
            forced_val = (item.tt[0] == BoolTT[0])
            sets.union(forced_val, root)

    for expr in arg_vars:
        visitExpr(expr, forceExact=True)
    visitStatementTree(root, callback=visitStatement)

    #Fix the propagated types
    for var in set(varlist):
        tag, dim = var.dtype

        assert(tag in int_tags or (dim>0 and tag == BExpr))