*
* @param script The scriptlet to run
* @returns The result of the eval
*/
public IRubyObject evalScriptlet(String script) {
ThreadContext context = getCurrentContext();
DynamicScope currentScope = context.getCurrentScope();
ManyVarsDynamicScope newScope = new ManyVarsDynamicScope(new EvalStaticScope(currentScope.getStaticScope()), currentScope);
Node node = parseEval(script, "<script>", newScope, 0);
try {
context.preEvalScriptlet(newScope);
return node.interpret(this, context, context.getFrameSelf(), Block.NULL_BLOCK);
} catch (JumpException.ReturnJump rj) {
throw newLocalJumpError(RubyLocalJumpError.Reason.RETURN, (IRubyObject)rj.getValue(), "unexpected return");
} catch (JumpException.BreakJump bj) {
throw newLocalJumpError(RubyLocalJumpError.Reason.BREAK, (IRubyObject)bj.getValue(), "unexpected break");
} catch (JumpException.RedoJump rj) {
throw newLocalJumpError(RubyLocalJumpError.Reason.REDO, (IRubyObject)rj.getValue(), "unexpected redo");
} finally {
context.postEvalScriptlet();
}
}