@@ -57,6 +57,7 @@ public abstract class RubyNode extends RubyBaseNodeWithExecute implements Instru
57
57
private static final byte FLAG_ROOT = 3 ; // 1<<3 = 8
58
58
59
59
protected static final int NO_SOURCE = -1 ;
60
+ private static final int UNAVAILABLE_SOURCE_SECTION_LENGTH = -1 ;
60
61
61
62
// Used when the return value of a node is ignored syntactically.
62
63
// Returns Nil instead of void to force RubyNodeWrapper to call `delegateNode.executeVoid(frame)`, otherwise
@@ -85,21 +86,13 @@ public boolean hasSource() {
85
86
return isAdoptable () && getSourceCharIndex () != NO_SOURCE ;
86
87
}
87
88
88
- public void unsafeSetSourceSection (SourceIndexLength sourceIndexLength ) {
89
- assert !hasSource ();
90
-
91
- if (sourceIndexLength != null ) {
92
- unsafeSetSourceSection (sourceIndexLength .getCharIndex (), sourceIndexLength .getLength ());
93
- }
94
- }
95
-
96
89
public void unsafeSetSourceSection (SourceSection sourceSection ) {
97
90
assert !hasSource ();
98
91
99
92
if (sourceSection .isAvailable ()) {
100
93
unsafeSetSourceSection (sourceSection .getCharIndex (), sourceSection .getCharLength ());
101
94
} else {
102
- unsafeSetSourceSection (0 , SourceIndexLength . UNAVAILABLE );
95
+ unsafeSetSourceSection (0 , UNAVAILABLE_SOURCE_SECTION_LENGTH );
103
96
}
104
97
}
105
98
@@ -121,14 +114,6 @@ public RubyNode copySourceSection(RubyNode from) {
121
114
return this ;
122
115
}
123
116
124
- public SourceIndexLength getSourceIndexLength () {
125
- if (!hasSource ()) {
126
- return null ;
127
- } else {
128
- return new SourceIndexLength (getSourceCharIndex (), getSourceLength ());
129
- }
130
- }
131
-
132
117
@ Override
133
118
@ TruffleBoundary
134
119
public SourceSection getSourceSection () {
@@ -141,7 +126,7 @@ public SourceSection getSourceSection() {
141
126
}
142
127
143
128
int sourceLength = getSourceLength ();
144
- if (sourceLength == SourceIndexLength . UNAVAILABLE ) {
129
+ if (sourceLength == UNAVAILABLE_SOURCE_SECTION_LENGTH ) {
145
130
return source .createUnavailableSection ();
146
131
} else {
147
132
return source .createSection (getSourceCharIndex (), sourceLength );
@@ -166,23 +151,6 @@ private Source getSource() {
166
151
return sourceSection .getSource ();
167
152
}
168
153
169
- public SourceIndexLength getEncapsulatingSourceIndexLength () {
170
- Node node = this ;
171
- while (node != null ) {
172
- if (node instanceof RubyNode && ((RubyNode ) node ).hasSource ()) {
173
- return ((RubyNode ) node ).getSourceIndexLength ();
174
- }
175
-
176
- if (node instanceof RootNode ) {
177
- return SourceIndexLength .fromSourceSection (node .getSourceSection ());
178
- }
179
-
180
- node = node .getParent ();
181
- }
182
-
183
- return null ;
184
- }
185
-
186
154
@ Override
187
155
public String toString () {
188
156
return super .toString () + " at " + RubyLanguage .fileLineRange (getSourceSection ());
0 commit comments