57
57
import com .oracle .graal .python .builtins .modules .PosixModuleBuiltins .PathConversionNode ;
58
58
import com .oracle .graal .python .builtins .modules .PosixModuleBuiltins .PosixPath ;
59
59
import com .oracle .graal .python .builtins .objects .PNone ;
60
+ import com .oracle .graal .python .lib .PyOSFSPathNode ;
60
61
import com .oracle .graal .python .nodes .function .PythonBuiltinBaseNode ;
62
+ import com .oracle .graal .python .nodes .function .builtins .PythonUnaryBuiltinNode ;
61
63
import com .oracle .graal .python .nodes .function .builtins .PythonUnaryClinicBuiltinNode ;
62
64
import com .oracle .graal .python .nodes .function .builtins .clinic .ArgumentClinicProvider ;
65
+ import com .oracle .graal .python .nodes .util .CannotCastException ;
66
+ import com .oracle .graal .python .nodes .util .CastToJavaStringNode ;
63
67
import com .oracle .graal .python .runtime .PosixSupportLibrary ;
68
+ import com .oracle .graal .python .util .PythonUtils ;
64
69
import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
70
+ import com .oracle .truffle .api .dsl .Cached ;
65
71
import com .oracle .truffle .api .dsl .GenerateNodeFactory ;
66
72
import com .oracle .truffle .api .dsl .NodeFactory ;
67
73
import com .oracle .truffle .api .dsl .Specialization ;
@@ -88,20 +94,20 @@ public void initialize(Python3Core core) {
88
94
}
89
95
90
96
@ Builtin (name = "_getfullpathname" , minNumOfPositionalArgs = 1 , parameterNames = {"path" })
91
- @ ArgumentClinic (name = "path" , conversionClass = PathConversionNode .class , args = {"false" , "false" })
92
97
@ GenerateNodeFactory
93
- abstract static class GetfullpathnameNode extends PythonUnaryClinicBuiltinNode {
98
+ abstract static class GetfullpathnameNode extends PythonUnaryBuiltinNode {
94
99
@ Specialization
95
100
@ TruffleBoundary
96
- Object getfullpathname (PosixPath path ,
97
- @ CachedLibrary ("getPosixSupport()" ) PosixSupportLibrary posixLib ) {
101
+ Object getfullpathname (Object path ,
102
+ @ Cached PyOSFSPathNode fsPathNode ,
103
+ @ Cached CastToJavaStringNode castStr ) {
98
104
// TODO should call win api
99
- return posixLib . getPathAsString ( getPosixSupport (), path . value );
100
- }
101
-
102
- @ Override
103
- protected ArgumentClinicProvider getArgumentClinic () {
104
- return NtModuleBuiltinsClinicProviders . GetfullpathnameNodeClinicProviderGen . INSTANCE ;
105
+ try {
106
+ String fspath = castStr . execute ( fsPathNode . execute ( null , path ));
107
+ return PythonUtils . toTruffleStringUncached ( getContext (). getEnv (). getPublicTruffleFile ( fspath ). getAbsoluteFile (). toString ());
108
+ } catch ( CannotCastException e ) {
109
+ return path ;
110
+ }
105
111
}
106
112
}
107
113
0 commit comments