|
12 | 12 | import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff;
|
13 | 13 | import com.oracle.truffle.api.dsl.NeverDefault;
|
14 | 14 | import com.oracle.truffle.api.dsl.TypeSystemReference;
|
| 15 | +import org.truffleruby.core.CoreLibrary; |
15 | 16 | import org.truffleruby.core.encoding.RubyEncoding;
|
16 | 17 | import org.truffleruby.core.klass.RubyClass;
|
17 | 18 | import org.truffleruby.core.numeric.RubyBignum;
|
@@ -41,90 +42,94 @@ public static MetaClassNode getUncached() {
|
41 | 42 | return MetaClassNodeGen.getUncached();
|
42 | 43 | }
|
43 | 44 |
|
44 |
| - public abstract RubyClass execute(Object value); |
| 45 | + public final RubyClass execute(Object value) { |
| 46 | + return execute(value, coreLibrary()); |
| 47 | + } |
| 48 | + |
| 49 | + protected abstract RubyClass execute(Object value, CoreLibrary coreLibrary); |
45 | 50 |
|
46 | 51 | // Cover all primitives, nil and symbols
|
47 | 52 |
|
48 | 53 | @Specialization(guards = "value")
|
49 |
| - protected RubyClass metaClassTrue(boolean value) { |
50 |
| - return coreLibrary().trueClass; |
| 54 | + protected RubyClass metaClassTrue(boolean value, CoreLibrary coreLibrary) { |
| 55 | + return coreLibrary.trueClass; |
51 | 56 | }
|
52 | 57 |
|
53 | 58 | @Specialization(guards = "!value")
|
54 |
| - protected RubyClass metaClassFalse(boolean value) { |
55 |
| - return coreLibrary().falseClass; |
| 59 | + protected RubyClass metaClassFalse(boolean value, CoreLibrary coreLibrary) { |
| 60 | + return coreLibrary.falseClass; |
56 | 61 | }
|
57 | 62 |
|
58 | 63 | @Specialization
|
59 |
| - protected RubyClass metaClassInt(int value) { |
60 |
| - return coreLibrary().integerClass; |
| 64 | + protected RubyClass metaClassInt(int value, CoreLibrary coreLibrary) { |
| 65 | + return coreLibrary.integerClass; |
61 | 66 | }
|
62 | 67 |
|
63 | 68 | @Specialization
|
64 |
| - protected RubyClass metaClassLong(long value) { |
65 |
| - return coreLibrary().integerClass; |
| 69 | + protected RubyClass metaClassLong(long value, CoreLibrary coreLibrary) { |
| 70 | + return coreLibrary.integerClass; |
66 | 71 | }
|
67 | 72 |
|
68 | 73 | @Specialization
|
69 |
| - protected RubyClass metaClassBignum(RubyBignum value) { |
70 |
| - return coreLibrary().integerClass; |
| 74 | + protected RubyClass metaClassBignum(RubyBignum value, CoreLibrary coreLibrary) { |
| 75 | + return coreLibrary.integerClass; |
71 | 76 | }
|
72 | 77 |
|
73 | 78 | @Specialization
|
74 |
| - protected RubyClass metaClassDouble(double value) { |
75 |
| - return coreLibrary().floatClass; |
| 79 | + protected RubyClass metaClassDouble(double value, CoreLibrary coreLibrary) { |
| 80 | + return coreLibrary.floatClass; |
76 | 81 | }
|
77 | 82 |
|
78 | 83 | @Specialization
|
79 |
| - protected RubyClass metaClassNil(Nil value) { |
80 |
| - return coreLibrary().nilClass; |
| 84 | + protected RubyClass metaClassNil(Nil value, CoreLibrary coreLibrary) { |
| 85 | + return coreLibrary.nilClass; |
81 | 86 | }
|
82 | 87 |
|
83 | 88 | @Specialization
|
84 |
| - protected RubyClass metaClassSymbol(RubySymbol value) { |
85 |
| - return coreLibrary().symbolClass; |
| 89 | + protected RubyClass metaClassSymbol(RubySymbol value, CoreLibrary coreLibrary) { |
| 90 | + return coreLibrary.symbolClass; |
86 | 91 | }
|
87 | 92 |
|
88 | 93 | @Specialization
|
89 |
| - protected RubyClass metaClassEncoding(RubyEncoding value) { |
90 |
| - return coreLibrary().encodingClass; |
| 94 | + protected RubyClass metaClassEncoding(RubyEncoding value, CoreLibrary coreLibrary) { |
| 95 | + return coreLibrary.encodingClass; |
91 | 96 | }
|
92 | 97 |
|
93 | 98 | @Specialization
|
94 |
| - protected RubyClass metaClassImmutableString(ImmutableRubyString value) { |
95 |
| - return coreLibrary().stringClass; |
| 99 | + protected RubyClass metaClassImmutableString(ImmutableRubyString value, CoreLibrary coreLibrary) { |
| 100 | + return coreLibrary.stringClass; |
96 | 101 | }
|
97 | 102 |
|
98 | 103 | @Specialization
|
99 |
| - protected RubyClass metaClassRegexp(RubyRegexp value) { |
100 |
| - return coreLibrary().regexpClass; |
| 104 | + protected RubyClass metaClassRegexp(RubyRegexp value, CoreLibrary coreLibrary) { |
| 105 | + return coreLibrary.regexpClass; |
101 | 106 | }
|
102 | 107 |
|
103 | 108 | @Specialization
|
104 |
| - protected RubyClass metaClassIntRange(RubyIntOrLongRange value) { |
105 |
| - return coreLibrary().rangeClass; |
| 109 | + protected RubyClass metaClassIntRange(RubyIntOrLongRange value, CoreLibrary coreLibrary) { |
| 110 | + return coreLibrary.rangeClass; |
106 | 111 | }
|
107 | 112 |
|
108 | 113 | // Cover all RubyDynamicObject cases with cached and uncached
|
109 | 114 |
|
110 | 115 | @Specialization(
|
111 | 116 | guards = { "object == cachedObject", "metaClass.isSingleton" },
|
112 | 117 | limit = "getIdentityCacheContextLimit()")
|
113 |
| - protected RubyClass singletonClassCached(RubyDynamicObject object, |
| 118 | + protected RubyClass singletonClassCached(RubyDynamicObject object, CoreLibrary coreLibrary, |
114 | 119 | @Cached("object") RubyDynamicObject cachedObject,
|
115 | 120 | @Cached("object.getMetaClass()") RubyClass metaClass) {
|
116 | 121 | return metaClass;
|
117 | 122 | }
|
118 | 123 |
|
119 | 124 | @Specialization(replaces = "singletonClassCached")
|
120 |
| - protected RubyClass metaClassObject(RubyDynamicObject object) { |
| 125 | + protected RubyClass metaClassObject(RubyDynamicObject object, CoreLibrary coreLibrary) { |
121 | 126 | return object.getMetaClass();
|
122 | 127 | }
|
123 | 128 |
|
124 | 129 | // Foreign object
|
125 | 130 | @InliningCutoff
|
126 | 131 | @Specialization(guards = "isForeignObject(object)")
|
127 |
| - protected RubyClass metaClassForeign(Object object, |
| 132 | + protected RubyClass metaClassForeign(Object object, CoreLibrary coreLibrary, |
128 | 133 | @Cached ForeignClassNode foreignClassNode) {
|
129 | 134 | return foreignClassNode.execute(object);
|
130 | 135 | }
|
|
0 commit comments