diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RSerialize.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RSerialize.java index 13399a622a4a24222487d9f8165d88fb6a4abde7..1c4f702778cab78ddeac249f4d4bfa2e69ca1f8d 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RSerialize.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RSerialize.java @@ -1821,7 +1821,8 @@ public class RSerialize { if (ss != null) { String path = RSource.getPathInternal(ss.getSource()); if (path != null) { - REnvironment createSrcfile = RSrcref.createSrcfile(path); + Path relPath = Paths.get(REnvVars.rHome()).relativize(Paths.get(path)); + REnvironment createSrcfile = RSrcref.createSrcfile(relPath); Object createLloc = RSrcref.createLloc(ss, createSrcfile); writePairListEntry(RRuntime.R_SRCREF, createLloc); writePairListEntry(RRuntime.R_SRCFILE, createSrcfile); @@ -2492,9 +2493,7 @@ public class RSerialize { SourceSection ss = getFileSourceSection(syntaxElement); if (ss != null && serObj instanceof RAttributable) { String pathInternal = RSource.getPathInternal(ss.getSource()); - String wd = REnvVars.rHome(); - Path wdPath = Paths.get(wd); - Path relPath = wdPath.relativize(Paths.get(pathInternal)); + Path relPath = Paths.get(REnvVars.rHome()).relativize(Paths.get(pathInternal)); RAttributable attributable = (RAttributable) serObj; attributable.setAttr(RRuntime.R_SRCFILE, RSrcref.createSrcfile(relPath)); RList createBlockSrcrefs = RSrcref.createBlockSrcrefs(syntaxElement); @@ -2739,10 +2738,15 @@ public class RSerialize { } } } catch (NoSuchFileException e) { - RError.warning(RError.SHOW_CALLER, RError.Message.GENERIC, "Missing source file: " + e.getMessage()); + assert debugWarning("Missing source file: " + e.getMessage()); } catch (IOException e) { - RError.warning(RError.SHOW_CALLER, RError.Message.GENERIC, "Cannot access source file: " + e.getMessage()); + assert debugWarning("Cannot access source file: " + e.getMessage()); } } } + + private static boolean debugWarning(String message) { + RError.warning(RError.SHOW_CALLER, RError.Message.GENERIC, message); + return true; + } } diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RSrcref.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RSrcref.java index a79bfefa1840a04a5e88bb92de0a88297b531fd2..e8da4c611e3dab75d3cc60c6baacf2a4d9c51162 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RSrcref.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RSrcref.java @@ -224,15 +224,20 @@ public class RSrcref { int length = getLineStartOffset(source, srcrefVec.getDataAt(2)) + srcrefVec.getDataAt(3) - startIdx + 1; return source.createSection(startLine, startColumn, length); } catch (NoSuchFileException e) { - RError.warning(RError.SHOW_CALLER, RError.Message.GENERIC, "Missing source file: " + e.getMessage()); + assert debugWarning("Missing source file: " + e.getMessage()); } catch (IOException e) { - RError.warning(RError.SHOW_CALLER, RError.Message.GENERIC, "Cannot access source file: " + e.getMessage()); + assert debugWarning("Cannot access source file: " + e.getMessage()); } catch (IllegalArgumentException e) { - RError.warning(RError.SHOW_CALLER, RError.Message.GENERIC, "Invalid source reference: " + e.getMessage()); + assert debugWarning("Invalid source reference: " + e.getMessage()); } return RSourceSectionNode.LAZY_DEPARSE; } + private static boolean debugWarning(String message) { + RError.warning(RError.SHOW_CALLER, RError.Message.GENERIC, message); + return true; + } + private static int getLineStartOffset(Source source, int lineNum) { try { return source.getLineStartOffset(lineNum);