From 1251ba2d6ac8f8614c3ac79f2e49b47e0177ce2d Mon Sep 17 00:00:00 2001 From: Florian Angerer <florian.angerer@oracle.com> Date: Fri, 2 Jun 2017 12:53:53 +0200 Subject: [PATCH] Restricting srcref generation to syntax elements with statement tag. --- .../oracle/truffle/r/runtime/RSerialize.java | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) 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 7aed042bc1..410a9d3b4f 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 @@ -39,6 +39,8 @@ import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.FrameSlot; import com.oracle.truffle.api.frame.FrameSlotKind; import com.oracle.truffle.api.frame.MaterializedFrame; +import com.oracle.truffle.api.instrumentation.StandardTags; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.object.DynamicObject; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.source.SourceSection; @@ -2301,7 +2303,9 @@ public class RSerialize { state.linkPairList(arguments.length); } Object pl = state.closePairList(); - attachSrcref(callElement, pl); + if (callElement instanceof Node && RContext.getRRuntimeASTAccess().isTaggedWith((Node) callElement, StandardTags.StatementTag.class)) { + attachSrcref(callElement, pl); + } state.setCdr(pl); } @@ -2428,20 +2432,18 @@ public class RSerialize { */ private static void attachSrcref(RSyntaxElement syntaxElement, Object serObj) { SourceSection ss = getFileSourceSection(syntaxElement); - if (ss != null) { - if (serObj instanceof RAttributable) { - String pathInternal = RSource.getPathInternal(ss.getSource()); - RAttributable attributable = (RAttributable) serObj; - attributable.setAttr(RRuntime.R_SRCFILE, RSrcref.createSrcfile(pathInternal)); - RList createBlockSrcrefs = RSrcref.createBlockSrcrefs(syntaxElement); - if (createBlockSrcrefs != null) { - attributable.setAttr(RRuntime.R_SRCREF, createBlockSrcrefs); - attributable.setAttr(RRuntime.R_WHOLE_SRCREF, RSrcref.createLloc(ss)); - } else { - Object createLloc = RSrcref.createLloc(ss); - attributable.setAttr(RRuntime.R_SRCREF, createLloc); - attributable.setAttr(RRuntime.R_WHOLE_SRCREF, RSrcref.createLloc(ss)); - } + if (ss != null && serObj instanceof RAttributable) { + String pathInternal = RSource.getPathInternal(ss.getSource()); + RAttributable attributable = (RAttributable) serObj; + attributable.setAttr(RRuntime.R_SRCFILE, RSrcref.createSrcfile(pathInternal)); + RList createBlockSrcrefs = RSrcref.createBlockSrcrefs(syntaxElement); + if (createBlockSrcrefs != null) { + attributable.setAttr(RRuntime.R_SRCREF, createBlockSrcrefs); + attributable.setAttr(RRuntime.R_WHOLE_SRCREF, RSrcref.createLloc(ss)); + } else { + Object createLloc = RSrcref.createLloc(ss); + attributable.setAttr(RRuntime.R_SRCREF, createLloc); + attributable.setAttr(RRuntime.R_WHOLE_SRCREF, RSrcref.createLloc(ss)); } } } -- GitLab