Search in sources :

Example 1 with LineNumberTableAttribute

use of com.oracle.truffle.espresso.classfile.attributes.LineNumberTableAttribute in project graal by oracle.

the class BytecodeNode method getSourceSectionAtBCI.

public SourceSection getSourceSectionAtBCI(int bci) {
    Source s = getSource();
    if (s == null) {
        return null;
    }
    LineNumberTableAttribute table = getMethodVersion().getLineNumberTableAttribute();
    if (table == LineNumberTableAttribute.EMPTY) {
        return null;
    }
    int line = table.getLineNumber(bci);
    return s.createSection(line);
}
Also used : LineNumberTableAttribute(com.oracle.truffle.espresso.classfile.attributes.LineNumberTableAttribute) Source(com.oracle.truffle.api.source.Source) TruffleSafepoint(com.oracle.truffle.api.TruffleSafepoint)

Example 2 with LineNumberTableAttribute

use of com.oracle.truffle.espresso.classfile.attributes.LineNumberTableAttribute in project graal by oracle.

the class EspressoMethodNode method getSourceSection.

@TruffleBoundary
@Override
public final SourceSection getSourceSection() {
    Source s = getSource();
    if (s == null) {
        return null;
    }
    if (sourceSection == null) {
        SourceSection localSourceSection = null;
        LineNumberTableAttribute lineNumberTable = method.getLineNumberTableAttribute();
        if (lineNumberTable != LineNumberTableAttribute.EMPTY) {
            List<LineNumberTableAttribute.Entry> entries = lineNumberTable.getEntries();
            int startLine = Integer.MAX_VALUE;
            int endLine = 0;
            for (int i = 0; i < entries.size(); i++) {
                int line = entries.get(i).getLineNumber();
                if (line > endLine) {
                    endLine = line;
                }
                if (line < startLine) {
                    startLine = line;
                }
            }
            if (startLine >= 1 && endLine >= 1 && startLine <= endLine) {
                localSourceSection = s.createSection(startLine, 1, endLine, 1);
            }
        // (else) Most likely generated bytecodes with dummy LineNumberTable attribute.
        }
        if (localSourceSection == null) {
            localSourceSection = s.createUnavailableSection();
        }
        synchronized (this) {
            if (sourceSection == null) {
                sourceSection = localSourceSection;
            }
        }
    }
    return sourceSection;
}
Also used : LineNumberTableAttribute(com.oracle.truffle.espresso.classfile.attributes.LineNumberTableAttribute) SourceSection(com.oracle.truffle.api.source.SourceSection) Source(com.oracle.truffle.api.source.Source) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

Example 3 with LineNumberTableAttribute

use of com.oracle.truffle.espresso.classfile.attributes.LineNumberTableAttribute in project graal by oracle.

the class Method method isLastLine.

public boolean isLastLine(long codeIndex) {
    LineNumberTableAttribute table = getLineNumberTable();
    int lastLine = table.getLastLine();
    int lineAt = table.getLineNumber((int) codeIndex);
    return lastLine == lineAt;
}
Also used : LineNumberTableAttribute(com.oracle.truffle.espresso.classfile.attributes.LineNumberTableAttribute)

Aggregations

LineNumberTableAttribute (com.oracle.truffle.espresso.classfile.attributes.LineNumberTableAttribute)3 Source (com.oracle.truffle.api.source.Source)2 TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)1 TruffleSafepoint (com.oracle.truffle.api.TruffleSafepoint)1 SourceSection (com.oracle.truffle.api.source.SourceSection)1