Mercurial > hg > truffle
changeset 22038:5cefc50e3379
Merge
author | Mick Jordan <mick.jordan@oracle.com> |
---|---|
date | Mon, 27 Jul 2015 15:58:58 -0700 |
parents | a4c9f8c89c68 (current diff) 494b5e7094d0 (diff) |
children | fb6c6070b64d |
files | truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java |
diffstat | 2 files changed, 12 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java Mon Jul 27 16:34:38 2015 +0200 +++ b/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java Mon Jul 27 15:58:58 2015 -0700 @@ -113,7 +113,7 @@ /** * Clears any previously assigned guest language source code from this node. */ - public final void clearSourceSection() { + public void clearSourceSection() { this.sourceSection = null; }
--- a/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/source/Source.java Mon Jul 27 16:34:38 2015 +0200 +++ b/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/source/Source.java Mon Jul 27 15:58:58 2015 -0700 @@ -1273,6 +1273,9 @@ */ public int offsetToLine(int offset) throws IllegalArgumentException { if (offset < 0 || offset >= textLength) { + if (offset == 0 && textLength == 0) { + return 1; + } throw new IllegalArgumentException("offset out of bounds"); } int line = 1; @@ -1319,7 +1322,10 @@ * @throws IllegalArgumentException if there is no such line in the text. */ public int lineStartOffset(int line) throws IllegalArgumentException { - if (textLength == 0 || lineOutOfRange(line)) { + if (textLength == 0) { + return 0; + } + if (lineOutOfRange(line)) { throw new IllegalArgumentException("line out of bounds"); } return nlOffsets[line - 1]; @@ -1332,7 +1338,10 @@ * @throws IllegalArgumentException if there is no such line in the text. */ public int lineLength(int line) throws IllegalArgumentException { - if (textLength == 0 || lineOutOfRange(line)) { + if (textLength == 0) { + return 0; + } + if (lineOutOfRange(line)) { throw new IllegalArgumentException("line out of bounds"); } if (line == nlOffsets.length - 1 && !finalNL) {