|
28 | 28 |
|
29 | 29 | import static com.oracle.graal.python.nodes.SpecialAttributeNames.__CLASS__; |
30 | 30 | import static com.oracle.graal.python.nodes.SpecialAttributeNames.__DICT__; |
| 31 | +import static com.oracle.graal.python.nodes.SpecialAttributeNames.__MODULE__; |
| 32 | +import static com.oracle.graal.python.nodes.SpecialAttributeNames.__QUALNAME__; |
31 | 33 | import static com.oracle.graal.python.nodes.SpecialMethodNames.RICHCMP; |
32 | 34 | import static com.oracle.graal.python.nodes.SpecialMethodNames.__BOOL__; |
33 | 35 | import static com.oracle.graal.python.nodes.SpecialMethodNames.__DELATTR__; |
|
75 | 77 | import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; |
76 | 78 | import com.oracle.graal.python.nodes.function.builtins.PythonVarargsBuiltinNode; |
77 | 79 | import com.oracle.graal.python.nodes.object.GetClassNode; |
78 | | -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; |
79 | 80 | import com.oracle.truffle.api.CompilerDirectives; |
80 | 81 | import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; |
81 | 82 | import com.oracle.truffle.api.dsl.Cached; |
82 | 83 | import com.oracle.truffle.api.dsl.Fallback; |
83 | 84 | import com.oracle.truffle.api.dsl.GenerateNodeFactory; |
84 | 85 | import com.oracle.truffle.api.dsl.NodeFactory; |
85 | 86 | import com.oracle.truffle.api.dsl.Specialization; |
86 | | -import com.oracle.truffle.api.dsl.TypeSystemReference; |
87 | 87 | import com.oracle.truffle.api.frame.VirtualFrame; |
88 | 88 | import com.oracle.truffle.api.nodes.UnexpectedResultException; |
89 | 89 | import com.oracle.truffle.api.profiles.BranchProfile; |
@@ -168,17 +168,24 @@ public Object str(Object self, |
168 | 168 | } |
169 | 169 |
|
170 | 170 | @Builtin(name = __REPR__, fixedNumOfPositionalArgs = 1) |
171 | | - @TypeSystemReference(PythonArithmeticTypes.class) |
172 | 171 | @GenerateNodeFactory |
173 | 172 | public abstract static class ReprNode extends PythonUnaryBuiltinNode { |
174 | 173 | @Specialization |
175 | 174 | @TruffleBoundary |
176 | 175 | String repr(Object self, |
177 | | - @Cached("create()") GetClassNode getClass) { |
| 176 | + @Cached("create()") GetClassNode getClass, |
| 177 | + @Cached("create()") ReadAttributeFromObjectNode readModuleNode, |
| 178 | + @Cached("create()") ReadAttributeFromObjectNode readQualNameNode) { |
178 | 179 | if (self == PNone.NONE) { |
179 | 180 | return "None"; |
180 | 181 | } |
181 | | - return String.format("<%s object at 0x%x>", getClass.execute(self).getName(), self.hashCode()); |
| 182 | + PythonClass type = getClass.execute(self); |
| 183 | + Object moduleName = readModuleNode.execute(type, __MODULE__); |
| 184 | + Object qualName = readQualNameNode.execute(type, __QUALNAME__); |
| 185 | + if (moduleName != PNone.NO_VALUE && !moduleName.equals(getCore().getBuiltins().getModuleName())) { |
| 186 | + return String.format("<%s.%s object at 0x%x>", moduleName, qualName, self.hashCode()); |
| 187 | + } |
| 188 | + return String.format("<%s object at 0x%x>", qualName, self.hashCode()); |
182 | 189 | } |
183 | 190 | } |
184 | 191 |
|
|
0 commit comments