126126import com .oracle .truffle .api .object .DynamicObject ;
127127import com .oracle .truffle .api .object .Shape ;
128128
129- public abstract class PythonObjectFactory extends Node {
130- public static PythonObjectFactory create () {
131- return new PythonObjectFactory () {
132- @ CompilationFinal private ContextReference <PythonContext > contextRef ;
133-
134- @ Override
135- public NodeCost getCost () {
136- return contextRef == null ? NodeCost .UNINITIALIZED : NodeCost .MONOMORPHIC ;
137- }
129+ public final class PythonObjectFactory extends Node {
130+ @ CompilationFinal private ContextReference <PythonContext > contextRef ;
138131
139- @ Override
140- public PythonCore getCore () {
141- if (contextRef == null ) {
142- CompilerDirectives .transferToInterpreterAndInvalidate ();
143- contextRef = PythonLanguage .getContextRef ();
144- }
145- return contextRef .get ().getCore ();
146- }
147- };
132+ private PythonObjectFactory () {
148133 }
149134
150- public abstract PythonCore getCore ();
135+ public static PythonObjectFactory create () {
136+ return new PythonObjectFactory ();
137+ }
151138
152139 private PythonClass lookupClass (PythonBuiltinClassType type ) {
153140 return getCore ().lookupType (type );
@@ -158,6 +145,19 @@ public final <T> T trace(T allocatedObject) {
158145 return allocatedObject ;
159146 }
160147
148+ @ Override
149+ public NodeCost getCost () {
150+ return contextRef == null ? NodeCost .UNINITIALIZED : NodeCost .MONOMORPHIC ;
151+ }
152+
153+ public PythonCore getCore () {
154+ if (contextRef == null ) {
155+ CompilerDirectives .transferToInterpreterAndInvalidate ();
156+ contextRef = PythonLanguage .getContextRef ();
157+ }
158+ return contextRef .get ().getCore ();
159+ }
160+
161161 /*
162162 * Python objects
163163 */
0 commit comments