67
67
import com .oracle .graal .python .builtins .objects .PNotImplemented ;
68
68
import com .oracle .graal .python .builtins .objects .function .PKeyword ;
69
69
import com .oracle .graal .python .builtins .objects .list .PList ;
70
+ import com .oracle .graal .python .builtins .objects .object .ObjectBuiltins ;
71
+ import com .oracle .graal .python .builtins .objects .object .ObjectBuiltinsFactory ;
70
72
import com .oracle .graal .python .nodes .PGuards ;
71
73
import com .oracle .graal .python .nodes .call .special .LookupAndCallBinaryNode ;
72
74
import com .oracle .graal .python .nodes .call .special .LookupAndCallUnaryNode ;
@@ -931,6 +933,7 @@ protected Object doIt(TruffleObject object) {
931
933
@ GenerateNodeFactory
932
934
abstract static class StrNode extends UnboxNode {
933
935
@ Child private LookupAndCallUnaryNode callStrNode ;
936
+ @ Child private ObjectBuiltins .StrNode objectStrNode ;
934
937
935
938
@ Specialization (guards = "isForeignObject(object)" )
936
939
protected Object doIt (TruffleObject object ) {
@@ -941,7 +944,7 @@ protected Object doIt(TruffleObject object) {
941
944
throw new IllegalStateException ("The object '%s' claims to be boxed, but does not support the UNBOX message" );
942
945
}
943
946
}
944
- throw raise ( PythonErrorType . AttributeError );
947
+ return getObjectStrNode (). execute ( object );
945
948
}
946
949
947
950
private LookupAndCallUnaryNode getCallStrNode () {
@@ -951,12 +954,21 @@ private LookupAndCallUnaryNode getCallStrNode() {
951
954
}
952
955
return callStrNode ;
953
956
}
957
+
958
+ private ObjectBuiltins .StrNode getObjectStrNode () {
959
+ if (objectStrNode == null ) {
960
+ CompilerDirectives .transferToInterpreterAndInvalidate ();
961
+ objectStrNode = insert (ObjectBuiltinsFactory .StrNodeFactory .create ());
962
+ }
963
+ return objectStrNode ;
964
+ }
954
965
}
955
966
956
967
@ Builtin (name = __REPR__ , fixedNumOfArguments = 1 )
957
968
@ GenerateNodeFactory
958
969
abstract static class ReprNode extends UnboxNode {
959
970
@ Child private LookupAndCallUnaryNode callReprNode ;
971
+ @ Child private ObjectBuiltins .ReprNode objectReprNode ;
960
972
961
973
@ Specialization (guards = "isForeignObject(object)" )
962
974
protected Object doIt (TruffleObject object ) {
@@ -967,7 +979,7 @@ protected Object doIt(TruffleObject object) {
967
979
throw new IllegalStateException ("The object '%s' claims to be boxed, but does not support the UNBOX message" );
968
980
}
969
981
}
970
- throw raise ( PythonErrorType . AttributeError );
982
+ return getObjectReprNode (). execute ( object );
971
983
}
972
984
973
985
private LookupAndCallUnaryNode getCallReprNode () {
@@ -977,5 +989,13 @@ private LookupAndCallUnaryNode getCallReprNode() {
977
989
}
978
990
return callReprNode ;
979
991
}
992
+
993
+ private ObjectBuiltins .ReprNode getObjectReprNode () {
994
+ if (objectReprNode == null ) {
995
+ CompilerDirectives .transferToInterpreterAndInvalidate ();
996
+ objectReprNode = insert (ObjectBuiltinsFactory .ReprNodeFactory .create ());
997
+ }
998
+ return objectReprNode ;
999
+ }
980
1000
}
981
1001
}
0 commit comments