org.jruby.Ruby.parseEval()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(84)

本文整理了Java中org.jruby.Ruby.parseEval方法的一些代码示例,展示了Ruby.parseEval的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.parseEval方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:parseEval

Ruby.parseEval介绍

暂无

代码示例

代码示例来源:origin: org.jruby/jruby-complete

/**
 * Parse the script and return an object which can be run().  This allows the script
 * to be parsed once and evaluated many times.
 * @param runtime to parse the script under
 * @param script to be parsed
 * @param filename the filename to display for parse errors and backtraces
 * @param lineNumber the linenumber to display for parse errors and backtraces
 * @return an object which can be run
 */
public EvalUnit parse(Ruby runtime, String script, String filename, int lineNumber) {
  return new InterpretedEvalUnit(runtime, runtime.parseEval(script, filename, null, lineNumber));
}

代码示例来源:origin: org.jruby/jruby-core

/**
 * Parse the script and return an object which can be run().  This allows the script
 * to be parsed once and evaluated many times.
 * @param runtime to parse the script under
 * @param script to be parsed
 * @param filename the filename to display for parse errors and backtraces
 * @param lineNumber the linenumber to display for parse errors and backtraces
 * @return an object which can be run
 */
public EvalUnit parse(Ruby runtime, String script, String filename, int lineNumber) {
  return new InterpretedEvalUnit(runtime, runtime.parseEval(script, filename, null, lineNumber));
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

/**
 * Parse the script and return an object which can be run().  This allows the script
 * to be parsed once and evaluated many times.
 * @param runtime to parse the script under
 * @param script to be parsed
 * @param filename the filename to display for parse errors and backtraces
 * @param lineNumber the linenumber to display for parse errors and backtraces
 * @return an object which can be run
 */
public EvalUnit parse(Ruby runtime, String script, String filename, int lineNumber) {
  return new InterpretedEvalUnit(runtime, runtime.parseEval(script, filename, null, lineNumber));
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

/**
 * Parse the script and return an object which can be run().  This allows the script
 * to be parsed once and evaluated many times.
 * @param runtime to parse the script under
 * @param script to be parsed
 * @param filename the filename to display for parse errors and backtraces
 * @param lineNumber the linenumber to display for parse errors and backtraces
 * @return an object which can be run
 */
public EvalUnit parse(Ruby runtime, String script, String filename, int lineNumber) {
  return new InterpretedEvalUnit(runtime, runtime.parseEval(script, filename, null, lineNumber));
}

代码示例来源:origin: apache/servicemix-bundles

/**
 * Create a new JRuby-scripted object from the given script source.
 * @param scriptSource the script source text
 * @param interfaces the interfaces that the scripted Java object is to implement
 * @param classLoader the {@link ClassLoader} to create the script proxy with
 * @return the scripted Java object
 * @throws JumpException in case of JRuby parsing failure
 */
public static Object createJRubyObject(String scriptSource, Class<?>[] interfaces, ClassLoader classLoader) {
  Ruby ruby = initializeRuntime();
  Node scriptRootNode = ruby.parseEval(scriptSource, "", null, 0);
  IRubyObject rubyObject = ruby.runNormally(scriptRootNode);
  if (rubyObject instanceof RubyNil) {
    String className = findClassName(scriptRootNode);
    rubyObject = ruby.evalScriptlet("\n" + className + ".new");
  }
  // still null?
  if (rubyObject instanceof RubyNil) {
    throw new IllegalStateException("Compilation of JRuby script returned RubyNil: " + rubyObject);
  }
  return Proxy.newProxyInstance(classLoader, interfaces, new RubyObjectInvocationHandler(rubyObject, ruby));
}

代码示例来源:origin: org.jruby/jruby-complete

/**
 * Evaluates a script under the current scope (perhaps the top-level
 * scope) and returns the result (generally the last value calculated).
 * This version goes straight into the interpreter, bypassing compilation
 * and runtime preparation typical to normal script runs.
 *
 * This version accepts a scope to use, so you can eval many times against
 * the same scope.
 *
 * @param script The scriptlet to run
 * @param scope The scope to execute against (ManyVarsDynamicScope is
 * recommended, so it can grow as needed)
 * @returns The result of the eval
 */
public IRubyObject evalScriptlet(String script, DynamicScope scope) {
  ThreadContext context = getCurrentContext();
  RootNode rootNode = (RootNode) parseEval(script, "<script>", scope, 0);
  context.preEvalScriptlet(scope);
  try {
    return interpreter.execute(this, rootNode, context.getFrameSelf());
  } finally {
    context.postEvalScriptlet();
  }
}

代码示例来源:origin: org.jruby/jruby-core

/**
 * Evaluates a script under the current scope (perhaps the top-level
 * scope) and returns the result (generally the last value calculated).
 * This version goes straight into the interpreter, bypassing compilation
 * and runtime preparation typical to normal script runs.
 *
 * This version accepts a scope to use, so you can eval many times against
 * the same scope.
 *
 * @param script The scriptlet to run
 * @param scope The scope to execute against (ManyVarsDynamicScope is
 * recommended, so it can grow as needed)
 * @returns The result of the eval
 */
public IRubyObject evalScriptlet(String script, DynamicScope scope) {
  ThreadContext context = getCurrentContext();
  RootNode rootNode = (RootNode) parseEval(script, "<script>", scope, 0);
  context.preEvalScriptlet(scope);
  try {
    return interpreter.execute(this, rootNode, context.getFrameSelf());
  } finally {
    context.postEvalScriptlet();
  }
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

Node node = parseEval(script, "<script>", scope, 0);

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

Node node = parseEval(script, "<script>", scope, 0);

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

Node node = runtime.parseEval(source.getByteList(), file, evalScope, lineNumber);

代码示例来源: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: com.ning.billing/killbill-osgi-bundles-jruby

Node node = runtime.parseEval(source.getByteList(), file, evalScope, lineNumber);

代码示例来源: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-complete

node = runtime.parseEval((String)input, filename, scope, line);
} else {
  node = runtime.parseFile((InputStream)input, filename, scope, line);

代码示例来源:origin: org.jruby/jruby-core

node = runtime.parseEval((String)input, filename, scope, line);
} else {
  node = runtime.parseFile((InputStream)input, filename, scope, line);

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

node = runtime.parseEval((String)input, filename, scope, line);
} else {
  node = runtime.parseFile((InputStream)input, filename, scope, line);

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

node = runtime.parseEval((String)input, filename, scope, line);
} else {
  node = runtime.parseFile((InputStream)input, filename, scope, line);

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

Node node = runtime.parseEval(source.getByteList(), binding.getFile(), evalScope, binding.getLine());
Block block = binding.getFrame().getBlock();

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

Node node = runtime.parseEval(source.getByteList(), binding.getFile(), evalScope, binding.getLine());
Block block = binding.getFrame().getBlock();

相关文章

微信公众号

最新文章

更多

Ruby类方法