File tree Expand file tree Collapse file tree 3 files changed +15
-14
lines changed
graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set Expand file tree Collapse file tree 3 files changed +15
-14
lines changed Original file line number Diff line number Diff line change 33
33
34
34
public abstract class PBaseSet extends PHashingCollection {
35
35
36
- protected final HashingStorage set ;
36
+ private HashingStorage set ;
37
37
38
38
public PBaseSet (Object clazz , DynamicObject storage ) {
39
39
super (clazz , storage );
@@ -58,4 +58,9 @@ public int size() {
58
58
public HashingStorage getDictStorage () {
59
59
return set ;
60
60
}
61
+
62
+ @ Override
63
+ public void setDictStorage (HashingStorage storage ) {
64
+ set = storage ;
65
+ }
61
66
}
Original file line number Diff line number Diff line change 26
26
package com .oracle .graal .python .builtins .objects .set ;
27
27
28
28
import com .oracle .graal .python .builtins .objects .common .HashingStorage ;
29
- import com .oracle .truffle .api .CompilerDirectives ;
30
29
import com .oracle .truffle .api .object .DynamicObject ;
31
30
32
31
public final class PSet extends PBaseSet {
@@ -38,13 +37,4 @@ public PSet(Object clazz, DynamicObject storage) {
38
37
public PSet (Object clazz , DynamicObject storage , HashingStorage store ) {
39
38
super (clazz , storage , store );
40
39
}
41
-
42
- @ Override
43
- public void setDictStorage (HashingStorage newStorage ) {
44
- // ignore if storage stays unchanged
45
- if (newStorage != getDictStorage ()) {
46
- CompilerDirectives .transferToInterpreterAndInvalidate ();
47
- throw new RuntimeException ("set has fixed storage" );
48
- }
49
- }
50
40
}
Original file line number Diff line number Diff line change 38
38
import com .oracle .graal .python .builtins .PythonBuiltins ;
39
39
import com .oracle .graal .python .builtins .objects .PNone ;
40
40
import com .oracle .graal .python .builtins .objects .common .HashingCollectionNodes ;
41
+ import com .oracle .graal .python .builtins .objects .common .HashingCollectionNodes .GetDictStorageNode ;
42
+ import com .oracle .graal .python .builtins .objects .common .HashingCollectionNodes .SetDictStorageNode ;
41
43
import com .oracle .graal .python .builtins .objects .common .HashingStorage ;
42
44
import com .oracle .graal .python .builtins .objects .common .HashingStorageLibrary ;
43
45
import com .oracle .graal .python .nodes .ErrorMessages ;
@@ -74,9 +76,13 @@ protected List<? extends NodeFactory<? extends PythonBuiltinBaseNode>> getNodeFa
74
76
@ GenerateNodeFactory
75
77
public abstract static class ClearNode extends PythonUnaryBuiltinNode {
76
78
77
- @ Specialization
78
- public Object clear (PSet self , @ CachedLibrary (limit = "1" ) HashingStorageLibrary lib ) {
79
- lib .clear (self .getDictStorage ());
79
+ @ Specialization (limit = "1" )
80
+ public Object clear (PSet self ,
81
+ @ Cached GetDictStorageNode getStorage ,
82
+ @ Cached SetDictStorageNode setStorage ,
83
+ @ CachedLibrary ("getStorage.execute(self)" ) HashingStorageLibrary lib ) {
84
+ HashingStorage newStorage = lib .clear (getStorage .execute (self ));
85
+ setStorage .execute (self , newStorage );
80
86
return PNone .NONE ;
81
87
}
82
88
}
You can’t perform that action at this time.
0 commit comments