comparison 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
comparison
equal deleted inserted replaced
13306:dfb780080923 13455:69d2e4baa215
22 * or visit www.oracle.com if you need additional information or have any 22 * or visit www.oracle.com if you need additional information or have any
23 * questions. 23 * questions.
24 */ 24 */
25 package com.oracle.truffle.api; 25 package com.oracle.truffle.api;
26 26
27 import java.io.*;
28
27 /** 29 /**
28 * Represents the source code of a guest language program. 30 * Represents a unit (typically a file) of guest language source code.
29 */ 31 */
30 public interface Source { 32 public interface Source {
31 33
32 /** 34 /**
33 * Returns the name of this resource holding a guest language program. An example would be the 35 * Returns the name of this resource holding a guest language program. An example would be the
36 * @return the name of the guest language program 38 * @return the name of the guest language program
37 */ 39 */
38 String getName(); 40 String getName();
39 41
40 /** 42 /**
41 * Returns the guest language source code represented by this source object. 43 * The normalized, canonical name of the file.
42 * 44 */
43 * @return the source code as a String object 45 String getPath();
46
47 /**
48 * Access to the source contents.
49 */
50 Reader getReader();
51
52 /**
53 * Access to the source contents.
54 */
55 InputStream getInputStream();
56
57 /**
58 * Return the complete text of the code.
44 */ 59 */
45 String getCode(); 60 String getCode();
61
62 /**
63 * Given a 1-based line number, return the text in the line, not including a possible
64 * terminating newline.
65 */
66 String getCode(int lineNumber);
67
68 /**
69 * The number of text lines in the source, including empty lines; characters at the end of the
70 * source without a terminating newline count as a line.
71 */
72 int getLineCount();
73
74 /**
75 * Given a 0-based character offset, return the 1-based number of the line that includes the
76 * position.
77 */
78 int getLineNumber(int offset);
79
80 /**
81 * Given a 1-based line number, return the 0-based offset of the first character in the line.
82 */
83 int getLineStartOffset(int lineNumber);
84
85 /**
86 * The number of characters (not counting a possible terminating newline) in a (1-based)
87 * numbered line.
88 */
89 int getLineLength(int lineNumber);
90
46 } 91 }