本文整理了Java中org.jruby.Ruby.getIRManager
方法的一些代码示例,展示了Ruby.getIRManager
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.getIRManager
方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:getIRManager
暂无
代码示例来源:origin: org.jruby/jruby-core
@JIT
public static IRScope decodeScopeFromBytes(Ruby runtime, byte[] scopeBytes, String filename) {
try {
return IRReader.load(runtime.getIRManager(), new IRReaderStream(runtime.getIRManager(), new ByteArrayInputStream(scopeBytes), new ByteList(filename.getBytes())));
} catch (IOException ioe) {
// should not happen for bytes
return null;
}
}
代码示例来源:origin: org.jruby/jruby-complete
@JIT
public static IRScope decodeScopeFromBytes(Ruby runtime, byte[] scopeBytes, String filename) {
try {
return IRReader.load(runtime.getIRManager(), new IRReaderStream(runtime.getIRManager(), new ByteArrayInputStream(scopeBytes), new ByteList(filename.getBytes())));
} catch (IOException ioe) {
// should not happen for bytes
return null;
}
}
代码示例来源:origin: org.jruby/jruby-core
public ParseResult parseFile(String file, InputStream in, DynamicScope scope, int lineNumber) {
addLoadParseToStats();
if (!RubyInstanceConfig.IR_READING) return (ParseResult) parseFileAndGetAST(in, file, scope, lineNumber, false);
try {
// Get IR from .ir file
return IRReader.load(getIRManager(), new IRReaderStream(getIRManager(), IRFileExpert.getIRPersistedFile(file), new ByteList(file.getBytes())));
} catch (IOException e) {
// FIXME: What is something actually throws IOException
return (ParseResult) parseFileAndGetAST(in, file, scope, lineNumber, false);
}
}
代码示例来源:origin: org.jruby/jruby-complete
public ParseResult parseFile(String file, InputStream in, DynamicScope scope, int lineNumber) {
addLoadParseToStats();
if (!RubyInstanceConfig.IR_READING) return (ParseResult) parseFileAndGetAST(in, file, scope, lineNumber, false);
try {
// Get IR from .ir file
return IRReader.load(getIRManager(), new IRReaderStream(getIRManager(), IRFileExpert.getIRPersistedFile(file), new ByteList(file.getBytes())));
} catch (IOException e) {
// FIXME: What is something actually throws IOException
return (ParseResult) parseFileAndGetAST(in, file, scope, lineNumber, false);
}
}
代码示例来源:origin: org.jruby/jruby-core
public ParseResult parseFileFromMain(String file, InputStream in, DynamicScope scope) {
addLoadParseToStats();
if (!RubyInstanceConfig.IR_READING) return (ParseResult) parseFileFromMainAndGetAST(in, file, scope);
try {
return IRReader.load(getIRManager(), new IRReaderStream(getIRManager(), IRFileExpert.getIRPersistedFile(file), new ByteList(file.getBytes())));
} catch (IOException ex) {
if (config.isVerbose()) {
LOG.info(ex);
}
else {
LOG.debug(ex);
}
return (ParseResult) parseFileFromMainAndGetAST(in, file, scope);
}
}
代码示例来源:origin: org.jruby/jruby-complete
public ParseResult parseFileFromMain(String file, InputStream in, DynamicScope scope) {
addLoadParseToStats();
if (!RubyInstanceConfig.IR_READING) return (ParseResult) parseFileFromMainAndGetAST(in, file, scope);
try {
return IRReader.load(getIRManager(), new IRReaderStream(getIRManager(), IRFileExpert.getIRPersistedFile(file), new ByteList(file.getBytes())));
} catch (IOException ex) {
if (config.isVerbose()) {
LOG.info(ex);
}
else {
LOG.debug(ex);
}
return (ParseResult) parseFileFromMainAndGetAST(in, file, scope);
}
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
private RubyModule newClass(ThreadContext context, IRubyObject self, RubyModule classContainer, DynamicScope currDynScope, Object[] temp) {
if (newIRClassBody instanceof IRMetaClassBody) return classContainer.getMetaClass();
RubyClass sc;
if (superClass == context.runtime.getIRManager().getNil()) {
sc = null;
} else {
Object o = superClass.retrieve(context, self, currDynScope, temp);
if (!(o instanceof RubyClass)) {
throw context.runtime.newTypeError("superclass must be Class (" + o + " given)");
}
sc = (RubyClass) o;
}
return classContainer.defineOrGetClassUnder(newIRClassBody.getName(), sc);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
private RubyModule newClass(ThreadContext context, IRubyObject self, RubyModule classContainer, DynamicScope currDynScope, Object[] temp) {
if (newIRClassBody instanceof IRMetaClassBody) return classContainer.getMetaClass();
RubyClass sc;
if (superClass == context.runtime.getIRManager().getNil()) {
sc = null;
} else {
Object o = superClass.retrieve(context, self, currDynScope, temp);
if (!(o instanceof RubyClass)) {
throw context.runtime.newTypeError("superclass must be Class (" + o + " given)");
}
sc = (RubyClass) o;
}
return classContainer.defineOrGetClassUnder(newIRClassBody.getName(), sc);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@Override
public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block aBlock) {
// SSS FIXME: Copied this from ast/LambdaNode ... Is this required here as well?
//
// JRUBY-5686: do this before executing so first time sets cref module
getLambdaBody().getStaticScope().determineModule();
IRClosure body = getLambdaBody();
// ENEBO: Now can live nil be passed as block reference?
return RubyProc.newProc(context.runtime,
(Block) (body == null ? context.runtime.getIRManager().getNil() : operands[0]).retrieve(context, self, currDynScope, temp),
Block.Type.LAMBDA, position);
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@Override
public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block aBlock) {
// SSS FIXME: Copied this from ast/LambdaNode ... Is this required here as well?
//
// JRUBY-5686: do this before executing so first time sets cref module
getLambdaBody().getStaticScope().determineModule();
IRClosure body = getLambdaBody();
// ENEBO: Now can live nil be passed as block reference?
return RubyProc.newProc(context.runtime,
(Block) (body == null ? context.runtime.getIRManager().getNil() : operands[0]).retrieve(context, self, currDynScope, temp),
Block.Type.LAMBDA, position);
}
代码示例来源:origin: org.jruby/jruby-complete
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);
}
代码示例来源:origin: org.jruby/jruby-core
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);
}
代码示例来源:origin: org.jruby/jruby-complete
private static BeginEndInterpreterContext prepareIC(ThreadContext context, DynamicScope evalScope, IRubyObject src,
String file, int lineNumber, EvalType evalType) {
Ruby runtime = context.runtime;
IRScope containingIRScope = evalScope.getStaticScope().getEnclosingScope().getIRScope();
RootNode rootNode = (RootNode) runtime.parseEval(src.convertToString().getByteList(), file, evalScope, lineNumber);
StaticScope staticScope = evalScope.getStaticScope();
// Top-level script!
IREvalScript script = new IREvalScript(runtime.getIRManager(), containingIRScope, file, lineNumber, staticScope, evalType);
// enable refinements if incoming scope already has an overlay active
if (staticScope.getOverlayModuleForRead() != null) {
script.setIsMaybeUsingRefinements();
}
// We link IRScope to StaticScope because we may add additional variables (like %block). During execution
// we end up growing dynamicscope potentially based on any changes made.
staticScope.setIRScope(script);
BeginEndInterpreterContext ic = (BeginEndInterpreterContext) IRBuilder.topIRBuilder(runtime.getIRManager(), script).buildEvalRoot(rootNode);
if (IRRuntimeHelpers.isDebug()) LOG.info(script.debugOutput());
return ic;
}
}
代码示例来源:origin: org.jruby/jruby-core
private static BeginEndInterpreterContext prepareIC(ThreadContext context, DynamicScope evalScope, IRubyObject src,
String file, int lineNumber, EvalType evalType) {
Ruby runtime = context.runtime;
IRScope containingIRScope = evalScope.getStaticScope().getEnclosingScope().getIRScope();
RootNode rootNode = (RootNode) runtime.parseEval(src.convertToString().getByteList(), file, evalScope, lineNumber);
StaticScope staticScope = evalScope.getStaticScope();
// Top-level script!
IREvalScript script = new IREvalScript(runtime.getIRManager(), containingIRScope, file, lineNumber, staticScope, evalType);
// enable refinements if incoming scope already has an overlay active
if (staticScope.getOverlayModuleForRead() != null) {
script.setIsMaybeUsingRefinements();
}
// We link IRScope to StaticScope because we may add additional variables (like %block). During execution
// we end up growing dynamicscope potentially based on any changes made.
staticScope.setIRScope(script);
BeginEndInterpreterContext ic = (BeginEndInterpreterContext) IRBuilder.topIRBuilder(runtime.getIRManager(), script).buildEvalRoot(rootNode);
if (IRRuntimeHelpers.isDebug()) LOG.info(script.debugOutput());
return ic;
}
}
代码示例来源:origin: org.jruby/jruby-core
@Override
public int interpretAndGetNewIPC(ThreadContext context, DynamicScope currDynScope, StaticScope currScope, IRubyObject self, Object[] temp, int ipc) {
Object value1 = getArg1().retrieve(context, self, currScope, currDynScope, temp);
Object value2 = getArg2().retrieve(context, self, currScope, currDynScope, temp);
boolean eql = getArg2() == context.getRuntime().getIRManager().getNil() || getArg2() == UndefinedValue.UNDEFINED ?
value1 == value2 : ((IRubyObject) value1).op_equal(context, (IRubyObject)value2).isTrue();
return !eql ? getJumpTarget().getTargetPC() : ipc;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@Override
public int interpretAndGetNewIPC(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int ipc) {
Object value1 = getArg1().retrieve(context, self, currDynScope, temp);
Object value2 = getArg2().retrieve(context, self, currDynScope, temp);
boolean eql = getArg2() == context.getRuntime().getIRManager().getNil() || getArg2() == UndefinedValue.UNDEFINED ?
value1 == value2 : ((IRubyObject) value1).op_equal(context, (IRubyObject)value2).isTrue();
return !eql ? getJumpTarget().getTargetPC() : ipc;
}
代码示例来源:origin: org.jruby/jruby-complete
@Override
public int interpretAndGetNewIPC(ThreadContext context, DynamicScope currDynScope, StaticScope currScope, IRubyObject self, Object[] temp, int ipc) {
Object value1 = getArg1().retrieve(context, self, currScope, currDynScope, temp);
Object value2 = getArg2().retrieve(context, self, currScope, currDynScope, temp);
boolean eql = getArg2() == context.getRuntime().getIRManager().getNil() || getArg2() == UndefinedValue.UNDEFINED ?
value1 == value2 : ((IRubyObject) value1).op_equal(context, (IRubyObject)value2).isTrue();
return !eql ? getJumpTarget().getTargetPC() : ipc;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@Override
public int interpretAndGetNewIPC(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int ipc) {
Object value1 = getArg1().retrieve(context, self, currDynScope, temp);
Object value2 = getArg2().retrieve(context, self, currDynScope, temp);
boolean eql = getArg2() == context.getRuntime().getIRManager().getNil() || getArg2() == UndefinedValue.UNDEFINED ?
value1 == value2 : ((IRubyObject) value1).op_equal(context, (IRubyObject)value2).isTrue();
return !eql ? getJumpTarget().getTargetPC() : ipc;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
public static IRubyObject interpretCommonEval(Ruby runtime, String file, int lineNumber, String backtraceName, RootNode rootNode, IRubyObject self, Block block) {
// SSS FIXME: Is this required here since the IR version cannot change from eval-to-eval? This is much more of a global setting.
boolean is_1_9 = runtime.is1_9();
if (is_1_9) IRBuilder.setRubyVersion("1.9");
StaticScope ss = rootNode.getStaticScope();
IRScope containingIRScope = getEvalContainerScope(runtime, ss);
IREvalScript evalScript = IRBuilder.createIRBuilder(runtime, runtime.getIRManager()).buildEvalRoot(ss, containingIRScope, file, lineNumber, rootNode);
evalScript.prepareForInterpretation(false);
// evalScript.runCompilerPass(new CallSplitter());
ThreadContext context = runtime.getCurrentContext();
runBeginEndBlocks(evalScript.getBeginBlocks(), context, self, null); // FIXME: No temp vars yet right?
IRubyObject rv = evalScript.call(context, self, evalScript.getStaticScope().getModule(), rootNode.getScope(), block, backtraceName);
runBeginEndBlocks(evalScript.getEndBlocks(), context, self, null); // FIXME: No temp vars right?
return rv;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public static IRubyObject interpretCommonEval(Ruby runtime, String file, int lineNumber, String backtraceName, RootNode rootNode, IRubyObject self, Block block) {
// SSS FIXME: Is this required here since the IR version cannot change from eval-to-eval? This is much more of a global setting.
boolean is_1_9 = runtime.is1_9();
if (is_1_9) IRBuilder.setRubyVersion("1.9");
StaticScope ss = rootNode.getStaticScope();
IRScope containingIRScope = getEvalContainerScope(runtime, ss);
IREvalScript evalScript = IRBuilder.createIRBuilder(runtime, runtime.getIRManager()).buildEvalRoot(ss, containingIRScope, file, lineNumber, rootNode);
evalScript.prepareForInterpretation(false);
// evalScript.runCompilerPass(new CallSplitter());
ThreadContext context = runtime.getCurrentContext();
runBeginEndBlocks(evalScript.getBeginBlocks(), context, self, null); // FIXME: No temp vars yet right?
IRubyObject rv = evalScript.call(context, self, evalScript.getStaticScope().getModule(), rootNode.getScope(), block, backtraceName);
runBeginEndBlocks(evalScript.getEndBlocks(), context, self, null); // FIXME: No temp vars right?
return rv;
}
内容来源于网络,如有侵权,请联系作者删除!