4545import com .oracle .graal .python .builtins .Builtin ;
4646import com .oracle .graal .python .builtins .CoreFunctions ;
4747import com .oracle .graal .python .builtins .PythonBuiltins ;
48- import com .oracle .graal .python .builtins .objects .PNone ;
48+ import com .oracle .graal .python .builtins .objects .str . PString ;
4949import com .oracle .graal .python .nodes .function .PythonBuiltinBaseNode ;
50- import com .oracle .graal .python .nodes .function .builtins .PythonBinaryBuiltinNode ;
5150import com .oracle .graal .python .nodes .function .builtins .PythonUnaryBuiltinNode ;
5251import com .oracle .graal .python .runtime .exception .PythonErrorType ;
5352import com .oracle .truffle .api .TruffleLanguage .Env ;
@@ -65,8 +64,7 @@ protected List<? extends NodeFactory<? extends PythonBuiltinBaseNode>> getNodeFa
6564 @ Builtin (name = "type" , fixedNumOfPositionalArgs = 1 )
6665 @ GenerateNodeFactory
6766 abstract static class TypeNode extends PythonUnaryBuiltinNode {
68- @ Specialization
69- Object type (String name ) {
67+ private Object get (String name ) {
7068 Env env = getContext ().getEnv ();
7169 if (!env .isHostLookupAllowed ()) {
7270 throw raise (PythonErrorType .NotImplementedError , "host lookup is not allowed" );
@@ -83,13 +81,23 @@ Object type(String name) {
8381 return hostValue ;
8482 }
8583 }
84+
85+ @ Specialization
86+ Object type (String name ) {
87+ return get (name );
88+ }
89+
90+ @ Specialization
91+ Object type (PString name ) {
92+ return get (name .getValue ());
93+ }
8694 }
8795
8896 @ Builtin (name = "is_function" , fixedNumOfPositionalArgs = 1 )
8997 @ GenerateNodeFactory
9098 abstract static class IsFunctionNode extends PythonUnaryBuiltinNode {
9199 @ Specialization
92- Object check (Object object ) {
100+ boolean check (Object object ) {
93101 Env env = getContext ().getEnv ();
94102 return env .isHostFunction (object );
95103 }
@@ -99,7 +107,7 @@ Object check(Object object) {
99107 @ GenerateNodeFactory
100108 abstract static class IsObjectNode extends PythonUnaryBuiltinNode {
101109 @ Specialization
102- Object check (Object object ) {
110+ boolean check (Object object ) {
103111 Env env = getContext ().getEnv ();
104112 return env .isHostObject (object );
105113 }
@@ -109,7 +117,7 @@ Object check(Object object) {
109117 @ GenerateNodeFactory
110118 abstract static class IsSymbolNode extends PythonUnaryBuiltinNode {
111119 @ Specialization
112- Object check (Object object ) {
120+ boolean check (Object object ) {
113121 Env env = getContext ().getEnv ();
114122 return env .isHostSymbol (object );
115123 }
0 commit comments