PredicateDispatchHeadNode.java

  1. /*
  2.  * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved. This
  3.  * code is released under a tri EPL/GPL/LGPL license. You can use it,
  4.  * redistribute it and/or modify it under the terms of the:
  5.  *
  6.  * Eclipse Public License version 1.0
  7.  * GNU General Public License version 2
  8.  * GNU Lesser General Public License version 2.1
  9.  */
  10. package org.jruby.truffle.nodes.dispatch;

  11. import com.oracle.truffle.api.frame.VirtualFrame;
  12. import com.oracle.truffle.api.nodes.Node;
  13. import org.jruby.truffle.nodes.cast.BooleanCastNode;
  14. import org.jruby.truffle.nodes.cast.BooleanCastNodeFactory;
  15. import org.jruby.truffle.runtime.RubyContext;
  16. import org.jruby.truffle.runtime.core.RubyProc;

  17. public class PredicateDispatchHeadNode extends Node {

  18.     @Child protected DispatchHeadNode dispatchNode;
  19.     @Child protected BooleanCastNode booleanCastNode;

  20.     public PredicateDispatchHeadNode(RubyContext context) {
  21.         dispatchNode = new DispatchHeadNode(context);
  22.         booleanCastNode = BooleanCastNodeFactory.create(context, getSourceSection(), null);
  23.     }

  24.     public boolean call(
  25.             VirtualFrame frame,
  26.             Object receiverObject,
  27.             Object methodName,
  28.             RubyProc blockObject,
  29.             Object... argumentsObjects) {
  30.         return booleanCastNode.executeBoolean(frame,
  31.                 dispatchNode.call(frame, receiverObject, methodName, blockObject, argumentsObjects));
  32.     }
  33. }