public TryNode( RubyContext context, SourceSection sourceSection, ExceptionTranslatingNode tryPart, RescueNode[] rescueParts, RubyNode elsePart) { super(context, sourceSection); this.tryPart = tryPart; this.rescueParts = rescueParts; this.elsePart = elsePart; clearExceptionVariableNode = new WriteInstanceVariableNode( context, sourceSection, "$!", new ObjectLiteralNode( context, sourceSection, context.getCoreLibrary().getGlobalVariablesObject()), new ObjectLiteralNode(context, sourceSection, context.getCoreLibrary().getNilObject()), true); }
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; }