45
45
import com .oracle .graal .python .builtins .Builtin ;
46
46
import com .oracle .graal .python .builtins .CoreFunctions ;
47
47
import 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 ;
49
49
import com .oracle .graal .python .nodes .function .PythonBuiltinBaseNode ;
50
- import com .oracle .graal .python .nodes .function .builtins .PythonBinaryBuiltinNode ;
51
50
import com .oracle .graal .python .nodes .function .builtins .PythonUnaryBuiltinNode ;
52
51
import com .oracle .graal .python .runtime .exception .PythonErrorType ;
53
52
import com .oracle .truffle .api .TruffleLanguage .Env ;
@@ -65,8 +64,7 @@ protected List<? extends NodeFactory<? extends PythonBuiltinBaseNode>> getNodeFa
65
64
@ Builtin (name = "type" , fixedNumOfPositionalArgs = 1 )
66
65
@ GenerateNodeFactory
67
66
abstract static class TypeNode extends PythonUnaryBuiltinNode {
68
- @ Specialization
69
- Object type (String name ) {
67
+ private Object get (String name ) {
70
68
Env env = getContext ().getEnv ();
71
69
if (!env .isHostLookupAllowed ()) {
72
70
throw raise (PythonErrorType .NotImplementedError , "host lookup is not allowed" );
@@ -83,13 +81,23 @@ Object type(String name) {
83
81
return hostValue ;
84
82
}
85
83
}
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
+ }
86
94
}
87
95
88
96
@ Builtin (name = "is_function" , fixedNumOfPositionalArgs = 1 )
89
97
@ GenerateNodeFactory
90
98
abstract static class IsFunctionNode extends PythonUnaryBuiltinNode {
91
99
@ Specialization
92
- Object check (Object object ) {
100
+ boolean check (Object object ) {
93
101
Env env = getContext ().getEnv ();
94
102
return env .isHostFunction (object );
95
103
}
@@ -99,7 +107,7 @@ Object check(Object object) {
99
107
@ GenerateNodeFactory
100
108
abstract static class IsObjectNode extends PythonUnaryBuiltinNode {
101
109
@ Specialization
102
- Object check (Object object ) {
110
+ boolean check (Object object ) {
103
111
Env env = getContext ().getEnv ();
104
112
return env .isHostObject (object );
105
113
}
@@ -109,7 +117,7 @@ Object check(Object object) {
109
117
@ GenerateNodeFactory
110
118
abstract static class IsSymbolNode extends PythonUnaryBuiltinNode {
111
119
@ Specialization
112
- Object check (Object object ) {
120
+ boolean check (Object object ) {
113
121
Env env = getContext ().getEnv ();
114
122
return env .isHostSymbol (object );
115
123
}
0 commit comments