From f1545365a247c82bb5f82bfb86887007c28052ca Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Sun, 24 Oct 2021 10:37:16 +0200 Subject: [PATCH] Add FilePlugin#primitiveHasFileAccess --- .../trufflesqueak/nodes/plugins/FilePlugin.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/nodes/plugins/FilePlugin.java b/src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/nodes/plugins/FilePlugin.java index 42a9d0ccf..8e438f837 100644 --- a/src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/nodes/plugins/FilePlugin.java +++ b/src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/nodes/plugins/FilePlugin.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2017-2021 Software Architecture Group, Hasso Plattner Institute + * Copyright (c) 2021 Oracle and/or its affiliates * * Licensed under the MIT License. */ @@ -696,4 +697,19 @@ private static void writeToOutputStream(final OutputStream outputStream, final b } } } + + @GenerateNodeFactory + @SqueakPrimitive(names = "primitiveHasFileAccess") + protected abstract static class PrimHasFileAccessNode extends AbstractPrimitiveNode { + @Specialization + @TruffleBoundary + protected final boolean hasFileAccess(@SuppressWarnings("unused") final Object receiver) { + try { + getContext().env.getCurrentWorkingDirectory(); + return BooleanObject.TRUE; + } catch (final SecurityException e) { + return BooleanObject.FALSE; + } + } + } }