Skip to content

Commit 3288b87

Browse files
author
Nicolas Laurent
committed
get rid of the old dispatch chain classes
1 parent 896b91f commit 3288b87

23 files changed

+43
-1755
lines changed

src/main/java/org/truffleruby/core/basicobject/BasicObjectNodes.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import org.truffleruby.language.methods.DeclarationContext;
4848
import org.truffleruby.language.methods.DeclarationContext.SingletonClassOfSelfDefaultDefinee;
4949
import org.truffleruby.language.methods.InternalMethod;
50+
import org.truffleruby.language.methods.LookupMethodNode;
5051
import org.truffleruby.language.methods.UnsupportedOperationBehavior;
5152
import org.truffleruby.language.objects.AllocateHelperNode;
5253
import org.truffleruby.language.objects.ObjectIDOperations;
@@ -560,8 +561,7 @@ private boolean lastCallWasSuper(FrameAndCallNode callerFrame) {
560561
return superCallNode != null;
561562
}
562563

563-
/** See {@link org.truffleruby.language.dispatch.DispatchNode#lookup}. The only way to fail if method is not
564-
* null and not undefined is visibility. */
564+
/** See {@link LookupMethodNode}. The only way to fail if method is not null and not undefined is visibility. */
565565
private Visibility lastCallWasCallingPrivateOrProtectedMethod(Object self, String name,
566566
FrameAndCallNode callerFrame) {
567567
final DeclarationContext declarationContext = RubyArguments.tryGetDeclarationContext(callerFrame.frame);

src/main/java/org/truffleruby/core/cast/ArrayCastNode.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
import org.truffleruby.language.RubyNode;
2020
import org.truffleruby.language.control.RaiseException;
2121
import org.truffleruby.language.dispatch.NewDispatchHeadNode;
22-
import org.truffleruby.language.dispatch.DispatchNode;
23-
2422
import com.oracle.truffle.api.CompilerDirectives;
2523
import com.oracle.truffle.api.dsl.Cached;
2624
import com.oracle.truffle.api.dsl.NodeChild;
@@ -114,7 +112,7 @@ protected Object cast(RubyDynamicObject object,
114112
return nil;
115113
}
116114

117-
if (result == DispatchNode.MISSING) {
115+
if (result == NewDispatchHeadNode.MISSING) {
118116
return nil;
119117
}
120118

src/main/java/org/truffleruby/core/cast/HashCastNode.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
import org.truffleruby.language.RubyNode;
1919
import org.truffleruby.language.control.RaiseException;
2020
import org.truffleruby.language.dispatch.NewDispatchHeadNode;
21-
import org.truffleruby.language.dispatch.DispatchNode;
22-
2321
import com.oracle.truffle.api.dsl.Cached;
2422
import com.oracle.truffle.api.dsl.NodeChild;
2523
import com.oracle.truffle.api.dsl.Specialization;
@@ -77,7 +75,7 @@ protected Object cast(RubyDynamicObject object,
7775
@Cached BranchProfile errorProfile) {
7876
final Object result = toHashNode.call(object, "to_hash");
7977

80-
if (result == DispatchNode.MISSING) {
78+
if (result == NewDispatchHeadNode.MISSING) {
8179
return nil;
8280
}
8381

src/main/java/org/truffleruby/interop/InteropNodes.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
import org.truffleruby.language.RubySourceNode;
4141
import org.truffleruby.language.Visibility;
4242
import org.truffleruby.language.control.RaiseException;
43-
import org.truffleruby.language.dispatch.DispatchNode;
43+
import org.truffleruby.language.dispatch.NewDispatchHeadNode;
4444
import org.truffleruby.shared.TruffleRuby;
4545

4646
import com.oracle.truffle.api.CallTarget;
@@ -1139,7 +1139,7 @@ public abstract static class DispatchMissingNode extends PrimitiveArrayArguments
11391139

11401140
@Specialization
11411141
protected Object dispatchMissing() {
1142-
return DispatchNode.MISSING;
1142+
return NewDispatchHeadNode.MISSING;
11431143
}
11441144

11451145
}

src/main/java/org/truffleruby/language/ImmutableRubyObject.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
import org.truffleruby.interop.ForeignToRubyArgumentsNode;
1616
import org.truffleruby.interop.ForeignToRubyNode;
1717
import org.truffleruby.language.dispatch.NewDispatchHeadNode;
18-
import org.truffleruby.language.dispatch.DispatchNode;
1918
import org.truffleruby.language.library.RubyLibrary;
20-
2119
import com.oracle.truffle.api.dsl.Cached;
2220
import com.oracle.truffle.api.dsl.Cached.Exclusive;
2321
import com.oracle.truffle.api.dsl.Cached.Shared;
@@ -147,7 +145,7 @@ public Object invokeMember(String name, Object[] arguments,
147145
throws UnknownIdentifierException {
148146
Object[] convertedArguments = foreignToRubyArgumentsNode.executeConvert(arguments);
149147
Object result = dispatchMember.call(this, name, convertedArguments);
150-
if (result == DispatchNode.MISSING) {
148+
if (result == NewDispatchHeadNode.MISSING) {
151149
errorProfile.enter();
152150
throw UnknownIdentifierException.create(name);
153151
}

src/main/java/org/truffleruby/language/RubyDynamicObject.java

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.truffleruby.interop.TranslateInteropRubyExceptionNode;
2828
import org.truffleruby.language.control.RaiseException;
2929
import org.truffleruby.language.dispatch.NewDispatchHeadNode;
30-
import org.truffleruby.language.dispatch.DispatchNode;
3130
import org.truffleruby.language.library.RubyLibrary;
3231
import org.truffleruby.language.objects.LogicalClassNode;
3332
import org.truffleruby.language.objects.WriteObjectFieldNode;
@@ -198,7 +197,7 @@ public boolean hasArrayElements(
198197
@Exclusive @Cached(parameters = "PRIVATE_RETURN_MISSING") NewDispatchHeadNode dispatchNode,
199198
@Exclusive @Cached BooleanCastNode booleanCastNode) {
200199
Object value = dispatchNode.call(this, "polyglot_has_array_elements?");
201-
return value != DispatchNode.MISSING && booleanCastNode.executeToBoolean(value);
200+
return value != NewDispatchHeadNode.MISSING && booleanCastNode.executeToBoolean(value);
202201
}
203202

204203
@ExportMessage
@@ -214,7 +213,7 @@ public long getArraySize(
214213
} catch (RaiseException e) {
215214
throw translateRubyException.execute(e);
216215
}
217-
if (value == DispatchNode.MISSING) {
216+
if (value == NewDispatchHeadNode.MISSING) {
218217
errorProfile.enter();
219218
throw UnsupportedMessageException.create();
220219
}
@@ -230,7 +229,7 @@ public Object readArrayElement(long index,
230229
throws InvalidArrayIndexException, UnsupportedMessageException {
231230
try {
232231
Object value = dispatchNode.call(this, "polyglot_read_array_element", index);
233-
if (value == DispatchNode.MISSING) {
232+
if (value == NewDispatchHeadNode.MISSING) {
234233
errorProfile.enter();
235234
throw UnsupportedMessageException.create();
236235
}
@@ -249,7 +248,7 @@ public void writeArrayElement(long index, Object value,
249248
throws UnsupportedMessageException, InvalidArrayIndexException, UnsupportedTypeException {
250249
try {
251250
Object result = dispatchNode.call(this, "polyglot_write_array_element", index, value);
252-
if (result == DispatchNode.MISSING) {
251+
if (result == NewDispatchHeadNode.MISSING) {
253252
errorProfile.enter();
254253
throw UnsupportedMessageException.create();
255254
}
@@ -267,7 +266,7 @@ public void removeArrayElement(long index,
267266
throws UnsupportedMessageException, InvalidArrayIndexException {
268267
try {
269268
Object result = dispatchNode.call(this, "polyglot_remove_array_element", index);
270-
if (result == DispatchNode.MISSING) {
269+
if (result == NewDispatchHeadNode.MISSING) {
271270
errorProfile.enter();
272271
throw UnsupportedMessageException.create();
273272
}
@@ -281,31 +280,31 @@ public boolean isArrayElementReadable(long index,
281280
@Exclusive @Cached(parameters = "PRIVATE_RETURN_MISSING") NewDispatchHeadNode dispatchNode,
282281
@Exclusive @Cached BooleanCastNode booleanCastNode) {
283282
Object value = dispatchNode.call(this, "polyglot_array_element_readable?", index);
284-
return value != DispatchNode.MISSING && booleanCastNode.executeToBoolean(value);
283+
return value != NewDispatchHeadNode.MISSING && booleanCastNode.executeToBoolean(value);
285284
}
286285

287286
@ExportMessage
288287
public boolean isArrayElementModifiable(long index,
289288
@Exclusive @Cached(parameters = "PRIVATE_RETURN_MISSING") NewDispatchHeadNode dispatchNode,
290289
@Exclusive @Cached BooleanCastNode booleanCastNode) {
291290
Object value = dispatchNode.call(this, "polyglot_array_element_modifiable?", index);
292-
return value != DispatchNode.MISSING && booleanCastNode.executeToBoolean(value);
291+
return value != NewDispatchHeadNode.MISSING && booleanCastNode.executeToBoolean(value);
293292
}
294293

295294
@ExportMessage
296295
public boolean isArrayElementInsertable(long index,
297296
@Exclusive @Cached(parameters = "PRIVATE_RETURN_MISSING") NewDispatchHeadNode dispatchNode,
298297
@Exclusive @Cached BooleanCastNode booleanCastNode) {
299298
Object value = dispatchNode.call(this, "polyglot_array_element_insertable?", index);
300-
return value != DispatchNode.MISSING && booleanCastNode.executeToBoolean(value);
299+
return value != NewDispatchHeadNode.MISSING && booleanCastNode.executeToBoolean(value);
301300
}
302301

303302
@ExportMessage
304303
public boolean isArrayElementRemovable(long index,
305304
@Exclusive @Cached(parameters = "PRIVATE_RETURN_MISSING") NewDispatchHeadNode dispatchNode,
306305
@Exclusive @Cached BooleanCastNode booleanCastNode) {
307306
Object value = dispatchNode.call(this, "polyglot_array_element_removable?", index);
308-
return value != DispatchNode.MISSING && booleanCastNode.executeToBoolean(value);
307+
return value != NewDispatchHeadNode.MISSING && booleanCastNode.executeToBoolean(value);
309308
}
310309
// endregion
311310

@@ -316,7 +315,7 @@ public boolean isPointer(
316315
@Exclusive @Cached BooleanCastNode booleanCastNode) {
317316

318317
Object value = dispatchNode.call(this, "polyglot_pointer?");
319-
return value != DispatchNode.MISSING && booleanCastNode.executeToBoolean(value);
318+
return value != NewDispatchHeadNode.MISSING && booleanCastNode.executeToBoolean(value);
320319
}
321320

322321
@ExportMessage
@@ -332,7 +331,7 @@ public long asPointer(
332331
} catch (RaiseException e) {
333332
throw translateRubyException.execute(e);
334333
}
335-
if (value == DispatchNode.MISSING) {
334+
if (value == NewDispatchHeadNode.MISSING) {
336335
errorProfile.enter();
337336
throw UnsupportedMessageException.create();
338337
}
@@ -355,7 +354,7 @@ public boolean hasMembers(
355354
@Exclusive @Cached(parameters = "PRIVATE_RETURN_MISSING") NewDispatchHeadNode dispatchNode,
356355
@Exclusive @Cached BooleanCastNode booleanCastNode) {
357356
Object dynamic = dispatchNode.call(this, "polyglot_has_members?");
358-
return dynamic == DispatchNode.MISSING || booleanCastNode.executeToBoolean(dynamic);
357+
return dynamic == NewDispatchHeadNode.MISSING || booleanCastNode.executeToBoolean(dynamic);
359358
}
360359

361360
@ExportMessage
@@ -394,7 +393,7 @@ public Object readMember(String name,
394393
throw translateRubyException.execute(e, name);
395394
}
396395

397-
if (dynamicProfile.profile(dynamic == DispatchNode.MISSING)) {
396+
if (dynamicProfile.profile(dynamic == NewDispatchHeadNode.MISSING)) {
398397
Object iVar = objectLibrary.getOrDefault(this, name, null);
399398
if (ivarFoundProfile.profile(iVar != null)) {
400399
return iVar;
@@ -427,7 +426,7 @@ public void writeMember(String name, Object value,
427426
throw translateRubyException.execute(e, name);
428427
}
429428

430-
if (dynamicProfile.profile(dynamic == DispatchNode.MISSING)) {
429+
if (dynamicProfile.profile(dynamic == NewDispatchHeadNode.MISSING)) {
431430
if (rubyLibrary.isFrozen(this)) {
432431
errorProfile.enter();
433432
throw UnsupportedMessageException.create();
@@ -460,7 +459,7 @@ public void removeMember(String name,
460459
throw translateRubyException.execute(e, name);
461460
}
462461

463-
if (dynamicProfile.profile(dynamic == DispatchNode.MISSING)) {
462+
if (dynamicProfile.profile(dynamic == NewDispatchHeadNode.MISSING)) {
464463
if (!interopLibrary.isMemberRemovable(this, name)) {
465464
errorProfile.enter();
466465
throw UnknownIdentifierException.create(name);
@@ -495,9 +494,9 @@ public Object invokeMember(String name, Object[] arguments,
495494
throw translateRubyException.execute(e, name, arguments);
496495
}
497496

498-
if (dynamicProfile.profile(dynamic == DispatchNode.MISSING)) {
497+
if (dynamicProfile.profile(dynamic == NewDispatchHeadNode.MISSING)) {
499498
Object result = dispatchMember.call(this, name, convertedArguments);
500-
if (result == DispatchNode.MISSING) {
499+
if (result == NewDispatchHeadNode.MISSING) {
501500
errorProfile.enter();
502501
throw UnknownIdentifierException.create(name);
503502
}
@@ -517,7 +516,7 @@ public boolean isMemberReadable(String name,
517516
@Shared("ivarFoundProfile") @Cached ConditionProfile ivarFoundProfile) {
518517
Object rubyName = nameToRubyNode.executeConvert(name);
519518
Object dynamic = dispatchNode.call(this, "polyglot_member_readable?", rubyName);
520-
if (dynamicProfile.profile(dynamic == DispatchNode.MISSING)) {
519+
if (dynamicProfile.profile(dynamic == NewDispatchHeadNode.MISSING)) {
521520
if (ivarFoundProfile.profile(objectLibrary.containsKey(this, name))) {
522521
return true;
523522
} else {
@@ -572,7 +571,7 @@ private boolean isMemberModifiableRemovable(Object dynamic,
572571
DynamicObjectLibrary objectLibrary,
573572
BooleanCastNode booleanCastNode,
574573
ConditionProfile dynamicProfile) {
575-
if (dynamicProfile.profile(dynamic == DispatchNode.MISSING)) {
574+
if (dynamicProfile.profile(dynamic == NewDispatchHeadNode.MISSING)) {
576575
if (rubyLibrary.isFrozen(this)) {
577576
return false;
578577
} else {
@@ -593,7 +592,7 @@ public boolean isMemberInsertable(String name,
593592
@Cached @Shared("nameToRubyNode") ForeignToRubyNode nameToRubyNode) {
594593
Object rubyName = nameToRubyNode.executeConvert(name);
595594
Object dynamic = dispatchNode.call(this, "polyglot_member_insertable?", rubyName);
596-
if (dynamicProfile.profile(dynamic == DispatchNode.MISSING)) {
595+
if (dynamicProfile.profile(dynamic == NewDispatchHeadNode.MISSING)) {
597596
if (rubyLibrary.isFrozen(this) || !isIVar(name)) {
598597
return false;
599598
} else {
@@ -615,7 +614,7 @@ public boolean isMemberInvocable(String name,
615614
@Shared("ivarFoundProfile") @Cached ConditionProfile ivarFoundProfile) {
616615
Object rubyName = nameToRubyNode.executeConvert(name);
617616
Object dynamic = dispatchNode.call(this, "polyglot_member_invocable?", rubyName);
618-
if (dynamicProfile.profile(dynamic == DispatchNode.MISSING)) {
617+
if (dynamicProfile.profile(dynamic == NewDispatchHeadNode.MISSING)) {
619618
Object iVar = objectLibrary.getOrDefault(this, name, null);
620619
if (ivarFoundProfile.profile(iVar != null)) {
621620
return false;
@@ -639,7 +638,7 @@ public boolean isMemberInternal(String name,
639638
@Shared("ivarFoundProfile") @Cached ConditionProfile ivarFoundProfile) {
640639
Object rubyName = nameToRubyNode.executeConvert(name);
641640
Object dynamic = dispatchNode.call(this, "polyglot_member_internal?", rubyName);
642-
if (dynamicProfile.profile(dynamic == DispatchNode.MISSING)) {
641+
if (dynamicProfile.profile(dynamic == NewDispatchHeadNode.MISSING)) {
643642
Object result = objectLibrary.getOrDefault(this, name, null);
644643
if (ivarFoundProfile.profile(result != null)) {
645644
return true;
@@ -661,7 +660,7 @@ public boolean hasMemberReadSideEffects(String name,
661660
@Exclusive @Cached BooleanCastNode booleanCastNode) {
662661
Object rubyName = nameToRubyNode.executeConvert(name);
663662
Object dynamic = dispatchNode.call(this, "polyglot_has_member_read_side_effects?", rubyName);
664-
if (dynamicProfile.profile(dynamic == DispatchNode.MISSING)) {
663+
if (dynamicProfile.profile(dynamic == NewDispatchHeadNode.MISSING)) {
665664
return false;
666665
} else {
667666
return booleanCastNode.executeToBoolean(dynamic);
@@ -676,7 +675,7 @@ public boolean hasMemberWriteSideEffects(String name,
676675
@Exclusive @Cached BooleanCastNode booleanCastNode) {
677676
Object rubyName = nameToRubyNode.executeConvert(name);
678677
Object dynamic = dispatchNode.call(this, "polyglot_has_member_write_side_effects?", rubyName);
679-
if (dynamicProfile.profile(dynamic == DispatchNode.MISSING)) {
678+
if (dynamicProfile.profile(dynamic == NewDispatchHeadNode.MISSING)) {
680679
return false;
681680
} else {
682681
return booleanCastNode.executeToBoolean(dynamic);
@@ -700,7 +699,7 @@ public Object instantiate(Object[] arguments,
700699
Object instance = dispatchNode.call(this, "new", foreignToRubyArgumentsNode.executeConvert(arguments));
701700

702701
// TODO (pitr-ch 28-Jan-2020): we should translate argument-error caused by bad arity to ArityException
703-
if (instance == DispatchNode.MISSING) {
702+
if (instance == NewDispatchHeadNode.MISSING) {
704703
errorProfile.enter();
705704
throw UnsupportedMessageException.create();
706705
}

0 commit comments

Comments
 (0)