48
48
import static com .oracle .graal .python .nodes .SpecialMethodNames .__GETATTRIBUTE__ ;
49
49
import static com .oracle .graal .python .nodes .SpecialMethodNames .__GETATTR__ ;
50
50
import static com .oracle .graal .python .nodes .SpecialMethodNames .__INIT__ ;
51
- import static com .oracle .graal .python .nodes .SpecialMethodNames .__REPR__ ;
52
51
import static com .oracle .graal .python .runtime .exception .PythonErrorType .AttributeError ;
53
52
54
53
import java .util .List ;
55
54
56
- import com .oracle .graal .python .PythonLanguage ;
57
55
import com .oracle .graal .python .builtins .Builtin ;
58
56
import com .oracle .graal .python .builtins .CoreFunctions ;
59
57
import com .oracle .graal .python .builtins .PythonBuiltinClassType ;
68
66
import com .oracle .graal .python .nodes .function .PythonBuiltinBaseNode ;
69
67
import com .oracle .graal .python .nodes .function .PythonBuiltinNode ;
70
68
import com .oracle .graal .python .nodes .function .builtins .PythonBinaryBuiltinNode ;
71
- import com .oracle .graal .python .nodes .function .builtins .PythonUnaryBuiltinNode ;
72
69
import com .oracle .graal .python .nodes .object .IsBuiltinClassProfile ;
73
70
import com .oracle .graal .python .nodes .truffle .PythonArithmeticTypes ;
74
71
import com .oracle .graal .python .nodes .util .CannotCastException ;
75
72
import com .oracle .graal .python .nodes .util .CastToJavaStringNode ;
76
- import com .oracle .graal .python .runtime .PythonContext ;
77
73
import com .oracle .graal .python .runtime .exception .PException ;
78
74
import com .oracle .truffle .api .dsl .Cached ;
79
- import com .oracle .truffle .api .dsl .CachedContext ;
80
75
import com .oracle .truffle .api .dsl .GenerateNodeFactory ;
81
76
import com .oracle .truffle .api .dsl .NodeFactory ;
82
77
import com .oracle .truffle .api .dsl .Specialization ;
83
78
import com .oracle .truffle .api .dsl .TypeSystemReference ;
84
79
import com .oracle .truffle .api .frame .VirtualFrame ;
85
- import com .oracle .truffle .api .interop .ArityException ;
86
- import com .oracle .truffle .api .interop .InteropLibrary ;
87
- import com .oracle .truffle .api .interop .UnknownIdentifierException ;
88
- import com .oracle .truffle .api .interop .UnsupportedMessageException ;
89
- import com .oracle .truffle .api .interop .UnsupportedTypeException ;
90
- import com .oracle .truffle .api .library .CachedLibrary ;
91
80
import com .oracle .truffle .api .profiles .ConditionProfile ;
92
81
93
82
@ CoreFunctions (extendClasses = PythonBuiltinClassType .PythonModule )
@@ -98,31 +87,6 @@ protected List<? extends NodeFactory<? extends PythonBuiltinBaseNode>> getNodeFa
98
87
return ModuleBuiltinsFactory .getFactories ();
99
88
}
100
89
101
- @ Builtin (name = __REPR__ , minNumOfPositionalArgs = 1 , declaresExplicitSelf = true )
102
- @ GenerateNodeFactory
103
- public abstract static class ModuleReprNode extends PythonUnaryBuiltinNode {
104
- @ Specialization
105
- public Object repr (PythonModule self ,
106
- @ CachedLibrary (limit = "1" ) InteropLibrary lib ,
107
- @ CachedContext (PythonLanguage .class ) PythonContext context ) {
108
- // PyObject_CallMethod(interp->importlib, "_module_repr", "O", m);
109
- PythonModule builtins = context .getCore ().getBuiltins ();
110
- try {
111
- Object __import__ = lib .readMember (builtins , "__import__" );
112
- Object module_repr = importFrom (__import__ , "importlib._bootstrap" , "_module_repr" , lib );
113
- return lib .execute (module_repr , self );
114
- } catch (UnknownIdentifierException | UnsupportedMessageException | UnsupportedTypeException | ArityException e ) {
115
- return self .toString ();
116
- }
117
- }
118
-
119
- private Object importFrom (Object importBuiltinFunction , String moduleName , String from , InteropLibrary lib )
120
- throws UnsupportedTypeException , ArityException , UnsupportedMessageException , UnknownIdentifierException {
121
- Object _bootstrap = lib .execute (importBuiltinFunction , moduleName , PNone .NONE , PNone .NONE , factory ().createList (new Object []{from }));
122
- return lib .readMember (_bootstrap , from );
123
- }
124
- }
125
-
126
90
@ Builtin (name = __INIT__ , minNumOfPositionalArgs = 2 , declaresExplicitSelf = true , parameterNames = {"self" , "name" , "doc" })
127
91
@ GenerateNodeFactory
128
92
@ TypeSystemReference (PythonArithmeticTypes .class )
0 commit comments