Mercurial > hg > graal-jvmci-8
diff graal/com.oracle.truffle.api/src/com/oracle/truffle/api/Source.java @ 13455:69d2e4baa215
Truffle: new infrastructure related to instrumentation, and in particular debugging: support for managing Source objects; framework for generalized "instrumentation proxy nodes" (to be inserted into ASTs with no runtime cost when inactive), and "probes" (which can be attached to proxy nodes to receive event notification); a rudimentary interface and abstract implementation for a "debug manager" (mostly a placeholder at this point); and the beginning of a language-agnostic ExecutionContext interface.
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Tue, 17 Dec 2013 20:22:45 -0800 |
parents | 494b818b527c |
children | c54f5fa05fd5 |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/Source.java Thu Dec 12 14:56:52 2013 -0800 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/Source.java Tue Dec 17 20:22:45 2013 -0800 @@ -24,8 +24,10 @@ */ package com.oracle.truffle.api; +import java.io.*; + /** - * Represents the source code of a guest language program. + * Represents a unit (typically a file) of guest language source code. */ public interface Source { @@ -38,9 +40,52 @@ String getName(); /** - * Returns the guest language source code represented by this source object. - * - * @return the source code as a String object + * The normalized, canonical name of the file. + */ + String getPath(); + + /** + * Access to the source contents. + */ + Reader getReader(); + + /** + * Access to the source contents. + */ + InputStream getInputStream(); + + /** + * Return the complete text of the code. */ String getCode(); + + /** + * Given a 1-based line number, return the text in the line, not including a possible + * terminating newline. + */ + String getCode(int lineNumber); + + /** + * The number of text lines in the source, including empty lines; characters at the end of the + * source without a terminating newline count as a line. + */ + int getLineCount(); + + /** + * Given a 0-based character offset, return the 1-based number of the line that includes the + * position. + */ + int getLineNumber(int offset); + + /** + * Given a 1-based line number, return the 0-based offset of the first character in the line. + */ + int getLineStartOffset(int lineNumber); + + /** + * The number of characters (not counting a possible terminating newline) in a (1-based) + * numbered line. + */ + int getLineLength(int lineNumber); + }