Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/SourceSection.java @ 9254:4497235516df
New API for representing Source objects and SourceSection objects. SourceSection objects can be associated with Truffle interpreter nodes.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Tue, 23 Apr 2013 14:59:24 +0200 |
parents | |
children | 5054a206fcf0 |
comparison
equal
deleted
inserted
replaced
9246:ba3dfa9e36d8 | 9254:4497235516df |
---|---|
1 /* | |
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
23 package com.oracle.truffle.api; | |
24 | |
25 /** | |
26 * Represents a section in the source code of a guest language program. | |
27 */ | |
28 public class SourceSection { | |
29 | |
30 private final Source source; | |
31 private final String identifier; | |
32 private final int startLine; | |
33 private final int startColumn; | |
34 private final int endLine; | |
35 private final int endColumn; | |
36 | |
37 /** | |
38 * Creates a new object representing a section in the source code of a guest language program. | |
39 * | |
40 * @param source object representing the source program this is should be a section of | |
41 * @param identifier an identifier used when printing the section | |
42 * @param startLine the index of the start line of the section (inclusive) | |
43 * @param startColumn the index of the start column of the section (inclusive) | |
44 * @param endLine the index of the end line of the section (inclusive) | |
45 * @param endColumn the index of the end column of the section (inclusive) | |
46 */ | |
47 public SourceSection(Source source, String identifier, int startLine, int startColumn, int endLine, int endColumn) { | |
48 this.source = source; | |
49 this.identifier = identifier; | |
50 this.startLine = startLine; | |
51 this.startColumn = startColumn; | |
52 this.endLine = endLine; | |
53 this.endColumn = endColumn; | |
54 } | |
55 | |
56 /** | |
57 * Returns the source object representing the source program this is a section of. | |
58 * | |
59 * @return the source object | |
60 */ | |
61 public final Source getSource() { | |
62 return source; | |
63 } | |
64 | |
65 /** | |
66 * Returns the index of the start line of this source section (inclusive). | |
67 * | |
68 * @return the start line | |
69 */ | |
70 public final int getStartLine() { | |
71 return startLine; | |
72 } | |
73 | |
74 /** | |
75 * Returns the index of the start column of this source section (inclusive). | |
76 * | |
77 * @return the start column | |
78 */ | |
79 public final int getStartColumn() { | |
80 return startColumn; | |
81 } | |
82 | |
83 /** | |
84 * Returns the index of the end line of this source section (inclusive). | |
85 * | |
86 * @return the end line | |
87 */ | |
88 public final int getEndLine() { | |
89 return endLine; | |
90 } | |
91 | |
92 /** | |
93 * Returns the index of the end column of this source section (inclusive). | |
94 * | |
95 * @return the end column | |
96 */ | |
97 public final int getEndColumn() { | |
98 return endColumn; | |
99 } | |
100 | |
101 /** | |
102 * Returns the identifier of this source section that is used for printing the section. | |
103 * | |
104 * @return the identifier of the section | |
105 */ | |
106 public final String getIdentifier() { | |
107 return identifier; | |
108 } | |
109 } |