|
141 | 141 | import com.oracle.graal.python.nodes.attributes.HasInheritedAttributeNode;
|
142 | 142 | import com.oracle.graal.python.nodes.attributes.LookupAttributeInMRONode;
|
143 | 143 | import com.oracle.graal.python.nodes.attributes.ReadAttributeFromObjectNode;
|
| 144 | +import com.oracle.graal.python.nodes.attributes.WriteAttributeToDynamicObjectNode; |
144 | 145 | import com.oracle.graal.python.nodes.attributes.WriteAttributeToObjectNode;
|
145 | 146 | import com.oracle.graal.python.nodes.call.InvokeNode;
|
146 | 147 | import com.oracle.graal.python.nodes.call.PythonCallNode;
|
@@ -590,25 +591,25 @@ Object op5(VirtualFrame frame, Object a, Object b, @SuppressWarnings("unused") i
|
590 | 591 |
|
591 | 592 | @Builtin(name = "PyTruffle_SetAttr", minNumOfPositionalArgs = 3)
|
592 | 593 | @GenerateNodeFactory
|
593 |
| - abstract static class PyObject_Setattr extends PythonBuiltinNode { |
| 594 | + abstract static class PyObject_Setattr extends PythonTernaryBuiltinNode { |
594 | 595 | @Specialization
|
595 |
| - @TruffleBoundary |
596 |
| - Object setattr(PythonBuiltinClass object, String key, Object value) { |
597 |
| - object.setAttributeUnsafe(key, value); |
| 596 | + Object doBuiltinClass(PythonBuiltinClass object, String key, Object value, |
| 597 | + @Exclusive @Cached("createForceType()") WriteAttributeToObjectNode writeAttrNode) { |
| 598 | + writeAttrNode.execute(object, key, value); |
598 | 599 | return PNone.NONE;
|
599 | 600 | }
|
600 | 601 |
|
601 |
| - @Specialization(guards = {"!isPythonBuiltinClass(object)"}) |
602 |
| - @TruffleBoundary |
603 |
| - Object setattr(PythonObject object, String key, Object value) { |
604 |
| - object.getStorage().define(key, value); |
| 602 | + @Specialization |
| 603 | + Object doNativeClass(PythonNativeClass object, String key, Object value, |
| 604 | + @Exclusive @Cached("createForceType()") WriteAttributeToObjectNode writeAttrNode) { |
| 605 | + writeAttrNode.execute(object, key, value); |
605 | 606 | return PNone.NONE;
|
606 | 607 | }
|
607 | 608 |
|
608 |
| - @Specialization |
609 |
| - Object setattr(PythonNativeClass object, String key, Object value, |
610 |
| - @Cached("createForceType()") WriteAttributeToObjectNode writeAttrNode) { |
611 |
| - writeAttrNode.execute(object, key, value); |
| 609 | + @Specialization(guards = {"!isPythonBuiltinClass(object)"}) |
| 610 | + Object doObject(PythonObject object, String key, Object value, |
| 611 | + @Exclusive @Cached WriteAttributeToDynamicObjectNode writeAttrToDynamicObjectNode) { |
| 612 | + writeAttrToDynamicObjectNode.execute(object.getStorage(), key, value); |
612 | 613 | return PNone.NONE;
|
613 | 614 | }
|
614 | 615 | }
|
|
0 commit comments