|
52 | 52 | import com.oracle.graal.python.builtins.objects.function.PArguments;
|
53 | 53 | import com.oracle.graal.python.builtins.objects.object.PythonObjectLibrary;
|
54 | 54 | import com.oracle.graal.python.nodes.SpecialMethodNames;
|
55 |
| -import com.oracle.graal.python.nodes.attributes.ReadAttributeFromObjectNode; |
56 |
| -import com.oracle.graal.python.nodes.attributes.WriteAttributeToObjectNode; |
57 | 55 | import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
|
58 | 56 | import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode;
|
59 | 57 | import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
|
@@ -150,22 +148,19 @@ boolean test(PDirEntry self) {
|
150 | 148 | }
|
151 | 149 | }
|
152 | 150 |
|
153 |
| - @Builtin(name = "stat", minNumOfPositionalArgs = 1, doc = "return stat_result object for the entry; cached per entry") |
| 151 | + @Builtin(name = "stat", minNumOfPositionalArgs = 1, parameterNames = {"$self", "follow_symlinks"}, doc = "return stat_result object for the entry; cached per entry") |
154 | 152 | @GenerateNodeFactory
|
155 |
| - abstract static class StatNode extends PythonUnaryBuiltinNode { |
156 |
| - private static final String STAT_RESULT = "__stat_result__"; |
| 153 | + abstract static class StatNode extends PythonBinaryBuiltinNode { |
157 | 154 |
|
158 | 155 | @Specialization
|
159 |
| - Object test(VirtualFrame frame, PDirEntry self, |
160 |
| - @Cached("create()") ReadAttributeFromObjectNode readNode, |
161 |
| - @Cached("create()") WriteAttributeToObjectNode writeNode, |
| 156 | + Object test(VirtualFrame frame, PDirEntry self, Object followSymlinks, |
162 | 157 | @Cached("create()") PosixModuleBuiltins.StatNode statNode) {
|
163 |
| - Object stat_result = readNode.execute(self, STAT_RESULT); |
164 |
| - if (stat_result == PNone.NO_VALUE) { |
165 |
| - stat_result = statNode.execute(frame, self.getFile().getAbsoluteFile().getPath(), PNone.NO_VALUE); |
166 |
| - writeNode.execute(self, STAT_RESULT, stat_result); |
| 158 | + Object statResult = self.getCachedStatResult(); |
| 159 | + if (statResult == null) { |
| 160 | + statResult = statNode.execute(frame, self.getFile().getAbsoluteFile().getPath(), followSymlinks); |
| 161 | + self.setCachedStatResult(statResult); |
167 | 162 | }
|
168 |
| - return stat_result; |
| 163 | + return statResult; |
169 | 164 | }
|
170 | 165 | }
|
171 | 166 |
|
|
0 commit comments