private static IRScriptBody compileIR(ThreadContext context, IRubyObject[] args, Block block) { RootNode node = (RootNode) parseImpl(context, args, block); IRManager manager = new IRManager(context.runtime, context.runtime.getInstanceConfig()); manager.setDryRun(true); IRScriptBody scope = (IRScriptBody) IRBuilder.buildRoot(manager, node).getScope(); scope.setScriptDynamicScope(node.getScope()); return scope; }
private static IRScriptBody compileIR(ThreadContext context, IRubyObject[] args, Block block) { RootNode node = (RootNode) parseImpl(context, args, block); IRManager manager = new IRManager(context.runtime, context.runtime.getInstanceConfig()); manager.setDryRun(true); IRScriptBody scope = (IRScriptBody) IRBuilder.buildRoot(manager, node).getScope(); scope.setScriptDynamicScope(node.getScope()); return scope; }
public R execute(Ruby runtime, ParseResult result, S specificObject) { IRScriptBody scope = null; if (result instanceof IRScriptBody) { // Already have it (likely from read from persistent store). scope = (IRScriptBody) result; } else if (result instanceof RootNode) { // Need to perform create IR from AST // FIXME: In terms of writing and reading we should emit enough to rebuild IC + minimal IRScope state InterpreterContext ic = IRBuilder.buildRoot(runtime.getIRManager(), (RootNode) result); scope = (IRScriptBody) ic.getScope(); scope.setScriptDynamicScope(((RootNode) result).getScope()); if (RubyInstanceConfig.IR_WRITING) { try { IRWriter.persist(new IRWriterStream(IRFileExpert.getIRPersistedFile(scope.getFileName())), scope); } catch (IOException ex) { ex.printStackTrace(); // FIXME: Handle errors better return null; } } } return execute(runtime, scope, specificObject); }
public R execute(Ruby runtime, ParseResult result, S specificObject) { IRScriptBody scope = null; if (result instanceof IRScriptBody) { // Already have it (likely from read from persistent store). scope = (IRScriptBody) result; } else if (result instanceof RootNode) { // Need to perform create IR from AST // FIXME: In terms of writing and reading we should emit enough to rebuild IC + minimal IRScope state InterpreterContext ic = IRBuilder.buildRoot(runtime.getIRManager(), (RootNode) result); scope = (IRScriptBody) ic.getScope(); scope.setScriptDynamicScope(((RootNode) result).getScope()); if (RubyInstanceConfig.IR_WRITING) { try { IRWriter.persist(new IRWriterStream(IRFileExpert.getIRPersistedFile(scope.getFileName())), scope); } catch (IOException ex) { ex.printStackTrace(); // FIXME: Handle errors better return null; } } } return execute(runtime, scope, specificObject); }