本文整理了Java中org.jruby.Ruby.parseInline
方法的一些代码示例,展示了Ruby.parseInline
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.parseInline
方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:parseInline
暂无
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
/**
* Parse and execute the specified script
* This differs from the other methods in that it accepts a string-based script and
* parses and runs it as though it were loaded at a command-line. This is the preferred
* way to start up a new script when calling directly into the Ruby object (which is
* generally *dis*couraged.
*
* @param script The contents of the script to run as a normal, root script
* @return The last value of the script
*/
public IRubyObject executeScript(String script, String filename) {
byte[] bytes = script.getBytes();
Node node = parseInline(new ByteArrayInputStream(bytes), filename, null);
ThreadContext context = getCurrentContext();
String oldFile = context.getFile();
int oldLine = context.getLine();
try {
context.setFileAndLine(node.getPosition());
return runInterpreter(node);
} finally {
context.setFileAndLine(oldFile, oldLine);
}
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
/**
* Parse and execute the specified script
* This differs from the other methods in that it accepts a string-based script and
* parses and runs it as though it were loaded at a command-line. This is the preferred
* way to start up a new script when calling directly into the Ruby object (which is
* generally *dis*couraged.
*
* @param script The contents of the script to run as a normal, root script
* @return The last value of the script
*/
public IRubyObject executeScript(String script, String filename) {
byte[] bytes = script.getBytes();
Node node = parseInline(new ByteArrayInputStream(bytes), filename, null);
ThreadContext context = getCurrentContext();
String oldFile = context.getFile();
int oldLine = context.getLine();
try {
context.setFileAndLine(node.getPosition());
return runInterpreter(node);
} finally {
context.setFileAndLine(oldFile, oldLine);
}
}
代码示例来源:origin: org.jruby/jruby-complete
public ParseResult parseFromMain(String fileName, InputStream in) {
if (config.isInlineScript()) return (ParseResult) parseInline(in, fileName, getCurrentContext().getCurrentScope());
return parseFileFromMain(fileName, in, getCurrentContext().getCurrentScope());
}
代码示例来源:origin: org.jruby/jruby-core
public ParseResult parseFromMain(String fileName, InputStream in) {
if (config.isInlineScript()) return (ParseResult) parseInline(in, fileName, getCurrentContext().getCurrentScope());
return parseFileFromMain(fileName, in, getCurrentContext().getCurrentScope());
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
/**
* Parse the script contained in the given input stream, using the given
* filename as the name of the script, and return the root Node. This
* is used to verify that the script syntax is valid, for jruby -c. The
* current scope (generally the top-level scope) is used as the parent
* scope for parsing.
*
* @param inputStream The input stream from which to read the script
* @param filename The filename to use for parsing
* @returns The root node of the parsed script
*/
public Node parseFromMain(InputStream inputStream, String filename) {
if (config.isInlineScript()) {
return parseInline(inputStream, filename, getCurrentContext().getCurrentScope());
} else {
return parseFileFromMain(inputStream, filename, getCurrentContext().getCurrentScope());
}
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
/**
* Parse the script contained in the given input stream, using the given
* filename as the name of the script, and return the root Node. This
* is used to verify that the script syntax is valid, for jruby -c. The
* current scope (generally the top-level scope) is used as the parent
* scope for parsing.
*
* @param inputStream The input stream from which to read the script
* @param filename The filename to use for parsing
* @returns The root node of the parsed script
*/
public Node parseFromMain(InputStream inputStream, String filename) {
if (config.isInlineScript()) {
return parseInline(inputStream, filename, getCurrentContext().getCurrentScope());
} else {
return parseFileFromMain(inputStream, filename, getCurrentContext().getCurrentScope());
}
}
代码示例来源:origin: org.jruby/jruby-core
/**
* Parse the script contained in the given input stream, using the given
* filename as the name of the script, and return the root Node. This
* is used to verify that the script syntax is valid, for jruby -c. The
* current scope (generally the top-level scope) is used as the parent
* scope for parsing.
*
* @param inputStream The input stream from which to read the script
* @param filename The filename to use for parsing
* @returns The root node of the parsed script
*/
public Node parseFromMain(InputStream inputStream, String filename) {
if (config.isInlineScript()) {
return parseInline(inputStream, filename, getCurrentContext().getCurrentScope());
} else {
return parseFileFromMain(inputStream, filename, getCurrentContext().getCurrentScope());
}
}
代码示例来源:origin: org.jruby/jruby-complete
/**
* Parse the script contained in the given input stream, using the given
* filename as the name of the script, and return the root Node. This
* is used to verify that the script syntax is valid, for jruby -c. The
* current scope (generally the top-level scope) is used as the parent
* scope for parsing.
*
* @param inputStream The input stream from which to read the script
* @param filename The filename to use for parsing
* @returns The root node of the parsed script
*/
public Node parseFromMain(InputStream inputStream, String filename) {
if (config.isInlineScript()) {
return parseInline(inputStream, filename, getCurrentContext().getCurrentScope());
} else {
return parseFileFromMain(inputStream, filename, getCurrentContext().getCurrentScope());
}
}
代码示例来源:origin: org.jruby/jruby-complete
/**
* Parse and execute the specified script
* This differs from the other methods in that it accepts a string-based script and
* parses and runs it as though it were loaded at a command-line. This is the preferred
* way to start up a new script when calling directly into the Ruby object (which is
* generally *dis*couraged.
*
* @param script The contents of the script to run as a normal, root script
* @return The last value of the script
*/
public IRubyObject executeScript(String script, String filename) {
byte[] bytes = encodeToBytes(script);
ParseResult root = (ParseResult) parseInline(new ByteArrayInputStream(bytes), filename, null);
ThreadContext context = getCurrentContext();
String oldFile = context.getFile();
int oldLine = context.getLine();
try {
context.setFileAndLine(root.getFile(), root.getLine());
return runInterpreter(root);
} finally {
context.setFileAndLine(oldFile, oldLine);
}
}
代码示例来源:origin: org.jruby/jruby-core
/**
* Parse and execute the specified script
* This differs from the other methods in that it accepts a string-based script and
* parses and runs it as though it were loaded at a command-line. This is the preferred
* way to start up a new script when calling directly into the Ruby object (which is
* generally *dis*couraged.
*
* @param script The contents of the script to run as a normal, root script
* @return The last value of the script
*/
public IRubyObject executeScript(String script, String filename) {
byte[] bytes = encodeToBytes(script);
ParseResult root = (ParseResult) parseInline(new ByteArrayInputStream(bytes), filename, null);
ThreadContext context = getCurrentContext();
String oldFile = context.getFile();
int oldLine = context.getLine();
try {
context.setFileAndLine(root.getFile(), root.getLine());
return runInterpreter(root);
} finally {
context.setFileAndLine(oldFile, oldLine);
}
}
内容来源于网络,如有侵权,请联系作者删除!