16
16
import org .truffleruby .core .cast .BooleanCastNodeGen ;
17
17
import org .truffleruby .core .cast .ProcOrNullNode ;
18
18
import org .truffleruby .core .cast .ProcOrNullNodeGen ;
19
- import org .truffleruby .core .module .ModuleOperations ;
20
19
import org .truffleruby .core .proc .RubyProc ;
21
20
import org .truffleruby .core .symbol .RubySymbol ;
22
21
import org .truffleruby .language .RubyBaseNode ;
23
22
import org .truffleruby .language .RubyContextSourceNode ;
24
23
import org .truffleruby .language .RubyNode ;
25
24
import org .truffleruby .language .arguments .RubyArguments ;
26
25
import org .truffleruby .language .methods .BlockDefinitionNode ;
27
- import org .truffleruby .language .methods .DeclarationContext ;
28
26
import org .truffleruby .language .methods .InternalMethod ;
29
27
30
28
import com .oracle .truffle .api .CompilerDirectives ;
31
- import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
32
29
import com .oracle .truffle .api .frame .VirtualFrame ;
33
30
import com .oracle .truffle .api .nodes .ExplodeLoop ;
34
31
import com .oracle .truffle .api .profiles .BranchProfile ;
35
32
import com .oracle .truffle .api .profiles .ConditionProfile ;
33
+ import org .truffleruby .language .methods .LookupMethodOnSelfNode ;
36
34
37
35
import static org .truffleruby .language .dispatch .DispatchConfiguration .PRIVATE ;
38
36
import static org .truffleruby .language .dispatch .DispatchConfiguration .PRIVATE_RETURN_MISSING ;
@@ -48,7 +46,7 @@ public class RubyCallNode extends RubyContextSourceNode {
48
46
@ Children private final RubyNode [] arguments ;
49
47
50
48
private final boolean isSplatted ;
51
- private final boolean ignoreVisibility ;
49
+ private final DispatchConfiguration dispatchConfig ;
52
50
private final boolean isVCall ;
53
51
private final boolean isSafeNavigation ;
54
52
private final boolean isAttrAssign ;
@@ -73,7 +71,7 @@ public RubyCallNode(RubyCallNodeParameters parameters) {
73
71
}
74
72
75
73
this .isSplatted = parameters .isSplatted ();
76
- this .ignoreVisibility = parameters .isIgnoreVisibility ();
74
+ this .dispatchConfig = parameters .isIgnoreVisibility () ? PRIVATE : PROTECTED ;
77
75
this .isVCall = parameters .isVCall ();
78
76
this .isSafeNavigation = parameters .isSafeNavigation ();
79
77
this .isAttrAssign = parameters .isAttrAssign ();
@@ -114,7 +112,7 @@ public Object executeWithArgumentsEvaluated(VirtualFrame frame, Object receiverO
114
112
Object [] argumentsObjects ) {
115
113
if (dispatch == null ) {
116
114
CompilerDirectives .transferToInterpreterAndInvalidate ();
117
- dispatch = insert (DispatchNode .create (ignoreVisibility ? PRIVATE : PROTECTED ));
115
+ dispatch = insert (DispatchNode .create (dispatchConfig ));
118
116
}
119
117
120
118
final Object returnValue = dispatch
@@ -183,8 +181,8 @@ private class DefinedNode extends RubyBaseNode {
183
181
@ Child private DispatchNode respondToMissing = DispatchNode .create (PRIVATE_RETURN_MISSING );
184
182
@ Child private BooleanCastNode respondToMissingCast = BooleanCastNodeGen .create (null );
185
183
186
- // TODO CS-10-Apr-17 see below
187
- // @Child private LookupMethodNode lookupMethodNode = LookupMethodNodeGen .create(ignoreVisibility, false, null, null );
184
+
185
+ @ Child private LookupMethodOnSelfNode lookupMethodNode = LookupMethodOnSelfNode .create ();
188
186
189
187
private final ConditionProfile receiverDefinedProfile = ConditionProfile .create ();
190
188
private final BranchProfile argumentNotDefinedProfile = BranchProfile .create ();
@@ -218,8 +216,7 @@ public Object isDefined(VirtualFrame frame, RubyContext context) {
218
216
return nil ;
219
217
}
220
218
221
- final DeclarationContext declarationContext = RubyArguments .getDeclarationContext (frame );
222
- final InternalMethod method = doLookup (receiverObject , declarationContext );
219
+ final InternalMethod method = lookupMethodNode .lookup (frame , receiverObject , methodName , dispatchConfig );
223
220
final Object self = RubyArguments .getSelf (frame );
224
221
225
222
if (methodNotFoundProfile .profile (method == null )) {
@@ -230,32 +227,16 @@ public Object isDefined(VirtualFrame frame, RubyContext context) {
230
227
}
231
228
} else if (methodUndefinedProfile .profile (method .isUndefined ())) {
232
229
return nil ;
233
- } else if (methodNotVisibleProfile .profile (!ignoreVisibility && !isVisibleTo (method , self ))) {
230
+ } else if (methodNotVisibleProfile
231
+ .profile (!dispatchConfig .ignoreVisibility && !isVisibleTo (method , self ))) {
234
232
return nil ;
235
233
}
236
234
237
235
return coreStrings ().METHOD .createInstance ();
238
236
}
239
237
240
- // TODO CS-10-Apr-17 remove this boundary
241
-
242
- @ TruffleBoundary
243
- private InternalMethod doLookup (Object receiverObject , DeclarationContext declarationContext ) {
244
- // TODO CS-10-Apr-17 I'd like to use this but it doesn't give the same result
245
- // lookupMethodNode.executeLookupMethod(frame, coreLibrary().getMetaClass(receiverObject), methodName);
246
-
247
- return ModuleOperations
248
- .lookupMethodUncached (coreLibrary ().getMetaClass (receiverObject ), methodName , declarationContext );
249
- }
250
-
251
- // TODO CS-10-Apr-17 remove this boundary
252
-
253
- @ TruffleBoundary
254
238
private boolean isVisibleTo (InternalMethod method , Object self ) {
255
239
return method .isVisibleTo (coreLibrary ().getMetaClass (self ));
256
240
}
257
-
258
241
}
259
-
260
-
261
242
}
0 commit comments