19
19
import org .truffleruby .language .objects .MetaClassNode ;
20
20
21
21
import com .oracle .truffle .api .CompilerDirectives ;
22
+ import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
22
23
import com .oracle .truffle .api .dsl .Cached ;
23
24
import com .oracle .truffle .api .dsl .Specialization ;
24
25
import com .oracle .truffle .api .frame .VirtualFrame ;
@@ -47,15 +48,15 @@ public abstract class LookupSuperMethodNode extends RubyContextNode {
47
48
protected InternalMethod lookupSuperMethodCachedDynamicObject (VirtualFrame frame , DynamicObject self ,
48
49
@ Cached ("getCurrentMethod(frame)" ) InternalMethod currentMethod ,
49
50
@ Cached ("metaClass(self)" ) DynamicObject selfMetaClass ,
50
- @ Cached ("doLookup(frame, currentMethod, selfMetaClass)" ) MethodLookupResult superMethod ) {
51
+ @ Cached ("doLookup(currentMethod, selfMetaClass)" ) MethodLookupResult superMethod ) {
51
52
return superMethod .getMethod ();
52
53
}
53
54
54
55
@ Specialization
55
56
protected InternalMethod lookupSuperMethodUncached (VirtualFrame frame , Object self ) {
56
57
final InternalMethod currentMethod = getCurrentMethod (frame );
57
58
final DynamicObject selfMetaClass = metaClass (self );
58
- return doLookup (frame , currentMethod , selfMetaClass ).getMethod ();
59
+ return doLookup (currentMethod , selfMetaClass ).getMethod ();
59
60
}
60
61
61
62
protected InternalMethod getCurrentMethod (VirtualFrame frame ) {
@@ -70,15 +71,16 @@ protected DynamicObject metaClass(Object object) {
70
71
return metaClassNode .executeMetaClass (object );
71
72
}
72
73
73
- protected MethodLookupResult doLookup (VirtualFrame frame , InternalMethod currentMethod ,
74
+ @ TruffleBoundary
75
+ protected MethodLookupResult doLookup (InternalMethod currentMethod ,
74
76
DynamicObject selfMetaClass ) {
75
77
assert RubyGuards .isRubyClass (selfMetaClass );
76
78
77
79
MethodLookupResult superMethod = ModuleOperations
78
80
.lookupSuperMethod (
79
81
currentMethod ,
80
82
selfMetaClass ,
81
- getDeclarationContext (frame , currentMethod , selfMetaClass ));
83
+ getDeclarationContext (currentMethod , selfMetaClass ));
82
84
// TODO (eregon, 12 June 2015): Is this correct?
83
85
if (!superMethod .isDefined ()) {
84
86
return superMethod .withNoMethod ();
@@ -90,15 +92,14 @@ protected int getCacheLimit() {
90
92
return getContext ().getOptions ().METHOD_LOOKUP_CACHE ;
91
93
}
92
94
93
- private DeclarationContext getDeclarationContext (VirtualFrame frame , InternalMethod currentMethod ,
95
+ private DeclarationContext getDeclarationContext (InternalMethod currentMethod ,
94
96
DynamicObject selfMetaClass ) {
95
- final DeclarationContext context = RubyArguments .getDeclarationContext (frame );
97
+ final DeclarationContext context = currentMethod .getDeclarationContext ();
98
+ final DeclarationContext activeRefinements = currentMethod .getActiveRefinements ();
96
99
97
- if (currentMethod . isRefined () ) {
100
+ if (activeRefinements != null ) {
98
101
// super from the refined method has access to the parent's active refinements for the selfMetaClass
99
- final DynamicObject [] classRefinements = currentMethod
100
- .getActiveRefinements ()
101
- .getRefinementsFor (selfMetaClass );
102
+ final DynamicObject [] classRefinements = activeRefinements .getRefinementsFor (selfMetaClass );
102
103
103
104
if (classRefinements == null ) {
104
105
return context ;
0 commit comments