Пример #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;
  }
Пример #2
0
 @Override
 public Object execute(
     TranslatorDriver.ParserContext parserContext,
     Object self,
     MaterializedFrame parentFrame,
     org.jruby.ast.RootNode rootNode) {
   try {
     final RubyParserResult parseResult =
         truffleContext
             .getTranslator()
             .parse(
                 truffleContext,
                 truffleContext.getSourceManager().get(rootNode.getPosition().getFile()),
                 parserContext,
                 parentFrame,
                 rootNode);
     final CallTarget callTarget =
         Truffle.getRuntime().createCallTarget(parseResult.getRootNode());
     return callTarget.call(RubyArguments.pack(parentFrame, self, null));
   } catch (ThrowException e) {
     throw new RaiseException(truffleContext.getCoreLibrary().nameErrorUncaughtThrow(e.getTag()));
   } catch (RaiseException | BreakShellException | QuitException e) {
     throw e;
   } catch (Throwable e) {
     e.printStackTrace();
     throw new RaiseException(ExceptionTranslator.translateException(truffleContext, e));
   }
 }
Пример #3
0
 public void toggleBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
   ISelection sel = translateToMembers(part, selection);
   if (sel instanceof IStructuredSelection) {
     IMember member = (IMember) ((IStructuredSelection) sel).getFirstElement();
     int mtype = member.getElementType();
     if (mtype == IRubyElement.FIELD || mtype == IRubyElement.METHOD) {
       // remove line breakpoint if present first
       if (selection instanceof ITextSelection) {
         ITextSelection ts = (ITextSelection) selection;
         IType declaringType = member.getDeclaringType();
         IResource resource = BreakpointUtils.getBreakpointResource(declaringType);
         IRubyLineBreakpoint breakpoint =
             RdtDebugModel.lineBreakpointExists(resource, null, ts.getStartLine());
         if (breakpoint != null) {
           breakpoint.delete();
           return;
         }
         RootNode unit = parseRubyScript(getTextEditor(part));
         ValidBreakpointLocationLocator loc =
             new ValidBreakpointLocationLocator(unit, ts.getStartLine(), true);
         unit.accept(loc);
         if (loc.getLocationType() == ValidBreakpointLocationLocator.LOCATION_METHOD) {
           toggleMethodBreakpoints(part, sel);
         } else if (loc.getLocationType() == ValidBreakpointLocationLocator.LOCATION_FIELD) {
           toggleWatchpoints(part, ts);
         } else if (loc.getLocationType() == ValidBreakpointLocationLocator.LOCATION_LINE) {
           toggleLineBreakpoints(part, ts);
         } else {
           // fall back to old behavior, always create a line breakpoint
           toggleLineBreakpoints(part, selection, true);
         }
       }
     }
     // else if(member.getElementType() == IRubyElement.TYPE) {
     // toggleClassBreakpoints(part, sel);
     // }
     else {
       // fall back to old behavior, always create a line breakpoint
       toggleLineBreakpoints(part, selection, true);
     }
   } else {
     toggleLineBreakpoints(part, selection, true);
   }
 }