annotate graal/com.oracle.truffle.api/src/com/oracle/truffle/api/SourceSection.java @ 13107:91933915d1d0

minor fix to output format of CITime
author Doug Simon <doug.simon@oracle.com>
date Fri, 22 Nov 2013 01:22:34 +0100
parents 5f532ea846fb
children 69d2e4baa215
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9254
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
11279
494b818b527c Adding "Classpath" exception to the classes in the com.oracle.truffle.api and the com.oracle.truffle.api.dsl package.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9989
diff changeset
7 * published by the Free Software Foundation. Oracle designates this
494b818b527c Adding "Classpath" exception to the classes in the com.oracle.truffle.api and the com.oracle.truffle.api.dsl package.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9989
diff changeset
8 * particular file as subject to the "Classpath" exception as provided
494b818b527c Adding "Classpath" exception to the classes in the com.oracle.truffle.api and the com.oracle.truffle.api.dsl package.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9989
diff changeset
9 * by Oracle in the LICENSE file that accompanied this code.
9254
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 *
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * This code is distributed in the hope that it will be useful, but WITHOUT
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 * version 2 for more details (a copy is included in the LICENSE file that
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * accompanied this code).
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 *
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License version
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 * 2 along with this work; if not, write to the Free Software Foundation,
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 *
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 * or visit www.oracle.com if you need additional information or have any
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
23 * questions.
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24 */
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
25 package com.oracle.truffle.api;
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
26
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
27 /**
11610
5f532ea846fb applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents: 11279
diff changeset
28 * Description of contiguous text section within the source code of a guest language program.
9254
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
29 */
11610
5f532ea846fb applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents: 11279
diff changeset
30 public interface SourceSection {
9254
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
31
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
32 /**
9989
b9b8af46c2b7 Upgrade the documentation for SourceSection, especially with respect to the specification of text locations.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 9822
diff changeset
33 * Returns the object representing the source program that contains this section.
9254
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
34 *
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
35 * @return the source object
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
36 */
11610
5f532ea846fb applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents: 11279
diff changeset
37 Source getSource();
9254
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
38
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
39 /**
9989
b9b8af46c2b7 Upgrade the documentation for SourceSection, especially with respect to the specification of text locations.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 9822
diff changeset
40 * Returns 1-based line number of the first character in this source section (inclusive).
9254
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
41 *
9989
b9b8af46c2b7 Upgrade the documentation for SourceSection, especially with respect to the specification of text locations.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 9822
diff changeset
42 * @return the starting line number
9254
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
43 */
11610
5f532ea846fb applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents: 11279
diff changeset
44 int getStartLine();
9254
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
45
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
46 /**
9989
b9b8af46c2b7 Upgrade the documentation for SourceSection, especially with respect to the specification of text locations.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 9822
diff changeset
47 * Returns the 1-based column number of the first character in this source section (inclusive).
9254
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
48 *
9989
b9b8af46c2b7 Upgrade the documentation for SourceSection, especially with respect to the specification of text locations.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 9822
diff changeset
49 * @return the starting column number
9254
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
50 */
11610
5f532ea846fb applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents: 11279
diff changeset
51 int getStartColumn();
9254
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
52
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
53 /**
9989
b9b8af46c2b7 Upgrade the documentation for SourceSection, especially with respect to the specification of text locations.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 9822
diff changeset
54 * Returns the 0-based index of the first character in this source section.
b9b8af46c2b7 Upgrade the documentation for SourceSection, especially with respect to the specification of text locations.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 9822
diff changeset
55 * <p>
b9b8af46c2b7 Upgrade the documentation for SourceSection, especially with respect to the specification of text locations.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 9822
diff changeset
56 * The complete text of the source that contains this section can be retrieved via
b9b8af46c2b7 Upgrade the documentation for SourceSection, especially with respect to the specification of text locations.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 9822
diff changeset
57 * {@link Source#getCode()}.
9254
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
58 *
9989
b9b8af46c2b7 Upgrade the documentation for SourceSection, especially with respect to the specification of text locations.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 9822
diff changeset
59 * @return the starting character index
9254
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
60 */
11610
5f532ea846fb applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents: 11279
diff changeset
61 int getCharIndex();
9254
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
62
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
63 /**
9989
b9b8af46c2b7 Upgrade the documentation for SourceSection, especially with respect to the specification of text locations.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 9822
diff changeset
64 * Returns the length of this source section in characters.
b9b8af46c2b7 Upgrade the documentation for SourceSection, especially with respect to the specification of text locations.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 9822
diff changeset
65 * <p>
b9b8af46c2b7 Upgrade the documentation for SourceSection, especially with respect to the specification of text locations.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 9822
diff changeset
66 * The complete text of the source that contains this section can be retrieved via
b9b8af46c2b7 Upgrade the documentation for SourceSection, especially with respect to the specification of text locations.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 9822
diff changeset
67 * {@link Source#getCode()}.
9254
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
68 *
9989
b9b8af46c2b7 Upgrade the documentation for SourceSection, especially with respect to the specification of text locations.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 9822
diff changeset
69 * @return the number of characters in the section
9254
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
70 */
11610
5f532ea846fb applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents: 11279
diff changeset
71 int getCharLength();
5f532ea846fb applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents: 11279
diff changeset
72
5f532ea846fb applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents: 11279
diff changeset
73 /**
5f532ea846fb applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents: 11279
diff changeset
74 * Returns the index of the text position immediately following the last character in the
5f532ea846fb applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents: 11279
diff changeset
75 * section.
5f532ea846fb applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents: 11279
diff changeset
76 *
5f532ea846fb applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents: 11279
diff changeset
77 * @return the end position of the section
5f532ea846fb applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents: 11279
diff changeset
78 */
5f532ea846fb applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents: 11279
diff changeset
79 int getCharEndIndex();
9254
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
80
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
81 /**
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
82 * Returns the identifier of this source section that is used for printing the section.
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
83 *
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
84 * @return the identifier of the section
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
85 */
11610
5f532ea846fb applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents: 11279
diff changeset
86 String getIdentifier();
9284
5054a206fcf0 Remove endLine and endIndex from SourceSection class and add charIndex and charLength instead. Also add getCode() method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9254
diff changeset
87
5054a206fcf0 Remove endLine and endIndex from SourceSection class and add charIndex and charLength instead. Also add getCode() method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9254
diff changeset
88 /**
9989
b9b8af46c2b7 Upgrade the documentation for SourceSection, especially with respect to the specification of text locations.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 9822
diff changeset
89 * Returns text of the code represented by this source section.
9284
5054a206fcf0 Remove endLine and endIndex from SourceSection class and add charIndex and charLength instead. Also add getCode() method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9254
diff changeset
90 *
5054a206fcf0 Remove endLine and endIndex from SourceSection class and add charIndex and charLength instead. Also add getCode() method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9254
diff changeset
91 * @return the code as a String object
5054a206fcf0 Remove endLine and endIndex from SourceSection class and add charIndex and charLength instead. Also add getCode() method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9254
diff changeset
92 */
11610
5f532ea846fb applied changes to basic-graal that were made in a downstream repo
Doug Simon <doug.simon@oracle.com>
parents: 11279
diff changeset
93 String getCode();
9822
e210293dca77 Generated hashCode and equals for SourceSection. Source is abstract, so just uses identity methods for that.
Chris Seaton <chris.seaton@oracle.com>
parents: 9775
diff changeset
94
9254
4497235516df New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
95 }