Esempio n. 1
0
def p_invokevirtual(p):
    '''invokevirtual : INVOKEVIRTUAL SHORT
                     | INVOKEVIRTUAL BYTE
                     | INVOKEVIRTUAL IDENTIFIER'''

    isString = False
    cp = cf.constant_pool

    print("Inside invokevirtual")

    try:
        p[2] = int(p[2])
    except:
        isString = True

    if not isString:
        p[0] = opc_compile(p[1])
        p[0] += struct.pack('>h', p[2])
    else:
        print("inside invokevirtual 2")
        p[0] = opc_compile(p[1])
        method_name = None
        found = False

        mri_index = 1
        for i in cp.entries[1:]:
            if i.tag == CONSTANT_METHODREF:
                nat_index = i.name_and_type_index
                method_name = cp.entries[
                    cp.entries[nat_index].name_index].get_bytes_as_str()
                print("method_name = %s" % method_name)
                if method_name == p[2]:
                    found = True
                    break

            mri_index += 1

        if found:
            print("Found on index %d" % mri_index)
            p[0] += struct.pack('>h', mri_index)
Esempio n. 2
0
def p_invokevirtual(p):
    '''invokevirtual : INVOKEVIRTUAL SHORT
                     | INVOKEVIRTUAL BYTE
                     | INVOKEVIRTUAL IDENTIFIER'''

    isString = False
    cp = cf.constant_pool

    print("Inside invokevirtual")

    try:
        p[2] = int(p[2])
    except:
        isString = True

    if not isString:
        p[0] = opc_compile(p[1])
        p[0] += struct.pack('>h', p[2])
    else:
        print("inside invokevirtual 2")
        p[0] = opc_compile(p[1])
        method_name = None
        found = False

        mri_index = 1
        for i in cp.entries[1:]:
            if i.tag == CONSTANT_METHODREF:
                    nat_index = i.name_and_type_index
                    method_name = cp.entries[cp.entries[nat_index].name_index].get_bytes_as_str()
                    print("method_name = %s" % method_name)
                    if method_name == p[2]:
                        found = True
                        break

            mri_index += 1

        if found:
            print("Found on index %d" % mri_index)
            p[0] += struct.pack('>h', mri_index)
Esempio n. 3
0
def p_aload_0(p):
    '''aload_0 : ALOAD_0'''
    p[0] = opc_compile(p[1])
Esempio n. 4
0
def p_astore_0(p):
    '''astore_0 : ASTORE_0'''
    p[0] = opc_compile(p[1])
Esempio n. 5
0
def p_astore_2(p):
    '''astore_2 : ASTORE_2'''
    p[0] = opc_compile(p[1])
Esempio n. 6
0
def p_invokespecial(p):
    '''invokespecial : INVOKESPECIAL SHORT
                     | INVOKESPECIAL BYTE'''
    p[0] = opc_compile(p[1])
    p[0] += struct.pack('>h', p[2])
Esempio n. 7
0
def p_ireturn(p):
    '''ireturn : IRETURN'''
    p[0] = opc_compile(p[1])
Esempio n. 8
0
def p_iload_2(p):
    '''iload_2 : ILOAD_2'''
    p[0] = opc_compile(p[1])
Esempio n. 9
0
def p_istore_1(p):
    '''istore_1 : ISTORE_1'''
    p[0] = opc_compile(p[1])
Esempio n. 10
0
def p_iload_0(p):
    '''iload_0 : ILOAD_0'''
    p[0] = opc_compile(p[1])
Esempio n. 11
0
def p_iload_1(p):
    '''iload_1 : ILOAD_1'''
    p[0] = opc_compile(p[1])
Esempio n. 12
0
def p_aload_2(p):
    '''aload_2 : ALOAD_2'''
    p[0] = opc_compile(p[1])
Esempio n. 13
0
def p_aload_3(p):
    '''aload_3 : ALOAD_3'''
    p[0] = opc_compile(p[1])
Esempio n. 14
0
def p_aload_1(p):
    '''aload_1 : ALOAD_1'''
    p[0] = opc_compile(p[1])
Esempio n. 15
0
def p_aload_0(p):
    '''aload_0 : ALOAD_0'''
    p[0] = opc_compile(p[1])
Esempio n. 16
0
def p_astore_3(p):
    '''astore_3 : ASTORE_3'''
    p[0] = opc_compile(p[1])
Esempio n. 17
0
def p_aload_2(p):
    '''aload_2 : ALOAD_2'''
    p[0] = opc_compile(p[1])
Esempio n. 18
0
def p_iload_2(p):
    '''iload_2 : ILOAD_2'''
    p[0] = opc_compile(p[1])
Esempio n. 19
0
def p_iload_0(p):
    '''iload_0 : ILOAD_0'''
    p[0] = opc_compile(p[1])
Esempio n. 20
0
def p_iload_3(p):
    '''iload_3 : ILOAD_3'''
    p[0] = opc_compile(p[1])
Esempio n. 21
0
def p_isub(p):
    '''isub : ISUB'''
    p[0] = opc_compile(p[1])
Esempio n. 22
0
def p_isub(p):
    '''isub : ISUB'''
    p[0] = opc_compile(p[1])
