diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/GridContext.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/GridContext.java index 928e050945ce7f070f6cade8a4b713191b3abeb8..688c3aa6344d79d994cf23b3fb4546485e4fe627 100644 --- a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/GridContext.java +++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/GridContext.java @@ -34,6 +34,7 @@ import com.oracle.truffle.r.library.fastrGrid.device.GridDevice.DeviceCloseExcep import com.oracle.truffle.r.library.fastrGrid.device.SVGDevice; import com.oracle.truffle.r.library.fastrGrid.device.awt.BufferedImageDevice; import com.oracle.truffle.r.library.fastrGrid.device.awt.BufferedImageDevice.NotSupportedImageFormatException; +import com.oracle.truffle.r.library.fastrGrid.grDevices.FileDevUtils; import com.oracle.truffle.r.library.fastrGrid.graphics.RGridGraphicsAdapter; import com.oracle.truffle.r.runtime.FastRConfig; import com.oracle.truffle.r.runtime.RCaller; @@ -107,13 +108,15 @@ public final class GridContext { } setCurrentDevice(defaultDev, WindowDevice.createWindowDevice()); } else if (defaultDev.equals("svg")) { - setCurrentDevice(defaultDev, new SVGDevice("Rplot.svg", GridDevice.DEFAULT_WIDTH, GridDevice.DEFAULT_HEIGHT)); + String filename = "Rplot%03d.svg"; + SVGDevice svgDevice = new SVGDevice(FileDevUtils.formatInitialFilename(filename), GridDevice.DEFAULT_WIDTH, GridDevice.DEFAULT_HEIGHT); + setCurrentDevice(defaultDev, svgDevice, filename); } else if (defaultDev.equals("png")) { - setCurrentDevice(defaultDev, safeOpenImageDev("Rplot.png", "png")); + safeOpenImageDev("Rplot%03d.png", "png"); } else if (defaultDev.equals("bmp")) { - setCurrentDevice(defaultDev, safeOpenImageDev("Rplot.bmp", "bmp")); + safeOpenImageDev("Rplot%03d.bmp", "bmp"); } else if (defaultDev.equals("jpg") || defaultDev.equals("jpeg")) { - setCurrentDevice("jpeg", safeOpenImageDev("Rplot.jpg", "jpeg")); + safeOpenImageDev("Rplot%03d.jpg", "jpeg"); } else { throw RError.error(RError.NO_CALLER, Message.GENERIC, "FastR does not support device '" + defaultDev + "'."); } @@ -149,15 +152,17 @@ public final class GridContext { return RContext.getEngine().evalFunction(redrawAll, REnvironment.baseEnv().getFrame(), RCaller.topLevel, true, null, args); } - private static BufferedImageDevice safeOpenImageDev(String filename, String formatName) { + private void safeOpenImageDev(String filename, String formatName) { if (!FastRConfig.InternalGridAwtSupport) { throw awtNotSupported(); } + BufferedImageDevice dev = null; try { - return BufferedImageDevice.open(filename, formatName, GridDevice.DEFAULT_WIDTH, GridDevice.DEFAULT_HEIGHT); + dev = BufferedImageDevice.open(FileDevUtils.formatInitialFilename(filename), formatName, GridDevice.DEFAULT_WIDTH, GridDevice.DEFAULT_HEIGHT); } catch (NotSupportedImageFormatException e) { throw RInternalError.shouldNotReachHere("Device format " + formatName + " should be supported."); } + setCurrentDevice(formatName, dev, filename); } private static final class DeviceAndState { diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/graphics/R/fastrGraphics.R b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/graphics/R/fastrGraphics.R index 7619418cf06cff628c699de3f03fd22aa79b19f8..7703096dc540abbe784a8fc4e87b9a385fa2891c 100644 --- a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/graphics/R/fastrGraphics.R +++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/fastrGrid/graphics/R/fastrGraphics.R @@ -30,7 +30,7 @@ eval(expression({ NULL } - plot <- function (x, y = NULL, type = "p", xlim = NULL, ylim = NULL, + plot.default <- function (x, y = NULL, type = "p", xlim = NULL, ylim = NULL, log = "", main = NULL, sub = NULL, xlab = NULL, ylab = NULL, ann = par("ann"), axes = TRUE, frame.plot = axes, panel.first = NULL, panel.last = NULL, asp = NA, ...) @@ -87,10 +87,8 @@ eval(expression({ axis.Date <- graphicsWarning; axis.POSIXct <- graphicsWarning; axTicks <- graphicsWarning; - barplot <- graphicsWarning; barplot.default <- graphicsWarning; box <- graphicsWarning; - boxplot <- graphicsWarning; boxplot.default <- graphicsWarning; boxplot.matrix <- graphicsWarning; bxp <- graphicsWarning; @@ -132,7 +130,6 @@ eval(expression({ panel.smooth <- graphicsWarning; persp <- graphicsWarning; pie <- graphicsWarning; - plot.default <- graphicsWarning; plot.design <- graphicsWarning; plot.function <- graphicsWarning; plot.new <- graphicsWarning; diff --git a/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/ParserGeneration.java b/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/ParserGeneration.java index e7e235f3364dccf7ef83477e84354303437ac3d4..fffc1c206aa93ee5054340d38bd1ffe0e87ff3b5 100644 --- a/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/ParserGeneration.java +++ b/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/ParserGeneration.java @@ -92,6 +92,7 @@ public class ParserGeneration { "raise ZERO_LENGTH_VARIABLE errors in parser", "support for file delimiter", "pass along TruffleRLanguage", - "convert line endings" + "convert line endings", + "handle four and more dots as identifier" }; } diff --git a/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/R.g b/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/R.g index 2cfda4f041a34406cae79c0440ec0ed04bab8790..20ab69d491987eb8d616cbbe3837dac5f629b9c0 100644 --- a/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/R.g +++ b/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/R.g @@ -685,6 +685,7 @@ ID | '.' '.'+ ('0'..'9')* ID_NAME | '.' | '.' '.' + | '.' '.' '.' '.' '.'* | '`' BACKTICK_NAME ; diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test index 406e40f87fa2b5cae0874b02a1faa6b9f68a4101..2e9161bfb56cc72ddf8ebd4b1cb4dd4dacda6e0f 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test @@ -148132,6 +148132,18 @@ see '?methods' for accessing help and source code "","double","bool","raw" "1",1231231234.5,TRUE,2a +##com.oracle.truffle.r.test.parser.TestParser.testDotIdentifiers# +#{ .. <- 42; cat(..); } +42 +##com.oracle.truffle.r.test.parser.TestParser.testDotIdentifiers# +#{ .... <- 42; cat(....); } +42 +##com.oracle.truffle.r.test.parser.TestParser.testDotIdentifiers# +#{ ...... <- 42; cat(......); } +42 +##com.oracle.truffle.r.test.parser.TestParser.testDotIdentifiers# +#{ ....x <- 42; cat(....x); } +42 ##com.oracle.truffle.r.test.parser.TestParser.testDoubleLiterals# #0x0p0 [1] 0 diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/parser/TestParser.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/parser/TestParser.java index 3b1ac309b83aa8eb0b3317479421741b8174d4b8..8dd0021279f5c625ccf18e4a945682a4dd27c662 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/parser/TestParser.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/parser/TestParser.java @@ -142,6 +142,14 @@ public class TestParser extends TestBase { assertEval(Output.IgnoreErrorMessage, "%0"); } + @Test + public void testDotIdentifiers() { + assertEval("{ .. <- 42; cat(..); }"); + assertEval("{ .... <- 42; cat(....); }"); + assertEval("{ ....x <- 42; cat(....x); }"); + assertEval("{ ...... <- 42; cat(......); }"); + } + /** * Recursively look for .r source files in the args[0] directory and parse them. */