Skip to content

Commit 907adf6

Browse files
committed
[GR-41453] Remove usages of term "rope"
PullRequest: truffleruby/3654
2 parents e26d7f7 + c5fed38 commit 907adf6

29 files changed

+186
-181
lines changed

src/main/java/org/truffleruby/core/CoreLibrary.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,6 @@ public CoreLibrary(RubyContext context, RubyLanguage language) {
499499
defineModule(truffleModule, "ObjSpace");
500500
defineModule(truffleModule, "Coverage");
501501
defineModule(truffleModule, "Graal");
502-
defineModule(truffleModule, "Ropes");
503502
truffleRegexpOperationsModule = defineModule(truffleModule, "RegexpOperations");
504503
truffleStringOperationsModule = defineModule(truffleModule, "StringOperations");
505504
truffleBootModule = defineModule(truffleModule, "Boot");
@@ -762,9 +761,10 @@ public void loadRubyCoreLibraryAndPostBoot() {
762761
state = State.LOADED;
763762
}
764763

765-
var sourceRopePair = loadCoreFileSource(language.coreLoadPath + file);
766-
final Source source = sourceRopePair.getLeft();
767-
final RootCallTarget callTarget = context.getCodeLoader().parseTopLevelWithCache(sourceRopePair, node);
764+
var sourceTStringPair = loadCoreFileSource(language.coreLoadPath + file);
765+
final Source source = sourceTStringPair.getLeft();
766+
final RootCallTarget callTarget = context.getCodeLoader().parseTopLevelWithCache(sourceTStringPair,
767+
node);
768768

769769
final CodeLoader.DeferredCall deferredCall = context.getCodeLoader().prepareExecute(
770770
callTarget,

src/main/java/org/truffleruby/core/array/ArrayNodes.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,12 +1596,12 @@ protected RubyString packUncached(RubyArray array, Object format,
15961596
@Cached RubyStringLibrary libFormat,
15971597
@Cached ToJavaStringNode toJavaStringNode,
15981598
@Cached IndirectCallNode callPackNode) {
1599-
final String formatRope = toJavaStringNode.executeToJavaString(format);
1599+
final String formatString = toJavaStringNode.executeToJavaString(format);
16001600

16011601
final BytesResult result;
16021602
try {
16031603
result = (BytesResult) callPackNode.call(
1604-
compileFormat(formatRope),
1604+
compileFormat(formatString),
16051605
new Object[]{ array.getStore(), array.size, false, null });
16061606
} catch (FormatException e) {
16071607
exceptionProfile.enter();

src/main/java/org/truffleruby/core/encoding/EncodingNodes.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ protected RubyEncoding negotiateStandardEncodingAndCr7Bit(
130130
"getCodeRange(first, firstEncoding) == firstCodeRange",
131131
"getCodeRange(second, secondEncoding) == secondCodeRange" },
132132
limit = "getCacheLimit()")
133-
protected RubyEncoding negotiateRopeRopeCached(
133+
protected RubyEncoding negotiateEncodingCached(
134134
AbstractTruffleString first,
135135
RubyEncoding firstEncoding,
136136
AbstractTruffleString second,
@@ -141,19 +141,19 @@ protected RubyEncoding negotiateRopeRopeCached(
141141
@Cached("getCodeRange(second, secondEncoding)") TruffleString.CodeRange secondCodeRange,
142142
@Cached("firstEncoding") RubyEncoding cachedFirstEncoding,
143143
@Cached("secondEncoding") RubyEncoding cachedSecondEncoding,
144-
@Cached("compatibleEncodingForRopes(first, firstEncoding, second, secondEncoding)") RubyEncoding negotiatedEncoding) {
144+
@Cached("compatibleEncodingForStrings(first, firstEncoding, second, secondEncoding)") RubyEncoding negotiatedEncoding) {
145145
assert first.isCompatibleTo(firstEncoding.tencoding) && second.isCompatibleTo(secondEncoding.tencoding);
146146
return negotiatedEncoding;
147147
}
148148

149-
@Specialization(guards = "firstEncoding != secondEncoding", replaces = "negotiateRopeRopeCached")
150-
protected RubyEncoding negotiateRopeRopeUncached(
149+
@Specialization(guards = "firstEncoding != secondEncoding", replaces = "negotiateEncodingCached")
150+
protected RubyEncoding negotiateEncodingUncached(
151151
AbstractTruffleString first,
152152
RubyEncoding firstEncoding,
153153
AbstractTruffleString second,
154154
RubyEncoding secondEncoding) {
155155
assert first.isCompatibleTo(firstEncoding.tencoding) && second.isCompatibleTo(secondEncoding.tencoding);
156-
return compatibleEncodingForRopes(first, firstEncoding, second, secondEncoding);
156+
return compatibleEncodingForStrings(first, firstEncoding, second, secondEncoding);
157157
}
158158

159159
/** This method returns non-null if either:
@@ -163,17 +163,17 @@ protected RubyEncoding negotiateRopeRopeUncached(
163163
* </ul>
164164
*/
165165
@TruffleBoundary
166-
protected RubyEncoding compatibleEncodingForRopes(AbstractTruffleString firstRope, RubyEncoding firstEncoding,
167-
AbstractTruffleString secondRope, RubyEncoding secondEncoding) {
166+
protected RubyEncoding compatibleEncodingForStrings(AbstractTruffleString first, RubyEncoding firstEncoding,
167+
AbstractTruffleString second, RubyEncoding secondEncoding) {
168168
// MRI: enc_compatible_latter
169169
assert firstEncoding != secondEncoding : "this method assumes the encodings are different";
170170

171-
if (secondRope.isEmpty()) {
171+
if (second.isEmpty()) {
172172
return firstEncoding;
173173
}
174-
if (firstRope.isEmpty()) {
174+
if (first.isEmpty()) {
175175
return (firstEncoding.isAsciiCompatible &&
176-
StringGuards.is7Bit(secondRope, secondEncoding, getCodeRangeNode()))
176+
StringGuards.is7Bit(second, secondEncoding, getCodeRangeNode()))
177177
? firstEncoding
178178
: secondEncoding;
179179
}
@@ -182,10 +182,10 @@ protected RubyEncoding compatibleEncodingForRopes(AbstractTruffleString firstRop
182182
return null;
183183
}
184184

185-
if (StringGuards.is7Bit(secondRope, secondEncoding, getCodeRangeNode())) {
185+
if (StringGuards.is7Bit(second, secondEncoding, getCodeRangeNode())) {
186186
return firstEncoding;
187187
}
188-
if (StringGuards.is7Bit(firstRope, firstEncoding, getCodeRangeNode())) {
188+
if (StringGuards.is7Bit(first, firstEncoding, getCodeRangeNode())) {
189189
return secondEncoding;
190190
}
191191

@@ -257,10 +257,10 @@ protected RubyEncoding negotiateSameEncodingUncached(Object first, Object second
257257
protected RubyEncoding negotiateStringStringEncoding(Object first, Object second,
258258
@Cached RubyStringLibrary libFirst,
259259
@Cached RubyStringLibrary libSecond,
260-
@Cached NegotiateCompatibleStringEncodingNode ropeNode) {
260+
@Cached NegotiateCompatibleStringEncodingNode negotiateNode) {
261261
final RubyEncoding firstEncoding = libFirst.getEncoding(first);
262262
final RubyEncoding secondEncoding = libSecond.getEncoding(second);
263-
return ropeNode.execute(
263+
return negotiateNode.execute(
264264
libFirst.getTString(first),
265265
firstEncoding,
266266
libSecond.getTString(second),

src/main/java/org/truffleruby/core/kernel/TruffleKernelNodes.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,13 @@ protected boolean load(Object file, Nil wrapModule,
8585
@Cached RubyStringLibrary strings,
8686
@Cached IndirectCallNode callNode) {
8787
final String feature = RubyGuards.getJavaString(file);
88-
final Pair<Source, TStringWithEncoding> sourceRopePair = getSourceRopePair(feature);
88+
final Pair<Source, TStringWithEncoding> sourceTStringPair = getSourceTStringPair(feature);
8989

9090
final DeclarationContext declarationContext = DeclarationContext.topLevel(getContext());
9191
final LexicalScope lexicalScope = getContext().getRootLexicalScope();
9292
final Object self = getContext().getCoreLibrary().mainObject;
93-
final RootCallTarget callTarget = getContext().getCodeLoader().parseTopLevelWithCache(sourceRopePair, this);
93+
final RootCallTarget callTarget = getContext().getCodeLoader().parseTopLevelWithCache(sourceTStringPair,
94+
this);
9495

9596
final CodeLoader.DeferredCall deferredCall = getContext().getCodeLoader().prepareExecute(
9697
callTarget,
@@ -111,7 +112,7 @@ protected boolean load(Object file, RubyModule wrapModule,
111112
@Cached RubyStringLibrary strings,
112113
@Cached IndirectCallNode callNode) {
113114
final String feature = RubyGuards.getJavaString(file);
114-
final Pair<Source, TStringWithEncoding> sourceRopePair = getSourceRopePair(feature);
115+
final Pair<Source, TStringWithEncoding> sourceTStringPair = getSourceTStringPair(feature);
115116

116117
final DeclarationContext declarationContext = DeclarationContext.topLevel(wrapModule);
117118
final LexicalScope lexicalScope = new LexicalScope(getContext().getRootLexicalScope(), wrapModule);
@@ -123,9 +124,9 @@ protected boolean load(Object file, RubyModule wrapModule,
123124

124125
// callTarget
125126
final RubySource rubySource = new RubySource(
126-
sourceRopePair.getLeft(),
127+
sourceTStringPair.getLeft(),
127128
feature,
128-
sourceRopePair.getRight());
129+
sourceTStringPair.getRight());
129130
final RootCallTarget callTarget = getContext()
130131
.getCodeLoader()
131132
.parse(rubySource, ParserContext.TOP_LEVEL, null, lexicalScope, this);
@@ -143,7 +144,7 @@ protected boolean load(Object file, RubyModule wrapModule,
143144
return true;
144145
}
145146

146-
private Pair<Source, TStringWithEncoding> getSourceRopePair(String feature) {
147+
private Pair<Source, TStringWithEncoding> getSourceTStringPair(String feature) {
147148
try {
148149
final FileLoader fileLoader = new FileLoader(getContext(), getLanguage());
149150
return fileLoader.loadFile(feature);

src/main/java/org/truffleruby/core/regexp/ClassicRegexp.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -542,10 +542,10 @@ public static int readEscapedByte(byte[] to, int toP, byte[] bytes, int p, int e
542542
} // while
543543
}
544544

545-
public static void preprocessCheck(TStringWithEncoding ropeWithEncoding) throws DeferredRaiseException {
545+
public static void preprocessCheck(TStringWithEncoding tstringWithEncoding) throws DeferredRaiseException {
546546
preprocess(
547-
ropeWithEncoding,
548-
ropeWithEncoding.getEncoding(),
547+
tstringWithEncoding,
548+
tstringWithEncoding.getEncoding(),
549549
new RubyEncoding[]{ null },
550550
RegexpSupport.ErrorMode.RAISE);
551551
}

src/main/java/org/truffleruby/core/regexp/InterpolatedRegexpNode.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public RegexpBuilderNode(RegexpOptions options) {
8787

8888
public abstract Object execute(TStringWithEncoding[] parts);
8989

90-
@Specialization(guards = "ropesWithEncodingsMatch(cachedParts, parts)", limit = "getDefaultCacheLimit()")
90+
@Specialization(guards = "tstringsWithEncodingsMatch(cachedParts, parts)", limit = "getDefaultCacheLimit()")
9191
protected Object fast(TStringWithEncoding[] parts,
9292
@Cached(value = "parts", dimensions = 1) TStringWithEncoding[] cachedParts,
9393
@Cached("createRegexp(cachedParts)") RubyRegexp regexp) {
@@ -102,7 +102,7 @@ protected Object slow(TStringWithEncoding[] parts,
102102
}
103103

104104
@ExplodeLoop
105-
protected boolean ropesWithEncodingsMatch(TStringWithEncoding[] a, TStringWithEncoding[] b) {
105+
protected boolean tstringsWithEncodingsMatch(TStringWithEncoding[] a, TStringWithEncoding[] b) {
106106
for (int i = 0; i < a.length; i++) {
107107
var aEncoding = a[i].encoding;
108108
if (aEncoding != b[i].encoding) {

src/main/java/org/truffleruby/core/regexp/RubyRegexp.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ private RubyRegexp(Regex regex, RegexpOptions options) {
7979
// in the Regex object as the "user object". Since ropes are immutable, we need to take this updated copy when
8080
// constructing the final regexp.
8181
this.regex = regex;
82-
final TStringWithEncoding ropeWithEncoding = (TStringWithEncoding) regex.getUserObject();
83-
this.source = ropeWithEncoding.tstring;
84-
this.encoding = ropeWithEncoding.getEncoding();
82+
final TStringWithEncoding tstringWithEncoding = (TStringWithEncoding) regex.getUserObject();
83+
this.source = tstringWithEncoding.tstring;
84+
this.encoding = tstringWithEncoding.getEncoding();
8585
this.options = options;
8686
this.cachedEncodings = new EncodingCache();
8787
this.tregexCache = new TRegexCache();

src/main/java/org/truffleruby/core/regexp/TruffleRegexpNodes.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,9 @@ public RubyRegexp buildUnion(RubyString str, Object sep, Object[] args, BranchPr
320320

321321
public Object string(Object obj) {
322322
if (rubyStringLibrary.isRubyString(obj)) {
323-
final TStringWithEncoding quotedRopeResult = ClassicRegexp
323+
final TStringWithEncoding quotedString = ClassicRegexp
324324
.quote19(new ATStringWithEncoding(rubyStringLibrary, obj));
325-
return createString(quotedRopeResult);
325+
return createString(quotedString);
326326
} else {
327327
return toSNode.execute((RubyRegexp) obj);
328328
}
@@ -726,8 +726,8 @@ private RubyHash buildMatchInfoStatsHash(HashStoreLibrary hashStoreLibrary, Matc
726726
buildAndSetDistributionHash(
727727
hashStoreLibrary,
728728
ret,
729-
"rope_types",
730-
stats.ropeClassFrequencies,
729+
"string_types",
730+
stats.tstringClassFrequencies,
731731
Optional.of(className -> StringOperations.createUTF8String(getContext(), getLanguage(), className)),
732732
Optional.of(count -> count.get()));
733733

@@ -1164,7 +1164,7 @@ static final class MatchInfoStats {
11641164
private final ConcurrentHashMap<Integer, AtomicLong> characterLengthFrequencies = new ConcurrentHashMap<>();
11651165
private final ConcurrentHashMap<TruffleString.CodeRange, AtomicLong> codeRangeFrequencies = new ConcurrentHashMap<>();
11661166
private final ConcurrentHashMap<RubyEncoding, AtomicLong> encodingFrequencies = new ConcurrentHashMap<>();
1167-
private final ConcurrentHashMap<String, AtomicLong> ropeClassFrequencies = new ConcurrentHashMap<>();
1167+
private final ConcurrentHashMap<String, AtomicLong> tstringClassFrequencies = new ConcurrentHashMap<>();
11681168

11691169
private void record(ATStringWithEncoding string) {
11701170
ConcurrentOperations
@@ -1179,7 +1179,7 @@ private void record(ATStringWithEncoding string) {
11791179
ConcurrentOperations.getOrCompute(encodingFrequencies, string.encoding, x -> new AtomicLong())
11801180
.incrementAndGet();
11811181
ConcurrentOperations
1182-
.getOrCompute(ropeClassFrequencies, string.getClass().getSimpleName(), x -> new AtomicLong())
1182+
.getOrCompute(tstringClassFrequencies, string.getClass().getSimpleName(), x -> new AtomicLong())
11831183
.incrementAndGet();
11841184
}
11851185

src/main/java/org/truffleruby/core/string/ConvertBytes.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class ConvertBytes {
3131
private final RubyContext context;
3232
private final Node caller;
3333
private final FixnumOrBignumNode fixnumOrBignumNode;
34-
private final AbstractTruffleString rope;
34+
private final AbstractTruffleString tstring;
3535
private int p;
3636
private int end;
3737
private byte[] data;
@@ -42,18 +42,18 @@ public ConvertBytes(
4242
RubyContext context,
4343
Node caller,
4444
FixnumOrBignumNode fixnumOrBignumNode,
45-
AbstractTruffleString rope,
45+
AbstractTruffleString tstring,
4646
RubyEncoding encoding,
4747
int base,
4848
boolean badcheck) {
49-
assert rope != null;
49+
assert tstring != null;
5050

51-
var byteArray = rope.getInternalByteArrayUncached(encoding.tencoding);
51+
var byteArray = tstring.getInternalByteArrayUncached(encoding.tencoding);
5252

5353
this.context = context;
5454
this.caller = caller;
5555
this.fixnumOrBignumNode = fixnumOrBignumNode;
56-
this.rope = rope;
56+
this.tstring = tstring;
5757
this.p = byteArray.getOffset();
5858
this.data = byteArray.getArray();
5959
this.end = byteArray.getEnd();
@@ -71,8 +71,8 @@ public ConvertBytes(
7171

7272
/** rb_cstr_to_inum */
7373
public static Object bytesToInum(RubyContext context, Node caller, FixnumOrBignumNode fixnumOrBignumNode,
74-
AbstractTruffleString rope, RubyEncoding encoding, int base, boolean badcheck) {
75-
return new ConvertBytes(context, caller, fixnumOrBignumNode, rope, encoding, base, badcheck).bytesToInum();
74+
AbstractTruffleString tstring, RubyEncoding encoding, int base, boolean badcheck) {
75+
return new ConvertBytes(context, caller, fixnumOrBignumNode, tstring, encoding, base, badcheck).bytesToInum();
7676
}
7777

7878
/** conv_digit */
@@ -534,7 +534,8 @@ public Kind getKind() {
534534
private void invalidString() {
535535
throw new RaiseException(
536536
context,
537-
context.getCoreExceptions().argumentErrorInvalidStringToInteger(rope.toJavaStringUncached(), caller));
537+
context.getCoreExceptions().argumentErrorInvalidStringToInteger(tstring.toJavaStringUncached(),
538+
caller));
538539
}
539540

540541
public static final byte[] intToBinaryBytes(int i) {

src/main/java/org/truffleruby/core/string/DoubleConverter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ public class DoubleConverter {
5959
public DoubleConverter() {
6060
}
6161

62-
public void init(AbstractTruffleString rope, RubyEncoding encoding, boolean isStrict) {
63-
var byteArray = rope.getInternalByteArrayUncached(encoding.tencoding);
62+
public void init(AbstractTruffleString tstring, RubyEncoding encoding, boolean isStrict) {
63+
var byteArray = tstring.getInternalByteArrayUncached(encoding.tencoding);
6464
bytes = byteArray.getArray();
6565
index = byteArray.getOffset();
6666
endIndex = byteArray.getEnd();
@@ -176,8 +176,8 @@ private boolean strictError() {
176176

177177
/** Everything runs in 1.9+ mode now, so the `is19` parameter is vestigial. However, in order to maintain binary
178178
* compatibility with extensions we can't just change the signature either. */
179-
public double parse(AbstractTruffleString rope, RubyEncoding encoding, boolean strict, boolean is19) {
180-
init(rope, encoding, strict);
179+
public double parse(AbstractTruffleString tstring, RubyEncoding encoding, boolean strict, boolean is19) {
180+
init(tstring, encoding, strict);
181181

182182
if (skipWhitespace()) {
183183
return completeCalculation();

0 commit comments

Comments
 (0)