From 1089579e809ecbcc9d6af9e6e4aa21f2a7250a55 Mon Sep 17 00:00:00 2001 From: Michael Haupt <michael.haupt@oracle.com> Date: Thu, 24 Apr 2014 14:23:31 +0200 Subject: [PATCH] add commentary on RArguments --- .../oracle/truffle/r/runtime/RArguments.java | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RArguments.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RArguments.java index 3eaa35d6ae..7bcc02944e 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RArguments.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RArguments.java @@ -25,11 +25,30 @@ package com.oracle.truffle.r.runtime; import com.oracle.truffle.api.frame.*; import com.oracle.truffle.r.runtime.data.*; +// @formatter:off /** * Provide access to arguments contained in frames. This is a purely static class. It defines, by * means of slot offsets, where in a frame certain information is stored, such as the function * executed in the frame. + * + * The frame layout, depicted, is as follows: + * <pre> + * +-------------------+ + * INDEX_FUNCTION -> | RFunction | + * +-------------------+ + * INDEX_ENCLOSING_FRAME -> | MaterializedFrame | + * +-------------------+ + * INDEX_ARGUMENTS -> | Object[] | + * +-------------------+ + * INDEX_NAMES -> | Object[] | + * +-------------------+ + * </pre> + * + * All frame elements should <b>always</b> be accessed through the getter and setter functions + * defined in this class, as they provide a means of accessing the frame contents that is + * transparent to layout changes. */ +// @formatter:on public final class RArguments { public static final Object[] EMPTY_OBJECT_ARRAY = new Object[0]; @@ -42,10 +61,6 @@ public final class RArguments { private RArguments() { } - public static RFunction getFunction(Frame frame) { - return (RFunction) frame.getArguments()[INDEX_FUNCTION]; - } - public static Object[] create() { return create(null, null, EMPTY_OBJECT_ARRAY); } @@ -66,6 +81,10 @@ public final class RArguments { return new Object[]{functionObj, enclosingFrame, evaluatedArgs, names}; } + public static RFunction getFunction(Frame frame) { + return (RFunction) frame.getArguments()[INDEX_FUNCTION]; + } + public static Object[] getArgumentsArray(Frame frame) { return (Object[]) frame.getArguments()[INDEX_ARGUMENTS]; } -- GitLab