}
public static IRubyObject interpret(Ruby runtime, Node rootNode, IRubyObject self) {
if (runtime.is1_9()) IRBuilder.setRubyVersion("1.9");
IRScriptBody root = (IRScriptBody) IRBuilder.createIRBuilder(runtime.getIRManager(), runtime.is1_9()).buildRoot((RootNode) rootNode);
// We get the live object ball rolling here. This give a valid value for the top
// of this lexical tree. All new scope can then retrieve and set based on lexical parent.
if (root.getStaticScope().getModule() == null) { // If an eval this may already be setup.
root.getStaticScope().setModule(runtime.getObject());
}
RubyModule currModule = root.getStaticScope().getModule();
// Scope state for root?
IRStaticScopeFactory.newIRLocalScope(null).setModule(currModule);
ThreadContext context = runtime.getCurrentContext();
try {
runBeginEndBlocks(root.getBeginBlocks(), context, self, null); // FIXME: No temp vars yet...not needed?
InterpretedIRMethod method = new InterpretedIRMethod(root, currModule);
IRubyObject rv = method.call(context, self, currModule, "(root)", IRubyObject.NULL_ARRAY);
runBeginEndBlocks(root.getEndBlocks(), context, self, null); // FIXME: No temp vars yet...not needed?
if (IRRuntimeHelpers.isDebug() || IRRuntimeHelpers.inProfileMode()) LOG.info("-- Interpreted instructions: {}", interpInstrsCount);
return rv;
} catch (IRBreakJump bj) {
throw IRException.BREAK_LocalJumpError.getException(context.runtime);
}