GeneralSuperReCallNode.java

  1. /*
  2.  * Copyright (c) 2013, 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.supercall;

  11. import com.oracle.truffle.api.CompilerDirectives;
  12. import com.oracle.truffle.api.frame.VirtualFrame;
  13. import com.oracle.truffle.api.source.SourceSection;
  14. import org.jruby.truffle.runtime.RubyArguments;
  15. import org.jruby.truffle.runtime.RubyContext;

  16. public class GeneralSuperReCallNode extends AbstractGeneralSuperCallNode {

  17.     private final boolean inBlock;

  18.     public GeneralSuperReCallNode(RubyContext context, SourceSection sourceSection, boolean inBlock) {
  19.         super(context, sourceSection);
  20.         this.inBlock = inBlock;
  21.     }

  22.     @Override
  23.     public final Object execute(VirtualFrame frame) {
  24.         if (!guard()) {
  25.             CompilerDirectives.transferToInterpreterAndInvalidate();
  26.             lookup(frame);
  27.         }

  28.         final Object[] superArguments;

  29.         if (inBlock) {
  30.             superArguments = RubyArguments.getDeclarationFrame(frame.getArguments()).getArguments();
  31.         } else {
  32.             superArguments = frame.getArguments();
  33.         }

  34.         return callNode.call(frame, superArguments);
  35.     }

  36. }