42
42
43
43
import static com .oracle .graal .python .nodes .BuiltinNames .CONTEXTVARS ;
44
44
45
- import com .oracle .graal .python .builtins .Builtin ;
46
45
import java .util .List ;
47
46
47
+ import com .oracle .graal .python .builtins .Builtin ;
48
48
import com .oracle .graal .python .builtins .CoreFunctions ;
49
49
import com .oracle .graal .python .builtins .PythonBuiltinClassType ;
50
50
import com .oracle .graal .python .builtins .PythonBuiltins ;
51
51
import com .oracle .graal .python .builtins .objects .PNone ;
52
52
import com .oracle .graal .python .builtins .objects .contextvars .PContextVar ;
53
- import com .oracle .graal .python .lib .PyObjectLookupAttr ;
54
- import com .oracle .graal .python .nodes .call .CallNode ;
53
+ import com .oracle .graal .python .builtins .objects .function .PKeyword ;
55
54
import com .oracle .graal .python .nodes .function .PythonBuiltinBaseNode ;
56
55
import com .oracle .graal .python .nodes .function .PythonBuiltinNode ;
57
56
import com .oracle .graal .python .nodes .function .builtins .PythonTernaryBuiltinNode ;
58
57
import com .oracle .graal .python .nodes .statement .ImportNode ;
59
- import com .oracle .truffle . api . dsl . Cached ;
58
+ import com .oracle .graal . python . util . PythonUtils ;
60
59
import com .oracle .truffle .api .dsl .GenerateNodeFactory ;
61
60
import com .oracle .truffle .api .dsl .NodeFactory ;
62
61
import com .oracle .truffle .api .dsl .Specialization ;
@@ -83,21 +82,13 @@ protected Object copyCtx() {
83
82
@ GenerateNodeFactory
84
83
public abstract static class ContextVarNode extends PythonTernaryBuiltinNode {
85
84
@ Specialization
86
- protected Object construct (VirtualFrame frame , Object cls , String name , PNone def ,
87
- @ Cached ("createImportThreading()" ) ImportNode .ImportExpression threadingImport ,
88
- @ Cached PyObjectLookupAttr lookupAttrNode ,
89
- @ Cached CallNode callNode ) {
90
- return constructDef (frame , cls , name , PContextVar .NO_DEFAULT , threadingImport , lookupAttrNode , callNode );
85
+ protected Object construct (VirtualFrame frame , Object cls , String name , PNone def ) {
86
+ return constructDef (frame , cls , name , PContextVar .NO_DEFAULT );
91
87
}
92
88
93
89
@ Specialization (guards = "!isPNone(def)" )
94
- protected Object constructDef (VirtualFrame frame , Object cls , String name , Object def ,
95
- @ Cached ("createImportThreading()" ) ImportNode .ImportExpression threadingImport ,
96
- @ Cached PyObjectLookupAttr lookupAttrNode ,
97
- @ Cached CallNode callNode ) {
98
- Object threading = threadingImport .execute (frame );
99
- Object localCallable = lookupAttrNode .execute (frame , threading , "local" );
100
- Object local = callNode .execute (frame , localCallable );
90
+ protected Object constructDef (VirtualFrame frame , Object cls , String name , Object def ) {
91
+ Object local = factory ().createThreadLocal (PythonBuiltinClassType .PThreadLocal , PythonUtils .EMPTY_OBJECT_ARRAY , PKeyword .EMPTY_KEYWORDS );
101
92
return factory ().createContextVar (name , def , local );
102
93
}
103
94
0 commit comments