changeset 9288:cadb3702cb8f

Merge.
author Christian Humer <christian.humer@gmail.com>
date Wed, 24 Apr 2013 21:50:26 +0200
parents 8e3a1635cc9e (current diff) 5054a206fcf0 (diff)
children 17b598df8da9 90ca451a2f28 e6251a86e8e3
files
diffstat 2 files changed, 36 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- 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) {
+    }
 }
--- 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);
+    }
 }