Пример #1
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));
   }
 }
Пример #2
0
  private Object handleException(VirtualFrame frame, RuntimeException exception) {
    CompilerAsserts.neverPartOfCompilation();

    final RubyContext context = getContext();

    final RubyBasicObject rubyException =
        ExceptionTranslator.translateException(context, exception);

    context.getCoreLibrary().getGlobalVariablesObject().setInstanceVariable("$!", rubyException);

    for (RescueNode rescue : rescueParts) {
      if (rescue.canHandle(frame, rubyException)) {
        return rescue.execute(frame);
      }
    }

    throw exception;
  }