changeset 22249:bda4b68f2e07

Truffle/Source: the "unavailable" SourceSection kind now provides a default name "<unknown>" if one not supplied.
author Michael Van De Vanter <michael.van.de.vanter@oracle.com>
date Thu, 24 Sep 2015 13:11:19 -0700
parents 6d328e688339
children 0fb3522e5b72
files truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/source/SourceSection.java
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/source/SourceSection.java	Wed Sep 23 21:48:02 2015 -0700
+++ b/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/source/SourceSection.java	Thu Sep 24 13:11:19 2015 -0700
@@ -98,7 +98,7 @@
 
     /**
      * Gets a representation of the first line of the section, suitable for a hash key.
-     * 
+     *
      * @return first line of the section
      */
     public LineLocation getLineLocation() {
@@ -175,7 +175,7 @@
      * @return the code as a String object
      */
     public String getCode() {
-        return getSource().getCode(charIndex, charLength);
+        return source == null ? "<unavailable>" : source.getCode(charIndex, charLength);
     }
 
     /**
@@ -262,6 +262,6 @@
      * @return source section which is mostly <em>empty</em>
      */
     public static SourceSection createUnavailable(String kind, String name) {
-        return new SourceSection(kind, null, name, -1, -1, -1, -1);
+        return new SourceSection(kind, null, name == null ? "<unknown>" : name, -1, -1, -1, -1);
     }
 }