12
12
import java .util .Arrays ;
13
13
import java .util .Iterator ;
14
14
15
- import com .oracle .truffle .api .library .CachedLibrary ;
16
15
import org .jcodings .Encoding ;
17
16
import org .joni .NameEntry ;
18
17
import org .joni .Regex ;
30
29
import org .truffleruby .core .array .ArrayIndexNodes ;
31
30
import org .truffleruby .core .array .ArrayOperations ;
32
31
import org .truffleruby .core .array .ArrayUtils ;
33
- import org .truffleruby .core .cast .ToIntNode ;
34
32
import org .truffleruby .core .cast .IntegerCastNode ;
33
+ import org .truffleruby .core .cast .ToIntNode ;
35
34
import org .truffleruby .core .regexp .MatchDataNodesFactory .ValuesNodeFactory ;
36
35
import org .truffleruby .core .rope .Rope ;
37
36
import org .truffleruby .core .rope .RopeNodes ;
41
40
import org .truffleruby .core .symbol .RubySymbol ;
42
41
import org .truffleruby .language .Nil ;
43
42
import org .truffleruby .language .NotProvided ;
44
- import org .truffleruby .language .library .RubyLibrary ;
45
43
import org .truffleruby .language .RubyNode ;
46
44
import org .truffleruby .language .Visibility ;
47
45
import org .truffleruby .language .control .RaiseException ;
48
46
import org .truffleruby .language .dispatch .CallDispatchHeadNode ;
47
+ import org .truffleruby .language .library .RubyLibrary ;
49
48
import org .truffleruby .language .objects .AllocateObjectNode ;
50
49
51
50
import com .oracle .truffle .api .CompilerDirectives ;
52
51
import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
53
52
import com .oracle .truffle .api .dsl .Cached ;
54
53
import com .oracle .truffle .api .dsl .Specialization ;
54
+ import com .oracle .truffle .api .library .CachedLibrary ;
55
55
import com .oracle .truffle .api .object .DynamicObject ;
56
- import com .oracle .truffle .api .profiles .BranchProfile ;
57
56
import com .oracle .truffle .api .profiles .ConditionProfile ;
58
57
59
58
@ CoreModule (value = "MatchData" , isClass = true )
@@ -230,7 +229,7 @@ public static GetIndexNode create(RubyNode... nodes) {
230
229
return MatchDataNodesFactory .GetIndexNodeFactory .create (nodes );
231
230
}
232
231
233
- public abstract Object executeGetIndex (Object matchData , Object index , Object length );
232
+ protected abstract Object executeGetIndex (Object matchData , int index , NotProvided length );
234
233
235
234
@ Specialization
236
235
protected Object getIndex (DynamicObject matchData , int index , NotProvided length ,
@@ -283,14 +282,12 @@ protected Object getIndexSymbolSingleMatch(DynamicObject matchData, RubySymbol i
283
282
return executeGetIndex (matchData , backRefIndex , NotProvided .INSTANCE );
284
283
} else {
285
284
final int i = getBackRef (matchData , regexp , name );
286
-
287
285
return executeGetIndex (matchData , i , NotProvided .INSTANCE );
288
286
}
289
287
}
290
288
291
289
@ Specialization
292
- protected Object getIndexSymbol (DynamicObject matchData , RubySymbol index , NotProvided length ,
293
- @ Cached BranchProfile errorProfile ) {
290
+ protected Object getIndexSymbol (DynamicObject matchData , RubySymbol index , NotProvided length ) {
294
291
return executeGetIndex (matchData , getBackRefFromSymbol (matchData , index ), NotProvided .INSTANCE );
295
292
}
296
293
@@ -299,7 +296,8 @@ protected Object getIndexString(DynamicObject matchData, DynamicObject index, No
299
296
return executeGetIndex (matchData , getBackRefFromString (matchData , index ), NotProvided .INSTANCE );
300
297
}
301
298
302
- @ Specialization (guards = { "!isRubySymbol(index)" , "!isRubyString(index)" , "!isIntRange(index)" })
299
+ @ Specialization (
300
+ guards = { "!isInteger(index)" , "!isRubySymbol(index)" , "!isRubyString(index)" , "!isIntRange(index)" })
303
301
protected Object getIndex (DynamicObject matchData , Object index , NotProvided length ,
304
302
@ Cached ToIntNode toIntNode ) {
305
303
return executeGetIndex (matchData , toIntNode .execute (index ), NotProvided .INSTANCE );
0 commit comments