示例#1
0
  public static IRubyObject interpretCommonEval(
      Ruby runtime,
      String file,
      int lineNumber,
      String backtraceName,
      RootNode rootNode,
      IRubyObject self,
      Block block) {
    // SSS FIXME: Is this required here since the IR version cannot change from eval-to-eval? This
    // is much more of a global setting.
    boolean is_1_9 = runtime.is1_9();
    if (is_1_9) IRBuilder.setRubyVersion("1.9");

    StaticScope ss = rootNode.getStaticScope();
    IRScope containingIRScope = getEvalContainerScope(runtime, ss);
    IREvalScript evalScript =
        IRBuilder.createIRBuilder(runtime, runtime.getIRManager())
            .buildEvalRoot(ss, containingIRScope, file, lineNumber, rootNode);
    evalScript.prepareForInterpretation(false);
    //        evalScript.runCompilerPass(new CallSplitter());
    ThreadContext context = runtime.getCurrentContext();
    runBeginEndBlocks(
        evalScript.getBeginBlocks(), context, self, null); // FIXME: No temp vars yet right?
    IRubyObject rv =
        evalScript.call(
            context,
            self,
            evalScript.getStaticScope().getModule(),
            rootNode.getScope(),
            block,
            backtraceName);
    runBeginEndBlocks(evalScript.getEndBlocks(), context, self, null); // FIXME: No temp vars right?
    return rv;
  }