Search in sources :

Example 1 with CTypeParser

use of com.ibm.j9ddr.CTypeParser in project openj9 by eclipse.

the class StructureStubGenerator method writeOffsetStub.

private static void writeOffsetStub(PrintWriter writer, FieldDescriptor fieldDescriptor, String className, String postFix) {
    String getter = fieldDescriptor.getName();
    CTypeParser parser = new CTypeParser(fieldDescriptor.getType());
    if (parser.getSuffix().contains(":")) {
        writer.format("\tpublic static final int _%s_s_;%n", getter);
        writer.format("\tpublic static final int _%s_b_;%n", getter);
    } else {
        writer.format("\tpublic static final int _%s%s_;%n", getter, postFix);
    }
}
Also used : CTypeParser(com.ibm.j9ddr.CTypeParser)

Example 2 with CTypeParser

use of com.ibm.j9ddr.CTypeParser in project openj9 by eclipse.

the class PointerGenerator method writeBitFieldMethod.

private void writeBitFieldMethod(PrintWriter writer, StructureDescriptor structure, FieldDescriptor fieldDescriptor, int type, String getter) {
    CTypeParser parser = new CTypeParser(fieldDescriptor.getType());
    String typeString = parser.getCoreType();
    if (getter.length() == 0) {
        writer.format("\t// %s %s%n", fieldDescriptor.getDeclaredType(), fieldDescriptor.getName());
        writer.println();
        return;
    }
    if (cacheFields) {
        writer.format("\tprivate %s %s_cache;%n", typeString, getter);
    }
    writeMethodSignature(writer, typeString, getter, fieldDescriptor, true);
    if (cacheFields) {
        writer.format("\t\tif (CACHE_FIELDS) {%n");
        writer.format("\t\t\tif (%s_cache == null) {%n", getter);
        writer.format("\t\t\t\t%s_cache = get%sBitfield(%s._%s_s_, %s._%s_b_);%n", getter, typeString, structure.getName(), getter, structure.getName(), getter);
        writer.format("\t\t\t}%n");
        writer.format("\t\t\treturn %s_cache;%n", getter);
        writer.format("\t\t} else {%n\t");
    }
    writer.format("\t\treturn get%sBitfield(%s._%s_s_, %s._%s_b_);%n", typeString, structure.getName(), getter, structure.getName(), getter);
    if (cacheFields) {
        writer.println("\t\t}");
    }
    writeMethodClose(writer);
}
Also used : CTypeParser(com.ibm.j9ddr.CTypeParser)

Example 3 with CTypeParser

use of com.ibm.j9ddr.CTypeParser in project openj9 by eclipse.

the class CStringFieldFormatter method postFormat.

@Override
public FormatWalkResult postFormat(String name, String type, String declaredType, int typeCode, long address, PrintStream out, Context context, IStructureFormatter structureFormatter) throws CorruptDataException {
    if (typeCode == StructureTypeManager.TYPE_POINTER) {
        CTypeParser parser = new CTypeParser(declaredType);
        if (parser.getCoreType().equals("char") && parser.getSuffix().equals("*")) {
            U8Pointer ptr = U8Pointer.cast(PointerPointer.cast(address).at(0));
            if (ptr.isNull()) {
                return FormatWalkResult.KEEP_WALKING;
            }
            String str = ptr.getCStringAtOffset(0, MAXIMUM_LENGTH);
            if (str.length() > 0) {
                out.print(" // \"");
                out.print(str);
                if (str.length() >= MAXIMUM_LENGTH) {
                    out.print("...");
                }
                out.print("\"");
            }
        }
    }
    return FormatWalkResult.KEEP_WALKING;
}
Also used : U8Pointer(com.ibm.j9ddr.vm29.pointer.U8Pointer) CTypeParser(com.ibm.j9ddr.CTypeParser)

Example 4 with CTypeParser

use of com.ibm.j9ddr.CTypeParser in project openj9 by eclipse.

the class CTypeParserTest method testSimpleArray3.

@Test
public void testSimpleArray3() {
    CTypeParser sut = new CTypeParser("int [ ]");
    assertEquals("", sut.getPrefix());
    assertEquals("int", sut.getCoreType());
    assertEquals("[]", sut.getSuffix());
}
Also used : CTypeParser(com.ibm.j9ddr.CTypeParser) Test(org.junit.Test)

Example 5 with CTypeParser

use of com.ibm.j9ddr.CTypeParser in project openj9 by eclipse.

the class CTypeParserTest method testVolatilePointers.

@Test
public void testVolatilePointers() {
    CTypeParser sut = new CTypeParser("const int * volatile");
    assertEquals("const ", sut.getPrefix());
    assertEquals("int", sut.getCoreType());
    assertEquals("* volatile", sut.getSuffix());
}
Also used : CTypeParser(com.ibm.j9ddr.CTypeParser) Test(org.junit.Test)

Aggregations

CTypeParser (com.ibm.j9ddr.CTypeParser)20 Test (org.junit.Test)16 FieldDescriptor (com.ibm.j9ddr.StructureReader.FieldDescriptor)1 U8Pointer (com.ibm.j9ddr.vm29.pointer.U8Pointer)1