9
9
*/
10
10
package org .truffleruby .core .thread ;
11
11
12
- import java .io .File ;
13
-
14
12
import org .jcodings .specific .UTF8Encoding ;
15
13
import org .truffleruby .Layouts ;
16
14
import org .truffleruby .RubyContext ;
22
20
import org .truffleruby .core .string .StringNodes ;
23
21
import org .truffleruby .core .string .StringOperations ;
24
22
import org .truffleruby .language .backtrace .Backtrace ;
23
+ import org .truffleruby .language .backtrace .BacktraceFormatter ;
25
24
26
25
import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
27
26
import com .oracle .truffle .api .TruffleStackTraceElement ;
28
27
import com .oracle .truffle .api .dsl .Cached ;
29
28
import com .oracle .truffle .api .dsl .Specialization ;
30
29
import com .oracle .truffle .api .object .DynamicObject ;
30
+ import com .oracle .truffle .api .source .Source ;
31
31
import com .oracle .truffle .api .source .SourceSection ;
32
- import org .truffleruby .language .backtrace .BacktraceFormatter ;
33
32
34
33
@ CoreModule (value = "Thread::Backtrace::Location" , isClass = true )
35
34
public class ThreadBacktraceLocationNodes {
@@ -56,16 +55,17 @@ protected DynamicObject absolutePath(DynamicObject threadBacktraceLocation,
56
55
if (sourceSection == null ) {
57
56
return coreStrings ().UNKNOWN .createInstance ();
58
57
} else {
59
- final String path = RubyContext .getPath (sourceSection .getSource ());
60
- if (new File (path ).isAbsolute ()) { // A normal file
58
+ final Source source = sourceSection .getSource ();
59
+ final String path = RubyContext .getPath (source );
60
+ if (source .getPath () != null ) { // A normal file
61
61
final String canonicalPath = getContext ().getFeatureLoader ().canonicalize (path );
62
62
final Rope cachedRope = getContext ()
63
63
.getRopeCache ()
64
64
.getRope (StringOperations .encodeRope (canonicalPath , UTF8Encoding .INSTANCE ));
65
65
return makeStringNode .fromRope (cachedRope );
66
66
} else { // eval()
67
67
return makeStringNode
68
- .fromRope (getContext ().getPathToRopeCache ().getCachedPath (sourceSection . getSource () ));
68
+ .fromRope (getContext ().getPathToRopeCache ().getCachedPath (source ));
69
69
}
70
70
}
71
71
}
0 commit comments