# Path: krakatau-lib/src/main/resources/Lib/Krakatau/ssa/objtypes.py
# def TypeTT(baset, dim):
# def baset(tt): return tt[0]
# def dim(tt): return tt[1]
# def withDimInc(tt, inc): return TypeTT(baset(tt), dim(tt)+inc)
# def withNoDim(tt): return TypeTT(baset(tt), 0)
# def isBaseTClass(tt): return not baset(tt).startswith('.')
# def className(tt): return baset(tt) if not baset(tt).startswith('.') else None
# def primName(tt): return baset(tt)[1:] if baset(tt).startswith('.') else None
# def isSubtype(env, x, y):
# def commonSupertype(env, tts):
# def verifierToSynthetic_seq(vtypes):
# def verifierToSynthetic(vtype):
# def declTypeToActual(env, decltype):
# 
# Path: krakatau-lib/src/main/resources/Lib/Krakatau/verifier/descriptors.py
# def parseFieldDescriptor(desc_str, unsynthesize=True):
#     rval = parseFieldDescriptors(desc_str, unsynthesize)
# 
#     cat = 2 if (rval and rval[0] in cat2tops) else 1
#     if len(rval) != cat:
#         raise ValueError('Incorrect number of fields in descriptor, expected {} but found {}'.format(cat, len(rval)))
#     return rval
# 
# Path: krakatau-lib/src/main/resources/Lib/Krakatau/java/reserved.py



import struct
        import traceback
from ..ssa import objtypes
from ..verifier.descriptors import parseFieldDescriptor
from . import ast, ast2, javamethod, throws
from .reserved import reserved_identifiers
            data = const_attrs[0]
            index = struct.unpack('>h', data)[0]
            initexpr = loadConstValue(cpool, index)
    return ast2.FieldDef(' '.join(flags), ast.TypeName(dtype), field.class_, field.name, desc, initexpr)

def _getMethod(method, cb, forbidden_identifiers, skip_errors):
    try:
        graph = cb(method) if method.code is not None else None
        print 'Decompiling method', method.name.encode('utf8'), method.descriptor.encode('utf8')
        code_ast = javamethod.generateAST(method, graph, forbidden_identifiers)
        return code_ast
    except Exception as e:
        if not skip_errors:
            raise

        message = traceback.format_exc()
        code_ast = javamethod.generateAST(method, None, forbidden_identifiers)
        code_ast.comments.add(message)
        print message
        return code_ast

# Method argument allows decompilng only a single method, primarily useful for debugging
def generateAST(cls, cb, skip_errors, method=None, add_throws=False):
    methods = cls.methods if method is None else [cls.methods[method]]
    fi = set(reserved_identifiers)
    for field in cls.fields:
        fi.add(field.name)
    forbidden_identifiers = frozenset(fi)

    myflags = [x.lower() for x in sorted(cls.flags) if x not in ('INTERFACE','SUPER','SYNTHETIC','ANNOTATION','ENUM')]

# Path: krakatau-lib/src/main/resources/Lib/Krakatau/ssa/objtypes.py
# def TypeTT(baset, dim):
# def baset(tt): return tt[0]
# def dim(tt): return tt[1]
# def withDimInc(tt, inc): return TypeTT(baset(tt), dim(tt)+inc)
# def withNoDim(tt): return TypeTT(baset(tt), 0)
# def isBaseTClass(tt): return not baset(tt).startswith('.')
# def className(tt): return baset(tt) if not baset(tt).startswith('.') else None
# def primName(tt): return baset(tt)[1:] if baset(tt).startswith('.') else None
# def isSubtype(env, x, y):
# def commonSupertype(env, tts):
# def verifierToSynthetic_seq(vtypes):
# def verifierToSynthetic(vtype):
# def declTypeToActual(env, decltype):
# 
# Path: krakatau-lib/src/main/resources/Lib/Krakatau/verifier/descriptors.py
# def parseFieldDescriptor(desc_str, unsynthesize=True):
#     rval = parseFieldDescriptors(desc_str, unsynthesize)
# 
#     cat = 2 if (rval and rval[0] in cat2tops) else 1
#     if len(rval) != cat:
#         raise ValueError('Incorrect number of fields in descriptor, expected {} but found {}'.format(cat, len(rval)))
#     return rval
# 
# Path: krakatau-lib/src/main/resources/Lib/Krakatau/java/reserved.py



# Path: krakatau-lib/src/main/resources/Lib/Krakatau/java/javaclass.py
import struct
        import traceback
from ..ssa import objtypes
from ..verifier.descriptors import parseFieldDescriptor
from . import ast, ast2, javamethod, throws
from .reserved import reserved_identifiers

            data = const_attrs[0]
            index = struct.unpack('>h', data)[0]
            initexpr = loadConstValue(cpool, index)
    return ast2.FieldDef(' '.join(flags), ast.TypeName(dtype), field.class_, field.name, desc, initexpr)

def _getMethod(method, cb, forbidden_identifiers, skip_errors):
    try:
        graph = cb(method) if method.code is not None else None
        print 'Decompiling method', method.name.encode('utf8'), method.descriptor.encode('utf8')
        code_ast = javamethod.generateAST(method, graph, forbidden_identifiers)
        return code_ast
    except Exception as e:
        if not skip_errors:
            raise

        message = traceback.format_exc()
        code_ast = javamethod.generateAST(method, None, forbidden_identifiers)
        code_ast.comments.add(message)
        print message
        return code_ast

# Method argument allows decompilng only a single method, primarily useful for debugging
def generateAST(cls, cb, skip_errors, method=None, add_throws=False):
    methods = cls.methods if method is None else [cls.methods[method]]
    fi = set(reserved_identifiers)
    for field in cls.fields:
        fi.add(field.name)
    forbidden_identifiers = frozenset(fi)

    myflags = [x.lower() for x in sorted(cls.flags) if x not in ('INTERFACE','SUPER','SYNTHETIC','ANNOTATION','ENUM')]

    isInterface = 'INTERFACE' in cls.flags