Esempio n. 23
0
def p_astore_2(p):
    '''astore_2 : ASTORE_2'''
    p[0] = opc_compile(p[1])
Esempio n. 24
0
def p_istore_0(p):
    '''istore_0 : ISTORE_0'''
    p[0] = opc_compile(p[1])
Esempio n. 25
0
def p_ldc(p):
    '''ldc : LDC BYTE'''
    p[0] = opc_compile(p[1])
    p[0] += bytes([p[2]])
Esempio n. 26
0
def p_istore_1(p):
    '''istore_1 : ISTORE_1'''
    p[0] = opc_compile(p[1])
Esempio n. 27
0
def p_astore_0(p):
    '''astore_0 : ASTORE_0'''
    p[0] = opc_compile(p[1])
Esempio n. 28
0
def p_istore_2(p):
    '''istore_2 : ISTORE_2'''
    p[0] = opc_compile(p[1])
Esempio n. 29
0
def p_astore_1(p):
    '''astore_1 : ASTORE_1'''
    p[0] = opc_compile(p[1])
Esempio n. 30
0
def p_istore_3(p):
    '''istore_3 : ISTORE_3'''
    p[0] = opc_compile(p[1])
Esempio n. 31
0
def p_astore_3(p):
    '''astore_3 : ASTORE_3'''
    p[0] = opc_compile(p[1])
Esempio n. 32
0
def p_getstatic(p):
    '''getstatic : GETSTATIC SHORT
                 | GETSTATIC BYTE'''
    p[0] = opc_compile(p[1])
    p[0] += struct.pack('>h', p[2])
Esempio n. 33
0
def p_aload_1(p):
    '''aload_1 : ALOAD_1'''
    p[0] = opc_compile(p[1])
Esempio n. 34
0
def p_new(p):
    '''new : NEW SHORT
           | NEW BYTE'''
    p[0] = opc_compile(p[1])
    p[0] += struct.pack('>h', p[2])
Esempio n. 35
0
def p_aload_3(p):
    '''aload_3 : ALOAD_3'''
    p[0] = opc_compile(p[1])
Esempio n. 36
0
def p_dup(p):
    '''dup : DUP'''
    p[0] = opc_compile(p[1])
Esempio n. 37
0
def p_iload_1(p):
    '''iload_1 : ILOAD_1'''
    p[0] = opc_compile(p[1])
Esempio n. 38
0
def p_invokespecial(p):
    '''invokespecial : INVOKESPECIAL SHORT
                     | INVOKESPECIAL BYTE'''
    p[0] = opc_compile(p[1])
    p[0] += struct.pack('>h', p[2])
Esempio n. 39
0
def p_iload_3(p):
    '''iload_3 : ILOAD_3'''
    p[0] = opc_compile(p[1])
Esempio n. 40
0
def p_istore_3(p):
    '''istore_3 : ISTORE_3'''
    p[0] = opc_compile(p[1])
Esempio n. 41
0
def p_istore_0(p):
    '''istore_0 : ISTORE_0'''
    p[0] = opc_compile(p[1])
Esempio n. 42
0
def p_new(p):
    '''new : NEW SHORT
           | NEW BYTE'''
    p[0] = opc_compile(p[1])
    p[0] += struct.pack('>h', p[2])
Esempio n. 43
0
def p_istore_2(p):
    '''istore_2 : ISTORE_2'''
    p[0] = opc_compile(p[1])
Esempio n. 44
0
def p_astore_1(p):
    '''astore_1 : ASTORE_1'''
    p[0] = opc_compile(p[1])
Esempio n. 45
0
def p_getstatic(p):
    '''getstatic : GETSTATIC SHORT
                 | GETSTATIC BYTE'''
    p[0] = opc_compile(p[1])
    p[0] += struct.pack('>h', p[2])
Esempio n. 46
0
def p_ldc(p):
    '''ldc : LDC BYTE'''
    p[0] = opc_compile(p[1])
    p[0] += bytes([p[2]])
Esempio n. 47
0
def p_dup(p):
    '''dup : DUP'''
    p[0] = opc_compile(p[1])
Esempio n. 48
0
def p_bipush(p):
    '''bipush : BIPUSH BYTE'''
    p[0] = opc_compile(p[1])
    p[0] += bytes([p[2]])
Esempio n. 49
0
def p_ireturn(p):
    '''ireturn : IRETURN'''
    p[0] = opc_compile(p[1])
Esempio n. 50
0
def p_return(p):
    '''return : RETURN'''
    p[0] = opc_compile(p[1])
Esempio n. 51
0
def p_bipush(p):
    '''bipush : BIPUSH BYTE'''
    p[0] = opc_compile(p[1])
    p[0] += bytes([p[2]])
Esempio n. 52
0
def p_nop(p):
    '''nop : NOP'''
    p[0] = opc_compile(p[1])
Esempio n. 53
0
def p_return(p):
    '''return : RETURN'''
    p[0] = opc_compile(p[1])
Esempio n. 54
0
def p_nop(p):
    '''nop : NOP'''
    p[0] = opc_compile(p[1])