T_BYTE = _makeinfo('.byte') T_CHAR = _makeinfo('.char') T_DOUBLE = _makeinfo('.double') T_FLOAT = _makeinfo('.float') T_INT = _makeinfo('.int') T_LONG = _makeinfo('.long') T_SHORT = _makeinfo('.short') T_BOOL = _makeinfo('.boolean') #Hotspot doesn't have a bool type, but we can use this elsewhere def T_OBJECT(name):
    return _makeinfo('.obj', extra=name) def T_ARRAY(baset, newDimensions=1):
    assert(0 <= baset.dim <= 255-newDimensions)
    return _makeinfo(baset.tag, baset.dim+newDimensions, baset.extra) def _makeinfo(tag, dim=0, extra=None):
def T_ADDRESS(entry):
def T_OBJECT(name):
def T_ARRAY(baset, newDimensions=1):
def T_UNINIT_OBJECT(origin):
def objOrArray(fi): #False on uninitialized
def unSynthesizeType(t):
def decrementDim(fi):
def withNoDimension(fi):
def _decToObjArray(fi):
def _arrbase(fi):
def mergeTypes(env, t1, t2, forAssignment=False):
def isAssignable(env, t1, t2):
def vt_toStr(self):
T_INVALID = _makeinfo(None)
T_INT = _makeinfo('.int')
T_FLOAT = _makeinfo('.float')
T_DOUBLE = _makeinfo('.double')
T_DOUBLE2 = _makeinfo('.double2') #Hotspot only uses these in locals, but we use them on the stack too to simplify things
T_LONG = _makeinfo('.long')
T_LONG2 = _makeinfo('.long2')
T_NULL = _makeinfo('.obj')
T_UNINIT_THIS = _makeinfo('.init')
T_BYTE = _makeinfo('.byte')
T_SHORT = _makeinfo('.short')
T_CHAR = _makeinfo('.char')
T_BOOL = _makeinfo('.boolean') #Hotspot doesn't have a bool type, but we can use this elsewhere
OBJECT_INFO = T_OBJECT('java/lang/Object')
CLONE_INFO = T_OBJECT('java/lang/Cloneable')
SERIAL_INFO = T_OBJECT('java/io/Serializable')
THROWABLE_INFO = T_OBJECT('java/lang/Throwable')
from .verifier_types import T_BYTE, T_CHAR, T_DOUBLE, T_FLOAT, T_INT, T_LONG, T_SHORT, T_BOOL, T_OBJECT, T_ARRAY
from .verifier_types import unSynthesizeType, cat2tops

def parseFieldDescriptors(desc_str, unsynthesize=True):
    baseTypes = {'B':T_BYTE, 'C':T_CHAR, 'D':T_DOUBLE, 'F':T_FLOAT,
                 'I':T_INT, 'J':T_LONG, 'S':T_SHORT, 'Z':T_BOOL}

    fields = []
    while desc_str:
        oldlen = len(desc_str)
        desc_str = desc_str.lstrip('[')
        dim = oldlen - len(desc_str)
        if dim > 255:
            raise ValueError('Dimension {} > 255 in descriptor'.format(dim))
        if not desc_str:
            raise ValueError('Descriptor contains [s at end of string')

        if desc_str[0] == 'L':
            end = desc_str.find(';')
            if end == -1:
                raise ValueError('Unmatched L in descriptor')

            name = desc_str[1:end]
            desc_str = desc_str[end+1:]
            baset = T_OBJECT(name)
        else:
            if desc_str[0] not in baseTypes:
                raise ValueError('Unrecognized code {} in descriptor'.format(desc_str[0]))
            baset = baseTypes[desc_str[0]]
            desc_str = desc_str[1:]

        if dim:
            #Hotspot considers byte[] and bool[] identical for type checking purposes
            if unsynthesize and baset == T_BOOL:
                baset = T_BYTE

            baset = T_ARRAY(baset, dim)