# HG changeset patch # User Christian Humer # Date 1366833026 -7200 # Node ID cadb3702cb8f1a8fdc45f752462d77f802738e5c # Parent 8e3a1635cc9e7266e9d6a9318b91d98fa3e46f8d# Parent 5054a206fcf0af328a246b7ea49203e640c93002 Merge. diff -r 8e3a1635cc9e -r cadb3702cb8f graal/com.oracle.truffle.api/src/com/oracle/truffle/api/CompilerDirectives.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/CompilerDirectives.java Wed Apr 24 21:50:03 2013 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/CompilerDirectives.java Wed Apr 24 21:50:26 2013 +0200 @@ -77,4 +77,12 @@ public static void injectBranchProbability(double probability) { assert probability >= 0.0 && probability <= 1.0; } + + /** + * Bails out of a compilation (e.g., for guest language features that should never be compiled). + * + * @param reason the reason for the bailout + */ + public static void bailout(String reason) { + } } diff -r 8e3a1635cc9e -r cadb3702cb8f graal/com.oracle.truffle.api/src/com/oracle/truffle/api/SourceSection.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/SourceSection.java Wed Apr 24 21:50:03 2013 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/SourceSection.java Wed Apr 24 21:50:26 2013 +0200 @@ -31,26 +31,26 @@ private final String identifier; private final int startLine; private final int startColumn; - private final int endLine; - private final int endColumn; + private final int charIndex; + private final int charLength; /** * Creates a new object representing a section in the source code of a guest language program. * * @param source object representing the source program this is should be a section of * @param identifier an identifier used when printing the section - * @param startLine the index of the start line of the section (inclusive) - * @param startColumn the index of the start column of the section (inclusive) - * @param endLine the index of the end line of the section (inclusive) - * @param endColumn the index of the end column of the section (inclusive) + * @param startLine the index of the start line of the section + * @param startColumn the index of the start column of the section + * @param charIndex the index of the first character of the section + * @param charLength the length of the section in number of characters */ - public SourceSection(Source source, String identifier, int startLine, int startColumn, int endLine, int endColumn) { + public SourceSection(Source source, String identifier, int startLine, int startColumn, int charIndex, int charLength) { this.source = source; this.identifier = identifier; this.startLine = startLine; this.startColumn = startColumn; - this.endLine = endLine; - this.endColumn = endColumn; + this.charIndex = charIndex; + this.charLength = charLength; } /** @@ -81,21 +81,23 @@ } /** - * Returns the index of the end line of this source section (inclusive). + * Returns the index of the first character of this section. All characters of the source can be + * retrieved via the {@link Source#getCode()} method. * - * @return the end line + * @return the character index */ - public final int getEndLine() { - return endLine; + public final int getCharIndex() { + return charIndex; } /** - * Returns the index of the end column of this source section (inclusive). + * Returns the length of this section in characters. All characters of the source can be + * retrieved via the {@link Source#getCode()} method. * - * @return the end column + * @return the character length */ - public final int getEndColumn() { - return endColumn; + public final int getCharLength() { + return charLength; } /** @@ -106,4 +108,13 @@ public final String getIdentifier() { return identifier; } + + /** + * Returns the code represented by this code section. + * + * @return the code as a String object + */ + public final String getCode() { + return getSource().getCode().substring(charIndex, charLength); + } }