|
62 | 62 | import com.oracle.graal.python.nodes.PGuards;
|
63 | 63 | import com.oracle.graal.python.nodes.PNodeWithContext;
|
64 | 64 | import com.oracle.graal.python.nodes.PRaiseNode;
|
| 65 | +import static com.oracle.graal.python.nodes.SpecialAttributeNames.__NAME__; |
| 66 | +import static com.oracle.graal.python.nodes.SpecialAttributeNames.__QUALNAME__; |
| 67 | +import static com.oracle.graal.python.nodes.SpecialMethodNames.__OBJCLASS__; |
| 68 | +import com.oracle.graal.python.nodes.attributes.GetAttributeNode.GetFixedAttributeNode; |
65 | 69 | import com.oracle.graal.python.nodes.attributes.ReadAttributeFromObjectNode;
|
66 | 70 | import com.oracle.graal.python.nodes.attributes.WriteAttributeToObjectNode;
|
67 | 71 | import com.oracle.graal.python.nodes.call.special.CallBinaryMethodNode;
|
@@ -96,13 +100,59 @@ protected List<? extends NodeFactory<? extends PythonBuiltinBaseNode>> getNodeFa
|
96 | 100 | @GenerateNodeFactory
|
97 | 101 | abstract static class GetSetReprNode extends PythonUnaryBuiltinNode {
|
98 | 102 | @Specialization
|
99 |
| - Object repr(GetSetDescriptor descr) { |
100 |
| - return PythonUtils.format("<attribute '%s' of '%s' objects>", descr.getName(), GetNameNode.doSlowPath(descr.getType())); |
| 103 | + Object repr(GetSetDescriptor descr, |
| 104 | + @Cached GetNameNode getName) { |
| 105 | + return PythonUtils.format("<attribute '%s' of '%s' objects>", descr.getName(), getName.execute(descr.getType())); |
101 | 106 | }
|
102 | 107 |
|
103 | 108 | @Specialization
|
104 |
| - Object repr(HiddenKeyDescriptor descr) { |
105 |
| - return PythonUtils.format("<attribute '%s' of '%s' objects>", descr.getKey(), GetNameNode.doSlowPath(descr.getType())); |
| 109 | + Object repr(HiddenKeyDescriptor descr, |
| 110 | + @Cached GetNameNode getName) { |
| 111 | + return PythonUtils.format("<attribute '%s' of '%s' objects>", descr.getKey(), getName.execute(descr.getType())); |
| 112 | + } |
| 113 | + } |
| 114 | + |
| 115 | + @Builtin(name = __OBJCLASS__, minNumOfPositionalArgs = 1, isGetter = true) |
| 116 | + @GenerateNodeFactory |
| 117 | + public abstract static class ObjclassNode extends PythonUnaryBuiltinNode { |
| 118 | + @Specialization |
| 119 | + Object objclass(GetSetDescriptor self) { |
| 120 | + return self; |
| 121 | + } |
| 122 | + |
| 123 | + @Specialization |
| 124 | + Object objclass(HiddenKeyDescriptor self) { |
| 125 | + return self; |
| 126 | + } |
| 127 | + } |
| 128 | + |
| 129 | + @Builtin(name = __QUALNAME__, minNumOfPositionalArgs = 1, isGetter = true) |
| 130 | + @GenerateNodeFactory |
| 131 | + public abstract static class QualnameNode extends PythonUnaryBuiltinNode { |
| 132 | + @Specialization |
| 133 | + Object qualname(VirtualFrame frame, GetSetDescriptor self, |
| 134 | + @Cached("create(__QUALNAME__)") GetFixedAttributeNode readQualNameNode) { |
| 135 | + return PythonUtils.format("%s.%s", readQualNameNode.executeObject(frame, self.getType()), self.getName()); |
| 136 | + } |
| 137 | + |
| 138 | + @Specialization |
| 139 | + Object qualname(VirtualFrame frame, HiddenKeyDescriptor self, |
| 140 | + @Cached("create(__QUALNAME__)") GetFixedAttributeNode readQualNameNode) { |
| 141 | + return PythonUtils.format("%s.%s", readQualNameNode.executeObject(frame, self.getType()), self.getKey().getName()); |
| 142 | + } |
| 143 | + } |
| 144 | + |
| 145 | + @Builtin(name = __NAME__, minNumOfPositionalArgs = 1, isGetter = true) |
| 146 | + @GenerateNodeFactory |
| 147 | + public abstract static class NameNode extends PythonUnaryBuiltinNode { |
| 148 | + @Specialization |
| 149 | + Object qualname(GetSetDescriptor self) { |
| 150 | + return self.getName(); |
| 151 | + } |
| 152 | + |
| 153 | + @Specialization |
| 154 | + Object qualname(HiddenKeyDescriptor self) { |
| 155 | + return self.getKey().getName(); |
106 | 156 | }
|
107 | 157 | }
|
108 | 158 |
|
|
0 commit comments