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