72
72
import com .oracle .graal .python .builtins .objects .function .PKeyword ;
73
73
import com .oracle .graal .python .builtins .objects .iterator .PForeignArrayIterator ;
74
74
import com .oracle .graal .python .builtins .objects .list .PList ;
75
- import com .oracle .graal .python .builtins .objects .object .ObjectBuiltins ;
76
75
import com .oracle .graal .python .builtins .objects .object .ObjectBuiltinsFactory ;
77
76
import com .oracle .graal .python .nodes .PGuards ;
78
77
import com .oracle .graal .python .nodes .call .special .LookupAndCallBinaryNode ;
@@ -958,8 +957,9 @@ protected Object doIt(TruffleObject object) {
958
957
@ Builtin (name = __STR__ , fixedNumOfPositionalArgs = 1 )
959
958
@ GenerateNodeFactory
960
959
abstract static class StrNode extends UnboxNode {
960
+ protected final String method = __STR__ ;
961
961
@ Child private LookupAndCallUnaryNode callStrNode ;
962
- @ Child private ObjectBuiltins . StrNode objectStrNode ;
962
+ @ Child protected PythonUnaryBuiltinNode objectStrNode ;
963
963
@ Child private Node getSizeNode ;
964
964
@ Child private Node readNode ;
965
965
@@ -996,12 +996,12 @@ protected Object doIt(Object object) {
996
996
private LookupAndCallUnaryNode getCallStrNode () {
997
997
if (callStrNode == null ) {
998
998
CompilerDirectives .transferToInterpreterAndInvalidate ();
999
- callStrNode = insert (LookupAndCallUnaryNode .create (__STR__ ));
999
+ callStrNode = insert (LookupAndCallUnaryNode .create (method ));
1000
1000
}
1001
1001
return callStrNode ;
1002
1002
}
1003
1003
1004
- private ObjectBuiltins . StrNode getObjectStrNode () {
1004
+ protected PythonUnaryBuiltinNode getObjectStrNode () {
1005
1005
if (objectStrNode == null ) {
1006
1006
CompilerDirectives .transferToInterpreterAndInvalidate ();
1007
1007
objectStrNode = insert (ObjectBuiltinsFactory .StrNodeFactory .create ());
@@ -1012,36 +1012,16 @@ private ObjectBuiltins.StrNode getObjectStrNode() {
1012
1012
1013
1013
@ Builtin (name = __REPR__ , fixedNumOfPositionalArgs = 1 )
1014
1014
@ GenerateNodeFactory
1015
- abstract static class ReprNode extends UnboxNode {
1016
- @ Child private LookupAndCallUnaryNode callReprNode ;
1017
- @ Child private ObjectBuiltins .ReprNode objectReprNode ;
1015
+ abstract static class ReprNode extends StrNode {
1016
+ protected final String method = __REPR__ ;
1018
1017
1019
- @ Specialization (guards = "isForeignObject(object)" )
1020
- protected Object doIt (TruffleObject object ) {
1021
- if (isBoxed (object )) {
1022
- try {
1023
- return getCallReprNode ().executeObject (unboxLeft (object ));
1024
- } catch (UnsupportedMessageException e ) {
1025
- throw new IllegalStateException ("The object '%s' claims to be boxed, but does not support the UNBOX message" );
1026
- }
1027
- }
1028
- return getObjectReprNode ().execute (object );
1029
- }
1030
-
1031
- private LookupAndCallUnaryNode getCallReprNode () {
1032
- if (callReprNode == null ) {
1033
- CompilerDirectives .transferToInterpreterAndInvalidate ();
1034
- callReprNode = insert (LookupAndCallUnaryNode .create (__REPR__ ));
1035
- }
1036
- return callReprNode ;
1037
- }
1038
-
1039
- private ObjectBuiltins .ReprNode getObjectReprNode () {
1040
- if (objectReprNode == null ) {
1018
+ @ Override
1019
+ protected PythonUnaryBuiltinNode getObjectStrNode () {
1020
+ if (objectStrNode == null ) {
1041
1021
CompilerDirectives .transferToInterpreterAndInvalidate ();
1042
- objectReprNode = insert (ObjectBuiltinsFactory .ReprNodeFactory .create ());
1022
+ objectStrNode = insert (ObjectBuiltinsFactory .ReprNodeFactory .create ());
1043
1023
}
1044
- return objectReprNode ;
1024
+ return objectStrNode ;
1045
1025
}
1046
1026
}
1047
1027
}
0 commit comments