Java Code Examples for com.oracle.truffle.api.frame.Frame#getArguments()

The following examples show how to use com.oracle.truffle.api.frame.Frame#getArguments() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HashemLexicalScope.java    From mr-hashemi with Universal Permissive License v1.0 5 votes vote down vote up
public Object getVariables(Frame frame) {
    Map<String, FrameSlot> vars = getVars();
    Object[] args = null;
    // Use arguments when the current node is above the block
    if (current == null) {
        args = (frame != null) ? frame.getArguments() : null;
    }
    return new VariablesMapObject(vars, args, frame);
}
 
Example 2
Source File: HashemLexicalScope.java    From mr-hashemi with Universal Permissive License v1.0 5 votes vote down vote up
public Object getArguments(Frame frame) {
    if (root == null) {
        // No arguments for block scope
        return null;
    }
    // The slots give us names of the arguments:
    Map<String, FrameSlot> argSlots = collectArgs(block);
    // The frame's arguments array give us the argument values:
    Object[] args = (frame != null) ? frame.getArguments() : null;
    // Create a TruffleObject having the arguments as properties:
    return new VariablesMapObject(argSlots, args, frame);
}
 
Example 3
Source File: SqueakLanguage.java    From trufflesqueak with MIT License 5 votes vote down vote up
@Override
protected Iterable<Scope> findLocalScopes(final SqueakImageContext context, final Node node, final Frame frame) {
    // TODO: support access at parse time (frame == null).
    if (!FrameAccess.isTruffleSqueakFrame(frame)) {
        return super.findLocalScopes(context, node, frame);
    }
    final CompiledCodeObject blockOrMethod = FrameAccess.getBlockOrMethod(frame);
    final String name = blockOrMethod.toString();
    final Object receiver = FrameAccess.getReceiver(frame);
    final ContextObjectInfo variables = new ContextObjectInfo(frame);
    final InteropArray arguments = new InteropArray(frame.getArguments());
    return Collections.singletonList(Scope.newBuilder(name, variables).node(node).receiver(receiver.toString(), receiver).arguments(arguments).build());
}
 
Example 4
Source File: MumblerNode.java    From mumbler with GNU General Public License v3.0 5 votes vote down vote up
protected static MaterializedFrame getLexicalScope(Frame frame) {
    Object[] args = frame.getArguments();
    if (args.length > 0) {
        return (MaterializedFrame) frame.getArguments()[0];
    } else {
        return null;
    }
}
 
Example 5
Source File: FrameAccess.java    From trufflesqueak with MIT License 4 votes vote down vote up
public static CompiledMethodObject getMethod(final Frame frame) {
    return (CompiledMethodObject) frame.getArguments()[ArgumentIndicies.METHOD.ordinal()];
}
 
Example 6
Source File: FrameAccess.java    From trufflesqueak with MIT License 4 votes vote down vote up
public static void setMethod(final Frame frame, final CompiledMethodObject method) {
    frame.getArguments()[ArgumentIndicies.METHOD.ordinal()] = method;
}
 
Example 7
Source File: FrameAccess.java    From trufflesqueak with MIT License 4 votes vote down vote up
public static Object getSender(final Frame frame) {
    return frame.getArguments()[ArgumentIndicies.SENDER_OR_SENDER_MARKER.ordinal()];
}
 
Example 8
Source File: FrameAccess.java    From trufflesqueak with MIT License 4 votes vote down vote up
public static void setSender(final Frame frame, final AbstractSqueakObject value) {
    frame.getArguments()[ArgumentIndicies.SENDER_OR_SENDER_MARKER.ordinal()] = value;
}
 
Example 9
Source File: FrameAccess.java    From trufflesqueak with MIT License 4 votes vote down vote up
public static BlockClosureObject getClosure(final Frame frame) {
    return (BlockClosureObject) frame.getArguments()[ArgumentIndicies.CLOSURE_OR_NULL.ordinal()];
}
 
Example 10
Source File: FrameAccess.java    From trufflesqueak with MIT License 4 votes vote down vote up
public static void setClosure(final Frame frame, final BlockClosureObject closure) {
    frame.getArguments()[ArgumentIndicies.CLOSURE_OR_NULL.ordinal()] = closure;
}
 
Example 11
Source File: FrameAccess.java    From trufflesqueak with MIT License 4 votes vote down vote up
public static Object getReceiver(final Frame frame) {
    return frame.getArguments()[ArgumentIndicies.RECEIVER.ordinal()];
}
 
Example 12
Source File: FrameAccess.java    From trufflesqueak with MIT License 4 votes vote down vote up
public static void setReceiver(final Frame frame, final Object receiver) {
    frame.getArguments()[ArgumentIndicies.RECEIVER.ordinal()] = receiver;
}
 
Example 13
Source File: FrameAccess.java    From trufflesqueak with MIT License 4 votes vote down vote up
public static Object getArgument(final Frame frame, final int index) {
    return frame.getArguments()[ArgumentIndicies.RECEIVER.ordinal() + index];
}
 
Example 14
Source File: FrameAccess.java    From trufflesqueak with MIT License 4 votes vote down vote up
public static boolean isTruffleSqueakFrame(final Frame frame) {
    final Object[] arguments = frame.getArguments();
    return arguments.length >= ArgumentIndicies.RECEIVER.ordinal() && arguments[ArgumentIndicies.METHOD.ordinal()] instanceof CompiledMethodObject;
}